<?xml version="1.0"?>

<!--
************************************************************************
YASim aerodynamic model for a Bristol Beaufighter

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

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

<!-- Approach configuration -->
<approach speed="90" aoa="10">
  <control-setting axis="/controls/engines/engine[0]/throttle" value="0.3"/>
  <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[1]/throttle" value="0.3"/>
  <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/flight/flaps" value="1.0"/>
  <control-setting axis="/controls/gear/gear-down" value="1"/>
</approach>

<!-- Cruise configuration -->
<cruise speed="220" alt="15000">
  <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="0.5"/>
  <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="-4.495" y="0" z="0.689"/>

<fuselage ax="-0.687" ay="0.0" az="0.424" bx="-11.53" by="0.0" bz="0.433"
          width="1.725" taper="0.5" midpoint="0.42"/>

<!--
<fuselage ax="-0.576" ay="-2.87" az="-0.124" bx="-4.938" by="-2.938" bz="-0.039"
          width="1.1" taper="0.6" midpoint="0.2"/>

<fuselage ax="-0.576" ay="2.87" az="-0.124" bx="-4.938" by="2.938" bz="-0.039"
          width="1.1" taper="0.6" midpoint="0.2"/>
-->


<!--inner wing-->

<vstab x="-4.0775" y="0.75" z="-0.046" taper="0.901" incidence="2.0"
      length="2.976" chord="3.499" sweep="-2" dihedral="2" camber="0.1">
  <stall aoa="14" width="18" peak="1.5"/>
  <flap0 start="0.0" end="1.0" lift="1.4" drag="1.8"/>
  <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"/>
</vstab>

<vstab x="-4.0775" y="-0.75" z="-0.046" taper="0.901" incidence="2.0"
      length="2.976" chord="3.499" sweep="-2" dihedral="2" camber="0.1">
  <stall aoa="14" width="18" peak="1.5"/>
  <flap0 start="0.0" end="1.0" lift="1.3" drag="1.5"/>
  <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"/>
</vstab>
<!--wingtip-->
<vstab x="3.7465" y="8.542" z="0.465" taper="0.2" incidence="0"
      length="0.759" chord="1.737" sweep="0" dihedral="8" camber="0.1">
  <stall aoa="14" width="18" peak="1.5"/>
</vstab>

<vstab x="3.7465" y="-8.542" z="0.465" taper="0.2" incidence="0"
      length="0.759" chord="1.737" sweep="0" dihedral="8" camber="0.1">
  <stall aoa="14" width="18" peak="1.5"/>
</vstab>

<!--outer wing-->
<wing x="-3.884" y="3.726" z="-0.034" taper="0.85" incidence="1.0"
      length="5.279" chord="3.156" sweep="0.0" dihedral="8" camber="0.1">
  <stall aoa="14" width="18" peak="1.5"/>
  <flap0 start="0.0" end="0.43" lift="1.2" drag="1.4"/>
  <flap1 start="0.43" end="1.0" lift="1.6" drag="1.2"/>
  <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-input axis="/controls/flight/aileron" control="FLAP1" split="true"/>
  <control-input axis="/controls/flight/aileron-trim" control="FLAP1" split="true"/>
</wing>

<hstab x="-10.89" y="0.25" z="0.696" taper="0.8" dihedral="10"
       length="3.04" chord="1.579" sweep="0" incidence="0">
  <stall aoa="15" width="28" peak="1.5"/>
  <flap0 start="0.0" end="1.0" lift="1.9" drag="1.4"/>
  <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>

<!-- rudder has to be able to counteract aileron drag -->
<vstab x="-11.4735" y="0" z="-0.104" taper="0.432" effectiveness="3.5"
       length="2.667" chord="2.535" sweep="15"  incidence="-3.0">
  <stall aoa="15" width="14" peak="1.5"/>
  <flap0 start="0" end="1" lift="1.3" drag="1.2"/>
  <control-input axis="/controls/flight/rudder" square="true" 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="-0.325" y="2.87" z="-0.08"
           radius="1.75" 
           mass="1870" moment="94.5"
           cruise-alt="7000" cruise-power="1385"
           cruise-speed="175" cruise-rpm="1056"
           gear-ratio="0.44"
           min-rpm="766" max-rpm="1437" >
  <actionpt x="-0.63" y="2.87" z="-0.08"/>
  <control-input axis="/controls/engines/engine[0]/propeller-pitch" control="ADVANCE" />
  <piston-engine
    eng-power="1725"
    eng-rpm="2900"
    turbo-mul="5.5"
    wastegate-mp="61"
    displacement="2360"
    >
    <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="-0.325" y="-2.87" z="-0.08"
           radius="1.75" 
           mass="1870" moment="94.5"
           cruise-alt="7000" cruise-power="1385"
           cruise-speed="185" cruise-rpm="1056"
           gear-ratio="0.44"
           min-rpm="766" max-rpm="1276" >
  <actionpt x="-0.63" y="-2.87" z="-0.08"/>
  <control-input axis="/controls/engines/engine[1]/propeller-pitch" control="ADVANCE" />
  <piston-engine
    eng-power="1725" 
    eng-rpm="2900"
    turbo-mul="5.5" 
    wastegate-mp="61"
    displacement="2360"
    >
    <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="-2.357" y="2.9" z="-2.65" compression="0.4" spring="0.7" damp="3.0">
  <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[0]/position-norm"/>
</gear>

 <!-- right main -->
<gear x="-2.357" y="-2.9" z="-2.65" compression="0.4" spring="0.7" damp="3.0">
  <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="6"/>
  <control-output control="EXTEND" prop="/gear/gear[1]/position-norm"/>
</gear>

<!-- Tail wheel -->

<gear x="-10.565" y="0" z="-0.779" compression="0.2" dfric="0.5" sfric ="0.3">
  <control-input axis="/controls/gear/tailwheel-lock" control="CASTERING" 
                 src0="0" src1="1"
                 dst0="1" dst1="0"/>
  <control-input axis="/controls/gear/gear-down" control="EXTEND"/>
  <control-output control="EXTEND" prop="/gear/gear[2]/position-norm"/>
</gear>

<tank x="-3.2" y="3.9" z="-0.04" capacity="696"/> 
<tank x="-3.254" y="1.5" z="-0.046" capacity="1507"/> 

<tank x="-3.2" y="-3.9" z="-0.04" capacity="696"/>
<tank x="-3.254" y="-1.5" z="-0.046" capacity="1507"/> 
 

<!-- pilot -->
<ballast x="-2.6" y="0" z="0.4" mass="180"/>

<ballast x="-6.242" y="0" z="0.9" mass="180"/>

<ballast x="-8.5" y="0" z="0.9" mass="400"/>

<weight x="2.499" y="0" z="-1.084" mass-prop="sim/weight[0]/weight-lb" size="0.46" />
<weight x="2.6" y="-5.8" z="-0.21" mass-prop="sim/weight[1]/weight-lb" size="0.25" />
<weight x="2.6" y="5.8" z="-0.21" mass-prop="sim/weight[2]/weight-lb" size="0.25" />

</airplane>
