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

<!-- Savoia Marchetti SM.79 : Emmanuel BARANGER 09/2024

     Source        : https://www.wikiwand.com/en/articles/Savoia-Marchetti_SM.79_Sparviero

     Wingspan      :    20.2 m      ( 66 ft 3 in )
     Length        :    16.2 m      ( 53 ft 2 in )
     Height        :     4.1 m      ( 13 ft 5 in )
     Empty weight  :    7700 kg     (   16976 lb )
     Gross weight  :   10050 kg     (   22156 lb )
     Engine        : 3 Alfa 128 R.C.18 9-cylinder air-cooled radial piston engines ( 861 hp ) each
     Maximum speed :   460 km/h     (   250 kn   ) at 3790 m ( 12430 ft )
     Fuel capacity :   231 US gal   (   874 l    )
-->
<airplane mass="16976" version="YASIM_VERSION_CURRENT" mtow-lbs="22156">

  <approach speed="80" aoa="2" fuel="0.3">
    <control-setting axis="/controls/engines/engine[0]/throttle"        value="0.4"/>
    <control-setting axis="/controls/engines/engine[0]/mixture"         value="1"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="0.5"/>

    <control-setting axis="/controls/engines/engine[1]/throttle"        value="0.4"/>
    <control-setting axis="/controls/engines/engine[1]/mixture"         value="1"/>
    <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="0.5"/>

    <control-setting axis="/controls/engines/engine[2]/throttle"        value="0.4"/>
    <control-setting axis="/controls/engines/engine[2]/mixture"         value="1"/>
    <control-setting axis="/controls/engines/engine[2]/propeller-pitch" value="0.5"/>

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

  <cruise speed="220" alt="3000" fuel="0.8">
    <control-setting axis="/controls/engines/engine[0]/throttle"        value="0.7"/>
    <control-setting axis="/controls/engines/engine[0]/mixture"         value="0.7"/>
    <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="1"/>

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

    <control-setting axis="/controls/engines/engine[2]/throttle"        value="0.7"/>
    <control-setting axis="/controls/engines/engine[2]/mixture"         value="0.7"/>
    <control-setting axis="/controls/engines/engine[2]/propeller-pitch" value="1"/>

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

  <cockpit x="3.653" y="0.304" z="1.344"/>

  <!-- Cockpit -->
  <fuselage ax=" 4.975" ay=" 0.000" az=" 0.812" bx=" 4.275" by=" 0.000" bz=" 1.093" width="0.748" taper="0.20" midpoint="1"/>
  <fuselage ax=" 4.275" ay=" 0.000" az=" 1.093" bx=" 3.319" by=" 0.000" bz=" 1.382" width="1.079" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.417" ay=" 0.000" az=" 1.379" bx=" 2.803" by=" 0.000" bz=" 1.379" width="1.079" taper="1.00" midpoint="1"/>
  <fuselage ax=" 2.803" ay=" 0.000" az=" 1.379" bx=" 0.855" by=" 0.000" bz=" 1.295" width="1.079" taper="0.30" midpoint="0"/>

  <!-- Fuselage -->
  <fuselage ax=" 7.566" ay=" 0.000" az=" 0.115" bx=" 7.364" by=" 0.000" bz=" 0.115" width="1.444" taper="0.70" midpoint="1"/>
  <fuselage ax=" 7.364" ay=" 0.000" az=" 0.115" bx=" 6.390" by=" 0.000" bz=" 0.115" width="1.444" taper="1.00" midpoint="1"/>
  <fuselage ax=" 6.393" ay=" 0.000" az=" 0.115" bx=" 4.958" by=" 0.000" bz=" 0.115" width="1.542" taper="0.79" midpoint="1"/>
  <fuselage ax=" 4.958" ay=" 0.000" az=" 0.115" bx=" 1.903" by=" 0.000" bz=" 0.115" width="1.542" taper="1.00" midpoint="1"/>

  <fuselage ax=" 1.911" ay=" 0.000" az=" 0.109" bx="-0.909" by=" 0.000" bz=" 0.110" width="1.542" taper="0.80" midpoint="0"/>
  <fuselage ax="-0.921" ay=" 0.000" az=" 0.115" bx="-7.383" by=" 0.000" bz=" 0.331" width="1.233" taper="0.48" midpoint="0"/>

  <!-- Up Fuselage -->
  <fuselage ax=" 3.620" ay=" 0.000" az=" 0.805" bx=" 1.903" by=" 0.000" bz=" 0.805" width="1.542" taper="1.00" midpoint="1"/>
  <fuselage ax=" 1.911" ay=" 0.000" az=" 0.799" bx="-0.924" by=" 0.000" bz=" 0.873" width="1.542" taper="0.80" midpoint="0"/>
  <fuselage ax="-0.921" ay=" 0.000" az=" 0.876" bx="-7.383" by=" 0.000" bz=" 0.782" width="1.233" taper="0.48" midpoint="0"/>

  <!-- Left engine -->
  <fuselage ax=" 5.856" ay=" 2.559" az="-0.409" bx=" 5.655" by=" 2.559" bz="-0.423" width="1.444" taper="0.70" midpoint="1"/>
  <fuselage ax=" 5.655" ay=" 2.559" az="-0.423" bx=" 4.683" by=" 2.559" bz="-0.491" width="1.444" taper="1.00" midpoint="1"/>
  <fuselage ax=" 4.683" ay=" 2.559" az="-0.491" bx=" 3.215" by=" 2.559" bz="-0.638" width="1.444" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.215" ay=" 2.559" az="-0.638" bx=" 0.495" by=" 2.559" bz="-0.638" width="1.444" taper="0.10" midpoint="0"/>

  <!-- Right engine -->
  <fuselage ax=" 5.856" ay="-2.559" az="-0.409" bx=" 5.655" by="-2.559" bz="-0.423" width="1.444" taper="0.70" midpoint="1"/>
  <fuselage ax=" 5.655" ay="-2.559" az="-0.423" bx=" 4.683" by="-2.559" bz="-0.491" width="1.444" taper="1.00" midpoint="1"/>
  <fuselage ax=" 4.683" ay="-2.559" az="-0.491" bx=" 3.215" by="-2.559" bz="-0.638" width="1.444" taper="0.70" midpoint="1"/>
  <fuselage ax=" 3.215" ay="-2.559" az="-0.638" bx=" 0.495" by="-2.559" bz="-0.638" width="1.444" taper="0.10" midpoint="0"/>

  <wing x="2.777" y="0.000" z="-0.254"
        chord    = "4.262"
        length   = "10.110"
        taper    = "0.4"
        dihedral = "2"
        sweep    = "-3"
        camber   = "0.04">
        <stall   aoa="20" width="1"    peak="1.5"/>
        <slat  start="0.33" end="0.89"  aoa="20"  drag="2"/>
        <flap0 start="0.31" end="0.57" lift="1.4" drag="2.2"/>
        <flap1 start="0.57" end="0.94" lift="1.2" drag="1.2"/>

        <control-input  control="SLAT"  axis="/controls/flight/flaps"/>
        <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="SLAT"  prop="/surface-positions/slat-pos-norm"/>
        <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="SLAT"  transition-time="5"/>
        <control-speed  control="FLAP0" transition-time="5"/>
  </wing>

  <hstab x="-6.090" y="0.000" z="1.026"
         chord  = "2.274"
         length = "2.860"
         sweep  = "12"
         taper  = "0.50">
         <stall   aoa="18" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.2" 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="-6.539" y="0.000" z="0.026"
         chord  = "2.998"
         length = "2.662"
         taper  = "0.50"
         sweep  = "17">
         <stall   aoa="16" width="1" peak="1.5"/>
         <flap0 start="0"    end="1" lift="1.4" 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>

  <!-- Engines      : Alfa Romeo 128

       Informations : https://www.wikiwand.com/en/articles/Alfa_Romeo_125

       Type         : 9-cylinder air-cooled radial engine
       Power        : 950 hp at 2300 rpm
       Displacement : 28.6 L ( 1745.28 cu in )
       Compression  : 7.1:1
       Diameter     :   51.38 in  (  1305 mm )
       Dry weight   :     516 kg  (  1138 lb )
  -->
  <!-- Left engine -->
  <propeller x="5.465" y="2.559" z="-0.461"
             mass          = "1138"
             moment        = "15"
             radius        = "1.678"
             cruise-speed  = "220"
             cruise-power  = "900"
             cruise-rpm    = "2000"
             cruise-alt    = "3000"
             takeoff-power = "220"
             takeoff-rpm   = "2000">
             <actionpt x="6.018" y="2.559" z="-0.508"/>
             <dir x="0.997" y="0.000" z="0.096"/>
             <piston-engine eng-power    = "950"
                            eng-rpm      = "2300"
                            displacement = "1745.28"
                            compression  = "7.1">
                            <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>

  <!-- Right engine -->
  <propeller x="5.465" y="-2.559" z="-0.461"
             mass          = "1138"
             moment        = "15"
             radius        = "1.678"
             cruise-speed  = "220"
             cruise-power  = "900"
             cruise-rpm    = "2000"
             cruise-alt    = "3000"
             takeoff-power = "220"
             takeoff-rpm   = "2000">
             <actionpt x="6.018" y="-2.559" z="-0.508"/>
             <dir x="0.997" y="0.000" z="0.096"/>
             <piston-engine eng-power    = "950"
                            eng-rpm      = "2300"
                            displacement = "1745.28"
                            compression  = "7.1">
                            <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>

  <!-- Center engine -->
  <propeller x="7.217" y="0" z="0.123"
             mass          = "1138"
             moment        = "15"
             radius        = "1.678"
             cruise-speed  = "220"
             cruise-power  = "900"
             cruise-rpm    = "2000"
             cruise-alt    = "3000"
             takeoff-power = "220"
             takeoff-rpm   = "2000">
             <actionpt x="7.771" y="0" z="0.123"/>
             <piston-engine eng-power    = "950"
                            eng-rpm      = "2300"
                            displacement = "1745.28"
                            compression  = "7.1">
                            <control-input control="THROTTLE" axis="/controls/engines/engine[2]/throttle"/>
                            <control-input control="STARTER"  axis="/controls/engines/engine[2]/starter"/>
                            <control-input control="MAGNETOS" axis="/controls/engines/engine[2]/magnetos"/>
                            <control-input control="MIXTURE"  axis="/controls/engines/engine[2]/mixture"/>
            </piston-engine>
  </propeller>

  <!-- Left wheel  -->
  <gear x="4.192" y="2.537" z="-2.598"
        compression = "0.3"
        spring      = "0.85"
        damp        = "1.4"
        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[0]/position-norm"/>

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

  <!-- Right wheel -->
  <gear x="4.192" y="-2.537" z="-2.598"
        compression = "0.3"
        spring      = "0.85"
        damp        = "1.4"
        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="5.2"/>
  </gear>

  <!-- Tail wheel -->
  <gear x="-7.083" y="0.000" z="-0.307"
        compression = "0.1"
        spring      = "0.8"
        damp        = "2"
        stiction    = "1">
        <control-input control="STEER" axis="/controls/flight/rudder" square="true" src0="-1.0" src1="1.0" dst0="0.8" dst1="-0.8"/>
  </gear>

  <!-- Fuel -->
  <!-- From 562 to 830 -->
  <tank x="3.200" y=" 4.000" z="-0.124" capacity="830"/>
  <tank x="1.900" y=" 0.000" z=" 0.000" capacity="830"/>
  <tank x="3.200" y="-4.000" z="-0.124" capacity="830"/>

  <!-- Mass distribution
       Dilbert : The cg should be about 1/6 chord ahead of the chord center.
                 4.262 / 6     = 0.710
                 2.777 + 0.710 = 3.487
  -->
  <ballast x="7.000" y="0.000" z="-0.4000" mass="3442"/>

</airplane>
