@@ -9,8 +9,8 @@ import { calculateMNA, calcBilinear } from "./mna.js";
99
1010//RESET IT ERROR OCCURS!
1111window . onerror = function ( message , file , line , col , error ) {
12- alert ( "The web page has crashed! Damn. If you can please describe what happened in a comment...\n\n" + error . message ) ;
13- window . location . href = location . protocol + '//' + location . host + location . pathname ;
12+ alert ( "The web page has crashed! Damn. If you can please describe what happened in a comment...\n\n" + error . message ) ;
13+ window . location . href = location . protocol + '//' + location . host + location . pathname ;
1414} ;
1515
1616//Decode the URL before starting and REACT stuff
@@ -742,19 +742,23 @@ class Game extends React.Component {
742742 this . freq = [ ] ;
743743 this . mag = [ ] ;
744744 var scaler ;
745- var test = this . resString ;
745+ // var complex_freq = this.resString;
746+ Algebrite . eval ( `complex_response = subst(s*i,s,mna_vo_vi)` ) ;
747+ // console.log('0', Algebrite.eval("complex_response").toString());
748+ var complex_freq = Algebrite . eval ( "abs(complex_response)" ) . toString ( ) ;
749+ // console.log('a', complex_freq)
746750 var rep ;
747751 for ( const key in current . elements ) {
748752 scaler = unitStrToVal ( current . elements [ key ] . unit ) ;
749753 rep = RegExp ( key , "g" ) ;
750- test = test . replace ( rep , current . elements [ key ] . value * scaler ) ;
754+ complex_freq = complex_freq . replace ( rep , current . elements [ key ] . value * scaler ) ;
751755 }
752756 // console.log(test, rep)
753757
754758 //Now only remaining variable is S, substitute that and solve. Also swap power ^ for **
755759 const re = / s / gi;
756760 const re2 = / \^ / gi;
757- var res = test . replace ( re2 , "**" ) ;
761+ var res = complex_freq . replace ( re2 , "**" ) ;
758762
759763 var fmin = current . fmin . value * unitStrToVal ( current . fmin . unit ) ;
760764 var fmax = current . fmax . value * unitStrToVal ( current . fmax . unit ) ;
@@ -1158,6 +1162,11 @@ class Game extends React.Component {
11581162 </ div >
11591163 </ div >
11601164 </ div >
1165+ < div className ="w-100 p-3 bg-navy text-white " key ="cont_w100 ">
1166+ < div className ="container-xl " key ="cont ">
1167+ git: https://github.com/28raining/28raining.github.io/tree/master/circuitSolver
1168+ </ div >
1169+ </ div >
11611170 ` ;
11621171 }
11631172}
0 commit comments