export function percentLiftGasNeededSTP(
liftForce,
totalVolume,
molarMassLiftGas,
molarMassHeavyGas
) {
const g = 9.81;
const density_air = 1.225;
const molarVolume = 0.0224;
const densityLift = molarMassLiftGas / molarVolume;
const densityHeavyGas = molarMassHeavyGas / molarVolume;
const densityMix = density_air - liftForce / (totalVolume * g);
let liftFraction =
(densityMix - densityHeavyGas) / (densityLift - densityHeavyGas);
if (liftFraction < 0 || liftFraction > 1) {
console.error(
"Error: The calculated hydrogen fraction is outside the valid range. It's not possible to achieve the desired lift force with the given total volume of gas and the available gases (hydrogen and xenon)."
);
return null;
}
console.log(
`Percentage of hydrogen required in the gas mixture: ${liftFraction * 100}%`
);
return liftFraction;
}