<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSim.xsl"?>
<fdm_config name="Piper PA-38 Tomahawk" version="2.0" release="ALPHA"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd">

 <fileheader>
  <author> Aeromatic v 0.95 </author>
  <filecreationdate>2016-07-17</filecreationdate>
  <version>$Revision: 1.15 $</version>
  <description> Models a Piper PA-38 Tomahawk. </description>
 </fileheader>

<!--
  File:     Piper PA-38 Tomahawk.xml
  Inputs:
    name:          Piper PA-38 Tomahawk
    type:          light single
    max weight:    1670.0 lb
    wing span:     34.0 ft
    length:        22.0 ft
    wing area:     unspecified
    gear type:     tricycle
    retractable?:  no
    # engines:     1
    engine type:   piston
    engine layout: forward fuselage
    yaw damper?    no

  Outputs:
    wing loading:  14.00 lb/sq-ft
    payload:       334.8 lbs
    CL-alpha:      5 per radian
    CL-0:          0.25
    CL-max:        1.4
    CD-0:          0.028
    K:             0.04

-->

 <metrics>
   <wingarea  unit="FT2">  124.75 </wingarea>
   <wingspan  unit="FT" >   34.02 </wingspan>
   <wing_incidence>          2.00 </wing_incidence>
   <chord     unit="FT" >    3.51 </chord>
   <htailarea unit="FT2">   22.68 </htailarea>
   <htailarm  unit="FT" >   10.06 </htailarm>
   <vtailarea unit="FT2">   11.93 </vtailarea>
   <vtailarm  unit="FT" >   11.00 </vtailarm>
   <location name="AERORP" unit="IN">
     <x> 75.72 </x>
     <y>   0.00 </y>
     <z>   0.00 </z>
   </location>
   <location name="EYEPOINT" unit="IN">
     <x> 56.72 </x>
     <y>  0.00 </y>
     <z>  7.00 </z>
   </location>
   <location name="VRP" unit="IN">
     <x>0</x>
     <y>0</y>
     <z>0</z>
   </location>
 </metrics>

 <mass_balance>
	<ixx unit="SLUG*FT2">1070</ixx>
	<iyy unit="SLUG*FT2">1249</iyy>
	<izz unit="SLUG*FT2">2312</izz>
   <ixy unit="SLUG*FT2">   0 </ixy>
   <ixz unit="SLUG*FT2">   0 </ixz>
   <iyz unit="SLUG*FT2">   0 </iyz>
   <emptywt unit="LBS"> 1128 </emptywt>
   <location name="CG" unit="IN">
     <x> 75.12 </x>
     <y>   0.00 </y>
     <z>  -9.42 </z>
   </location>

    <pointmass name="Pilot">
        <weight unit="LBS"> 176.37 </weight>
        <location name="POINTMASS" unit="IN">
            <x> 88 </x>
            <y> -18 </y>
            <z> -10.03 </z>
        </location>
    </pointmass>

    <pointmass name="Co-Pilot">
        <weight unit="LBS"> 176.37 </weight>
        <location name="POINTMASS" unit="IN">
            <x> 88 </x>
            <y> 18 </y>
            <z> -10.03 </z>
        </location>
    </pointmass>
    
    <pointmass name="Baggage">
        <description> Medium </description>
        <weight unit="LBS"> 0 </weight>
        <location name="POINTMASS" unit="IN">
            <x> 118.82 </x>
            <y>   0.00 </y>
            <z>  -7.23 </z>
        </location>
  </pointmass>

 </mass_balance>

 <ground_reactions>

  <contact type="BOGEY" name="NOSE">
   <location unit="IN">
     <x>  35.32 </x>
     <y>   0.00 </y>
     <z> -49.88 </z>
   </location>
   <static_friction>  0.72 </static_friction>
   <dynamic_friction> 0.60 </dynamic_friction>
   <rolling_friction> 0.02 </rolling_friction>
   <spring_coeff unit="LBS/FT">       1800.00 </spring_coeff>
   <damping_coeff unit="LBS/FT/SEC">   1000.00 </damping_coeff>
   <damping_coeff_rebound unit="LBS/FT/SEC">10</damping_coeff_rebound>
   <max_steer unit="DEG"> 30.00 </max_steer>
   <brake_group>NONE</brake_group>
   <retractable>0</retractable>
  </contact>

  <contact type="BOGEY" name="LEFT_MAIN">
   <location unit="IN">
     <x> 92.79 </x>
     <y> -50.72 </y>
     <z> -51.58 </z>
   </location>
   <static_friction>  0.43 </static_friction>
   <dynamic_friction> 0.60 </dynamic_friction>
   <rolling_friction> 0.02 </rolling_friction>
   <spring_coeff unit="LBS/FT">       2000.00 </spring_coeff>
   <damping_coeff unit="LBS/FT/SEC">  1500.00 </damping_coeff>
   <damping_coeff_rebound unit="LBS/FT/SEC">10</damping_coeff_rebound>
   <max_steer unit="DEG">0</max_steer>
   <brake_group>LEFT</brake_group>
   <retractable>0</retractable>
  </contact>

  <contact type="BOGEY" name="RIGHT_MAIN">
   <location unit="IN">
     <x> 92.79 </x>
     <y>  50.72 </y>
     <z> -51.58 </z>
   </location>
   <static_friction>  0.43 </static_friction>
   <dynamic_friction> 0.60 </dynamic_friction>
   <rolling_friction> 0.02 </rolling_friction>
   <spring_coeff unit="LBS/FT">       2000.00 </spring_coeff>
   <damping_coeff unit="LBS/FT/SEC">  1500.00 </damping_coeff>
   <damping_coeff_rebound unit="LBS/FT/SEC">10</damping_coeff_rebound>
   <max_steer unit="DEG">0</max_steer>
   <brake_group>RIGHT</brake_group>
   <retractable>0</retractable>
  </contact>

  <contact type="STRUCTURE" name="LEFT_WING">
    <location unit="IN">
     <x> 113.72 </x>
     <y> -17.00 </y>
     <z>   2.60 </z>
    </location>
    <static_friction>  0.75 </static_friction>
    <dynamic_friction> 0.60 </dynamic_friction>
    <spring_coeff unit="LBS/FT">       1670.00 </spring_coeff>
    <damping_coeff unit="LBS/FT/SEC">  370.00 </damping_coeff>
  </contact>

  <contact type="STRUCTURE" name="RIGHT_WING">
    <location unit="IN">
     <x> 113.72 </x>
     <y>  17.00 </y>
     <z>   2.60 </z>
    </location>
    <static_friction>  0.75 </static_friction>
    <dynamic_friction> 0.60 </dynamic_friction>
    <spring_coeff unit="LBS/FT">       1670.00 </spring_coeff>
    <damping_coeff unit="LBS/FT/SEC">   370.00 </damping_coeff>
  </contact>

  <contact type="STRUCTURE" name="NOSE">
    <location unit="IN">
     <x> -26.42 </x>
     <y>   0.00 </y>
     <z>  -6.60 </z>
    </location>
    <static_friction>  1.75 </static_friction>
    <dynamic_friction> 1.00 </dynamic_friction>
    <spring_coeff unit="LBS/FT">       1670.00 </spring_coeff>
    <damping_coeff unit="LBS/FT/SEC">   370.00 </damping_coeff>
  </contact>

  <contact type="STRUCTURE" name="TAIL">
    <location unit="IN">
     <x> 216.42 </x>
     <y>   0.00 </y>
     <z>   8.60 </z>
    </location>
    <static_friction>  0.75 </static_friction>
    <dynamic_friction> 0.60 </dynamic_friction>
    <spring_coeff unit="LBS/FT">       1670.00 </spring_coeff>
    <damping_coeff unit="LBS/FT/SEC">   370.00 </damping_coeff>
  </contact>

 </ground_reactions>

 <propulsion>

   <engine file="lyc_O-235">
    <feed>0</feed>
    <thruster file="sensenich">
     <sense> 1 </sense>
	 <p_factor>5</p_factor>	 
     <location unit="IN">
       <x>  12.00 </x>
       <y>   0.00 </y>
       <z>   -4.00 </z>
     </location>
     <orient unit="DEG">
       <pitch> 0.00 </pitch>
       <roll>  0.00 </roll>
       <yaw>   0.00 </yaw>
     </orient>
    </thruster>
  </engine>

	<tank type="FUEL" number="0"> <!-- Engine Pipe -->
		<location unit="IN">
			<x>   26.00 </x>
			<y>    0.0 </y>
			<z>    0.0 </z>
		</location>
		<capacity unit="LBS">  0.10 </capacity>
		<contents unit="LBS">  0.00 </contents>
		<type>AVGAS</type>  
		<priority>1</priority>
	</tank>

	<tank type="FUEL" number="1"> <!-- Left Wing Tank -->
		<location unit="IN">
			<x> 93.72 </x>
			<y>   -87.00 </y>
			<z>  -6.60 </z>
		</location>
		<capacity unit="LBS"> 96.30 </capacity>
		<contents unit="LBS">  72.20 </contents>
		<type>AVGAS</type> 
		<priority>1</priority>
	</tank>

	<tank type="FUEL" number="2"> <!-- Right Wing Tank -->
		<location unit="IN">
			<x> 93.72 </x>
			<y>	87.00 </y>
			<z>  -6.60 </z>
		</location>
		<capacity unit="LBS"> 96.30 </capacity>
		<contents unit="LBS">  72.20 </contents>
		<type>AVGAS</type> 
		<priority>1</priority>
	</tank>

 </propulsion>

	<system file="fuel"/>
	<system file="towbar"/> <!-- integrate towbar -->
 
 <flight_control name="FCS: Piper PA-38 Tomahawk">

        <channel name="Mixture">
            <!-- If the engine was primed enough times and throttle
                 is in starter position, then mixture is 1.
				 (Taked from J3Cub logic)
            -->
            <fcs_function name="fcs/mixture-primer-cmd">
                <function>
                    <table>
                        <independentVar lookup="row">/controls/engines/engine/primer</independentVar>
                        <independentVar lookup="column">/controls/engines/engine/throttle</independentVar>
                        <tableData>
                                 0.09    0.1    0.5    0.51
                            2    0       0      0      0
                            3    0       1      1      0
                            4    0       1      1      0
                            5    0       1      1      0
                            6    0       1      1      0
                            7    0       0      0      0
                        </tableData>
                    </table>
                </function>
            </fcs_function>

            <pure_gain name="fcs/mixture-primer">
                <input>fcs/mixture-cmd-norm</input>
                <gain>fcs/mixture-primer-cmd</gain>
            </pure_gain>

            <!-- Primer logic -->
            <switch name="Mixture Position">
                <default value="fcs/mixture-cmd-norm"/>
                <output>fcs/mixture-pos-norm</output>
                <!-- Use primer if used and engine is cold. If engine
                     is warm, then the mixture lever is used.
                -->
                <test logic="AND" value="fcs/mixture-primer">
                    /controls/engines/engine/use-primer eq 1
                    /engines/engine/oil-temperature-degf le 75
                </test>
            </switch>

        </channel>


		<!-- following code by Jonathan Redpath aka legoboyvdlp-->
		<channel name="NWS">
            <switch name="fcs/nws-enabled">
                <default value="0"/>
                <test logic="OR" value="1"> <!-- NWS mechanically centered if gear is fully extended -->
                    /gear/gear[0]/compression-norm gt 0.001
                </test>
            </switch>

            <fcs_function name="left brake nose-gear">
                <function name="fcs/nose-gear-left-brake-steer-factor">
                    <product>
                        <property>fcs/left-brake-cmd-norm</property>
                        <value>-1</value>
                    </product>
                </function>
            </fcs_function>

            <fcs_function name="right brake nose-gear">
                <function name="fcs/nose-gear-right-brake-steer-factor">
                    <product>
                        <property>fcs/right-brake-cmd-norm</property>
                        <value>1</value>
                    </product>
                </function>
            </fcs_function>

            <summer name="fcs/brake-sum">
                <input>fcs/nose-gear-right-brake-steer-factor</input>
                <input>fcs/nose-gear-left-brake-steer-factor</input>
                <clipto>
                    <min>-1</min>
                    <max>1</max>
                </clipto>
            </summer>

            <switch name="fcs/brake-influence-enabled"> <!-- brake should not influence nws if the aircraft is not moving -->
                <default value="0"/>
                <test logic="OR" value="1">
                    /gear/gear[0]/rollspeed-ms gt 0.25
                </test>
            </switch>

            <fcs_function name="fcs/brake-sum-adjusted">
                <function>
                    <product>
                        <property>fcs/brake-influence-enabled</property>
                        <property>fcs/brake-sum</property>
                    </product>
                </function>
            </fcs_function>

            <fcs_function name="fcs/nws-cmd-deg"> <!-- Drive the nose wheel with the rudder and brakes -->
                <function>
                    <table>
                        <independentVar lookup="row">fcs/brake-sum-adjusted</independentVar>
                        <independentVar lookup="column">/controls/flight/rudder</independentVar>
                        <tableData>
                                -1  0   1
                          -1    -29 0   11
                           0    -11 0   11
                           1    -11 0   29
                        </tableData>
                    </table>
                </function>
            </fcs_function>

            <fcs_function name="fcs/nws-cmd-deg-adjusted">
                <function>
                    <product>
                        <property>fcs/nws-cmd-deg</property>
                        <property>fcs/nws-enabled</property>
                    </product>
                </function>
            </fcs_function>

            <actuator name="fcs/steer-deg-actuator">
                <input>fcs/nws-cmd-deg-adjusted</input>
                <rate_limit>80</rate_limit> <!-- 80 deg / s , or 1/8 second to full deflection with NWS -->
                <output>fcs/steer-pos-deg-actuator</output>
            </actuator>
            <switch name="fcs/steer-pos-deg">
                <default value="fcs/steer-pos-deg-actuator"/>
                <test value="external_reactions/towbar/steer-deg">
                    external_reactions/towbar/attached eq 1
                    gear/unit[0]/WOW eq 1
                </test>
            </switch>
		</channel>


  <channel name="Pitch">

   <summer name="Pitch Trim Sum">
      <input>fcs/elevator-cmd-norm</input>
      <input>fcs/pitch-trim-cmd-norm</input>
      <clipto>
        <min> -1 </min>
        <max>  1 </max>
      </clipto>
   </summer>

   <aerosurface_scale name="Elevator Control">
      <input>fcs/pitch-trim-sum</input>
      <range>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </range>
      <output>fcs/elevator-pos-rad</output>
   </aerosurface_scale>

   <aerosurface_scale name="elevator normalization">
      <input>fcs/elevator-pos-rad</input>
      <domain>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </domain>
      <range>
        <min> -1 </min>
        <max>  1 </max>
      </range>
      <output>fcs/elevator-pos-norm</output>
   </aerosurface_scale>

  </channel>

  <channel name="Roll">

   <summer name="Roll Trim Sum">
      <input>fcs/aileron-cmd-norm</input>
      <input>fcs/roll-trim-cmd-norm</input>
      <clipto>
        <min> -1 </min>
        <max>  1 </max>
      </clipto>
   </summer>

   <aerosurface_scale name="Left Aileron Control">
      <input>fcs/roll-trim-sum</input>
      <range>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </range>
      <output>fcs/left-aileron-pos-rad</output>
   </aerosurface_scale>

   <aerosurface_scale name="Right Aileron Control">
      <input>fcs/roll-trim-sum</input>
      <range>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </range>
      <output>fcs/right-aileron-pos-rad</output>
   </aerosurface_scale>

   <aerosurface_scale name="left aileron normalization">
      <input>fcs/left-aileron-pos-rad</input>
      <domain>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </domain>
      <range>
        <min> -1 </min>
        <max>  1 </max>
      </range>
      <output>fcs/left-aileron-pos-norm</output>
   </aerosurface_scale>

   <aerosurface_scale name="right aileron normalization">
      <input>fcs/right-aileron-pos-rad</input>
      <domain>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </domain>
      <range>
        <min> -1 </min>
        <max>  1 </max>
      </range>
      <output>fcs/right-aileron-pos-norm</output>
   </aerosurface_scale>

  </channel>

  <channel name="Yaw">

   <summer name="Rudder Command Sum">
      <input>fcs/rudder-cmd-norm</input>
      <input>fcs/yaw-trim-cmd-norm</input>
      <clipto>
        <min> -1 </min>
        <max>  1 </max>
      </clipto>
   </summer>

   <aerosurface_scale name="Rudder Control">
      <input>fcs/rudder-command-sum</input>
      <range>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </range>
      <output>fcs/rudder-pos-rad</output>
   </aerosurface_scale>

   <aerosurface_scale name="rudder normalization">
      <input>fcs/rudder-pos-rad</input>
      <domain>
        <min> -0.35 </min>
        <max>  0.35 </max>
      </domain>
      <range>
        <min> -1 </min>
        <max>  1 </max>
      </range>
      <output>fcs/rudder-pos-norm</output>
   </aerosurface_scale>

  </channel>

