Skip to main content

Material

Struct Material 

Source
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: f64

Young’s modulus Pa

§shear_modulus: f64

Shear modulus Pa

§poissons_ratio: f64

Poisson’s ratio [-]

§density: f64

Density [kg/m³]

§thermal_expansion: f64

Coefficient of thermal expansion [1/K]

§yield_strength: f64

Yield strength Pa (for plastic analysis)

§ultimate_strength: f64

Ultimate tensile strength Pa

§name: &'static str

Optional: identifier/name for display

§color: Option<(u8, u8, u8)>

Optional: color for visualization (RGB 0-255)

Implementations§

Source§

impl Material

Source

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.

Source

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.

Source

pub fn with_thermal_expansion(self, alpha: f64) -> Self

Set thermal expansion coefficient.

Source

pub fn with_yield_strength(self, fy: f64) -> Self

Set yield strength.

Source

pub fn with_ultimate_strength(self, fu: f64) -> Self

Set ultimate strength.

Source

pub fn with_color(self, r: u8, g: u8, b: u8) -> Self

Set visualization color (RGB).

Source

pub fn modular_ratio(&self, ref_material: &Material) -> f64

Get modular ratio relative to another material (n = E_this / E_ref).

Source

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 > 0 and finite
  • G > 0 and finite
  • -1 < ν < 0.5 (strict on both sides: ν = -1 gives G = ∞, ν = 0.5 gives infinite bulk modulus)
  • ρ ≥ 0 and finite (zero density is admissible for a massless placeholder)

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Material

Source§

impl Debug for Material

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Material

Source§

fn default() -> Self

Default to generic structural steel (S355).

Source§

impl Display for Material

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Material

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Material

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.