#[cfg(test)]
mod test;
use super::*;
#[derive(Debug)]
pub struct NeoHookean<'a> {
parameters: Parameters<'a>,
}
impl<'a> Constitutive<'a> for NeoHookean<'a> {
fn new(parameters: Parameters<'a>) -> Self {
Self { parameters }
}
}
impl<'a> Solid<'a> for NeoHookean<'a> {
fn get_bulk_modulus(&self) -> &Scalar {
&self.parameters[0]
}
fn get_shear_modulus(&self) -> &Scalar {
&self.parameters[1]
}
}
impl<'a> Elastic<'a> for NeoHookean<'a> {
fn calculate_cauchy_stress(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<CauchyStress, ConstitutiveError> {
let jacobian = deformation_gradient.determinant();
if jacobian > 0.0 {
Ok(self
.calculate_left_cauchy_green_deformation(deformation_gradient)
.deviatoric()
/ jacobian.powf(FIVE_THIRDS)
* self.get_shear_modulus()
+ IDENTITY * self.get_bulk_modulus() * 0.5 * (jacobian - 1.0 / jacobian))
} else {
Err(ConstitutiveError::InvalidJacobian(
jacobian,
deformation_gradient.copy(),
format!("{:?}", &self),
))
}
}
fn calculate_cauchy_tangent_stiffness(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<CauchyTangentStiffness, ConstitutiveError> {
let jacobian = deformation_gradient.determinant();
if jacobian > 0.0 {
let inverse_transpose_deformation_gradient = deformation_gradient.inverse_transpose();
let scaled_shear_modulus = self.get_shear_modulus() / jacobian.powf(FIVE_THIRDS);
Ok(
(CauchyTangentStiffness::dyad_ik_jl(&IDENTITY, deformation_gradient)
+ CauchyTangentStiffness::dyad_il_jk(deformation_gradient, &IDENTITY)
- CauchyTangentStiffness::dyad_ij_kl(&IDENTITY, deformation_gradient)
* (TWO_THIRDS))
* scaled_shear_modulus
+ CauchyTangentStiffness::dyad_ij_kl(
&(IDENTITY * (0.5 * self.get_bulk_modulus() * (jacobian + 1.0 / jacobian))
- self
.calculate_left_cauchy_green_deformation(deformation_gradient)
.deviatoric()
* (scaled_shear_modulus * FIVE_THIRDS)),
&inverse_transpose_deformation_gradient,
),
)
} else {
Err(ConstitutiveError::InvalidJacobian(
jacobian,
deformation_gradient.copy(),
format!("{:?}", &self),
))
}
}
}
impl<'a> Hyperelastic<'a> for NeoHookean<'a> {
fn calculate_helmholtz_free_energy_density(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<Scalar, ConstitutiveError> {
let jacobian = deformation_gradient.determinant();
if jacobian > 0.0 {
Ok(0.5
* (self.get_shear_modulus()
* (self
.calculate_left_cauchy_green_deformation(deformation_gradient)
.trace()
/ jacobian.powf(TWO_THIRDS)
- 3.0)
+ self.get_bulk_modulus() * (0.5 * (jacobian.powi(2) - 1.0) - jacobian.ln())))
} else {
Err(ConstitutiveError::InvalidJacobian(
jacobian,
deformation_gradient.copy(),
format!("{:?}", &self),
))
}
}
}