Struct LinElasticity

Source
pub struct LinElasticity { /* private fields */ }
Expand description

Implements the linear elasticity equations for small-strain problems

Implementations§

Source§

impl LinElasticity

Source

pub fn new(young: f64, poisson: f64, two_dim: bool, plane_stress: bool) -> Self

Allocates a new instance

§Input
  • young – Young’s modulus
  • poisson – Poisson’s coefficient
  • two_dim – 2D instead of 3D
  • plane_stress – specifies a Plane-Stress problem and automatically set two_dim as appropriate.
§Examples
use russell_tensor::LinElasticity;

// 3D
let ela = LinElasticity::new(900.0, 0.25, false, false);
let dd = ela.get_modulus().as_matrix();
assert_eq!(
    format!("{}", dd),
    "┌                                              ┐\n\
     │ 1080  360  360    0    0    0    0    0    0 │\n\
     │  360 1080  360    0    0    0    0    0    0 │\n\
     │  360  360 1080    0    0    0    0    0    0 │\n\
     │    0    0    0  360    0    0  360    0    0 │\n\
     │    0    0    0    0  360    0    0  360    0 │\n\
     │    0    0    0    0    0  360    0    0  360 │\n\
     │    0    0    0  360    0    0  360    0    0 │\n\
     │    0    0    0    0  360    0    0  360    0 │\n\
     │    0    0    0    0    0  360    0    0  360 │\n\
     └                                              ┘"
);

// 2D plane-strain
let ela = LinElasticity::new(900.0, 0.25, true, false);
let dd = ela.get_modulus().as_matrix();
assert_eq!(
    format!("{}", dd),
    "┌                                              ┐\n\
     │ 1080  360  360    0    0    0    0    0    0 │\n\
     │  360 1080  360    0    0    0    0    0    0 │\n\
     │  360  360 1080    0    0    0    0    0    0 │\n\
     │    0    0    0  360    0    0  360    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0  360    0    0  360    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     └                                              ┘"
);

// 2D plane-stress
let ela = LinElasticity::new(3000.0, 0.2, false, true);
let dd = ela.get_modulus().as_matrix();
assert_eq!(
    format!("{}", dd),
    "┌                                              ┐\n\
     │ 3125  625    0    0    0    0    0    0    0 │\n\
     │  625 3125    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 1250    0    0 1250    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 1250    0    0 1250    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     └                                              ┘"
);
Source

pub fn mandel(&self) -> Mandel

Returns the Mandel representation

Source

pub fn set_young_poisson(&mut self, young: f64, poisson: f64)

Sets the Young’s modulus and Poisson’s coefficient

§Examples
use russell_tensor::LinElasticity;
let two_dim = true;
let plane_stress = true;
let mut ela = LinElasticity::new(3000.0, 0.2, two_dim, plane_stress);
ela.set_young_poisson(6000.0, 0.2);
let dd = ela.get_modulus().as_matrix();
assert_eq!(
    format!("{}", dd),
    "┌                                              ┐\n\
     │ 6250 1250    0    0    0    0    0    0    0 │\n\
     │ 1250 6250    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 2500    0    0 2500    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 2500    0    0 2500    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     └                                              ┘"
);
Source

pub fn set_bulk_shear(&mut self, bulk: f64, shear: f64)

Sets the bulk (K) and shear (G) moduli

Source

pub fn get_young_poisson(&self) -> (f64, f64)

Returns the Young’s modulus and Poisson’s coefficient

Returns (young, poisson)

Source

pub fn get_bulk_shear(&self) -> (f64, f64)

Returns the bulk (K) and shear (G) moduli

Returns (bulk, shear)

Source

pub fn get_modulus(&self) -> &Tensor4

Returns an access to the elastic rigidity (stiffness) modulus

The rigiDity modulus D is such that:

σ = D : ε
§Examples
use russell_tensor::LinElasticity;
let ela = LinElasticity::new(3000.0, 0.2, false, true);
let out = ela.get_modulus().as_matrix();
assert_eq!(
    format!("{}", out),
    "┌                                              ┐\n\
     │ 3125  625    0    0    0    0    0    0    0 │\n\
     │  625 3125    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 1250    0    0 1250    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0 1250    0    0 1250    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     │    0    0    0    0    0    0    0    0    0 │\n\
     └                                              ┘"
);
Source

pub fn calc_stress(&self, stress: &mut Tensor2, strain: &Tensor2)

Calculates stress from strain

σ = D : ε
§Output
  • stress – the stress tensor σ; with the same Mandel as strain
§Input
  • strain – the strain tensor ε; with the same Mandel as stress
§Panics

A panic will occur if the tensors have different Mandel

§Examples
use russell_tensor::{Mandel, LinElasticity, StrError, Tensor2};

