pub struct LinElasticity { /* private fields */ }Expand description
Implements the linear elasticity equations for small-strain problems
Implementations§
Source§impl LinElasticity
impl LinElasticity
Sourcepub fn new(young: f64, poisson: f64, two_dim: bool, plane_stress: bool) -> Self
pub fn new(young: f64, poisson: f64, two_dim: bool, plane_stress: bool) -> Self
Allocates a new instance
§Input
young– Young’s moduluspoisson– Poisson’s coefficienttwo_dim– 2D instead of 3Dplane_stress– specifies a Plane-Stress problem and automatically settwo_dimas 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\
└ ┘"
);Sourcepub fn set_young_poisson(&mut self, young: f64, poisson: f64)
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\
└ ┘"
);Sourcepub fn set_bulk_shear(&mut self, bulk: f64, shear: f64)
pub fn set_bulk_shear(&mut self, bulk: f64, shear: f64)
Sets the bulk (K) and shear (G) moduli
Sourcepub fn get_young_poisson(&self) -> (f64, f64)
pub fn get_young_poisson(&self) -> (f64, f64)
Returns the Young’s modulus and Poisson’s coefficient
Returns (young, poisson)
Sourcepub fn get_bulk_shear(&self) -> (f64, f64)
pub fn get_bulk_shear(&self) -> (f64, f64)
Returns the bulk (K) and shear (G) moduli
Returns (bulk, shear)
Sourcepub fn get_modulus(&self) -> &Tensor4
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\
└ ┘"
);Sourcepub fn calc_stress(&self, stress: &mut Tensor2, strain: &Tensor2)
pub fn calc_stress(&self, stress: &mut Tensor2, strain: &Tensor2)
Calculates stress from strain
σ = D : ε§Output
stress– the stress tensor σ; with the same Mandel asstrain
§Input
strain– the strain tensor ε; with the same Mandel asstress
§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(())
}Sourcepub fn out_of_plane_strain(&self, stress: &Tensor2) -> Result<f64, StrError>
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(())
}Sourcepub fn calc_compliance(&self, cc: &mut Tensor4) -> Result<(), StrError>
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(())
}