<channel name="Flaps">
   <kinematic name="Flaps Control">
     <input>fcs/flap-cmd-norm</input>
     <traverse>
       <setting>
          <position>  0 </position>
          <time>      0 </time>
       </setting>
       <setting>
          <position> 21 </position>
          <time>    1.0 </time>
       </setting>
       <setting>
          <position> 34 </position>
          <time>    1.0 </time>
       </setting>
     </traverse>
     <output>fcs/flap-pos-deg</output>
   </kinematic>

   <aerosurface_scale name="flap normalization">
      <input>fcs/flap-pos-deg</input>
      <domain>
        <min>  0 </min>
        <max> 34 </max>
      </domain>
      <range>
        <min> 0 </min>
        <max> 1 </max>
      </range>
      <output>fcs/flap-pos-norm</output>
   </aerosurface_scale>
            <kinematic name="Flaps Lever">
                <input>/controls/flight/flaps</input>
                <traverse>
                    <setting>
                        <position>0</position>
                        <time>0</time>
                    </setting>
                    <setting>
                        <position>1</position>
                        <time>1</time>
                    </setting>
                </traverse>
                <output>/sim/model/pa38/cockpit/flaps-lever</output>
            </kinematic>

  </channel> 

 </flight_control>

 <aerodynamics>

  <axis name="LIFT">

    <function name="aero/force/Lift_alpha">
      <description>Lift due to alpha</description>
      <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <table>
            <independentVar lookup="row">aero/alpha-rad</independentVar>
            <tableData>
              -0.20 -0.750
               0.00  0.250
               0.23  1.400
               0.60  0.710
            </tableData>
          </table>
      </product>
    </function>

    <function name="aero/force/Lift_flap">
       <description>Delta Lift due to flaps</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
			<table>
				<independentVar>fcs/flap-pos-deg</independentVar>
				<tableData>
					0	0.00
					17	0.08
					34	0.28
				</tableData>
			</table> 
       </product>
    </function>

    <function name="aero/force/Lift_elevator">
       <description>Lift due to Elevator Deflection</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>fcs/elevator-pos-rad</property>
           <value>0.2</value>
       </product>
    </function>

  </axis>

  <axis name="DRAG">

    <function name="aero/force/Drag_basic">
       <description>Drag at zero lift</description>
       <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <table>
            <independentVar lookup="row">aero/alpha-rad</independentVar>
            <tableData>
             -1.57    1.500
             -0.26    0.036
              0.00    0.028
              0.26    0.036
              1.57    1.500
            </tableData>
          </table>
       </product>
    </function>

    <function name="aero/force/Drag_induced">
       <description>Induced drag</description>
         <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>aero/cl-squared</property>
           <value>0.04</value>
         </product>
    </function>

    <function name="aero/force/Drag_mach">
       <description>Drag due to mach</description>
        <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <table>
            <independentVar lookup="row">velocities/mach</independentVar>
            <tableData>
                0.00      0.000
                0.7      0.000
                1.10      0.023
                1.80      0.015
            </tableData>
          </table>
        </product>
    </function>

    <function name="aero/force/Drag_flap">
       <description>Drag due to flaps</description>
         <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>fcs/flap-pos-deg</property>
           <value> 0.00300 </value>
         </product>
    </function>

    <function name="aero/force/Drag_beta">
       <description>Drag due to sideslip</description>
       <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <table>
            <independentVar lookup="row">aero/beta-rad</independentVar>
            <tableData>
              -1.57    1.230
              -0.26    0.050
               0.00    0.000
               0.26    0.050
               1.57    1.230
            </tableData>
          </table>
       </product>
    </function>

    <function name="aero/force/Drag_elevator">
       <description>Drag due to Elevator Deflection</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <abs><property>fcs/elevator-pos-norm</property></abs>
           <value>0.04</value>
       </product>
    </function>

  </axis>

  <axis name="SIDE">

    <function name="aero/force/Side_beta">
       <description>Side force due to beta</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>aero/beta-rad</property>
           <value>-1</value>
       </product>
    </function>

  </axis>

  <axis name="ROLL">

    <function name="aero/moment/Roll_beta">
       <description>Roll moment due to beta</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>aero/beta-rad</property>
           <value>-0.1</value>
       </product>
    </function>

    <function name="aero/moment/Roll_damp">
       <description>Roll moment due to roll rate</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>aero/bi2vel</property>
           <property>velocities/p-aero-rad_sec</property>
           <value>-0.4</value>
       </product>
    </function>

    <function name="aero/moment/Roll_yaw">
       <description>Roll moment due to yaw rate</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>aero/bi2vel</property>
           <property>velocities/r-aero-rad_sec</property>
           <value>0.15</value>
       </product>
    </function>

    <function name="aero/moment/Roll_aileron">
       <description>Roll moment due to aileron</description>
       <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <property>metrics/bw-ft</property>
          <property>fcs/left-aileron-pos-rad</property>
          <value>0.17</value>
       </product>
    </function>

    <function name="aero/moment/Roll_rudder">
       <description>Roll moment due to rudder</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>fcs/rudder-pos-rad</property>
           <value>0.01</value>
       </product>
    </function>

  </axis>

  <axis name="PITCH">

    <function name="aero/moment/Pitch_alpha">
       <description>Pitch moment due to alpha</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/cbarw-ft</property>
           <property>aero/alpha-rad</property>
           <value>-0.5786</value>
       </product>
    </function>

    <function name="aero/moment/Pitch_elevator">
       <description>Pitch moment due to elevator</description>
       <product>
          <property>aero/qbar-psf</property>
          <property>metrics/Sw-sqft</property>
          <property>metrics/cbarw-ft</property>
          <property>fcs/elevator-pos-rad</property>
          <table>
            <independentVar lookup="row">velocities/mach</independentVar>
            <tableData>
              0.0     -1.100
              2.0     -0.275
            </tableData>
			</table>
       </product>
    </function>

    <function name="aero/moment/Pitch_damp">
       <description>Pitch moment due to pitch rate</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/cbarw-ft</property>
           <property>aero/ci2vel</property>
           <property>velocities/q-aero-rad_sec</property>
           <value>-12</value>
       </product>
    </function>

    <function name="aero/moment/Pitch_alphadot">
       <description>Pitch moment due to alpha rate</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/cbarw-ft</property>
           <property>aero/ci2vel</property>
           <property>aero/alphadot-rad_sec</property>
           <value>-7</value>
       </product>
    </function>

  </axis>

  <axis name="YAW">

    <function name="aero/moment/Yaw_beta">
       <description>Yaw moment due to beta</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>aero/beta-rad</property>
           <value>0.08</value>
       </product>
    </function>

    <function name="aero/moment/Yaw_damp">
       <description>Yaw moment due to yaw rate</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>aero/bi2vel</property>
           <property>velocities/r-aero-rad_sec</property>
           <value>-0.15</value>
       </product>
    </function>

    <function name="aero/moment/Yaw_rudder">
       <description>Yaw moment due to rudder</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>fcs/rudder-pos-rad</property>
           <value>-0.1</value>
       </product>
    </function>

    <function name="aero/moment/Yaw_aileron">
       <description>Adverse yaw</description>
       <product>
           <property>aero/qbar-psf</property>
           <property>metrics/Sw-sqft</property>
           <property>metrics/bw-ft</property>
           <property>fcs/left-aileron-pos-rad</property>
           <value>-0.01</value>
       </product>
    </function>

	<function name="aero/coefficient/Clalpha">
        <!-- This causes wing to drop/induces spin on stall -->
        <description>roll_moment_due_to_alpha</description>
        <product>
            <property>aero/qbar-psf</property>
            <property>metrics/Sw-sqft</property>
            <property>metrics/bw-ft</property>
            <value>400</value><!-- This sets the overall strength of the stall spin -->
            <!-- This sets the direction of the spin, based on current yaw rate.-->
            <table>
                <independentVar>velocities/r-aero-rad_sec</independentVar>
                <tableData>
                      -24.15             -1
                      -.0001             -1
                      0                   0
                      .0001               1
                      43.15               1       
                </tableData>
            </table>
            <!-- This sets the amount and direction of spin, based on alpha -->
            <table>
                <independentVar lookup="row">aero/alpha-deg</independentVar>
                <independentVar lookup="column">aero/Re</independentVar>
                <tableData>
					0     2000000     5000000   10000000    20000000
					-180.0    0.0   -0.00065    -0.0010   -0.00065    -0.000065                 
                    -24.0     0.0   -0.00025    -0.0002   -0.00020    -0.000020
                    -20.8     0.0   -0.00010    -0.00015  -0.000100   -0.0000100
                    -16.8     0.0   -0.000010   -0.000015 -0.0000100  -0.00000100
                    -15       0      0           0         0           0
                    0.0     0.0    0.0         0.0       0.0         0.0
                    15       0      0           0         0           0
                    16.8     0.0    0.000010    0.000020  0.0000100   0.00000100
                    20.8     0.0    0.00010     0.00020   0.000100    0.00000100
                    24       0.0    0.00030     0.00025   0.00030     0.0000025
                    180      0.0    0.00080     0.0030    0.00085     0.0000085
                </tableData>
            </table>
         </product>
	</function>
  </axis>

 </aerodynamics>

 <external_reactions>

        <!-- Towbar -->
        <force name="towbar" frame="BODY">
             <location unit="IN">
                <x>-10.31</x>
                <y>0</y>
                <z>-47.17</z>
            </location>
            <direction>
                <x>1</x>
                <y>0</y>
                <z>0</z>
            </direction>
        </force>

 </external_reactions>

	<system file="pa38-engine"/>

</fdm_config>

