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

<!-- Piper Pa 23 Apache : Emmanuel BARANGER - 05/2023

  source                : https://www.wikiwand.com/en/Piper%20PA-23

  Wingspan              : 37 ft 2 1⁄2 in ( 11.341 m  )
  lenght                : 31 ft 2 3⁄4 in (  9.519 m  )
  height                : 10 ft 4     in (  3.15  m  )
  Empty mass            : 3180 lb        (   1442 kg )
  Max takeoff weight    : 5200 lb        (   2359 kg )
  Engine                : 2 Lycoming IO-540-C4B5 normally aspirated air-cooled flat-six piston engines, 250 hp each
  Stall speed           : 109 km/h       (     59 kn ) ( flaps down )
  Cruise speed          : 277 km/h       (    149 kn ) at 10200 ft ( 3100 m ) ( long-range cruise )
  Maximum speed         : 346 km/h       (    187 kn )
  Fuel capacity         : 140 US gal     ( 530 L     ) usable fuel (normal)
                          optional extra tanks with 40 US gal ( 150 L )
-->
<airplane mass="3180" version="YASIM_VERSION_CURRENT" mtow-lbs="5200">

  <!-- Approach configuration -->
  <approach speed="59" 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/engines/engine[1]/throttle"        value="0.2"/>
    <control-setting axis="/controls/engines/engine[1]/mixture"         value="1.0"/>
    <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="0.5"/>
    <control-setting axis="/controls/gear/gear-down"                    value="1"/>
  </approach>

  <!-- Cruise configuration -->
  <cruise speed="149" alt="10200" fuel="1">
    <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/engines/engine[1]/throttle"        value="0.75"/>
    <control-setting axis="/controls/engines/engine[1]/mixture"         value="1"/>
    <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="1"/>
    <control-setting axis="/controls/gear/gear-down"                    value="0"/>
  </cruise>

  <cockpit x="1.363" y="0.298" z="0.252"/>

  <!--Fuselage -->
  <fuselage ax=" 4.758" ay=" 0.000" az="-0.370" bx=" 4.408" by=" 0.000" bz="-0.370" width="0.584" taper="0.10" midpoint="1"/>
  <fuselage ax=" 4.408" ay=" 0.000" az="-0.370" bx=" 3.402" by=" 0.000" bz="-0.358" width="0.965" taper="0.60" midpoint="1"/>
  <fuselage ax=" 3.402" ay=" 0.000" az="-0.358" bx=" 2.109" by=" 0.000" bz="-0.358" width="1.171" taper="0.83" midpoint="1"/>
  <fuselage ax=" 2.109" ay=" 0.000" az="-0.358" bx=" 1.000" by=" 0.000" bz="-0.358" width="1.311" taper="0.89" midpoint="1"/>
  <fuselage ax=" 1.000" ay=" 0.000" az="-0.358" bx="-0.562" by=" 0.000" bz="-0.407" width="1.311" taper="0.82" midpoint="0"/>
  <fuselage ax="-0.562" ay=" 0.000" az="-0.407" bx="-2.841" by=" 0.000" bz="-0.445" width="1.065" taper="0.54" midpoint="0"/>
  <fuselage ax="-2.841" ay=" 0.000" az="-0.445" bx="-3.928" by=" 0.000" bz="-0.504" width="0.575" taper="0.50" midpoint="0"/>
  <fuselage ax="-2.841" ay=" 0.000" az="-0.445" bx="-3.928" by=" 0.000" bz="-0.295" width="0.575" taper="0.50" midpoint="0"/>
  <fuselage ax="-3.867" ay=" 0.000" az="-0.492" bx="-4.484" by=" 0.000" bz="-0.328" width="0.326" taper="0.50" midpoint="0"/>
  <fuselage ax="-3.907" ay=" 0.000" az="-0.301" bx="-4.477" by=" 0.000" bz="-0.210" width="0.326" taper="0.50" midpoint="0"/>

  <!-- Cabine -->
  <fuselage ax=" 2.524" ay=" 0.000" az="-0.101" bx=" 1.776" by=" 0.000" bz="-0.101" width="1.311" taper="0.44" midpoint="1"/>
  <fuselage ax=" 1.776" ay=" 0.000" az="-0.101" bx=" 0.984" by=" 0.000" bz="-0.101" width="1.311" taper="1.00" midpoint="1"/>
  <fuselage ax=" 0.984" ay=" 0.000" az="-0.101" bx="-2.843" by=" 0.000" bz="-0.448" width="1.311" taper="0.44" midpoint="0"/>

  <!-- Left engine -->
  <fuselage ax=" 3.243" ay=" 1.690" az="-0.542" bx=" 3.106" by=" 1.690" bz="-0.554" width="0.849" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.106" ay=" 1.690" az="-0.554" bx=" 0.516" by=" 1.690" bz="-0.790" width="0.849" taper="0.70" midpoint="0"/>

  <!-- Right engine -->
  <fuselage ax=" 3.243" ay="-1.690" az="-0.542" bx=" 3.106" by="-1.690" bz="-0.554" width="0.849" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.106" ay="-1.690" az="-0.554" bx=" 0.516" by="-1.690" bz="-0.790" width="0.849" taper="0.70" midpoint="0"/>

  <!-- Left float -->
  <fuselage ax=" 4.164" ay=" 1.156" az="-1.907" bx=" 3.500" by=" 1.156" bz="-2.025" width="0.621" taper="0.30" midpoint="1"/>
  <fuselage ax=" 3.500" ay=" 1.156" az="-2.025" bx=" 2.637" by=" 1.156" bz="-2.110" width="0.784" taper="0.80" midpoint="1"/>
  <fuselage ax=" 2.637" ay=" 1.156" az="-2.110" bx=" 0.751" by=" 1.156" bz="-2.093" width="0.784" taper="1.00" midpoint="1"/>
  <fuselage ax=" 0.751" ay=" 1.156" az="-2.093" bx="-3.080" by=" 1.156" bz="-1.860" width="0.783" taper="0.30" midpoint="0"/>

  <!-- Right float -->
  <fuselage ax=" 4.164" ay="-1.156" az="-1.907" bx=" 3.500" by="-1.156" bz="-2.025" width="0.621" taper="0.30" midpoint="1"/>
  <fuselage ax=" 3.500" ay="-1.156" az="-2.025" bx=" 2.637" by="-1.156" bz="-2.110" width="0.784" taper="0.80" midpoint="1"/>
  <fuselage ax=" 2.637" ay="-1.156" az="-2.110" bx=" 0.751" by="-1.156" bz="-2.093" width="0.784" taper="1.00" midpoint="1"/>
  <fuselage ax=" 0.751" ay="-1.156" az="-2.093" bx="-3.080" by="-1.156" bz="-1.860" width="0.783" taper="0.30" midpoint="0"/>

  <wing x="1.195" y="0" z="-0.819"
        chord    = "1.966"
        length   = "5.611"
        taper    = "0.90"
        sweep    = "1"
        dihedral = "4"
        camber   = "0.005">
        <stall   aoa="20" width="1"    peak="1.5"/>
        <flap0 start="0.11" end="0.49" lift="1.4" drag="1.5"/>
        <flap1 start="0.50" end="0.86" 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-output control="FLAP1" prop="/surface-positions/aileron-pos-norm"/>

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

  <hstab x="-4.097" y="0" z="-0.277"
         chord  = "1.326"
         length = "1.910"
         sweep  = "6"
         taper  = "0.55">
         <stall   aoa="18" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.2" drag="1.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.305" y="0" z="-0.113"
         chord  = "2.171"
         length = "1.8"
         taper  = "0.44"
         sweep  = "30">
         <stall   aoa="16" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.4" drag="1.1"/>

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

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

  <!-- Engines   source            : https://www.wikiwand.com/en/Lycoming_AEIO-540

                 name              : Lycoming O-540
                 type              : Six-cylinder air-cooled horizontally opposed engine
                 power cruise      : 300 hp at 2700 rpm at sea level
                 weight            : 438   lb    ( 199    kg )
                 displacement      : 541.5 in 3  (   8.9  L  )
                 compression       : 8.7:1
  -->
  <propeller x="2.759" y="1.690" z="-0.511"
             mass          = "438"
             radius        = "0.950"
             moment        = "9"
             min-rpm       = "900"
             cruise-speed  = "149"
             cruise-rpm    = "2700"
             cruise-alt    = "10200"
             cruise-power  = "280"
             takeoff-power = "300"
             takeoff-rpm   = "2700">
             <actionpt x="3.309" y="1.690" z="-0.511"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[0]/propeller-pitch"/>
             <piston-engine eng-rpm      = "2700"
                            eng-power    = "300"
                            displacement = "541.5"
                            compression  = "8.7">
                            <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>

  <propeller x="2.759" y="-1.690" z="-0.511"
             mass          = "438"
             radius        = "0.950"
             moment        = "9"
             min-rpm       = "900"
             cruise-speed  = "149"
             cruise-rpm    = "2700"
             cruise-alt    = "10200"
             cruise-power  = "280"
             takeoff-power = "300"
             takeoff-rpm   = "2700">
             <actionpt x="3.309" y="-1.690" z="-0.511"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[1]/propeller-pitch"/>
             <piston-engine eng-rpm      = "2700"
                            eng-power    = "300"
                            displacement = "541.5"
                            compression  = "8.7">
                            <control-input control="THROTTLE" axis="/controls/engines/engine[1]/throttle"/>
                            <control-input control="STARTER"  axis="/controls/engines/engine[1]/starter"/>
                            <control-input control="MAGNETOS" axis="/controls/engines/engine[1]/magnetos"/>
                            <control-input control="MIXTURE"  axis="/controls/engines/engine[1]/mixture"/>
             </piston-engine>
  </propeller>

  <!-- Retractable wheels 0/1/2/3 -->
  <gear x="4.504" y="1.156" z="-2.780"
        compression  = "0.2"
        spring       = "2"
        damp         = "1"
        stiction     = "1">
        <control-input  control="STEER"  axis="/controls/flight/rudder" square="true"/>
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

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

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

  <gear x="0.507" y="1.464" z="-2.725"
        compression  = "0.2"
        spring       = "2"
        damp         = "1"
        stiction     = "1">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking" />
        <control-input  control="BRAKE"  axis="/controls/gear/brake-left" />
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

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

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

  <gear x="4.504" y="-1.156" z="-2.780"
        compression  = "0.2"
        spring       = "2"
        damp         = "1"
        stiction     = "1">
        <control-input  control="STEER"  axis="/controls/flight/rudder" square="true"/>
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

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

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

  <gear x="0.507" y="-1.464" z="-2.725"
        compression  = "0.2"
        spring       = "2"
        damp         = "1"
        stiction     = "1">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking" />
        <control-input  control="BRAKE"  axis="/controls/gear/brake-right" />
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

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

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

  <!-- Flotteurs -->
  <!-- Avant 4/5 -->
  <gear x="3.599" y="1.167" z="-2.338"
        compression                  = "1.2"
        spring                       = "15"
        sfric                        = "0.8"
        dfric                        = "0.7"
        ignored-by-solver            = "0"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "1.15"
        speed-planing                = "15"
        spring-factor-not-planing    = "0.7">
  </gear>

  <gear x="3.599" y="-1.167" z="-2.338"
        compression                  = "1.2"
        spring                       = "15"
        sfric                        = "0.8"
        dfric                        = "0.7"
        ignored-by-solver            = "0"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "1.15"
        speed-planing                = "15"
        spring-factor-not-planing    = "0.7">
  </gear>

  <!-- Central 6/7 -->
  <gear x="0.862" y="1.167" z="-2.445"
        compression                  = "1.5"
        spring                       = "15"
        sfric                        = "0.85"
        dfric                        = "0.75"
        ignored-by-solver            = "0"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "1.15"
        speed-planing                = "25"
        spring-factor-not-planing    = "0.25">
  </gear>

  <gear x="0.862" y="-1.167" z="-2.445"
        compression                  = "1.5"
        spring                       = "15"
        sfric                        = "0.85"
        dfric                        = "0.75"
        ignored-by-solver            = "0"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "1.15"
        speed-planing                = "25"
        spring-factor-not-planing    = "0.25">
  </gear>

  <!-- Arriere 8/9 -->
  <gear x="-2.749" y="1.167" z="-1.965"
        compression                  = "1.8"
        spring                       = "8"
        sfric                        = "0.9"
        dfric                        = "0.8"
        ignored-by-solver            = "1"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "0.9"
        speed-planing                = "25"
        spring-factor-not-planing    = "0.9">
  </gear>

  <gear x="-2.749" y="-1.167" z="-1.965"
        compression                  = "1.8"
        spring                       = "8"
        sfric                        = "0.9"
        dfric                        = "0.8"
        ignored-by-solver            = "1"
        on-water                     = "1"
        on-solid                     = "1"
        reduce-friction-by-extension = "0.9"
        speed-planing                = "25"
        spring-factor-not-planing    = "0.9">
  </gear>

  <!-- 2 more Floats, need to be at this position in the file to do not brake the animation
       "reduce-friction-by-extension" is reduced to get steering control 10/11-->
  <gear x="-3.380" y="1.167" z="-2.106"
        compression                  = "1.8"
        spring                       = "8"
        sfric                        = "0.9"
        dfric                        = "0.8"
        ignored-by-solver            = "1"
        on-water                     = "1"
        on-solid                     = "0"
        reduce-friction-by-extension = "0.7"
        speed-planing                = "25"
        spring-factor-not-planing    = "3">
        <control-input control="STEER" axis="/controls/gear/water-rudder-pos" invert ="true" square="true"/>
  </gear>

  <gear x="-3.380" y="-1.167" z="-2.106"
        compression                  = "1.8"
        spring                       = "8"
        sfric                        = "0.9"
        dfric                        = "0.8"
        ignored-by-solver            = "1"
        on-water                     = "1"
        on-solid                     = "0"
        reduce-friction-by-extension = "0.7"
        speed-planing                = "25"
        spring-factor-not-planing    = "3">
        <control-input control="STEER" axis="/controls/gear/water-rudder-pos" invert ="true" square="true"/>
  </gear>

  <!-- Wing tank -->
  <tank x="1.400" y=" 2.223" z="-0.710" capacity="250"/>
  <tank x="1.400" y="-2.223" z="-0.710" capacity="250"/>

    <!-- Mass distribution
         Dilbert : The cg should be about 1/6 chord ahead of the chord center.
         1.966 / 6     = 0.327
         1.195 + 0.327 = 1.522
    -->
  <ballast x="4.240" y="0.000" z="-0.510" mass="443"/>

</airplane>
