<?xml version="1.0"?>  
<system name="HK36 Fuel System"> 
	<!--	Adapted from the FlightGear wiki	-->
	
	<!--	The engine takes fuel from the fuel pressure regulator, which is fed from the main fuel tank by two electric fuel pumps	-->
	
	<property value="1">systems/fuel/tank-valve</property>
	<property value="1">systems/fuel/boost-pump/serviceable</property>
	<property value="1">systems/fuel/engine-pump/serviceable</property>
	<property value="0.0">propulsion/tank[0]/leakage-norm</property>
	<property value="0.0">propulsion/tank[1]/leakage-norm</property>
	
	<channel name="Fuel Flow">    

		<switch name="systems/fuel/boost-pump/active">
			<default value="0"/>
			<test logic="AND" value="1">
				/systems/electrical/outputs/boost-fuel-pump GE 9
				systems/fuel/boost-pump/serviceable EQ 1
			</test>
		</switch>
		<switch name="systems/fuel/engine-pump/active">
			<default value="0"/>
			<test logic="AND" value="1">
				/systems/electrical/outputs/engine-fuel-pump GE 9
				systems/fuel/engine-pump/serviceable EQ 1
			</test>
		</switch>
		<switch name="systems/fuel/fuel-pumps-active">
			<default value="0"/>
			<test logic="OR" value="1">
				systems/fuel/boost-pump/active EQ 1
				systems/fuel/engine-pump/active EQ 1
			</test>
		</switch>
		<switch>
			<default value="-0.2"/>
			<test logic="OR" value="0">
				systems/fuel/tank-valve NE 1
				propulsion/tank[0]/contents-lbs LE 0
				propulsion/tank[1]/contents-lbs GE 0.015
				systems/fuel/fuel-pumps-active NE 1
			</test>
			<output>propulsion/tank[0]/flow-to-tank-1-pps</output>
		</switch>
		
		<pure_gain>
			<input>propulsion/tank[0]/leakage-norm</input>
			<gain>0.1</gain>
			<output>propulsion/tank[0]/leakage-pps</output>
		</pure_gain>
		<pure_gain>
			<input>propulsion/tank[1]/leakage-norm</input>
			<gain>0.1</gain>
			<output>propulsion/tank[1]/leakage-pps</output>
		</pure_gain>

		<summer>
			<input>-propulsion/tank[0]/leakage-pps</input>
			<input>propulsion/tank[0]/flow-to-tank-1-pps</input>
			<output>propulsion/tank[0]/external-flow-rate-pps</output>
		</summer>
		<summer>
			<input>-propulsion/tank[1]/leakage-pps</input>
			<input>-propulsion/tank[0]/flow-to-tank-1-pps</input>
			<output>propulsion/tank[1]/external-flow-rate-pps</output>
		</summer>  

	</channel>
	
	<channel name="Fuel Pressure">
		
		<fcs_function>
			<function>
				<table>
					<independentVar lookup="row">propulsion/tank[1]/contents-lbs</independentVar>
					<independentVar lookup="column">propulsion/tank[1]/leakage-pps</independentVar>
					<tableData>
							0	0.1
						0	0	0
						0.013	0.1	0.05
						0.015	3.6	1.0
					</tableData>
				</table>
			</function>
			<output>propulsion/tank[1]/pressure-psi</output>
		</fcs_function>
	</channel>

</system>
