<?xml version="1.0"?>

<aerodynamics>
		
	<!--	Glide Performance (AFM 5.3.2):
			(propeller feathered, maximum takeoff mass)
			minimum sink rate:	1.19m/s at 97 kph (52kts)
			
			additional data points:
				airspeed (kph)	(kts)	sink rate (m/s)
				150 		81	2.05
				200 		108	4.6
	-->
	<function name="aero/alpha-wing-deg">
		<todegrees>
			<property>aero/alpha-wing-rad</property>
		</todegrees>
	</function>
	
	<function name="aero/cl_groundeffect">
		<!--(ported from C172p:) ground effect-->
		<table>
			<independentVar>aero/h_b-mac-ft</independentVar>
			<tableData>
				0.0000	1.2030
				0.1000	1.1270
				0.1500	1.0900
				0.2000	1.0730
				0.3000	1.0460
				0.4000	1.0550
				0.5000	1.0190
				0.6000	1.0130
				0.7000	1.0080
				0.8000	1.0060
				0.9000	1.0030
				1.0000	1.0020
				1.1000	1.0000
			</tableData>
		</table>
	</function>
	
	<function name="aero/cd_groundeffect">
		<!--(ported from C172p:) ground effect-->
		<table>
			<independentVar>aero/h_b-mac-ft</independentVar>
			<tableData>
				0.0000	0.4800
				0.1000	0.5150
				0.1500	0.6290
				0.2000	0.7090
				0.3000	0.8150
				0.4000	0.8820
				0.5000	0.9280
				0.6000	0.9620
				0.7000	0.9880
				0.8000	1.0000
				0.9000	1.0000
				1.0000	1.0000
				1.1000	1.0000
			</tableData>
		</table>
	</function>
	
	<function name="aero/qbar-total-psf">
		<sum>
			<property>aero/qbar-psf</property>
			<product>
				<value>0.5</value>
				<property>atmosphere/rho-slugs_ft3</property>
				<pow>
					<property>propulsion/engine[0]/prop-induced-velocity_fps</property>
					<value>2</value>
				</pow>
			</product>
		</sum>
	</function>
	
	<axis name="LIFT">
		
		<function name="aero/force/Lift_propwash">
			<description>Delta lift due to propeller induced velocity</description>
			<product>
				<property>propulsion/engine[0]/thrust-coefficient</property>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<table>
					<independentVar lookup="row">aero/alpha-rad</independentVar>
					<independentVar lookup="column">fcs/flap-pos-deg</independentVar>
					<tableData>
						0.0     60.0
						-0.75  0.000   0.000
						0.00  0.038   0.101
						0.05  0.177   0.471
						0.10  0.000   0.000
					</tableData>
				</table>
			</product>
		</function>
		
		<!-- Lift above 0.85 and below -0.85 is generalised -->
		<function name="aero/force/Lift_alpha">
			<description>Lift due to alpha</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/cl_groundeffect</property>
				<!-- Polar from XFLR5 of Wortmann FX63-137 http://airfoiltools.com/airfoil/details?airfoil=fx63137-il -->
				<table>
					<independentVar lookup="row">aero/alpha-wing-deg</independentVar>
					<tableData>
						-90	0.0000
						-40	-0.5696956  
						-35	-0.7515933  
						-30	-0.6828823  
						-25	-0.5642942  
						-21	-0.4450105  
						-20	-0.4149251  
						-19	-0.3878522  
						-18	-0.3726398  
						-17	-0.3354148  
						-16	-0.3056753  
						-15	-0.2926994  
						-14	-0.2676154  
						-13	-0.2500798  
						-12	-0.2714582  
						-11	-0.3057115  
						-10	-0.2983434  
						-9	-0.2962876  
						-8	-0.229224  
						-7	-0.1953948  
						-5	-0.1393752  
						-4	0.1844832  
						-3	0.3322365  
						-2	0.5137611  
						-1	0.6245213  
						0	0.6986426  
						1	0.8279315  
						2	0.9488876  
						3	1.073064  
						4	1.164146  
						5	1.303082  
						6	1.432008  
						7	1.529671  
						8	1.602211  
						9	1.651629  
						10	1.668719  
						11	1.647075  
						12	1.602378  
						13	1.573118  
						14	1.571353  
						15	1.576913  
						16	1.566642  
						17	1.552756  
						18	1.543079  
						19	1.537413  
						20	1.509121  
						21	1.46489  
						22	1.335788  
						23	1.308765  
						90	0.0000
					</tableData>
				</table>
				<value>1.025</value> 
				<!-- factor to compensate for potentially wrong maximum lift:
					calculation of factor x: 86kph is 1.1*Vs1 (see AFM page 2-6)
						-> Vs1 is 78.18kph
					maximal lift at 10 degrees alpha (1.668)
					Lift force: F=q*A*(cl*x)
						with q = 0.5 * p * v2
							= 0.5 * 1.225 kg/m^3 * (21.717m/s)^2
							= 288.872 N/m^2
					so that	F = 288.872 N/m^2 * 15.30 m^2 * 1.668 * x
					F needs to be equivalent to mass, Vs1 is at MTOM -> 770kg
						Fg = 770kg * 9.81 N/kg = 7553.7 N
					=> x = 7553.7N / 7372.12899 N = 1.025
				-->
			</product>
		</function>
		
		<function name="aero/force/Lift_pitch_rate">
			<description>Lift due to pitch rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>velocities/q-aero-rad_sec</property>
				<property>aero/ci2vel</property>
				<value> 10.1723 </value>
			</product>
		</function>
		
		<function name="aero/force/Lift_alpha_rate">
			<description>Lift due to alpha rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/alphadot-rad_sec</property>
				<property>aero/ci2vel</property>
				<value> 2.1292 </value>
			</product>
		</function>
		
		<function name="aero/force/Lift_elevator">
			<description>Lift due to Elevator Deflection</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>fcs/elevator-pos-rad</property>
				<value> 0.6135 </value>
			</product>
		</function>
		
		<function name="aero/force/Lift_spoilers">
			<description>Delta Lift due to spoilers</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>fcs/spoiler-pos-norm</property>
				<value> -0.0100 </value>
			</product>
		</function>
		
	</axis>
	
	<axis name="DRAG">
		
		<function name="aero/force/Drag_minimum">
			<description>Minimum drag</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<value> 0.012 </value>
			</product>
		</function>
		
		<function name="aero/force/Drag_alpha">
			<description>Drag due to alpha</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<table>
					<independentVar lookup="row">aero/alpha-rad</independentVar>
					<tableData>
						-1.57    1.4100
						-0.05    0.013
						0.00    0.0000
						0.05    0.013
						1.57    1.4100
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/force/Drag_induced">
			<description>Induced drag</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/cl-squared</property>
				<property>aero/cd_groundeffect</property>
				<value> 0.02 </value>
			</product>
		</function>
		
		<function name="aero/force/Drag_mach">
			<description>Drag due to mach</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<table>
					<independentVar lookup="row">velocities/mach</independentVar>
					<tableData>
						0.00    0.0000
						0.70    0.0000
						1.10    0.0230
						1.80    0.0150
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/force/Drag_beta">
			<description>Drag due to sideslip</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<table>
					<independentVar lookup="row">aero/beta-rad</independentVar>
					<tableData>
						-1.57    1.2300
						-0.26    0.0500
						0.00    0.0000
						0.26    0.0500
						1.57    1.2300
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/force/Drag_elevator">
			<description>Drag due to Elevator Deflection</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<abs><property>fcs/elevator-pos-rad</property></abs>
				<value> 0.0400 </value>
			</product>
		</function>
		
		<function name="aero/force/Drag_spoilers">
			<description>Drag due to spoilers</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>fcs/spoiler-pos-norm</property>
				<value> 0.05 </value>
			</product>
		</function>
		
	</axis>
	
	<axis name="SIDE">
		
		<function name="aero/force/Side_beta">
			<description>Side force due to beta</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/beta-rad</property>
				<value> -0.9243 </value>
			</product>
		</function>
		<function name="aero/force/Side_roll_rate">
			<description>Side force due to roll rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/bi2vel</property>
				<property>velocities/p-aero-rad_sec</property>
				<value>0.0069</value>
			</product>
		</function>
		
		<function name="aero/force/Side_yaw_rate">
			<description>Side force due to yaw rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>aero/bi2vel</property>
				<property>velocities/r-aero-rad_sec</property>
				<value> 0.5337 </value>
			</product>
		</function>
		
		<function name="aero/force/Side_rudder">
			<description>Side force due to rudder</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>fcs/rudder-pos-rad</property>
				<value> 0.2758 </value>
			</product>
		</function>
		
	</axis>
	
	<axis name="PITCH">
		
		<function name="aero/moment/Pitch_propwash">
			<description>Pitch moment due to propeller induced velocity</description>
			<product>
				<property>propulsion/engine[0]/thrust-coefficient</property>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<table>
					<independentVar lookup="row">aero/alpha-rad</independentVar>
					<independentVar lookup="column">fcs/flap-pos-deg</independentVar>
					<tableData>
						0.0     60.0
						-0.01  0.000   0.000
						0.00 -0.047  -0.124
						0.05 -0.218  -0.580
						0.07  0.000   0.000
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/moment/Pitch_alpha">
			<description>Pitch moment due to alpha</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/cbarw-ft</property>
				<property>aero/alpha-rad</property>
				<value> -4.1526 </value>
			</product>
		</function>
		
		<function name="aero/moment/Pitch_elevator">
			<description>Pitch moment due to elevator</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/cbarw-ft</property>
				<property>fcs/elevator-pos-rad</property>
				<table>
					<independentVar lookup="row">velocities/mach</independentVar>
					<tableData>
						0.0    -3.2549
						2.0    -0.8137
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/moment/Pitch_damp">
			<description>Pitch moment due to pitch rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/cbarw-ft</property>
				<property>aero/ci2vel</property>
				<property>velocities/q-aero-rad_sec</property>
				<value> -54.7617 </value>
			</product>
		</function>
		
		<function name="aero/moment/Pitch_alphadot">
			<description>Pitch moment due to alpha rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/cbarw-ft</property>
				<property>aero/ci2vel</property>
				<property>aero/alphadot-rad_sec</property>
				<value> -11.4624 </value>
			</product>
		</function>
		
	</axis>
	
	<axis name="ROLL">
		
		<function name="aero/moment/Roll_differential_propwash">
			<description>Roll moment due to differential propwash</description>
			<product>
				<property>propulsion/engine[0]/thrust-coefficient</property>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/alpha-rad</property>
				<value> 0.4555 </value>
			</product>
		</function>
		
		<function name="aero/moment/Roll_beta">
			<description>Roll moment due to beta</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/beta-rad</property>
				<property>fcs/gear-no-wow</property>
				<table>
					<independentVar lookup="row">aero/alpha-rad</independentVar>
					<tableData>
						-0.0349  -0.3109
						0.3491  -0.3109
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/moment/Roll_damp">
			<description>Roll moment due to roll rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/bi2vel</property>
				<property>velocities/p-aero-rad_sec</property>
				<value> -0.7 </value>
			</product>
		</function>
		
		<function name="aero/moment/Roll_yaw">
			<description>Roll moment due to yaw rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/bi2vel</property>
				<property>velocities/r-aero-rad_sec</property>
				<table>
					<independentVar lookup="row">aero/alpha-rad</independentVar>
					<tableData>
						-0.0349  -0.1593
						0.3491   2.4945
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/moment/Roll_aileron">
			<description>Roll moment due to aileron</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>fcs/left-aileron-pos-rad</property>
				<value>0.2</value>
				<!-- (ported from c172p:) the ailerons are less efficient and even create an opposite roll moment close to stall because deflection down makes the wing portion stall-->
				<table>
					<independentVar lookup="row">aero/alpha-deg</independentVar>
					<tableData>
					15    1
					16    0.3
					18   -0.1
					</tableData>
				</table>
			</product>
		</function>
		
		<function name="aero/moment/Roll_rudder">
			<description>Roll moment due to rudder</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>fcs/rudder-pos-rad</property>
				<value> 0.0100 </value>
			</product>
		</function>
		
	</axis>
	
	<axis name="YAW">
		
		<function name="aero/moment/Yaw_beta">
			<description>Yaw moment due to beta</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/beta-rad</property>
				<value> 0.1282 </value>
			</product>
		</function>
		
		<function name="aero/moment/Yaw_roll_rate">
			<description>Yaw moment due to roll rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/bi2vel</property>
				<property>velocities/p-rad_sec</property>
				<value>-0.0020</value>
			</product>
		</function>
		
		<function name="aero/moment/Yaw_damp">
			<description>Yaw moment due to yaw rate</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>aero/bi2vel</property>
				<property>velocities/r-aero-rad_sec</property>
				<value> -0.0883 </value>
			</product>
		</function>
		
		<function name="aero/moment/Yaw_rudder">
			<description>Yaw moment due to rudder</description>
			<product>
				<property>aero/qbar-total-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>fcs/rudder-pos-rad</property>
				<value> -0.0796 </value>
			</product>
		</function>
		
		<function name="aero/moment/Yaw_aileron">
			<description>Adverse yaw</description>
			<product>
				<property>aero/qbar-psf</property>
				<property>metrics/Sw-sqft</property>
				<property>metrics/bw-ft</property>
				<property>fcs/left-aileron-pos-rad</property>
				<value> -0.0100 </value>
			</product>
		</function>
		
	</axis>
	
</aerodynamics>
