Skip to content

Commit

Permalink
feat: Add elastic energy density function and refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vollkornaffe committed Dec 6, 2023
1 parent ba72e3f commit 43c13a6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/dynamics/models/constitutive_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ use crate::math::{Matrix, Real};

pub trait ConstitutiveModel: Send + Sync {
fn is_fluid(&self) -> bool;

fn elastic_energy_density(&self, _deformation_gradient: Matrix<Real>) -> Real {
0.0
}

fn pos_energy(&self, _particle: &Particle) -> Real {
0.0
}
Expand Down
15 changes: 15 additions & 0 deletions src/dynamics/models/elasticity_corotated_linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ impl ConstitutiveModel for CorotatedLinearElasticity {
)
}

// https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.3
fn elastic_energy_density(&self, deformation_gradient: Matrix<Real>) -> Real {
let singular_values = deformation_gradient
.svd_unordered(false, false)
.singular_values;
let determinant: Real = singular_values.iter().product();

self.mu
* singular_values
.iter()
.map(|sigma| (sigma - 1.).powi(2))
.sum::<Real>()
+ self.lambda / 2. * (determinant - 1.).powi(2)
}

fn pos_energy(&self, particle: &Particle) -> Real {
self.pos_energy(particle.deformation_gradient, particle.elastic_hardening)
}
Expand Down
11 changes: 10 additions & 1 deletion src/dynamics/models/elasticity_neo_hookean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::dynamics::models::{
ActiveTimestepBounds, ConstitutiveModel, CoreConstitutiveModel, NeoHookeanElasticity,
};
use crate::dynamics::Particle;
use crate::math::{Matrix, Real};
use crate::math::{Matrix, Real, DIM};

impl ConstitutiveModel for NeoHookeanElasticity {
fn is_fluid(&self) -> bool {
Expand All @@ -17,6 +17,15 @@ impl ConstitutiveModel for NeoHookeanElasticity {
)
}

// https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.2
fn elastic_energy_density(&self, deformation_gradient: Matrix<Real>) -> Real {
let determinant_log = deformation_gradient.determinant().ln();
self.mu / 2.
* ((deformation_gradient.transpose() * deformation_gradient).trace() - DIM as Real)
- self.mu * determinant_log
+ self.lambda / 2. * determinant_log.powi(2)
}

fn pos_energy(&self, particle: &Particle) -> Real {
self.pos_energy(
particle.phase,
Expand Down
2 changes: 1 addition & 1 deletion src_core/dynamics/models/elasticity_corotated_linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CorotatedLinearElasticity {

pub fn pos_energy(&self, deformation_gradient: Matrix<Real>, elastic_hardening: Real) -> Real {
let j = deformation_gradient.determinant();
let mut pos_def = deformation_gradient.svd_unordered(true, true);
let mut pos_def = deformation_gradient.svd_unordered(true, true); // TODO: why compute U and V?
pos_def.singular_values.apply(|e| *e = (*e - 1.0).max(0.0));

let pos_dev_part = self.mu * elastic_hardening * pos_def.singular_values.norm_squared();
Expand Down
1 change: 1 addition & 0 deletions src_core/utils/physics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn inv_exact(e: Real) -> Real {
}

/// Computes the Lamé parameters (lambda, mu) from the young modulus and poisson ratio.
/// https://encyclopediaofmath.org/wiki/Lam%C3%A9_constants
pub fn lame_lambda_mu(young_modulus: Real, poisson_ratio: Real) -> (Real, Real) {
(
young_modulus * poisson_ratio / ((1.0 + poisson_ratio) * (1.0 - 2.0 * poisson_ratio)),
Expand Down

0 comments on commit 43c13a6

Please sign in to comment.