TITLE Spring2 - Spring model with multiple SOLVEs : Simulation Resources, Inc. : Same model as spring.mod, except in this file there : are three state variables (x,y,z) solved separately : in BREAKPOINT with three separate SOLVE statements. : There is a slight variation in the solution, compared : with the model with a single variable, because of : the automatic time step adjustment in the adrunge : integration algorithm. Note: this method works only : when the independent variable for the calculation is : the same as the mathematical independent variable. : 3/10/1999 PARAMETER { m = 10 (kg) k = 80 (N/m) c = 5 (N-sec/m) } STATE { x FROM -15 TO 15 START 10 (m) y FROM -15 TO 15 START 10 (m) z FROM -15 TO 15 START 10 (m) } INDEPENDENT { time FROM 0 TO 8 WITH 80 (sec) } PLOT x,y VS time DERIVATIVE motion { x'' = (- 1/m)*(k * x + c * x') } DERIVATIVE motiony { y'' = (- 5/m)*(k * y + c * y') } DERIVATIVE motionz { z'' = (- 5/m)*(k * z + c * z') } BREAKPOINT { : Save the time variables. : Note that "time" is the independent : variable for the model (change as : needed). LOCAL save_time, save_indep save_time = time VERBATIM _lsave_indep = _sav_indep; ENDVERBATIM SOLVE motion : Reset the time variables for the : next SOLVE statement. time = save_time VERBATIM _sav_indep = _lsave_indep; ENDVERBATIM SOLVE motiony : Repeat as needed for other independent : SOLVE statements. time = save_time VERBATIM _sav_indep = _lsave_indep; ENDVERBATIM SOLVE motionz }