Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AB water vapor pressure calc #4956

Merged
merged 5 commits into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/weather/functions/fnc_calculateAirDensity.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _pressure = _pressure * 100; // hPa to Pa

if (_relativeHumidity > 0) then {
// Saturation vapor pressure calculated according to: http://wahiduddin.net/calc/density_algorithms.htm
private _pSat = 6.1078 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3));
private _pSat = 610.78 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3));
private _vaporPressure = _relativeHumidity * _pSat;
private _partialPressure = _pressure - _vaporPressure;

Expand Down
2 changes: 1 addition & 1 deletion extensions/advanced_ballistics/AdvancedBallistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ double calculateAirDensity(double temperature, double pressure, double relativeH

if (relativeHumidity > 0) {
double _pSat = 6.1078 * pow(10, ((7.5 * temperature) / (temperature + 237.3)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't 6.1078 (hPa) be converted to Pa directly here instead of converting it in vaporPressure? I find it more clear than later multiplying by 100.0 and having _pSat in hPa while vaporPressure in Pa

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to use 610.78 and added note

double vaporPressure = relativeHumidity * _pSat;
double vaporPressure = 100 * relativeHumidity * _pSat;
double partialPressure = pressure - vaporPressure;

return (partialPressure * DRY_AIR_MOLAR_MASS + vaporPressure * WATER_VAPOR_MOLAR_MASS) / (UNIVERSAL_GAS_CONSTANT * KELVIN(temperature));
Expand Down