Material types and factory methods
Demonstrates how to instantiate the three main material families available in xfea — elastic-isotropic, elastic-plastic (nonlinear), and elastic-orthotropic — using both their constructors and the built-in grade factories.
The script
Section titled “The script”examples/scripts/02_core_concepts/model/materials.py. Run it from the repository with uv run python examples/scripts/02_core_concepts/model/materials.py, or, with xfea-examples installed, xfea-examples run 02_core_concepts/model/materials.py.
from xfea.model import ElasticIsotropicfrom xfea.model import ElasticOrthotropicfrom xfea.model import ElasticPlastic# Elastic Isotropic# Built-in grade factories (steel, concrete, aluminium)steel = ElasticIsotropic.steel("s355")concrete = ElasticIsotropic.concrete("C30/37")aluminum = ElasticIsotropic.aluminum()
print("--- Elastic Isotropic ---")print(f"Steel S355 E={steel.E}, density={steel.density}")print(f"Concrete C30/37 E={concrete.E}")print(f"Aluminium 6061 E={aluminum.E}")
# Custom density overrideheavy_steel_density = 8e-9 # [t/mm^3] custom steel densitysteel_heavy = ElasticIsotropic.steel("s355", density=heavy_steel_density)print(f"Custom density steel: density={steel_heavy.density}")
# Direct constructor — custom aluminium (SI-mm)E_alu = 70_000 # [MPa] Young's modulusv_alu = 0.33 # [-] Poisson's ratiorho_alu = 2.7e-9 # [t/mm^3] mass densitycustom = ElasticIsotropic(E=E_alu, v=v_alu, density=rho_alu)print(f"Custom aluminium: E={custom.E}")
# Elastic Plastic# Built-in grade factoriesep_steel = ElasticPlastic.steel("s355")ep_concrete = ElasticPlastic.concrete("c20")
print("\n--- Elastic Plastic ---")print(f"Steel S355: {len(ep_steel.strain_stress)} strain-stress points")print(f"Concrete C20: {len(ep_concrete.strain_stress)} strain-stress points")
# Manual bilinear definition (often used for structural steel) — SI-mmE = 210_000 # [MPa] Young's modulusv = 0.3 # [-] Poisson's ratiodensity = 7.85e-9 # [t/mm^3] mass densityfy = 355 # [MPa] yield stressfu = 450 # [MPa] ultimate stress (hardening branch fu > fy)eps_u = 0.02 # [-] ultimate straineps_y = fy / E # [-] yield strainstrain_stress = [(0.0, 0.0), (eps_y, fy), (eps_u, fu)]ep_manual = ElasticPlastic(E=E, v=v, density=density, strain_stress=strain_stress)print(f"Manual bilinear ({len(ep_manual.strain_stress)} pts): " f"fy={fy:.0f} MPa, fu={fu:.0f} MPa")
# Elastic Orthotropic (timber)c24 = ElasticOrthotropic.timber("c24")
print("\n--- Elastic Orthotropic (Timber C24) ---")print(f"Ex={c24.Ex}, Ey={c24.Ey}, Ez={c24.Ez}")print(f"Gxy={c24.Gxy}, Gyz={c24.Gyz}, Gzx={c24.Gzx}")© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them