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

<!-- Lockheed P 38        : BARANGER Emmanuel (2010) 

     Sources              : http://en.wikipedia.org/wiki/Lockheed_P-38_Lightning

     Envergure            :    52 ft 00 in   ( 15.85 m  )
     Longueur             :    37 ft 10 in   ( 11.53 m  )
     Hauteur              :    12 ft 10 in   (  3.91 m  )
     Masse a vide         : 12800 lb         (  5800 kg )
     Moteur               : 2 Allison V-1710-111/113 V-12 piston engine ( 1725 hp each)
     Vitesse max          : 712 km/h (385 kt) at 28000 ft (8530 m)
-->

<airplane mass="12800">

    <approach speed="60" aoa="3" fuel="0.3">
      <control-setting axis="/controls/engines/engine[0]/throttle" value="0.5"/>
      <control-setting axis="/controls/engines/engine[1]/throttle" value="0.5"/>

      <control-setting axis="/controls/engines/engine[0]/boost" value="0"/>
      <control-setting axis="/controls/engines/engine[1]/boost" value="0"/>

      <control-setting axis="/controls/engines/engine[0]/mixture" value="1"/>
      <control-setting axis="/controls/engines/engine[1]/mixture" value="1"/>

      <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="0.77"/>
      <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="0.77"/>

      <control-setting axis="/controls/flight/flaps" value="1"/>
      <control-setting axis="/controls/gear/gear-down" value="1"/>
    </approach>

    <cruise speed="350" alt="15000" fuel="0.7">
      <control-setting axis="/controls/engines/engine[0]/throttle" value="0.7"/>
      <control-setting axis="/controls/engines/engine[1]/throttle" value="0.7"/>

      <control-setting axis="/controls/engines/engine[0]/boost" value="1"/>
      <control-setting axis="/controls/engines/engine[1]/boost" value="1"/>

      <control-setting axis="/controls/engines/engine[0]/mixture" value="0.4"/>
      <control-setting axis="/controls/engines/engine[1]/mixture" value="0.4"/>

      <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="1"/>
      <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="1"/>

      <control-setting axis="/controls/flight/flaps" value="0"/>
      <control-setting axis="/controls/gear/gear-down" value="0"/>
    </cruise>

    <cockpit x="2.277" y="0" z="0.444"/>

    <!-- Fuselage -->
    <fuselage ax="5.752" ay=" 0.000" az="-0.124" bx="-0.233" by=" 0.000" bz="0.040" width="1.13" taper="0.5" midpoint="0.40"/>

    <!-- Engine left -->
    <fuselage ax="4.057" ay=" 2.404" az="-0.010" bx="-4.376" by=" 2.404" bz="0.651" width="1.00" taper="0.3" midpoint="0.02"/>

    <!-- Engine right -->
    <fuselage ax="4.057" ay="-2.404" az="-0.010" bx="-4.376" by="-2.404" bz="0.651" width="1.00" taper="0.3" midpoint="0.02"/>

    <!-- Wing -->
    <wing x="1.260" y="0.354" z="0.090"
          chord="2.880"
          length="7.6"
          taper="0.30"
          dihedral="5"
          sweep="-2"
          camber="0.002">
          <stall aoa="10" width="4" peak="3.0"/>
          <flap0 start="0.023" end="0.550" lift="1.2" drag="2.2"/>
          <flap1 start="0.550" end="0.930" lift="1.3" drag="1.2"/>

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

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

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

    <!-- Elevator -->
    <hstab x="-4.888" y="0" z="0.613"
           chord="1.117"
           length="3.277"
           taper="1">
           <stall aoa="15" width="1" peak="1.3"/>
           <flap0 start="0" end="0.85" lift="1.2" drag="1.3"/>

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

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

    <!-- Ruder -->
    <vstab x="-5.048" y="2.404" z="-0.052"
           chord="1.435"
           length="2.016"
           taper="1">
           <stall aoa="15" width="2" peak="2.5"/>
           <flap0 start="0" end="1" lift="1.3" drag="1.5"/>

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

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

    <vstab x="-5.048" y="-2.404" z="-0.052"
           chord="1.435"
           length="2.016"
           taper="1">
           <stall aoa="15" width="2" peak="2.5"/>
           <flap0 start="0" end="1" lift="1.3" drag="1.5"/>

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

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

  <!-- Engines   source            : http://en.wikipedia.org/wiki/Allison_V-1710
                                   : P51d in FG

                 name              : Allison V-1710
                 type              : 12-cylinder supercharged liquid-cooled 60 deg "Vee" piston aircraft engine
                 power cruise      : 1725 hp at 2700 rpm
                 weight            : 1395 lb  ( 633.5 kg )
                 compression       : 6.65:1
                 Displacement      : 1710 in3 ( 28 L)
  -->
    <!-- Engine left interior-->
    <propeller x="3.455" y="2.404" z="0.129"
               mass="1395"
               radius="1.8"
               moment="-94.5"
               cruise-alt="2000"
               cruise-power="1480"
               cruise-speed="350"
               cruise-rpm="2593"
               min-rpm="250"
               max-rpm="3000"
               gear-ratio="0.479"
               contra="1">
               <actionpt x="4.189" y="2.404" z="0.129"/>
               <control-input axis="/controls/engines/engine[0]/propeller-pitch" control="ADVANCE"/>
               <piston-engine eng-power="1725"
                              eng-rpm="3000"
                              turbo-mul="5.75"
                              wastegate-mp="85"
                              turbo-lag="0.1"
                              displacement="1710"
                              compression="6.65">
                              <control-input axis="/controls/engines/engine[0]/throttle" control="THROTTLE"/>
                              <control-input axis="/controls/engines/engine[0]/starter" control="STARTER"/>
                              <control-input axis="/controls/engines/engine[0]/magnetos" control="MAGNETOS"/>
                              <control-input axis="/controls/engines/engine[0]/mixture" control="MIXTURE"/>
                              <control-input axis="/controls/engines/engine[0]/boost" control="BOOST"/>
               </piston-engine>
    </propeller>

    <!-- Engine right interior-->
    <propeller x="3.455" y="-2.404" z="0.129"
               mass="1395"
               radius="1.8"
               moment="94.5"
               cruise-alt="2000"
               cruise-power="1480"
               cruise-speed="350"
               cruise-rpm="2593"
               min-rpm="250"
               max-rpm="3000"
               gear-ratio="0.479"
               contra="1">
               <actionpt x="4.189" y="-2.404" z="0.129"/>
               <control-input axis="/controls/engines/engine[1]/propeller-pitch" control="ADVANCE"/>
               <piston-engine eng-power="1725"
                              eng-rpm="3000"
                              turbo-mul="5.75"
                              wastegate-mp="85"
                              turbo-lag="0.1"
                              displacement="1710"
                              compression="6.65">
                              <control-input axis="/controls/engines/engine[1]/throttle" control="THROTTLE"/>
                              <control-input axis="/controls/engines/engine[1]/starter" control="STARTER"/>
                              <control-input axis="/controls/engines/engine[1]/magnetos" control="MAGNETOS"/>
                              <control-input axis="/controls/engines/engine[1]/mixture" control="MIXTURE"/>
                              <control-input axis="/controls/engines/engine[1]/boost" control="BOOST"/>
               </piston-engine>
    </propeller>

    <!-- Noze wheel -->
    <gear x="4.383" y="0" z="-1.948"
          compression="0.2"
          retract-time="5"
          spring="1.0"
          damp="1.50">
          <control-input axis="/controls/flight/rudder" control="STEER" src0="-1.0" src1="1.0" dst0="-0.2" dst1="0.2"/>
          <control-input axis="/controls/gear/gear-down" control="EXTEND"/>

          <control-output control="EXTEND" prop="/gear/gear[0]/position-norm"/>

          <control-speed control="EXTEND" transition-time="5"/>
    </gear>

    <!-- Left wheel -->
    <gear x="1.360" y="2.502" z="-1.635"
          compression="0.2"
          retract-time="5"
          spring="1"
          damp="1.5"
          sfric="1.2"
          dfric="1.2">
          <control-input axis="/controls/gear/brake-left" control="BRAKE"/>
          <control-input axis="/controls/gear/brake-parking" control="BRAKE"/>
          <control-input axis="/controls/gear/gear-down" control="EXTEND"/>

          <control-output control="EXTEND" prop="/gear/gear[1]/position-norm"/>

          <control-speed control="EXTEND" transition-time="3.5"/>
    </gear>

    <!-- Right wheel -->
    <gear x="1.360" y="-2.502" z="-1.635"
          compression="0.2"
          retract-time="5"
          spring="1"
          damp="1.5"
          sfric="1.2"
          dfric="1.2">
          <control-input axis="/controls/gear/brake-right" control="BRAKE"/>
          <control-input axis="/controls/gear/brake-parking" control="BRAKE"/>
          <control-input axis="/controls/gear/gear-down" control="EXTEND"/>

          <control-output control="EXTEND" prop="/gear/gear[2]/position-norm"/>

          <control-speed control="EXTEND" transition-time="3.5"/>
    </gear>

    <tank x="1.9" y=" 4.817" z="0.478" capacity="2000"/>
    <tank x="1.9" y="-4.817" z="0.478" capacity="2000"/>

    <!-- CG placment -->
    <ballast x="8" y="0" z="-4" mass="1000"/>
    <ballast x="-8" y="0" z="4" mass="-600"/>

</airplane>

