Index: mttroot/mtt/bin/trans/dae2cse_r ================================================================== --- mttroot/mtt/bin/trans/dae2cse_r +++ mttroot/mtt/bin/trans/dae2cse_r @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.5 1998/05/20 15:23:26 peterg +## Put MTTYz := MTTYz outsise the BEGIN/END +## ## Revision 1.4 1998/05/20 15:13:09 peterg ## Writes out algebraic equations (if any). ## ## Revision 1.3 1998/03/03 09:02:46 peterg ## Replaced MTTEyx*MTTEdX + MTTEyu*MTTdu; term @@ -38,12 +41,20 @@ ## Revision 1.1 1996/08/15 16:47:02 peter ## Initial revision ## ############################################################### -#Inform user -echo Creating $1_cse.r + +#Explicit solution option +Solving=$2; +if [ "$Solving" = "Solving" ]; then + solve=1 + echo "Creating $1_cse.r (with explicit solution of algebraic equations)" +else + solve=0 + echo "Creating $1_cse.r" +fi # Remove the old log file rm -f dae2cse_r.log # Use reduce to accomplish the transformation @@ -58,11 +69,12 @@ in "$1_subs.r"; in "$1_dae.r"; -%Create F_x, F_y matrices - assumming equations are linear in dZ +%Create F_x, F_y matrices - assumming equations are +% linear in dZ IF MTTNz>0 THEN BEGIN % Find MTTFx; write "% Find MTTFx;"; @@ -145,20 +157,19 @@ MTTdZ19 := 0; MTTEdX := MTTdX; %Ie MTTEdX is MTTdX with the dz terms deleted ie EdX. MTTdX := MTTdXs; %Restore the symbolic dX +%% Add on input derivative terms +MTTEdX := MTTEdX + MTTExu*MTTdu; MTTY := MTTY + MTTEyx*MTTEdX; %%% This causes the matrix mismatch %%% MTTdXs and MTTdu need setting in _def.r file %%MTTY := MTTY + MTTEyu*MTTdu; MTTY := MTTY + MTTEyx*(MTTE^(-1))*MTTEdX; - - - END; %%of MTTNz>0 IF MTTNz=0 THEN @@ -165,35 +176,40 @@ BEGIN MTTEdX := MTTdX; MTTE := MTTI; END; -%IF MTTNyz>0 THEN -%BEGIN -% %%%% Try and solve algebraic loops!! -% -% %Create list of the relevant equations -% MTT_eqns := {}; -% FOR i := 1:MTTNyz DO -% MTT_eqns := append(MTT_eqns,{MTTyz(i,1)}); -% -% %Create list of the relevant unknowns -% MTT_unknowns := {}; -% FOR i := 1:MTTNyz DO -% MTT_unknowns := append(MTT_unknowns,{MTTUi(i,1)}); -% -% %Solve the algebraic equations symbolically -% MTT_sol := solve(MTT_eqns,MTT_unknowns); -% -% %Substitute back into the equations -% FOR i := 1:MTTNyz DO -% BEGIN -% MTT_sol_i := first(MTT_sol); MTT_sol := rest(MTT_sol); -% set(lhs(MTT_sol_i),rhs(MTT_sol_i)); -% END; -% -%END; % IF MTTNyz>0 +IF (MTTNyz>0) AND ($solve>0) THEN +BEGIN + %%%% Try and solve algebraic loops!! + + %Create list of the relevant equations + MTT_eqns := {}; + FOR i := 1:MTTNyz DO + MTT_eqns := append(MTT_eqns,{MTTyz(i,1)}); + + %Create list of the relevant unknowns + MTT_unknowns := {}; + FOR i := 1:MTTNyz DO + MTT_unknowns := append(MTT_unknowns,{MTTUi(i,1)}); + + %Solve the algebraic equations symbolically + %The result seems to be in an extra list - I don't know why + % So remove the outer list with first. + + MTT_sol := first(solve(MTT_eqns,MTT_unknowns)); + + %Substitute back into the equations + FOR i := 1:MTTNyz DO + BEGIN + MTT_sol_i := first(MTT_sol); MTT_sol := rest(MTT_sol); + set(lhs(MTT_sol_i),rhs(MTT_sol_i)); + END; + + % No algebraic variables left! + MTTNYz := 0; +END; % IF MTTNyz>0 %%Create the _cse.r file OUT "$1_cse.r"; IF MTTNx>0 THEN @@ -204,10 +220,11 @@ IF MTTNy>0 THEN BEGIN write "matrix MTTY(", MTTNy, ",1)"; END; + MTTY := MTTY; IF MTTNu>0 THEN BEGIN write "matrix MTTU(", MTTNu, ",1)"; @@ -232,11 +249,17 @@ END; IF MTTNyz>0 THEN BEGIN write "matrix MTTYz(", MTTNyz, ",1)"; + END +ELSE + BEGIN + write "MTTNYz := 0;"; + MTTYz := 0; END; + MTTYz := MTTYz; write ";END;";