Skip to content

Commit

Permalink
Test the unusable fuel feature (see issue #759).
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Nov 13, 2022
1 parent 0d26057 commit 8fb7741
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
19 changes: 19 additions & 0 deletions aircraft/c172x/c172x.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@
</channel>
</system>

<system name="Fuel content in volume">
<fcs_function name="propulsion/tank[0]/contents-volume-gal">
<function>
<quotient>
<p> propulsion/tank[0]/contents-lbs </p>
<p> propulsion/tank[0]/density-lbs_per_gal </p>
</quotient>
</function>
</fcs_function>
<fcs_function name="propulsion/tank[1]/contents-volume-gal">
<function>
<quotient>
<p> propulsion/tank[1]/contents-lbs </p>
<p> propulsion/tank[1]/density-lbs_per_gal </p>
</quotient>
</function>
</fcs_function>
</system>

<system name="Mixture control">
<!--
E = 1.3 * Mixture * P_std / P_amb
Expand Down
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ set(PYTHON_TESTS ResetOutputFiles
TestLinearization
TestLinearActuator
TestPlanet
TestLighterThanAir)
TestLighterThanAir
TestUnusableFuel)

foreach(test ${PYTHON_TESTS})
add_test(NAME ${test}
Expand Down
60 changes: 60 additions & 0 deletions tests/TestUnusableFuel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# TestUnusableFuel.py
#
# Checks that the unusable fuel feature work (see issue GH#759)
#
# Copyright (c) 2022 Bertrand Coconnier
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>
#

from JSBSim_utils import JSBSimTestCase


class TestUnusableFuel(JSBSimTestCase):
def test_unusable_fuel(self):
fdm = self.create_fdm()
fdm.load_model("c172x")
fdm.load_ic("reset01", True)

fdm["propulsion/tank[0]/unusable-volume-gal"] = 1.5
fdm["propulsion/tank[1]/unusable-volume-gal"] = 1.5
fdm["propulsion/tank[0]/contents-lbs"] = 10
fdm["propulsion/tank[1]/contents-lbs"] = 10
fdm.run_ic()

# Check the engine is running
self.assertNotEqual(fdm["propulsion/engine/set-running"], 0.0)
# Check that tanks are not yet emptied.
self.assertLess(
fdm["propulsion/tank[0]/unusable-volume-gal"],
fdm["propulsion/tank[0]/contents-volume-gal"],
)
self.assertLess(
fdm["propulsion/tank[1]/unusable-volume-gal"],
fdm["propulsion/tank[1]/contents-volume-gal"],
)

# Run until the engine starves.
while fdm["propulsion/engine/set-running"] != 0.0:
fdm.run()

# Check that the fuel content in gallons is lower or equal to the unusable volume.
self.assertGreaterEqual(
fdm["propulsion/tank[0]/unusable-volume-gal"],
fdm["propulsion/tank[0]/contents-volume-gal"],
)
self.assertGreaterEqual(
fdm["propulsion/tank[1]/unusable-volume-gal"],
fdm["propulsion/tank[1]/contents-volume-gal"],
)

0 comments on commit 8fb7741

Please sign in to comment.