pub struct Material {
pub youngs_modulus: f64,
pub shear_modulus: f64,
pub poissons_ratio: f64,
pub density: f64,
pub thermal_expansion: f64,
pub yield_strength: f64,
pub ultimate_strength: f64,
pub name: &'static str,
pub color: Option<(u8, u8, u8)>,
}Fields§
§youngs_modulus: f64Young’s modulus Pa
shear_modulus: f64Shear modulus Pa
poissons_ratio: f64Poisson’s ratio [-]
density: f64Density [kg/m³]
thermal_expansion: f64Coefficient of thermal expansion [1/K]
yield_strength: f64Yield strength Pa (for plastic analysis)
ultimate_strength: f64Ultimate tensile strength Pa
name: &'static strOptional: identifier/name for display
color: Option<(u8, u8, u8)>Optional: color for visualization (RGB 0-255)
Implementations§
Source§impl Material
impl Material
Sourcepub fn new(
youngs_modulus: f64,
poissons_ratio: f64,
density: f64,
name: &'static str,
) -> Self
pub fn new( youngs_modulus: f64, poissons_ratio: f64, density: f64, name: &'static str, ) -> Self
Create a new material from E and ν (computes G = E / (2(1+ν))).
This is an unchecked constructor — it does not validate the
inputs. Call is_valid to verify that the
resulting material has physically admissible properties.
Sourcepub fn with_all(
youngs_modulus: f64,
shear_modulus: f64,
poissons_ratio: f64,
density: f64,
thermal_expansion: f64,
yield_strength: f64,
ultimate_strength: f64,
name: &'static str,
) -> Self
pub fn with_all( youngs_modulus: f64, shear_modulus: f64, poissons_ratio: f64, density: f64, thermal_expansion: f64, yield_strength: f64, ultimate_strength: f64, name: &'static str, ) -> Self
Create a new material with all properties specified.
This is an unchecked constructor — it does not validate the
inputs. Call is_valid to verify that the
resulting material has physically admissible properties.
Sourcepub fn with_thermal_expansion(self, alpha: f64) -> Self
pub fn with_thermal_expansion(self, alpha: f64) -> Self
Set thermal expansion coefficient.
Sourcepub fn with_yield_strength(self, fy: f64) -> Self
pub fn with_yield_strength(self, fy: f64) -> Self
Set yield strength.
Sourcepub fn with_ultimate_strength(self, fu: f64) -> Self
pub fn with_ultimate_strength(self, fu: f64) -> Self
Set ultimate strength.
Sourcepub fn with_color(self, r: u8, g: u8, b: u8) -> Self
pub fn with_color(self, r: u8, g: u8, b: u8) -> Self
Set visualization color (RGB).
Sourcepub fn modular_ratio(&self, ref_material: &Material) -> f64
pub fn modular_ratio(&self, ref_material: &Material) -> f64
Get modular ratio relative to another material (n = E_this / E_ref).
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if material properties are physically valid.
Returns true only when every field is finite and within the
physically admissible range for an isotropic linear-elastic solid:
E > 0and finiteG > 0and finite-1 < ν < 0.5(strict on both sides: ν = -1 gives G = ∞, ν = 0.5 gives infinite bulk modulus)ρ ≥ 0and finite (zero density is admissible for a massless placeholder)