<?xml version="1.0"?>

<!--
************************************************************************
YASim aerodynamic model for a He-111H

************************************************************************
-->

<!-- Weight of everything but fuel   -->
<airplane mass="19136">

<!-- Approach configuration -->
<approach speed="78" aoa="9">
  <control-setting axis="/controls/engines/engine[0]/throttle" value="0.5"/>
  <control-setting axis="/controls/engines/engine[0]/mixture" value="0.65"/>
  <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="0.5"/>
  <control-setting axis="/controls/engines/engine[0]/boost" value="0.0"/>
<control-setting axis="/controls/engines/engine[1]/throttle" value="0.5"/>
  <control-setting axis="/controls/engines/engine[1]/mixture" value="0.65"/>
  <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="0.5"/>
  <control-setting axis="/controls/engines/engine[1]/boost" value="0.0"/>
  <control-setting axis="/controls/flight/flaps" value="1.0"/>
  <control-setting axis="/controls/gear/gear-down" value="1"/>
</approach>

<!-- Cruise configuration -->
<cruise speed="210" alt="17000">
  <control-setting axis="/controls/engines/engine[0]/throttle" value="1.0"/>
  <control-setting axis="/controls/engines/engine[0]/mixture" value="1.00"/>
  <control-setting axis="/controls/engines/engine[0]/propeller-pitch" value="1.0"/>
  <control-setting axis="/controls/engines/engine[0]/boost" value="1.0"/>
  <control-setting axis="/controls/engines/engine[1]/throttle" value="1.0"/>
  <control-setting axis="/controls/engines/engine[1]/mixture" value="1.00"/>
  <control-setting axis="/controls/engines/engine[1]/propeller-pitch" value="1.0"/>
  <control-setting axis="/controls/engines/engine[1]/boost" value="1.0"/>
  <control-setting axis="/controls/flight/flaps" value="0.0"/>
  <control-setting axis="/controls/gear/gear-down" value="0"/>
</cruise>

<!-- pilot's eyepoint -->
<cockpit x="6.3" y="0" z="0.5"/>

<fuselage ax="8.0" ay="0.0" az="0.0" bx="5.9" by="0.0" bz="0.0"
          width="2.0" taper="0.4" midpoint="1.0"/>
<fuselage ax="5.9" ay="0.0" az="0.0" bx="0.6" by="0.0" bz="0.0"
          width="2.0" taper="1.0" midpoint="1.0"/>
<fuselage ax="0.6" ay="0.0" az="0.0" bx="-3.0" by="0.0" bz="-0.0"
          width="2.0" taper="0.8" midpoint="0.0"/>
<fuselage ax="-3.0" ay="0.0" az="0.0" bx="-8.3" by="0.0" bz="0.1"
          width="1.6" taper="0.0" midpoint="0.0"/>


<fuselage ax="7.7" ay="-2.65" az="-0.34" bx="2.5" by="-2.65" bz="-0.34"
          width="0.9" taper="0.6" midpoint="0.3"/>

<fuselage ax="7.7" ay="2.65" az="-0.34" bx="2.5" by="2.65" bz="-0.34"
          width="0.9" taper="0.6" midpoint="0.3"/>

<!-- wing-->
<wing x="3.5" y="2.8" z="-0.4" taper="0.5" incidence="0.3"
      length="8.4" chord="4.9" sweep="4.0" dihedral="6.6" camber="0.5">
  <stall aoa="9" width="6" peak="1.5"/>
  <flap0 start="0.0" end="0.638" lift="1.4" drag="2.2"/>
  <flap1 start="0.638" end="1.0" lift="1.3" drag="1.1"/>
  <control-input axis="/controls/flight/flaps" control="FLAP0"/>
  <control-output control="FLAP0" prop="/surface-positions/flap-pos-norm"/>
  <control-speed control="FLAP0" transition-time="5"/>
  <control-speed control="FLAP1" transition-time="3"/>
  <control-input axis="/controls/flight/aileron" control="FLAP1" split="true"/>
  <control-input axis="/controls/flight/aileron-trim" control="FLAP1" split="true"/>
</wing>

<mstab x="3.53" y="0.9" z="-0.4" taper="1.02" incidence="-2.3"
      length="1.9" chord="4.8" sweep="1.0" camber="0.2">
  <stall aoa="9" width="6" peak="1.5"/>
  <flap0 start="0.0" end="0.638" lift="1.4" drag="2.2"/>
  <flap1 start="0.638" end="1.0" lift="1.3" drag="1.1"/>
  <control-input axis="/controls/flight/flaps" control="FLAP0"/>
  <control-output control="FLAP0" prop="/surface-positions/flap-pos-norm"/>
  <control-speed control="FLAP0" transition-time="5"/>

</mstab>

<hstab x="-6.5" y="0.2" z="-0.1" taper="0.6" dihedral="0.0"
       length="3.7" chord="2.8" sweep="0" >
  <stall aoa="11" width="15" peak="2.5"/>
  <flap0 start="0.0" end="1.0" lift="2.3" drag="1.1"/>
  <control-input axis="/controls/flight/elevator" control="FLAP0"/>
  <control-speed control="FLAP0" transition-time="4"/>
  <control-input axis="/controls/flight/elevator-trim" control="FLAP0"/>
  <control-output control="FLAP0" prop="/surface-positions/elevator-pos-norm"/>
