Skip to content

Commit 5a7207a

Browse files
committed
WIP: samples/neohookean: second derivative
1 parent a6db214 commit 5a7207a

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • samples/tests/neohookean

samples/tests/neohookean/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ impl NH {
219219
}
220220
// https://en.wikipedia.org/wiki/Lam%C3%A9_parameters
221221
pub fn from_youngs(E: f64, nu: f64) -> Self {
222-
Self {
223-
lambda: E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu)),
224-
mu: E / (2.0 * (1.0 + nu)),
225-
}
222+
Self::from_lame(
223+
E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu)),
224+
E / (2.0 * (1.0 + nu)),
225+
)
226226
}
227227

228228
pub fn stress(&self, e: &KM) -> KM {
@@ -241,7 +241,7 @@ impl NH {
241241

242242
// We can only differentiate free functions, not methods (yet)
243243
// Helmholtz free energy density
244-
#[autodiff(d_psi, Reverse, Duplicated, Const, Active)]
244+
#[autodiff(d_psi, ReverseFirst, Duplicated, Const, Active)]
245245
fn psi(e: &KM, nh: &NH) -> f64 {
246246
let mu = nh.mu;
247247
let lambda = nh.lambda;
@@ -335,7 +335,6 @@ fn check_stress() {
335335
assert!(diff < 1e-14);
336336
}
337337

338-
#[cfg(broken)]
339338
#[test]
340339
fn check_dstress() {
341340
let nh = NH::from_youngs(1.0, 0.3);

0 commit comments

Comments
 (0)