<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://jsbsim.sf.net/JSBSimScript.xsl"?>
<runscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://jsbsim.sf.net/JSBSimScript.xsd"
    name="Jupiter 246">
  <description>
    This run is for testing the J246 Launch Vehicle
  </description>
  <use aircraft="J246" initialize="LC39"/>
  <run start="0.0" end="420" dt="0.0083333333333333333">

    <property value="2">simulation/integrator/rate/rotational</property>
    <property value="3">simulation/integrator/rate/translational</property>
    <property value="3">simulation/integrator/position/rotational</property>
    <property value="3">simulation/integrator/position/translational</property>

    <!--<property value="23"> atmosphere/delta-T </property>-->
    <property> simulation/notify-time-trigger </property>
    <property value="1"> forces/hold-down </property>

    <event name="Winds aloft" continuous="true">
      <condition>simulation/sim-time-sec  ge  10000.05</condition>
      <set name="atmosphere/psiw-rad">
        <function>
          <table>
            <independentVar lookup="row"> position/h-agl-ft </independentVar>
            <tableData>
          <!-- Alt (ft)  Dir (rad) -->
                   0.0    0.80
                5000.0    0.90
               10000.0    1.00
               15000.0    0.90
               20000.0    0.70
               25000.0    0.80
               30000.0    0.90
               35000.0    1.00
               40000.0    1.10
               45000.0    1.20
               50000.0    1.30
               55000.0    1.40
               60000.0    1.30
               65000.0    1.20
               70000.0    1.30
              100000.0    1.40
              200000.0    1.50
            </tableData>
          </table>
        </function>
      </set>
      <set name="atmosphere/wind-mag-fps">
        <function>
          <table>
            <independentVar lookup="row"> position/h-agl-ft </independentVar>
            <tableData>
          <!-- Alt (ft)  Speed (fps) -->
                   0.0     10.0
                5000.0     40.0
               10000.0     60.0
               15000.0    120.0
               20000.0    135.0
               25000.0    140.0
               30000.0    130.0
               35000.0    120.0
               40000.0    110.0
               45000.0    110.0
               50000.0    100.0
               55000.0     90.0
               60000.0     85.0
               65000.0     60.0
               70000.0     40.0
               100000.0    10.0
               200000.0     5.0
            </tableData>
          </table>
        </function>
      </set>
      <notify/>
    </event>

    <event name="Start SSME">
      <condition>simulation/sim-time-sec  ge  6.0</condition>
      <set name="fcs/throttle-cmd-norm[2]" value="1.0" action="exp" tc="0.5"/>
      <set name="fcs/throttle-cmd-norm[3]" value="1.0" action="exp" tc="0.5"/>
      <set name="fcs/throttle-cmd-norm[4]" value="1.0" action="exp" tc="0.5"/>
      <set name="fcs/throttle-cmd-norm[5]" value="1.0" action="exp" tc="0.5"/>
      <notify/>
    </event>

    <event name="Start Solid Rocket Boosters">
      <condition>simulation/sim-time-sec  ge  12.0</condition>
      <set name="fcs/throttle-cmd-norm[0]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[1]" value="1.0"/>
      <notify/>
    </event>

    <event name="Release">
      <condition>forces/fbx-prop-lbs gt inertia/weight-lbs</condition>
      <set name="forces/hold-down" value="0"/>
      <notify/>
    </event>
    
    <event name="Vehicle state:" persistent="true">
      <description>Output message at 10 second intervals</description>
      <notify>
        <description>Vehicle state:</description>
        <property caption="Mission Elapsed Time:    "> guidance/executive/MET </property>
        <property caption="ECI Velocity (fps):      "> velocities/eci-velocity-mag-fps </property>
        <property caption="Orbital apogee (miles):  "> guidance/executive/apoapsis </property>
        <property caption="Orbital perigee (miles): "> guidance/executive/periapsis </property>
        <property caption="Orbital eccentricity:    "> guidance/executive/eccentricity </property>
        <property caption="Altitude AGL (ft):       "> position/h-agl-ft </property>
        <property caption="Alpha (deg):             "> aero/alpha-deg </property>
        <property caption="Pitch rate cmd:          "> guidance/executive/gravity-turn-pitch-rate-command </property>
        <property caption="Thetadot (rad/sec):      "> velocities/thetadot-rad_sec </property>
        <property caption="Roll angle (rad):        "> attitude/phi-rad </property>
        <property caption="Pitch angle (rad):       "> attitude/theta-rad </property>
        <property caption="Heading (rad):           "> attitude/psi-rad </property>
        <property caption="Hold-down discrete:      "> forces/hold-down </property>
        <property caption="Throttle (norm):         "> fcs/throttle-cmd-norm[0] </property>
        <property caption="GNC Mode:                "> guidance/executive/current-mode </property>
      </notify>
      <condition> simulation/sim-time-sec >= simulation/notify-time-trigger </condition>
      <set name="simulation/notify-time-trigger" value="10" type="delta"/>
    </event>

    <event name="Jettison SRBs">
      <condition logic="OR">
        guidance/executive/left-srb-sep-flag eq 1
        guidance/executive/right-srb-sep-flag eq 1
      </condition>
      <set name="inertia/pointmass-weight-lbs[0]" value="0"/>
      <set name="inertia/pointmass-weight-lbs[1]" value="0"/>
      <notify/>
    </event>

    <event name="Jettison LAS">
      <condition>
        guidance/executive/las-jettison-flag eq 1
      </condition>
      <set name="inertia/pointmass-weight-lbs[18]" value="0"/>
      <notify/>
    </event>

    <event name="Core Stage Separation">
      <condition>
        guidance/upper-stage-flight-flag eq 1
      </condition>
      <set name="inertia/pointmass-weight-lbs[2]" value="0"/>
      <set name="inertia/pointmass-weight-lbs[3]" value="0"/>
      <set name="inertia/pointmass-weight-lbs[4]" value="0"/>
      <set name="inertia/pointmass-weight-lbs[5]" value="0"/>
      <set name="inertia/pointmass-weight-lbs[6]" value="0"/>
      <notify/>
    </event>

    <event name="Start Upper Stage Engines">
      <condition>
        guidance/upper-stage-flight-flag eq 1
      </condition>
      <delay> 2.0 </delay>
      <set name="fcs/throttle-cmd-norm[6]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[7]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[8]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[9]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[10]" value="1.0"/>
      <set name="fcs/throttle-cmd-norm[11]" value="1.0"/>
      <notify/>
    </event>

  </run>
</runscript>
