pyskyfire.common.fluids.Fluid

class pyskyfire.common.fluids.Fluid(type, propellants, fractions, basis='mass', precision=3)

Mixture helper for fluids.

Stores a set of component names and composition.

Parameters:
typestr

Role of the mixture (e.g., "fuel", "oxidizer", "coolant").

propellantslist[str]

Component names (CoolProp canonical names, e.g., "Ethanol", "Water").

fractionslist[float]

Composition fractions corresponding to propellants. Interpreted as mass or mole fractions depending on basis.

basisstr, optional

"mass" or "mole". Default is "mass".

precisionint, optional

Number of decimal digits when exporting mole fractions (e.g., in coolprop_string()). Default is 3.

Attributes:
typestr

Role marker for the mixture.

propellantslist[str]

CoolProp component names.

fractionslist[float]

Stored composition in the given basis.

basisstr

Basis of the stored composition ("mass" or "mole").

precisionint

Decimal places for exported mole fractions.

See also

CoolProp

External property library used for molar masses and HEOS string format.

Notes

Fractions are re-normalized internally when converting to mole basis to guard against small rounding errors.

as_mole_fractions()

Convert the stored composition to mole fractions.

Returns:
list[float]

Mole fractions for each component in propellants, rounded to precision decimals and re-normalized to sum to 1.0.

Raises:
ValueError

If basis is not "mass" or "mole".

Notes

For a mass-basis input, the conversion uses \(x_i = \frac{w_i/M_i}{\sum_j w_j/M_j}\) with molar masses \(M_i\) from molar_masses().

coolprop_string()

Format a CoolProp HEOS mixture string.

Returns:
str

A string such as 'HEOS::Ethanol[0.800]&Water[0.200]', where the bracketed values are mole fractions with precision digits.

Notes

The composition is always exported on a mole basis, using as_mole_fractions() for conversion when needed.

molar_masses()

Return molar masses for each component.

Returns:
list[float]

Molar masses in kg/mol for each name in propellants.

Notes

Values are retrieved via CoolProp.PropsSI("M", name).