Skip to content

models.propellants.formulations

Ready-to-use propellant formulation instances loaded from bundled JSON files.

Solid formulations (in formulations.solid): KNDX, KNSB, KNSB_NAKKA, KNSU, KNER, RNX_57, RNX_71V, MIT_CHERRY_LIMEADE

Biliquid formulations (in formulations.biliquid): LOX_LH2_6_0

You can also load custom formulations from JSON with get_propellant_from_json(filepath). The JSON schema expects mixture_type, components (with chemical formula, density, enthalpy, role, and optionally mass fractions), properties, and burn_rate_map (for solids).

machwave.models.propellants.formulations

get_propellant_from_json(filepath)

Load propellant formulation from JSON file.

Parameters:

Name Type Description Default
filepath str | Path

Path to JSON file.

required

Returns:

Type Description
SolidPropellant | BiliquidPropellant

SolidPropellant or BiliquidPropellant instance.

Raises:

Type Description
ValueError

If JSON data invalid.

FileNotFoundError

If file doesn't exist.

Source code in machwave/models/propellants/formulations/base.py
def get_propellant_from_json(
    filepath: str | Path,
) -> propellant_categories.SolidPropellant | propellant_categories.BiliquidPropellant:
    """Load propellant formulation from JSON file.

    Args:
        filepath: Path to JSON file.

    Returns:
        SolidPropellant or BiliquidPropellant instance.

    Raises:
        ValueError: If JSON data invalid.
        FileNotFoundError: If file doesn't exist.
    """
    filepath = Path(filepath)

    if not filepath.exists():
        raise FileNotFoundError(f"Propellant JSON file not found: {filepath}")

    with open(filepath, "r") as f:
        data = json.load(f)

    mixture_type = _parse_mixture_type(data)
    components, mass_fractions = _parse_components(data, mixture_type=mixture_type)
    properties = _parse_properties(data)
    return _create_propellant(
        mixture_type, data, components, mass_fractions, properties
    )