Chemistry · function

massFractions

A composition from species ids and mass fractions.

Explained in Chemistry.

function massFractions(registry: SpeciesRegistry, entries: Readonly<Record<string, number>>): Composition
import { massFractions } from '@driftengine/chemistry';

Parameters

ParameterTypeDescription
registrySpeciesRegistry
entriesReadonly<Record<string, number>>

In depth

Fails fast on anything wrong, per AGENTS.md: an unknown id, a fraction that is negative or not a number, a sum that is not one. Each names the offending value, because "invalid composition" in a stack trace is a sentence somebody has to reproduce to act on.