.. _mat-workflows: Workflows ========= These examples combine the native MAT objects into common composition and matter tasks. Use the :doc:`MAT model ` for formula syntax and :doc:`Matter and normalization ` for the calculation rules. Build a normalized mixture -------------------------- Create a material from substances and choose how the component amounts are interpreted: .. code-block:: cpp #include 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: .. code-block:: cpp #include #include 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 :doc:`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: .. code-block:: cpp #include 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 :doc:`MAT API commands <../api/mat>`. 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 :doc:`Matter and normalization ` for the meaning of aggregate and average rows.