Index: mttroot/mtt/bin/trans/make_ode2odes ================================================================== --- mttroot/mtt/bin/trans/make_ode2odes +++ mttroot/mtt/bin/trans/make_ode2odes @@ -7,10 +7,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.41 2000/11/09 17:06:39 peterg +## Now does euler for cc +## ## Revision 1.40 2000/10/17 09:55:00 peterg ## Replaced switchopen by logic ## ## Revision 1.39 2000/10/14 08:04:40 peterg ## Changed arguments to _inout for consistency @@ -166,15 +169,15 @@ mtt_header ${sys} ode2odes m > $filename cat <> $filename global MTT_data; if nargin<3 - simpar = ${sys}_simpar; + simpar = ${sys}_simpar(); [simpar.dt] = mtt_simpar_update; endif if nargin<2 - par = ${sys}_numpar; + par = ${sys}_numpar(); [par] = mtt_numpar_update(par); endif if nargin<1 [x] = ${sys}_state(par); [x] = mtt_state_update(x); @@ -241,38 +244,37 @@ #include #include "${sys}_def.h" #include "${sys}_sympar.h" -octave_value_list +ColumnVector mtt_${ode} (ColumnVector x, ColumnVector u, double t, ColumnVector par) { octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); - f = feval ("${sys}_${ode}", args, 2); - return (f); + f = feval ("${sys}_${ode}", args, 1); + return f(0).vector_value (); } ColumnVector -mtt_cseo (ColumnVector x, ColumnVector u, double t, ColumnVector par) +mtt_${odeo} (ColumnVector x, ColumnVector u, double t, ColumnVector par) { - octave_value_list args; + octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); - ColumnVector f; - f = feval ("${sys}_cseo", args, 1)(0).vector_value (); - return (f); + f = feval ("${sys}_${odeo}", args, 1); + return f(0).vector_value (); } -#define mtt_implicit(x,dx,AA,AAx,ddt,nx,open) call_mtt_implicit((x),(dx),(AA),(AAx),(ddt),(nx),(open)) +// #define mtt_implicit(x,dx,AA,AAx,ddt,nx,open) call_mtt_implicit((x),(dx),(AA),(AAx),(ddt),(nx),(open)) ColumnVector -call_mtt_implicit (ColumnVector x, +mtt_implicit (ColumnVector x, ColumnVector dx, Matrix AA, ColumnVector AAx, double ddt, int nx, @@ -288,10 +290,26 @@ args (6) = octave_value (open_switches); f = feval ("mtt_implicit", args, 1); return f(0).vector_value (); } +ColumnVector +mtt_euler (ColumnVector x, + ColumnVector dx, + double ddt, + int nx, + ColumnVector open_switches) +{ + octave_value_list args, f; + args (0) = octave_value (x); + args (1) = octave_value (dx); + args (2) = octave_value (ddt); + args (3) = octave_value ((double)nx); + args (4) = octave_value (open_switches); + f = feval ("mtt_euler", args, 1); + return f(0).vector_value (); +} ColumnVector mtt_input (ColumnVector x, ColumnVector y, const double t, ColumnVector par) { octave_value_list args; @@ -376,32 +394,44 @@ ColumnVector f; f = feval ("${sys}_logic", args, 1)(0).vector_value (); return (f); } + void -mtt_write (double t, ColumnVector x, ColumnVector y, int nx, int ny) -{ - register int i; - cout.precision (5); // this should be passed in as an argument - cout.width (12); // as should this (instead of nx, ny) - cout << t; - for (i = 0; i < y.length (); i++) - { - cout.width (12); - cout << '\t' << y (i); - } - cout.width (12); - cout << "\t\t" << t; - for (i = 0; i < x.length (); i++) - { - cout.width (12); - cout << '\t' << x (i); - } - cout << endl; -} +mtt_write (double t, ColumnVector x, ColumnVector y){ + octave_value_list args; + args (0) = octave_value (t); + args (1) = octave_value (x); + args (2) = octave_value (y); + ColumnVector f; + feval ("mtt_write", args, 1); + +} + +//void +//mtt_write (double t, ColumnVector x, ColumnVector y, int nx, int ny) +//{ +// register int i; +// cout.precision (5); // this should be passed in as an argument +// cout.width (12); // as should this (instead of nx, ny) +// cout << t; +// for (i = 0; i < y.length (); i++) +// { +// cout.width (12); +// cout << '\t' << y (i); +// } +// cout.width (12); +// cout << "\t\t" << t; +// for (i = 0; i < x.length (); i++) +// { +// cout.width (12); +// cout << '\t' << x (i); +// } +// cout << endl; +//} ColumnVector nozeros (const ColumnVector v0, const double tol = 0.0) { ColumnVector v (v0.length ()); register int j; @@ -503,21 +533,21 @@ // cse translation // LSODE will need ODEFUNC for (register int j = 0, i = 1; i <= ilast; i++) { - y = mtt_cseo (x, u, t, par); + y = mtt_${odeo} (x, u, t, par); u = mtt_input (x, y, t, par); if (0 == j) { - mtt_write (t, x, y, MTTNX, MTTNY); + //mtt_write (t, x, y, MTTNX, MTTNY); + mtt_write (t, x, y); } - dx = mtt_${ode} (x, u, t, par)(0).vector_value (); + dx = mtt_${ode} (x, u, t, par); EOF if [ "$method" = "implicit" ]; then -echo Hi $filename cat <> $filename AA = mtt_smxa (x, u, ddt, par); AAx = mtt_smxax (x, u, ddt, par); EOF @@ -524,11 +554,11 @@ fi ## Common stuff cat <> $filename open_switches = mtt_logic (x, u, t, par); - x = mtt_implicit (x, dx, AA, AAx, ddt, 1, open_switches); + x = $algorithm; t += ddt; j++; j = (j == (int)simpar ["stepfactor"].double_value ()) ? j : 0; }