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

<!-- Piaggio P166   : BARANGER Emmanuel    2016
            Updated : BARANGER Emmanuel 03/2020
            Updated : BARANGER Emmanuel 03/2023
            Updated : BARANGER Emmanuel 01/2026

          Sources   : https://en.wikipedia.org/wiki/Piaggio_P.166

     Wingspan       :   16.4 m   (   48 ft 2 in )
     Length         :   11.8 m   (   39 ft 0 in )
     Height         :    5.0 m   (   16 ft 5 in )
     Moteurs        : 2 x Lycoming LTP 101-700 turboprops (1200 hp each)
     Empty weight   :   5842 lb  ( 2650 kg      ) equipped
     Max weight     :   9480 lb  ( 4300 kg      )
     Max speed      : 215,98 kt  ( 400 km/h ) at sea level
     Cruise speed   : 160.00 kt  ( 300 km/h ) at 3660 m ( 12008 ft )
-->
<airplane mass="5842" version="YASIM_VERSION_CURRENT" mtow-lbs="9480">

  <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[1]/throttle"        value="0.2"/>

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

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

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

  <cruise            speed="160" alt="12000"                            fuel="0.8">
    <control-setting axis="/controls/engines/engine[0]/throttle"        value="0.8"/>
    <control-setting axis="/controls/engines/engine[1]/throttle"        value="0.8"/>

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

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

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

  <cockpit x="2.930" y="0.300" z="-0.577"/>

  <!-- Fuselage -->
  <fuselage ax=" 5.860" ay=" 0.000" az="-1.361" bx=" 5.595" by=" 0.000" bz="-1.345" width="0.566" taper="0.20" midpoint="1"/>
  <fuselage ax=" 5.595" ay=" 0.000" az="-1.345" bx=" 5.184" by=" 0.000" bz="-1.345" width="0.861" taper="0.66" midpoint="1"/>
  <fuselage ax=" 5.184" ay=" 0.000" az="-1.345" bx=" 4.418" by=" 0.000" bz="-1.328" width="1.234" taper="0.70" midpoint="1"/>

  <fuselage ax=" 4.429" ay=" 0.000" az="-1.332" bx=" 2.741" by=" 0.000" bz="-1.227" width="1.584" taper="0.76" midpoint="1"/>
  <fuselage ax=" 2.741" ay=" 0.000" az="-1.227" bx="-0.155" by=" 0.000" bz="-1.227" width="1.584" taper="1.00" midpoint="1"/>
  <fuselage ax="-0.155" ay=" 0.000" az="-1.227" bx="-5.764" by=" 0.000" bz="-0.553" width="1.584" taper="0.05" midpoint="0"/>

  <!-- Up part -->
  <fuselage ax=" 4.314" ay=" 0.000" az="-1.305" bx=" 2.691" by=" 0.000" bz="-0.828" width="1.584" taper="0.75" midpoint="1"/>
  <fuselage ax=" 2.921" ay=" 0.000" az="-0.833" bx="-0.155" by=" 0.000" bz="-0.833" width="1.584" taper="1.00" midpoint="1"/>
  <fuselage ax="-0.121" ay=" 0.000" az="-0.823" bx="-5.760" by=" 0.000" bz="-0.487" width="1.584" taper="0.05" midpoint="0"/>

  <!-- Engine left -->
  <fuselage ax=" 0.925" ay=" 1.900" az="-0.156" bx=" 0.887" by=" 1.900" bz="-0.156" width="0.360" taper="0.80" midpoint="1"/>
  <fuselage ax=" 0.887" ay=" 1.900" az="-0.156" bx=" 0.660" by=" 1.900" bz="-0.156" width="0.570" taper="0.62" midpoint="1"/>
  <fuselage ax=" 0.660" ay=" 1.900" az="-0.156" bx=" 0.135" by=" 1.900" bz="-0.156" width="0.744" taper="0.77" midpoint="1"/>
  <fuselage ax=" 0.135" ay=" 1.900" az="-0.156" bx="-0.137" by=" 1.900" bz="-0.156" width="0.799" taper="0.93" midpoint="1"/>
  <fuselage ax="-0.137" ay=" 1.900" az="-0.156" bx="-0.735" by=" 1.900" bz="-0.156" width="0.799" taper="0.88" midpoint="0"/>
  <fuselage ax="-0.735" ay=" 1.900" az="-0.156" bx="-1.091" by=" 1.900" bz="-0.156" width="0.703" taper="0.80" midpoint="0"/>
  <fuselage ax="-1.091" ay=" 1.900" az="-0.156" bx="-1.360" by=" 1.900" bz="-0.156" width="0.562" taper="0.72" midpoint="0"/>
  <fuselage ax="-1.360" ay=" 1.900" az="-0.156" bx="-1.642" by=" 1.900" bz="-0.156" width="0.407" taper="0.36" midpoint="0"/>

  <!-- Engine right -->
  <fuselage ax=" 0.925" ay="-1.900" az="-0.156" bx=" 0.887" by="-1.900" bz="-0.156" width="0.360" taper="0.80" midpoint="1"/>
  <fuselage ax=" 0.887" ay="-1.900" az="-0.156" bx=" 0.660" by="-1.900" bz="-0.156" width="0.570" taper="0.62" midpoint="1"/>
  <fuselage ax=" 0.660" ay="-1.900" az="-0.156" bx=" 0.135" by="-1.900" bz="-0.156" width="0.744" taper="0.77" midpoint="1"/>
  <fuselage ax=" 0.135" ay="-1.900" az="-0.156" bx="-0.137" by="-1.900" bz="-0.156" width="0.799" taper="0.93" midpoint="1"/>
  <fuselage ax="-0.137" ay="-1.900" az="-0.156" bx="-0.735" by="-1.900" bz="-0.156" width="0.799" taper="0.88" midpoint="0"/>
  <fuselage ax="-0.735" ay="-1.900" az="-0.156" bx="-1.091" by="-1.900" bz="-0.156" width="0.703" taper="0.80" midpoint="0"/>
  <fuselage ax="-1.091" ay="-1.900" az="-0.156" bx="-1.360" by="-1.900" bz="-0.156" width="0.562" taper="0.72" midpoint="0"/>
  <fuselage ax="-1.360" ay="-1.900" az="-0.156" bx="-1.642" by="-1.900" bz="-0.156" width="0.407" taper="0.36" midpoint="0"/>

  <wing x="0.551" y="0.000" z="-0.927"
        chord    = "2.552"
        length   = "2.01"
        dihedral = "19"
        taper    = "0.83"
        sweep    = "5"
        camber   = "0.005">
        <stall   aoa="20" width="1"    peak="1.5"/>
        <flap0 start="0.4"  end="0.78" lift="1.3" drag="1.4"/>

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

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

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

  <wing x="0.374" y="1.894" z="-0.258"
        append   = "1"
        chord    = "2.099"
        length   = "4.942"
        dihedral = "1"
        taper    = "0.6"
        sweep    = "4"
        camber   = "0.005">
        <stall   aoa="20" width="1"    peak="1.5"/>
        <flap0 start="0.10" end="0.48" lift="1.3" drag="1.4"/>
        <flap1 start="0.48" end="0.95" lift="1.2" drag="1.2"/>

        <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" 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>

  <hstab x="-4.772" y="0.000" z="0.144"
         chord  = "1.530"
         length = "2.54"
         taper  = "0.6"
         sweep  = "2">
         <stall   aoa="20" width="1" peak="1.5"/>
         <flap0 start="0.1"  end="1" lift="1.4" drag="1.2"/>

         <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="-4.714" y="0.000" z="-0.348"
         chord  = "2.052"
         length = "2.8"
         taper  = "0.44"
         sweep  = "15">
         <stall   aoa="16" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.2" drag="1.2"/>

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

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

  <!-- Moteurs       : Lycoming LTS101

        Source       : https://en.wikipedia.org/wiki/Lycoming_LTS101

        type         : Turboshaft
        weight       : 241 lb (109 kg)
        Compression  : 8.4:1
  -->
  <propeller x="-0.354" y="1.917" z="-0.125"
             mass          = "241"
             moment        = "2.5"
             radius        = "1.25"
             cruise-speed  = "160"
             cruise-rpm    = "2500"
             cruise-power  = "950"
             cruise-alt    = "12000"
             takeoff-power = "1200"
             takeoff-rpm   = "2700">
             <actionpt x="-1.320" y="1.901" z="-0.134"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[0]/propeller-pitch"/>
             <turbine-engine eng-power   = "1200"
                             eng-rpm     = "2700"
                             flat-rating = "1200"
                             alt         = "12000"
                             compression = "8.4">
                             <control-input control="THROTTLE"  axis="/controls/engines/engine[0]/throttle"/>
                             <control-input control="CONDLEVER" axis="/controls/engines/engine[0]/condition"/>
             </turbine-engine>
  </propeller>

  <propeller x="-0.354" y="-1.917" z="-0.125"
             mass          = "241"
             moment        = "2.5"
             radius        = "1.25"
             cruise-speed  = "160"
             cruise-rpm    = "2500"
             cruise-power  = "950"
             cruise-alt    = "12000"
             takeoff-power = "1200"
             takeoff-rpm   = "2700">
             <actionpt x="-1.320" y="-1.901" z="-0.134"/>
             <control-input control="ADVANCE" axis="/controls/engines/engine[1]/propeller-pitch"/>
             <turbine-engine eng-power   = "1200"
                             eng-rpm     = "2700"
                             flat-rating = "1200"
                             alt         = "12000"
                             compression = "8.4">
                             <control-input control="THROTTLE"  axis="/controls/engines/engine[1]/throttle"/>
                             <control-input control="CONDLEVER" axis="/controls/engines/engine[1]/condition"/>
             </turbine-engine>
  </propeller>

  <!-- Noze wheel -->
  <gear x="4.819" y=" 0.000" z="-2.485"
        compression ="0.2"
        spring      ="4"
        damp        ="1.5"
        stiction    ="1">
        <control-input  control="STEER"  axis="/controls/flight/rudder" src0="-1.0" src1="1.0" dst0="-0.8" dst1="0.8"/>
        <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="5"/>
  </gear>

  <!-- Left wheel -->
  <gear x="0.247" y=" 1.368" z="-2.425"
        compression = "0.2"
        spring      = "4"
        damp        = "1.5"
        stiction    = "1">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-left"/>
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking"/>
        <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="5"/>
  </gear>

  <!-- Right wheel -->
  <gear x="0.247" y="-1.368" z="-2.425"
        compression = "0.2"
        spring      = "4"
        damp        = "1.5"
        stiction    = "1">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-right"/>
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking"/>
        <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="3.5"/>
  </gear>

  <!-- 809.865 lbs = 135 gals -->
  <tank x="1.030" y=" 2.500" z="-0.200" capacity="809.865"/>
  <tank x="1.030" y="-2.500" z="-0.200" capacity="809.865"/>

  <!-- Mass distribution
       Dilbert : The cg should be about 1/6 chord ahead of the chord center.
                 2.552 / 6     = 0.425
                 0.551 + 0.425 = 0.976
  -->
  <ballast x="4.000" y="0.000" z="-2.000" mass="1826"/>

</airplane>