fn main() -> Result<(), StrError> {
    // define the strain matrix => will cause sum of rows of D
    let strain_matrix_3d = &[
        [1.0, 1.0, 1.0],
        [1.0, 1.0, 1.0],
        [1.0, 1.0, 1.0]
    ];
    let strain_matrix_2d = &[
        [1.0, 1.0, 0.0],
        [1.0, 1.0, 0.0],
        [0.0, 0.0, 1.0]
    ];

    // 3D
    // sum of first 3 rows = 1800
    // sum of other rows = 720
    let ela = LinElasticity::new(900.0, 0.25, false, false);
    let out = ela.get_modulus().as_matrix();
    assert_eq!(
        format!("{}", out),
        "┌                                              ┐\n\
         │ 1080  360  360    0    0    0    0    0    0 │\n\
         │  360 1080  360    0    0    0    0    0    0 │\n\
         │  360  360 1080    0    0    0    0    0    0 │\n\
         │    0    0    0  360    0    0  360    0    0 │\n\
         │    0    0    0    0  360    0    0  360    0 │\n\
         │    0    0    0    0    0  360    0    0  360 │\n\
         │    0    0    0  360    0    0  360    0    0 │\n\
         │    0    0    0    0  360    0    0  360    0 │\n\
         │    0    0    0    0    0  360    0    0  360 │\n\
         └                                              ┘"
    );
    let strain = Tensor2::from_matrix(strain_matrix_3d, Mandel::Symmetric)?;
    let mut stress = Tensor2::new(Mandel::Symmetric);
    ela.calc_stress(&mut stress, &strain);
    let out = stress.as_matrix();
    assert_eq!(
        format!("{:.0}", out),
        "┌                ┐\n\
         │ 1800  720  720 │\n\
         │  720 1800  720 │\n\
         │  720  720 1800 │\n\
         └                ┘"
    );

    // 2D plane-strain
    // sum of first 3 rows = 1800
    // sum of other rows = 720
    let ela = LinElasticity::new(900.0, 0.25, true, false);
    let out = ela.get_modulus().as_matrix();
    println!("{}", out);
    assert_eq!(
        format!("{}", out),
        "┌                                              ┐\n\
         │ 1080  360  360    0    0    0    0    0    0 │\n\
         │  360 1080  360    0    0    0    0    0    0 │\n\
         │  360  360 1080    0    0    0    0    0    0 │\n\
         │    0    0    0  360    0    0  360    0    0 │\n\
         │    0    0    0    0    0    0    0    0    0 │\n\
         │    0    0    0    0    0    0    0    0    0 │\n\
         │    0    0    0  360    0    0  360    0    0 │\n\
         │    0    0    0    0    0    0    0    0    0 │\n\
         │    0    0    0    0    0    0    0    0    0 │\n\
         └                                              ┘"
    );
    let strain = Tensor2::from_matrix(strain_matrix_2d, Mandel::Symmetric2D)?;
    let mut stress = Tensor2::new(Mandel::Symmetric2D);
    ela.calc_stress(&mut stress, &strain);
    let out = stress.as_matrix();
    assert_eq!(
        format!("{:.0}", out),
        "┌                ┐\n\
         │ 1800  720    0 │\n\
         │  720 1800    0 │\n\
         │    0    0 1800 │\n\
         └                ┘"
    );
    Ok(())
}
Source

pub fn out_of_plane_strain(&self, stress: &Tensor2) -> Result<f64, StrError>

Calculates and sets the out-of-plane strain in the Plane-Stress case

§Input
  • stress – the stress tensor σ
§Output
  • Returns the εzz (out-of-plane) component
§Examples
use russell_tensor::{Mandel, LinElasticity, StrError, Tensor2};

fn main() -> Result<(), StrError> {
    let young = 2500.0;
    let poisson = 0.25;
    let ela = LinElasticity::new(young, poisson, true, true);
    let (sig_xx, sig_yy) = (2000.0, 1000.0);
    let stress = Tensor2::from_matrix(&[
            [sig_xx,     0.0, 0.0],
            [   0.0,  sig_yy, 0.0],
            [   0.0,     0.0, 0.0],
        ], Mandel::Symmetric2D,
    )?;
    let eps_zz = ela.out_of_plane_strain(&stress)?;
    let eps_zz_correct = -(poisson / young) * (sig_xx + sig_yy);
    assert_eq!(eps_zz, eps_zz);
    Ok(())
}
Source

pub fn calc_compliance(&self, cc: &mut Tensor4) -> Result<(), StrError>

Calculates the elastic compliance modulus

Note: The compliance modulus is not available for plane-stress.

The Compliance modulus C is such that:

ε = C : σ

The compliance modulus is calculate as C = D⁻¹

§Panics

A panic will occur if cc has a different Mandel than dd.

§Examples
use russell_lab::mat_approx_eq;
use russell_tensor::*;

fn main() -> Result<(), StrError> {
    // calculate C
    let ela = LinElasticity::new(900.0, 0.25, false, false);
    let mut cc = Tensor4::new(ela.mandel());
    ela.calc_compliance(&mut cc).unwrap();

    // check
    let (kk, gg) = ela.get_bulk_shear();
    let psd = Tensor4::constant_pp_symdev(true);
    let piso = Tensor4::constant_pp_iso(true);
    let mut correct = Tensor4::new(Mandel::Symmetric);
    t4_add(&mut correct, 1.0 / (3.0 * kk), &piso, 1.0 / (2.0 * gg), &psd);
    mat_approx_eq(cc.matrix(), correct.matrix(), 1e-15);
    Ok(())
}

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.