New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Elastic energy #10
base: conditional_kernel
Are you sure you want to change the base?
Conversation
@@ -17,6 +17,21 @@ impl ConstitutiveModel for CorotatedLinearElasticity { | |||
) | |||
} | |||
|
|||
// https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.3 | |
// https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.3 | |
// This is essentially the same calculation as `[pos_energy]` but without ignoring the negative part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a reference to the pos_energy
instead.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend taking the whole &Particle
as argument, for consistency with pos_energy
and to take hardening into account the same way as in pos_energy
.
Can be in another PR.
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) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark regarding taking hardening into account.
@@ -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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just a refactoring leftover. It can be false, false
.
dd5d822
to
f85c628
Compare
// General elastic density function: https://dl.acm.org/doi/pdf/10.1145/3306346.3322949#section.5 (8) and (9) | ||
// With degradation: https://dl.acm.org/doi/pdf/10.1145/3306346.3322949#subsection.3.2 (3) | ||
// With hardening: https://www.math.ucla.edu/~cffjiang/research/mpmcourse/mpmcourse.pdf#subsection.6.5 (87) | ||
#[allow(non_snake_case)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s not allow non_snake_case
. It messes up with syntax highlighting, and is very unconventional in rust, even though I agree it makes it closer to the mathematical notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're now using more descriptive names (with proper snake case) while keeping aliases matching the paper in the comments.
let Psi_mu = | ||
|F: Matrix<Real>| hardened_mu / 2. * ((F.transpose() * F).trace() - DIM as Real); | ||
let Psi_mu = Psi_mu(J_alpha * F); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closure makes the code more difficult to read, especially since it’s only called once and bound to a variable with the same name.
59ff60f
to
21ca1b1
Compare
636a3c9
to
a98266f
Compare
Once we've converged on style for the neo-hookean one, I'll update the corotated code to match. |
This adds functions to compute the elastic energy density function from a given deformation gradient.
The new code is different from the existing one.
See
pos_energy
:sparkl/src/dynamics/models/elasticity_corotated_linear.rs
Lines 35 to 37 in 43c13a6
We may want to refactor.