—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-1 Day 5 Section 9 - Continuous Simulation –Exercise 9 Section 10 - Animation –Demonstration of SIMANIMATION –Exercise 10
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-2 Exercise 9 Missile Flight C:\Program Files\Simscript3\models\MISSILE
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-3 Missile Flight Problem X Y Angle
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-4 Continuous Simulation Given an equation for the rate of change of a variable, calculate the value of the variable continuously d(angle) = -.1 (radians/sec) dt dx = speed * cos(angle) dt dy = speed * sin(angle) dt
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-5 Continuous Simulation (continued) Preamble Processes include Every MISSILE has an X, a Y, a SPEED, an ANGLE Define X,Y,ANGLE as continuous real variables Define QUIT as an integer function End ''Preamble Process MISSILE Work continuously evaluating'EQUATIONS' testing'QUIT' End ''MISSILE
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-6 Continuous Simulation (continued) Routine EQUATIONS Given.MSL Let D.ANGLE(.MSL) = -.1 ''radians/second Let D.X(.MSL) = SPEED(.MSL) * cos.f(ANGLE(.MSL)) Let D.Y(.MSL) = SPEED(.MSL) * sin.f(ANGLE(.MSL)) End ''EQUATIONS Function QUIT If time.v > 5 ''seconds Return with 1 Endif ''time.v > 5 Return with 0 End ''QUIT
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— Preamble 2 3 '' Sample continuous simulation program 4 '' CACI Products Company, Normally mode is undefined 7 8 Processes include 9 REPORT Every MISSILE has 12 an MSL.X, 13 a MSL.Y, 14 a MSL.SPEED, 15 an MSL.ANGLE and 16 a MSL.PITCH.RATE Define MSL.PITCH.RATE as a real variable Define MSL.X, 21 MSL.Y, 22 MSL.SPEED and 23 MSL.ANGLE 24 as continuous real variables Define PITCH.OVER and 27 FLIGHT.TIME 28 as integer functions Define seconds to mean units 31 Define second to mean units End ''Preamble
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— Main 2 3 Open unit 10 for input, name = "MISSILE.DAT" 4 Use unit 10 for input 5 6 ''Defaults 7 Read max.step.v, ''.1 8 min.step.v, ''.01 9 abs.err.v and '' rel.err.v '' Close unit Activate a MISSILE now 15 Activate a REPORT now Start simulation End ''Main 1 Process MISSILE 2 3 Let MSL.SPEED(MISSILE) = 500 ''feet per second 4 Let MSL.ANGLE(MISSILE) = pi.c / 4 ''radians 5 6 Work continuously evaluating 'FLIGHT' testing 'PITCH.OVER' 7 8 Let MSL.PITCH.RATE(MISSILE) = ''radians per second 9 Work continuously evaluating 'FLIGHT' testing 'FLIGHT.TIME' Suspend End ''MISSILE
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— Routine FLIGHT 2 3 Given 4.MSL ''Pointer to missile process notice 5 6 Define.MSL as a pointer variable 7 8 Let D.MSL.ANGLE(.MSL) = MSL.PITCH.RATE(.MSL) 9 Let D.MSL.X(.MSL) = MSL.SPEED(.MSL) * cos.f(MSL.ANGLE(.MSL)) 10 Let D.MSL.Y(.MSL) = MSL.SPEED(.MSL) * sin.f(MSL.ANGLE(.MSL)) End ''FLIGHT 1 Function PITCH.OVER 2 Given 3.MSL ''Pointer to missile process notice 4 5 Define.MSL as a pointer variable 6 7 Let.MSL =.MSL 8 9 If time.v > 5 ''seconds 10 Return with 1 ''End integration 11 Endif ''time.v > 5 seconds Return with 0 ''Continue integration End ''PITCH.OVER
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— Function FLIGHT.TIME 2 3 Given 4.MSL ''Pointer to missile process notice 5 6 Define.MSL as a pointer variable 7 8 If MSL.ANGLE(.MSL) < -pi.c / 4 9 Return with 1 ''Pitch over is complete 10 Endif ''MSL.ANGLE(.MSL) < -pi.c / Return with 0 ''Continue simulation End ''FLIGHT.TIME
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— Process REPORT 2 3 Define.TERMINAL.MSL.ANGLE as a real variable 4 5 Let.TERMINAL.MSL.ANGLE = - pi.c / Print 3 lines thus Time MSL.X MSL.Y Angle Use unit 6 for output 12 Until MSL.ANGLE(MISSILE) <=.TERMINAL.MSL.ANGLE do Print 1 line with time.v, 15 MSL.X(MISSILE), 16 MSL.Y(MISSILE), 17 MSL.ANGLE(MISSILE) * radian.c thus ** **** **** **.* Wait 1 second Loop ''MSL.ANGLE(MISSILE) > =.TERMINAL.MSL.ANGLE do Read as / using unit Stop End ''REPORT
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-12 Values of Runge-Kutta parameters:.1,.1,.1,.1 Time MSL.X MSL.Y Angle
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-13 Values of Runge-Kutta parameters:.1,.01,.0001,.01 Time MSL.X MSL.Y Angle
—————————— CACI Products Company —————————————————————————————— SimScript II.5 —————————————— 9-14 This page is intentionally blank