Chemistry · function

elementTotals

Reduce kilograms per species into moles per element.

Explained in Chemistry.

function elementTotals(registry: SpeciesRegistry, speciesMass: Float64Array, out: Float64Array): void
import { elementTotals } from '@driftengine/chemistry';

Parameters

ParameterTypeDescription
registrySpeciesRegistry
speciesMassFloat64Array
outFloat64Array

In depth

out is overwritten, not accumulated into, so a caller may hold one vector for the life of a world and re-derive totals every tick without clearing it first. speciesMass is indexed by species, so it is the registry's width; a species with no mass costs one comparison.