<?xml version="1.0" encoding="UTF-8"?>
<!--
**************************************************************************

Beagle Pup Aerodynamics (JSBSim)

Copyright (c) 2015 Richard Senior

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

**************************************************************************
-->
<aerodynamics>

  <axis name="LIFT">

    <function name="aero/force/Lift_propwash">
      <description>Delta lift due to propeller induced velocity</description>
      <product>
        <property>propulsion/engine[0]/thrust-coefficient</property>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>tuning/lift-propwash</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <independentVar lookup="column">fcs/flap-pos-deg</independentVar>
          <tableData>
            0.0     60.0
            -0.24  0.000   0.000
            0.00  0.039   0.105
            0.17  0.187   0.498
            0.34  0.000   0.000
          </tableData>
        </table>
      </product>
    </function>

    <!-- Lift above 0.85 and below -0.85 is generalised -->
    <function name="aero/force/Lift_alpha">
      <description>Lift due to alpha</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>tuning/lift-alpha</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <tableData>
            -1.57  0.0000
            -1.22 -0.6056
            -1.05 -0.8159
            -0.88 -0.9422
            -0.64 -0.3246
            -0.19 -0.8116
            0.00  0.2173
            0.15  1.0288
            0.60  0.5419
            0.88  1.0578
            1.05  0.9161
            1.22  0.6800
            1.57  0.0000
          </tableData>
        </table>
      </product>
    </function>

    <function name="aero/force/Lift_pitch_rate">
      <description>Lift due to pitch rate</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>velocities/q-aero-rad_sec</property>
        <property>aero/ci2vel</property>
        <property>tuning/lift-pitch-rate</property>
        <value> 5.7349 </value>
      </product>
    </function>

    <function name="aero/force/Lift_alpha_rate">
      <description>Lift due to alpha rate</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>aero/alphadot-rad_sec</property>
        <property>aero/ci2vel</property>
        <property>tuning/lift-alpha-rate</property>
        <value> 2.2848 </value>
      </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>
        <property>tuning/lift-elevator</property>
        <value> 0.6172 </value>
      </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>
        <property>fcs/flap-pos-deg</property>
        <property>tuning/lift-flap</property>
        <value> 0.0123 </value>
      </product>
    </function>

  </axis>

  <axis name="DRAG">

    <!-- CD0 is based on fuselage, wing, horizontal- en vertical tail -->
    <!-- Antennas, struts and wires are not taken into account        -->
    <!-- CD for gear (fixed and retractable) is defined below         -->
    <function name="aero/force/Drag_minimum">
      <description>Minimum drag</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>tuning/drag-minimum</property>
        <value> 0.0222 </value>
      </product>
    </function>

    <function name="aero/force/Drag_alpha">
      <description>Drag due to alpha</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>tuning/drag-alpha</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <tableData>
            -1.57    1.4107
            -0.15    0.0151
            0.00    0.0000
            0.15    0.0151
            1.57    1.4107
          </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>
        <property>tuning/drag-induced</property>
        <value> 0.0427 </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>
        <property>tuning/drag-mach</property>
        <table>
          <independentVar lookup="row">velocities/mach</independentVar>
          <tableData>
            0.00    0.0000
            0.70    0.0000
            1.10    0.0230
            1.80    0.0150
          </tableData>
        </table>
      </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>
        <property>tuning/drag-beta</property>
        <table>
          <independentVar lookup="row">aero/beta-rad</independentVar>
          <tableData>
            -1.57    1.2300
            -0.26    0.0500
            0.00    0.0000
            0.26    0.0500
            1.57    1.2300
          </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-rad</property></abs>
        <property>tuning/drag-elevator</property>
        <value> 0.0400 </value>
      </product>
    </function>

    <function name="aero/force/Drag_gear">
      <description>Drag due to gear</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>tuning/drag-gear</property>
        <value> 0.0040 </value>
      </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>
        <property>tuning/drag-flap</property>
        <value> 0.0009 </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>
        <property>tuning/side-beta</property>
        <value> -0.8316 </value>
      </product>
    </function>

    <function name="aero/force/Side_roll_rate">
      <description>Side force due to roll rate</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>aero/bi2vel</property>
        <property>velocities/p-aero-rad_sec</property>
        <property>tuning/side-roll-rate</property>
        <table>
          <independentVar lookup="row">aero/Re</independentVar>
          <tableData>
            2546810   0.1872
            2801491   0.0160
            3820215   0.0071
            5115503   0.0040
          </tableData>
        </table>
      </product>
    </function>

    <function name="aero/force/Side_yaw_rate">
      <description>Side force due to yaw rate</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>aero/bi2vel</property>
        <property>velocities/r-aero-rad_sec</property>
        <property>tuning/side-yaw-rate</property>
        <value> 0.6621 </value>
      </product>
    </function>

    <function name="aero/force/Side_rudder">
      <description>Side force due to rudder</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>fcs/rudder-pos-rad</property>
        <property>tuning/side-rudder</property>
        <value> 0.2554 </value>
      </product>
    </function>

  </axis>

  <axis name="PITCH">

    <function name="aero/moment/Pitch_propwash">
      <description>Pitch moment due to propeller induced velocity</description>
      <product>
        <property>propulsion/engine[0]/thrust-coefficient</property>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>metrics/bw-ft</property>
        <property>tuning/pitch-propwash</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <independentVar lookup="column">fcs/flap-pos-deg</independentVar>
          <tableData>
            0.0     60.0
            -0.01  0.000   0.000
            0.00 -0.028  -0.075
            0.17 -0.133  -0.356
            0.22  0.000   0.000
          </tableData>
        </table>
      </product>
    </function>

    <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>
        <property>tuning/pitch-alpha</property>
        <value> -1.8646 </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>
        <property>tuning/pitch-elevator</property>
        <table>
          <independentVar lookup="row">velocities/mach</independentVar>
          <tableData>
            0.0    -1.8682
            2.0    -0.4670
          </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>
        <property>tuning/pitch-damp</property>
        <value> -17.8086 </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>
        <property>tuning/pitch-alphadot</property>
        <value> -7.0951 </value>
      </product>
    </function>

  </axis>

  <axis name="ROLL">

    <function name="aero/moment/Roll_differential_propwash">
      <description>Roll moment due to differential propwash</description>
      <product>
        <property>propulsion/engine[0]/thrust-coefficient</property>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>metrics/bw-ft</property>
        <property>aero/alpha-rad</property>
        <property>tuning/roll-differential-propwash</property>
        <value> 0.1412 </value>
      </product>
    </function>

    <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>
        <property>tuning/roll-beta</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <independentVar lookup="column">aero/Re</independentVar>
          <tableData>
            2546810  2801491  3820215  5115503
            -0.0349  -0.4144  -0.1765  -0.1642  -0.1599
            0.3491  -0.5393  -0.2020  -0.1904  -0.1874
          </tableData>
        </table>
      </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>
        <property>tuning/roll-damp</property>
        <value> -0.4599 </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>
        <property>tuning/roll-yaw</property>
        <table>
          <independentVar lookup="row">aero/alpha-rad</independentVar>
          <independentVar lookup="column">aero/Re</independentVar>
          <tableData>
            2546810  2801491  3820215  5115503
            -0.0349  -0.0144  -0.0144  -0.0144  -0.0144
            0.3491   2.5507   0.5068   0.5068   0.5068
          </tableData>
        </table>
      </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>
        <property>tuning/roll-aileron</property>
        <table>
          <independentVar lookup="row">velocities/mach</independentVar>
          <tableData>
            0.0    0.1700
            2.0    0.0425
          </tableData>
        </table>
      </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>
        <property>tuning/roll-rudder</property>
        <value> 0.0100 </value>
      </product>
    </function>

  </axis>

  <axis name="YAW">

    <!-- Stall initiator -->
    <function name="aero/moment/Yaw_alpha">
      <description>Yaw moment due to alpha</description>
      <product>
        <property>aero/qbar-psf</property>
        <property>metrics/Sw-sqft</property>
        <property>metrics/bw-ft</property>
        <property>aero/alpha-rad</property>
        <property>fcs/gear-no-wow</property>
        <property>tuning/yaw-alpha</property>
        <table>
          <independentVar lookup="row">aero/beta-rad</independentVar>
          <independentVar lookup="column">aero/Re</independentVar>
          <tableData>
            2546810  2801491
            -0.3491  -1.0000   0.0000
            0.3491   1.0000   0.0000
          </tableData>
        </table>
      </product>
    </function>

    <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>
        <property>tuning/yaw-beta</property>
        <value> 0.1591 </value>
      </product>
    </function>

    <function name="aero/moment/Yaw_roll_rate">
      <description>Yaw 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-rad_sec</property>
        <property>tuning/yaw-roll-rate</property>
        <table>
          <independentVar lookup="row">aero/Re</independentVar>
          <tableData>
            2546810  -0.0745
            2801491  -0.0063
            3820215  -0.0028
            5115503  -0.0016
          </tableData>
        </table>
      </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>
        <property>tuning/yaw-damp</property>
        <value> -0.1332 </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>
        <property>tuning/yaw-rudder</property>
        <value> -0.1017 </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>
        <property>tuning/yaw-aileron</property>
        <value> -0.0100 </value>
      </product>
    </function>

  </axis>

</aerodynamics>
