Skip to content

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.

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 ElasticIsotropic
from xfea.model import ElasticOrthotropic
from 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 override
heavy_steel_density = 8e-9 # [t/mm^3] custom steel density
steel_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 modulus
v_alu = 0.33 # [-] Poisson's ratio
rho_alu = 2.7e-9 # [t/mm^3] mass density
custom = ElasticIsotropic(E=E_alu, v=v_alu, density=rho_alu)
print(f"Custom aluminium: E={custom.E}")
# Elastic Plastic
# Built-in grade factories
ep_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-mm
E = 210_000 # [MPa] Young's modulus
v = 0.3 # [-] Poisson's ratio
density = 7.85e-9 # [t/mm^3] mass density
fy = 355 # [MPa] yield stress
fu = 450 # [MPa] ultimate stress (hardening branch fu > fy)
eps_u = 0.02 # [-] ultimate strain
eps_y = fy / E # [-] yield strain
strain_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