Workflows
These examples combine the native MAT objects into common composition and matter tasks. Use the MAT model for formula syntax and Matter and normalization for the calculation rules.
Build a normalized mixture
Create a material from substances and choose how the component amounts are interpreted:
#include <snt/mat/material.h>
using namespace snt;
const mat::Material mixture(
{{"N2", 0.7808}, {"O2", 0.2095}, {"Ar", 0.0093}, {"CO2", 0.0004}},
mat::Norm::NUMBER_FRACTION,
true
);
const auto components = mixture.data_components();
Use Norm::NUMBER to retain the supplied batch size,
Norm::NUMBER_FRACTION for normalized number fractions, or
Norm::MASS_FRACTION for mass-weighted mixtures.
Derive matter values
Supply the independent matter inputs and read the derived quantities:
#include <snt/mat/material.h>
#include <snt/mat/substance.h>
using namespace snt;
mat::MatterSpec matter;
matter.mass_density = puq::Quantity(1.02, "g/cm3");
matter.volume = puq::Quantity(1.0, "L");
const mat::Material brine(
{{"H2O", 0.965}, {"NaCl", 0.035}},
mat::Norm::MASS_FRACTION,
true,
matter
);
const auto matter_data = brine.data_matter();
MAT derives missing values only when the supplied inputs are sufficient and consistent. See Matter and normalization for the derivation rules and typed records.
Use the application facade
Applications that follow the SNT command boundary can use the typed facade in
snt-api instead of constructing MAT objects directly:
#include <snt/api/mat_eval.h>
snt::api::MATSubstance command("H2O");
command.argument_mass_density(snt::puq::Quantity(1.02, "g/cm3"));
command.argument_volume(snt::puq::Quantity(1.0, "L"));
const auto water = command.execute();
The native snt mat command uses this facade for element, substance, and
material evaluation, then formats the returned records. MATElement,
MATSubstance, and MATMaterial follow the same configure-then-execute
lifecycle as the PUQ and DIP application commands. The facade is enabled with
ENABLE_MAT and does not couple MAT to DIPL. See the MAT API commands.
Inspect typed records
Use data_components(), data_composite(), and data_matter() for
programmatic access. They return independent records; string formatting is a
presentation layer. See Matter and normalization for the
meaning of aggregate and average rows.