Materials¶
Bridge between py-mat materials and HYRR isotopic resolution.
materials ¶
Bridge between py-mat materials and HYRR isotopic resolution.
parse_formula ¶
Parse a chemical formula into element counts.
Examples:
"MoO3" -> {"Mo": 1, "O": 3} "H2O" -> {"H": 2, "O": 1} "Al2O3" -> {"Al": 2, "O": 3} "Cu" -> {"Cu": 1}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
formula
|
str
|
Chemical formula string |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
Dict mapping element symbol to atom count |
formula_to_mass_fractions ¶
Convert chemical formula to elemental mass fractions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
formula
|
str
|
Chemical formula (e.g., "MoO3") |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict mapping element symbol to mass fraction (sums to 1.0) |
mass_to_atom_fractions ¶
Convert mass fractions to atom fractions.
x_i = (w_i / M_i) / sum(w_j / M_j)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass_fractions
|
dict[str, float]
|
Dict of element symbol -> mass fraction |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict of element symbol -> atom fraction (sums to 1.0) |
resolve_element ¶
resolve_element(db: DatabaseProtocol, symbol: str, enrichment: dict[int, float] | None = None) -> Element
Resolve an element with natural or enriched isotopic composition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
DatabaseProtocol
|
Database for natural abundance lookup |
required |
symbol
|
str
|
Element symbol (e.g., "Mo") |
required |
enrichment
|
dict[int, float] | None
|
Optional dict of A -> fractional abundance overrides. If provided, must sum to ~1.0. Replaces natural abundances entirely. |
None
|
Returns:
| Type | Description |
|---|---|
Element
|
Element with isotopic composition |
resolve_isotopics ¶
resolve_isotopics(db: DatabaseProtocol, composition: dict[str, float], *, is_atom_fraction: bool = False, overrides: dict[str, dict[int, float]] | None = None) -> list[tuple[Element, float]]
Resolve a material composition into (Element, atom_fraction) pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
DatabaseProtocol
|
Database for natural abundance lookups |
required |
composition
|
dict[str, float]
|
Element symbol -> fraction mapping |
required |
is_atom_fraction
|
bool
|
If True, composition values are atom fractions. If False, they are mass fractions (will be converted). |
False
|
overrides
|
dict[str, dict[int, float]] | None
|
Optional enrichment overrides per element. Keys are element symbols, values are A -> fractional abundance dicts. |
None
|
Returns:
| Type | Description |
|---|---|
list[tuple[Element, float]]
|
List of (Element, atom_fraction) pairs |
resolve_formula ¶
resolve_formula(db: DatabaseProtocol, formula: str, overrides: dict[str, dict[int, float]] | None = None) -> tuple[list[tuple[Element, float]], float]
Resolve a chemical formula into isotopics and compute molecular weight.
Convenience function combining parse_formula + resolve_isotopics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
DatabaseProtocol
|
Database for natural abundance lookups |
required |
formula
|
str
|
Chemical formula (e.g., "MoO3") |
required |
overrides
|
dict[str, dict[int, float]] | None
|
Optional enrichment overrides per element |
None
|
Returns:
| Type | Description |
|---|---|
tuple[list[tuple[Element, float]], float]
|
(elements_with_fractions, molecular_weight_u) |