REQUIRE "ivpsystem.a4l"; REQUIRE "johnpye/dsg.a4c"; MODEL dsg_array; t IS_A time; dz IS_A distance; n IS_A integer_constant; n :== 3; node[1..n] IS_A dsg; (* consistent design *) node[1..n].rhow ARE_THE_SAME; node[1..n].D2 ARE_THE_SAME; node[1..n].cw ARE_THE_SAME; node[1..n].hw ARE_THE_SAME; node[1..n].qdots ARE_THE_SAME; node[1..n].Tamb ARE_THE_SAME; (* central difference *) FOR i IN [2..(n-1)] CREATE node[i].dp_dz = (node[i+1].p - node[i-1].p)/(2*dz); node[i].dmdot_dz = (node[i+1].mdot - node[i-1].mdot)/(2*dz); node[i].dmdoth_dz = (node[i+1].mdoth - node[i-1].mdoth)/(2*dz); node[i].drhovel2_dz = (node[i+1].rhovel2 - node[i-1].rhovel2)/(2*dz); node[i].dekdot_dz = (node[i+1].ekdot - node[i-1].ekdot)/(2*dz); END FOR; (* backward difference *) FOR i IN [n] CREATE dz_p[i]: node[i].dp_dz = (node[i].p - node[i-1].p)/dz; dz_mdot[i]: node[i].dmdot_dz = (node[i].mdot - node[i-1].mdot)/dz; dz_mdoth[i]: node[i].dmdoth_dz = (node[i].mdoth - node[i-1].mdoth)/dz; dz_rhovel2[i]: node[i].drhovel2_dz = (node[i].rhovel2 - node[i-1].rhovel2)/dz; dz_ekdot[i]: node[i].dekdot_dz = (node[i].ekdot - node[i-1].ekdot)/dz; END FOR; (* forward difference *) FOR i IN [1] CREATE node[i].dp_dz = (node[i+1].p - node[i].p)/dz; node[i].dmdot_dz = (node[i+1].mdot - node[i].mdot)/dz; node[i].dmdoth_dz = (node[i+1].mdoth - node[i].mdoth)/dz; node[i].drhovel2_dz = (node[i+1].rhovel2 - node[i].rhovel2)/dz; node[i].dekdot_dz = (node[i+1].ekdot - node[i].ekdot)/dz; END FOR; METHODS METHOD specify; FOR i IN [1..n] DO RUN node[i].fix_design; RUN node[i].fix_states; END FOR; RUN node[1].fix_temporals; RUN node[2].fix_temporals; END specify; METHOD values; FOR i IN [1..n] DO RUN node[i].values; END FOR; END values; METHOD on_load; RUN specify; RUN values; END on_load; END dsg_array;