1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export function percentLiftGasNeededSTP(
liftForce,
totalVolume,
molarMassLiftGas,
molarMassHeavyGas
) {
// Calculate the percent mix you need at STP of liftGas vs. heavyGas
const g = 9.81; // Acceleration due to gravity in m/s^2
const density_air = 1.225; // Density of air in kg/m^3 at sea level and at 15 °C
const molarVolume = 0.0224; // Molar volume in m^3/mol at STP
// Calculate the density of hydrogen and xenon at STP in kg/m^3
const densityLift = molarMassLiftGas / molarVolume;
const densityHeavyGas = molarMassHeavyGas / molarVolume;
// Calculate the density of the gas mixture required to generate the lift force in kg/m^3
const densityMix = density_air - liftForce / (totalVolume * g);
// Calculate the molar fraction of hydrogen required in the gas mixture
let liftFraction =
(densityMix - densityHeavyGas) / (densityLift - densityHeavyGas);
// Check if the calculated fraction is within the valid range
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;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.