Python
Use the native object model from scinumtools3.mat.
Basic examples
Calculate a formula’s composition with the native Python objects:
from scinumtools3.mat import Substance
water = Substance("H2O")
print(water.data_composite().sum.mass) # 18.0153*u
Calculate a mixture’s total mass through the command facade:
from scinumtools3.api.mat import MATMaterial, quantity_value
from scinumtools3.puq import Quantity
command = MATMaterial("0.965 <H2O> 0.035 <NaCl>")
command.argument_normalization("mass_fraction")
command.argument_mass_density(Quantity(1.02, "g/cm3"))
command.argument_volume(Quantity(1, "L"))
brine = command.execute()
print(quantity_value(brine.matter.mass, "g")) # approximately 1020
Common workflows
Task |
Call chain |
Result |
|---|---|---|
Evaluate a formula |
|
|
Derive matter values |
|
|
Build a normalized mixture |
|
|
Modify or extend a composition |
|
Updated object; component records |
Use the command facade |
|
|
from scinumtools3.mat import Material, MatterSpec, Norm, Substance
from scinumtools3.puq import Quantity
matter = MatterSpec()
matter.mass_density = Quantity(1.02, "g/cm3")
matter.volume = Quantity(1.0, "L")
water = Substance("H2O", matter=matter) # Substance
print(water.mass()) # Quantity
print(water.data_composite().sum.mass) # Quantity
mixture = Material("0.965 <H2O> 0.035 <NaCl>",
normalization=Norm.MASS_FRACTION) # Material
print(mixture.reference_count)
The command-oriented scinumtools3.api.mat facade returns the same typed
records used by the CLI and REST server and follows the same command-object
lifecycle as the PUQ and DIP API modules.
See the Python binding guide, native Python API reference, and application command reference.
Current limitations and differences
Compared with the canonical C++ implementation:
Python exposes the native Element, Substance, and Material objects and the command facade. Optional quantities use
Noneinstead ofstd::optional; returned record fields are read-only Python attributes.MatterSpecinputs remain writable.Direct ionization-table lookup and the C++ expression-solver extension interfaces are not wrapped.
The isotope choices, normalization, matter consistency checks, and physical limits are the same as in C++; the binding adds no separate physics model.
Binding reference
This is a lookup index, not a sequence to read from top to bottom. Use Common workflows above to choose a task, then find the exact Python names for that task below. Properties are shown without parentheses; callable names include their arguments. The linked API reference documents complete signatures and result fields.
Construction and matter inputs
Element(expression, proportion=1, natural=True, matter=MatterSpec()).Substance(expression, proportion=1.0, natural=True, matter=MatterSpec()),Substance(),Substance(number), andSubstance(elements, ...).Material(expression, normalization=Norm.NUMBER_FRACTION, natural=True, matter=MatterSpec()),Material(), andMaterial(substances, ...).MatterSpec()with writable fieldsnumber_density,mass_density,volume, andmass.
Element calls
Properties
expression,symbol,isotope,charge,natural,selection,effective_isotope_number,natural_abundance_sum,proportion, andcomponent_mass.Methods
mass(),mass_density(),number_density(),total_number_density(),volume(),matter_spec(),set_matter(),data(),data_matter(), andto_string().
Substance and material calls
Properties
expression,natural,normalization,reference_count,proportion(substance),formula(substance), andcomponent_mass(substance).Methods
add(expression, proportion=1),composite_mass(),mass(),mass_density(),number_density(),total_number_density(),volume(),matter_spec(),set_matter(),data_components(),data_composite(),data_matter(), andto_string().
Enums and result records
Norm.NUMBER,Norm.NUMBER_FRACTION,Norm.MASS_FRACTION.IsotopeSelection.EXPLICIT,NATURAL,DEFAULT, andPARTICLE.ElementData,ComponentData,CompositeRow,CompositeData,MatterSpecies,MatterRow, andMatterData.
Application command facade
scinumtools3.api.mat.MATElement(expression),MATSubstance(expression), andMATMaterial(expression).argument_natural(),argument_matter(),argument_normalization(),argument_number_density(),argument_mass_density(),argument_volume(),argument_mass(), andexecute().quantity_value(value, units)andnormalization_name(normalization).