</hstab>

<!-- rudder has to be able to counteract aileron drag -->
<vstab x="-6.6" y="0" z="0.25" taper="0.6" 
       length="2.5" chord="2.5" sweep="2"  incidence="0">
  <stall aoa="5" width="14" peak="2.5"/>
  <flap0 start="0" end="1" lift="1.6" drag="1.9"/>
  <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"
    min="1" max="-1"/>
</vstab>


<propeller   x="7.0" y="2.65" z="-0.34"
           radius="1.7" 
           mass="1290" moment="74.0"
           cruise-alt="17000" cruise-power="1000"
           cruise-speed="180" cruise-rpm="1420"
           gear-ratio="0.645"
           coarse-stop="5.0"
           min-rpm="766" max-rpm="1575" >
  <actionpt x="7.7" y="2.65" z="-0.34"/>
  <control-input axis="/controls/engines/engine[0]/propeller-pitch" control="ADVANCE" />
  <piston-engine
    eng-power="1340" 
		eng-rpm="2600"
    turbo-mul="2.4" 
		wastegate-mp="56"
		displacement="2135"
		compression="6.5"
    >
    <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>

<propeller   x="7.0" y="-2.65" z="-0.34"
           radius="1.7" 
           mass="1290" moment="74.0"
           cruise-alt="17000" cruise-power="1000"
           cruise-speed="180" cruise-rpm="1420"
           gear-ratio="0.645"
           coarse-stop="5.0"
           min-rpm="766" max-rpm="1575" >
  <actionpt x="7.7" y="-2.65" z="-0.34"/>
  <control-input axis="/controls/engines/engine[1]/propeller-pitch" control="ADVANCE" />
  <piston-engine
    eng-power="1340" 
		eng-rpm="2600"
    turbo-mul="2.4" 
		wastegate-mp="56"
		displacement="2135"
		compression="6.5"
    >
    <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>


 <!-- left main -->
<gear x="5.0" y="2.6" z="-2.9" compression="0.6" spring="0.7" damp="3.0" dfric="0.6" sfric ="0.40">
  <control-input axis="/controls/gear/brake-left" control="BRAKE"/>
  <control-input axis="/controls/gear/brake-parking" control="BRAKE" split="true"/>
  <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
  <control-speed control="EXTEND" transition-time="6"/>
  <control-output control="EXTEND" prop="/gear/gear[1]/position-norm"/>
</gear>

 <!-- right main -->
<gear x="5.0" y="-2.6" z="-2.9" compression="0.6" spring="0.7" damp="3.0" dfric="0.6" sfric ="0.40">
  <control-input axis="/controls/gear/brake-right" control="BRAKE"/>
  <control-input axis="/controls/gear/brake-parking" control="BRAKE" split="true"/>
  <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
  <control-speed control="EXTEND" transition-time="7"/>
  <control-output control="EXTEND" prop="/gear/gear[2]/position-norm"/>
</gear>

<!-- tail gear -->
	<gear x="-6.32" y="0.0" z="-0.99" compression="0.2"
	  castering="1" retract-time = "0" > 
      <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
  <control-input axis="/controls/gear/tailwheel-lock" control="CASTERING" 
                 src0="0" src1="1"
                 dst0="1" dst1="0"/>
      <control-speed control="EXTEND" transition-time="4"/>
      <control-output control="EXTEND" prop="/gear/gear[0]/position-norm"/>
    </gear>

<tank x="3.6" y="1.34" z="-0.19" capacity="2135"/> 
<tank x="3.5" y="3.35" z="-0.08" capacity="727"/> 


<tank x="3.6" y="-2.34" z="-0.19" capacity="2135"/> 
<tank x="3.5" y="-3.35" z="-0.08" capacity="727"/> 
<!--
<tank x="-7.4" y="-1.35" z="-0.08" capacity="273"/> 
-->
<!-- pilot -->
<ballast x="5.1" y="0.4" z="0.4" mass="3000"/>

<!--
<weight x="-7.4" y="0.3" z="-0.45" mass-prop="sim/weight[0]/weight-lb" size="0.0" />
<weight x="-7.4" y="-0.3" z="-0.45" mass-prop="sim/weight[1]/weight-lb" size="0.0" />
<weight x="-7.4" y="0.4" z="0.2" mass-prop="sim/weight[2]/weight-lb" size="0.0" />
<weight x="-7.4" y="-0.4" z="0.2" mass-prop="sim/weight[3]/weight-lb" size="0.0" />
<weight x="-7.4" y="0.75" z="-0.1" mass-prop="sim/weight[4]/weight-lb" size="0.0" />
<weight x="-7.4" y="-0.75" z="-0.1" mass-prop="sim/weight[5]/weight-lb" size="0.0" />
-->
</airplane>
