materia
Chemical composition to physical material properties, from first principles.
What it does
Define materials by their chemical structure — atoms, bonds, crystal lattice, polymer chains — and get all physical properties derived automatically from first principles.
use *;
// Define iron as a BCC crystal
let iron = compile;
assert_eq!;
println!; // ~7528
println!; // 1538
println!; // ~75
No hardcoded material databases. No magic numbers. Every property is computed from the atomic structure using established physics models.
Quick start
[]
= "0.1"
From molecules
use *;
let water = compile;
// Liquid at room temp, density ~1000, melting ~0°C, IOR 1.33
From crystals
let steel = compile; // 0.8% carbon
// Harder than pure iron — carbon solute strengthening
From polymers
let wood = compile_as;
Preset world materials
use presets;
let stone = stone; // basalt composition
let sand = sand; // quartz, granular form
let dirt = dirt; // soil mineral + organic mix
let grass = grass; // cellulose polymer
let water = water; // H2O, liquid
let lava = lava; // molten basalt, glows orange
let gold = gold; // FCC Au crystal
20 presets included: stone, granite, sand, clay, dirt, gravel, grass, wood, leaf, water, ice, snow, iron, steel, copper, gold, air, steam, smoke, lava.
Chemical reactions
let reaction = combustion_methane; // CH4 + 2O2 → CO2 + 2H2O
println!; // exothermic
assert!;
// Compile to a runtime interaction rule
let rule = reaction.to_interaction_rule;
13 reactions included: methane/hydrogen/carbon/sugar combustion, iron/copper/aluminum oxidation, water electrolysis, calcination, iron/copper smelting, magnesite decomposition, fermentation.
What it computes
Every field of MaterialDef is derived from the chemical structure:
| Property | Model | Accuracy |
|---|---|---|
| Density | Crystallographic d = ZM/(Na·a³) | Iron: 4%, Gold: 0.3% |
| Melting point | Element data + solute depression | Iron: exact, Water: 1.4°C off |
| Specific heat | Dulong-Petit (solids), DOF (gases) | Iron: 0.2% |
| Thermal conductivity | Wiedemann-Franz (metals) | Iron: 6%, Copper: 9% |
| Yield strength | Peierls-Nabarro + solute hardening | Order of magnitude |
| Color | Element-specific + oxide pigments | Qualitative |
| Refractive index | Lorentz-Lorenz density model | Water: exact |
| Emissivity | Hagen-Rubens (metals vs non-metals) | Qualitative |
| Surface tension | H-bond presence model | Water: exact |
| Phase state | Melting/boiling point comparison | All tested elements correct |
The 118 elements
All elements from hydrogen to oganesson, each with:
- Atomic mass (IUPAC 2021)
- Atomic radius (metallic/covalent, CRC Handbook)
- Electronegativity (Pauling scale)
- Cohesive energy (Kittel)
- Melting and boiling points (CRC Handbook)
- Electrical resistivity (15 common metals)
- Characteristic color
Substance types
| Type | Description | Example |
|---|---|---|
Molecular |
Discrete molecules with explicit bonds | H2O, CH4, glucose |
Crystalline |
Periodic lattice (BCC, FCC, HCP, Diamond) | Fe, Cu, Au, Si, diamond |
Polymer |
Long-chain with cross-linking | Cellulose, rubber |
Amorphous |
Disordered solid, defined by composition | Glass, basite rock, soil |
Phase-aware compilation
The same substance compiles differently depending on physical form:
let water = compile_as;
let ice = compile_as;
let steam = compile_as;
let snow = compile_as;
Each form gets adjusted density, viscosity, optical properties, etc.
Physics references
All estimation models cite their sources:
- Dulong-Petit specific heat: Kittel, Introduction to Solid State Physics, Ch. 5
- Wiedemann-Franz conductivity: Kittel, Ch. 6
- Lindemann criterion melting point: Lindemann (1910)
- Hagen-Rubens emissivity: Modest, Radiative Heat Transfer, Ch. 3
- Lorentz-Lorenz refractive index: Born & Wolf, Principles of Optics, Ch. 2
- Peierls-Nabarro yield strength: Hull & Bacon, Dislocations, Ch. 4
- Arrhenius activation energy: Atkins, Physical Chemistry
- Planck's law blackbody emission: Planck (1901)
No dependencies
Zero external dependencies. Pure Rust. No std features required beyond default.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.