<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
Diamond DA 40 - Emmanuel BARANGER - 2013
      Updated - Emmanuel BARANGER - 10/2019
      Updated - Emmanuel BARANGER - 04/2020
      Updated - Emmanuel BARANGER - 08/2022

  source       : http://en.wikipedia.org/wiki/Diamond_DA40

  Wingspan     : 39 ft 2 in ( 11.90 m    )
  lenght       : 26 ft 5 in (  8.10 m    )
  height       :  6 ft 6 in (  1.98 m    )
  Empty mass   :    1755 lb (   795 kg   )
  Gross weight :    2641 lb (  1198 kg   )
  Engine       :  1 x Lycoming IO-360-M1A air-cooled, 4-cylinder horizontally-opposed piston engine (180 hp)
  Cruise speed :     150 kt (   279 km/h )
-->
<airplane mass="1755" version="YASIM_VERSION_CURRENT" mtow-lbs="2641">

  <!-- Approach configuration -->
  <approach speed="50" aoa="4" fuel="0.3">
    <control-setting axis="/controls/engines/engine[0]/throttle"        value="0.2"/>
    <control-setting axis="/controls/engines/engine[0]/mixture"         value="1.0"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="0.5"/>
    <control-setting axis="/controls/flight/flaps"                      value="1"/>
    <control-setting axis="/controls/gear/gear-down"                    value="1"/>
  </approach>

  <!-- Cruise configuration -->
  <cruise speed="150" alt="16400" fuel="0.7">
    <control-setting axis="/controls/engines/engine[0]/throttle"        value="0.75"/>
    <control-setting axis="/controls/engines/engine[0]/mixture"         value="1"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="1"/>
    <control-setting axis="/controls/flight/flaps"                      value="0"/>
    <control-setting axis="/controls/gear/gear-down"                    value="0"/>
  </cruise>

  <cockpit x="1.541" y="0.222" z="0.362"/>

  <!-- Bol -->
  <fuselage ax=" 4.050" ay=" 0.000" az=" 0.003" bx=" 4.031" by=" 0.000" bz=" 0.003" width="0.106" taper="0.00" midpoint="1"/>
  <fuselage ax=" 4.031" ay=" 0.000" az=" 0.003" bx=" 3.976" by=" 0.000" bz=" 0.003" width="0.181" taper="0.60" midpoint="1"/>
  <fuselage ax=" 3.976" ay=" 0.000" az=" 0.003" bx=" 3.812" by=" 0.000" bz=" 0.003" width="0.262" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.812" ay=" 0.000" az=" 0.003" bx=" 3.651" by=" 0.000" bz=" 0.003" width="0.289" taper="0.90" midpoint="1"/>

  <!-- Fuselage -->
  <!-- center -->
  <fuselage ax=" 3.651" ay=" 0.000" az=" 0.003" bx=" 3.432" by=" 0.000" bz="-0.037" width="0.450" taper="0.64" midpoint="1"/>
  <fuselage ax=" 3.432" ay=" 0.000" az="-0.037" bx=" 3.091" by=" 0.000" bz="-0.094" width="0.588" taper="0.78" midpoint="1"/>
  <fuselage ax=" 3.091" ay=" 0.000" az="-0.094" bx=" 2.578" by=" 0.000" bz="-0.094" width="0.621" taper="0.94" midpoint="1"/>

  <fuselage ax="-1.363" ay=" 0.000" az="-0.049" bx="-3.335" by=" 0.000" bz="-0.049" width="0.371" taper="0.30" midpoint="0"/>

  <!-- Left -->
  <fuselage ax=" 3.651" ay=" 0.190" az=" 0.003" bx=" 3.432" by=" 0.190" bz="-0.037" width="0.450" taper="0.64" midpoint="1"/>
  <fuselage ax=" 3.432" ay=" 0.190" az="-0.037" bx=" 3.091" by=" 0.178" bz="-0.094" width="0.588" taper="0.78" midpoint="1"/>
  <fuselage ax=" 3.091" ay=" 0.180" az="-0.094" bx=" 2.578" by=" 0.213" bz="-0.094" width="0.621" taper="0.94" midpoint="1"/>
  <fuselage ax=" 2.578" ay=" 0.213" az="-0.094" bx=" 2.139" by=" 0.213" bz="-0.094" width="0.699" taper="0.90" midpoint="1"/>
  <fuselage ax=" 2.139" ay=" 0.213" az="-0.094" bx=" 0.552" by=" 0.213" bz="-0.094" width="0.699" taper="1.00" midpoint="1"/>
  <fuselage ax=" 0.604" ay=" 0.213" az="-0.094" bx="-0.937" by=" 0.058" bz="-0.049" width="0.699" taper="0.54" midpoint="0"/>
  <fuselage ax="-0.937" ay=" 0.058" az="-0.049" bx="-1.363" by=" 0.000" bz="-0.049" width="0.382" taper="0.98" midpoint="0"/>

  <!-- Right -->
  <fuselage ax=" 3.651" ay="-0.190" az=" 0.003" bx=" 3.432" by="-0.190" bz="-0.037" width="0.450" taper="0.64" midpoint="1"/>
  <fuselage ax=" 3.432" ay="-0.190" az="-0.037" bx=" 3.091" by="-0.178" bz="-0.094" width="0.588" taper="0.78" midpoint="1"/>
  <fuselage ax=" 3.091" ay="-0.180" az="-0.094" bx=" 2.578" by="-0.213" bz="-0.094" width="0.621" taper="0.94" midpoint="1"/>
  <fuselage ax=" 2.578" ay="-0.213" az="-0.094" bx=" 2.139" by="-0.213" bz="-0.094" width="0.699" taper="0.90" midpoint="1"/>
  <fuselage ax=" 2.139" ay="-0.213" az="-0.094" bx=" 0.552" by="-0.213" bz="-0.094" width="0.699" taper="1.00" midpoint="1"/>
  <fuselage ax=" 0.604" ay="-0.213" az="-0.094" bx="-0.937" by="-0.058" bz="-0.049" width="0.699" taper="0.54" midpoint="0"/>
  <fuselage ax="-0.937" ay="-0.058" az="-0.049" bx="-1.363" by=" 0.000" bz="-0.049" width="0.382" taper="0.98" midpoint="0"/>

  <!-- Cockpit -->
  <fuselage ax=" 2.589" ay=" 0.000" az="-0.057" bx=" 1.505" by=" 0.000" bz=" 0.041" width="1.030" taper="0.54" midpoint="1"/>
  <fuselage ax=" 1.599" ay=" 0.000" az=" 0.032" bx=" 0.787" by=" 0.000" bz=" 0.165" width="1.030" taper="0.80" midpoint="0"/>
  <fuselage ax=" 0.906" ay=" 0.000" az=" 0.154" bx="-0.932" by=" 0.000" bz="-0.049" width="0.824" taper="0.45" midpoint="0"/>

  <wing x="1.098" y="0" z="-0.329"
        chord    = "1.371"
        length   = "5.556"
        taper    = "0.67"
        dihedral = "3.2"
        sweep    = "-1.7"
        camber   = "0.05">
        <stall   aoa="20" width="1"    peak="1.5"/>
        <flap0 start="0.22" end="0.70" lift="1.4" drag="1.5"/>
        <flap1 start="0.70" end="1.00" lift="1.2" drag="1.1"/>

        <control-input  control="FLAP0" axis="/controls/flight/flaps"/>
        <control-input  control="FLAP1" axis="/controls/flight/aileron"                  split="true"/>
        <control-input  control="FLAP1" axis="/controls/flight/aileron-trim"             split="true"/>

        <control-output control="FLAP0" prop="/surface-positions/flap-pos-norm"/>
        <control-output control="FLAP1" prop="/surface-positions/left-aileron-pos-norm"  side="left"/>
        <control-output control="FLAP1" prop="/surface-positions/right-aileron-pos-norm" side="right"/>

        <control-speed  control="FLAP1" transition-time="0.01"/>
        <control-speed  control="FLAP0" transition-time="5"/>
  </wing>

  <wing x="1.260" y="5.551" z="-0.017"
        append    = "1"
        chord     = "0.90"
        length    = "0.50"
        taper     = "0.40"
        dihedral  = "25"
        incidence = "1"
        sweep     = "30">
        <stall aoa="20" width="1" peak="1.5"/>
  </wing>

  <hstab x="-3.56176" y="0" z="0.93372"
         chord  = "1.001"
         length = "1.626"
         taper  = "0.50"
         sweep  = "4">
         <stall   aoa="18" width="1" peak="1.35"/>
         <flap0 start="0"    end="1" lift="1.4" drag="1"/>

         <control-input  control="FLAP0" axis="/controls/flight/elevator"/>
         <control-input  control="FLAP0" axis="/controls/flight/elevator-trim"/>

         <control-output control="FLAP0" prop="/surface-positions/elevator-pos-norm"/>
  </hstab>

  <vstab x="-3.11094" y="0" z="-0.106"
         chord  = "1.385"
         length = "1.143"
         taper  = "0.60"
         sweep  = "25">
         <stall   aoa="16" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.4" drag="1.3"/>

         <control-input  control="FLAP0" axis="/controls/flight/rudder" invert="true"/>

         <control-output control="FLAP0" prop="/surface-positions/rudder-pos-norm"/>
  </vstab>

  <!--  Lycoming IO-320-L2A
                 source       : http://en.wikipedia.org/wiki/Lycoming_IO-360#IO-360

                 type         : Four-cylinder, dual magneto, horizontally opposed, four-stroke aircraft engine
                 power        : 180 hp at 2700 rpm
                 weight       : 258 lb ( 117 kg )
                 Displacement : 361 cu in ( 5,916 cc )
                 Compression  : 8.5:1
  -->
  <propeller x="3.000" y="0" z="0.046"
             mass          = "258"
             radius        = "0.83"
             moment        = "1.5"
             cruise-speed  = "150"
             cruise-rpm    = "2600"
             cruise-alt    = "16400"
             cruise-power  = "160"
             takeoff-power = "180"
             takeoff-rpm   = "2700">
             <actionpt x="3.76844" y="0" z="0.003092"  />
             <piston-engine eng-rpm      = "2700"
                            alt          = "0"
                            eng-power    = "180"
                            displacement = "361"
                            compression  = "8.5">
                            <control-input control="THROTTLE" axis="/controls/engines/engine[0]/throttle"/>
                            <control-input control="STARTER"  axis="/controls/engines/engine[0]/starter"/>
                            <control-input control="MAGNETOS" axis="/controls/engines/engine[0]/magnetos"/>
                            <control-input control="MIXTURE"  axis="/controls/engines/engine[0]/mixture"/>
             </piston-engine>
  </propeller>

  <gear x="3.033" y="0.073" z="-0.988"
        compression = "0.1"
        spring      = "2"
        stiction    = "1">
        <control-input control="STEER"     axis="/controls/flight/rudder" src0="-1.0" src1="1.0" dst0="-0.7" dst1="0.7"/>
        <control-input control="CASTERING" axis="/controls/gear/tailwheel-lock"/>
   </gear>
   <!-- src0="-1" src1="1" dst0="-0.8" dst1="0.8" -->


  <gear x="1.257" y=" 1.446" z="-0.901"
        compression ="0.12"
        spring      ="2"
        stiction    ="1">
        <control-input control="BRAKE" axis="/controls/gear/brake-left"/>
        <control-input control="BRAKE" axis="/controls/gear/brake-parking"/>
        <control-input control="STEER" axis="/sim/gears/toe-left"/>
  </gear>

  <gear x="1.257" y="-1.446" z="-0.901"
        compression = "0.12"
        spring      = "2"
        stiction    = "1">
        <control-input control="BRAKE" axis="/controls/gear/brake-right"/>
        <control-input control="BRAKE" axis="/controls/gear/brake-parking"/>
        <control-input control="STEER" axis="/sim/gears/toe-right"/>
  </gear>

  <!-- Fuel  -->
  <tank x="1.52" y=" 1.323" z="-0.272" capacity="169" />
  <tank x="1.52" y="-1.323" z="-0.272" capacity="169" />

  <!-- Mass distribution
       Dilbert : The cg should be about 1/6 chord ahead of the chord center.
                 1.371 / 6     = 0.228
                 1.098 + 0.199 = 1.326
  -->
  <!-- <ballast x="3.3" y="0" z="-0.03" mass="237"/> -->
  <ballast x="3.3" y="0" z="-0.03" mass="350"/>

</airplane>
