A better improved patch that supersedes the previous FuelDensity.diff
I sent to this list.
This one takes /consumables/fuel/tank[n]/density-ppg into account in the calcs.
Cheers,
Bertrand.
2011/1/29 Bertrand Coconnier <bcoco...@gmail.com>:
> 2011/1/28 Hal V. Engel <hven...@gmail.com>:
>> A thread was opened on the forum about how the C172P appeared to be
>> incorrectly calculating the amount of fuel in gallons based on the weight of
>> the fuel. It appears that the conversion is using 6.6 lbs/gal when it should
>> be using something close to 6.0. That is
>>
>> /fdm/jsbsim/propulsion/tank[n]/contents-lbs divided by
>> /consumables/fuel/tank[n]/level-us_gal == 6.6
>>
>> I also had an issue with this for the p51d-jsbsim model and I had to use 6.6
>> as the conversion factor when setting up the fuel tanks in order to get
>> /consumables/fuel/tank[n]/level-us_gal to report the correct amount of fuel.
>> What is really strange is that /consumables/fuel/tank[n]/density-ppg = 6.0.
>> Is this a bug or is there some other issue that aircraft developers need to
>> be
>> aware of to get this to work correctly?
>>
>> Hal
>>
>
> Hi Hal,
>
> This is somehow a bug since the fuel density is hardcoded to 6.6
> lbs/gal in src/FDM/JSBSim/JSBSim.cxx. Enclosed patch reads the fuel
> density from JSBSim to make conversion between volume and density.
>
> Note that JSBSim allows different sort of fuel density to be used (see
> JSBSim reference manual chapter 3.1.7.1 pp. 39-40). Most of the fuels
> seem to be around 6.6 lbs/gal with the notable exception of AVGAS and
> HYDRAZINE.
>
> Cheers,
>
> Bertrand.
>
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index f802c8c..fc09b0b 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -215,14 +213,25 @@ FGJSBsim::FGJSBsim( double dt )
// Set initial fuel levels if provided.
for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
+ FGTank* tank = Propulsion->GetTank(i);
+ double fuelDensity;
+
+ if (node->getChild("density-ppg", 0, false) != 0) {
+ fuelDensity = node->getDoubleValue("density-ppg");
+ tank->SetDensity(fuelDensity);
+ }
+ else {
+ fuelDensity = tank->GetDensity();
+ node->setDoubleValue("density-ppg", fuelDensity);
+ }
+
if (node->getChild("level-gal_us", 0, false) != 0) {
- Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+ tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
} else {
- node->setDoubleValue("level-lbs", Propulsion->GetTank(i)->GetContents());
- node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
+ node->setDoubleValue("level-lbs", tank->GetContents());
+ node->setDoubleValue("level-gal_us", tank->GetContents() / fuelDensity);
}
- node->setDoubleValue("capacity-gal_us",
- Propulsion->GetTank(i)->GetCapacity() / 6.6);
+ node->setDoubleValue("capacity-gal_us", tank->GetCapacity() / fuelDensity);
}
Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
@@ -670,7 +706,9 @@ bool FGJSBsim::copy_to_JSBsim()
for (i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
FGTank * tank = Propulsion->GetTank(i);
- tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
+ double fuelDensity = node->getDoubleValue("density-ppg");
+ tank->SetDensity(fuelDensity);
+ tank->SetContents(node->getDoubleValue("level-gal_us") * fuelDensity);
// tank->SetContents(node->getDoubleValue("level-lbs"));
}
@@ -909,7 +947,9 @@ bool FGJSBsim::copy_from_JSBsim()
FGTank* tank = Propulsion->GetTank(i);
double contents = tank->GetContents();
double temp = tank->GetTemperature_degC();
- node->setDoubleValue("level-gal_us", contents/6.6);
+ double fuelDensity = tank->GetDensity();
+ node->setDoubleValue("density-ppg" , fuelDensity);
+ node->setDoubleValue("level-gal_us", contents/fuelDensity);
node->setDoubleValue("level-lbs", contents);
if (temp != -9999.0) node->setDoubleValue("temperature_degC", temp);
}
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel