#![cfg(feature = "constitutive")]
use conspire::{
constitutive::{
fluid::viscoplastic::ViscoplasticFlow,
hybrid::{
ElasticMultiplicativeViscoplastic, ElasticViscoplasticAdditiveElastic,
ElasticViscoplasticAdditiveViscoplastic,
},
solid::{
elastic_plastic::ElasticPlasticOrViscoplastic,
elastic_viscoplastic::AppliedLoad,
hyperelastic::{ArrudaBoyce, Hencky},
hyperelastic_viscoplastic::SecondOrderMinimize,
},
},
math::{
Quantity, Tensor, assert::AssertionError, integrate::DormandPrince, optimize::NewtonRaphson,
},
units::{Rate, Stress, Time},
};
#[test]
fn demonstrate() -> Result<(), AssertionError> {
let model = ElasticViscoplasticAdditiveElastic::from((
ElasticMultiplicativeViscoplastic::from((
Hencky {
bulk_modulus: Stress::pascals(300.0),
shear_modulus: Stress::pascals(100.0),
},
ElasticViscoplasticAdditiveViscoplastic::from((
ElasticMultiplicativeViscoplastic::from((
Hencky {
bulk_modulus: Stress::pascals(0.0),
shear_modulus: Stress::pascals(25.0),
},
ElasticViscoplasticAdditiveViscoplastic::from((
ElasticMultiplicativeViscoplastic::from((
Hencky {
bulk_modulus: Stress::pascals(0.0),
shear_modulus: Stress::pascals(10.0),
},
ViscoplasticFlow {
yield_stress: Stress::pascals(3.0),
hardening_slope: Stress::pascals(0.0),
rate_sensitivity: 0.25,
reference_flow_rate: Rate::per_second(0.04),
},
)),
ViscoplasticFlow {
yield_stress: Stress::pascals(2.0),
hardening_slope: Stress::pascals(0.0),
rate_sensitivity: 0.25,
reference_flow_rate: Rate::per_second(0.02),
},
)),
)),
ViscoplasticFlow {
yield_stress: Stress::pascals(1.0),
hardening_slope: Stress::pascals(1.0),
rate_sensitivity: 0.25,
reference_flow_rate: Rate::per_second(0.01),
},
)),
)),
ArrudaBoyce {
bulk_modulus: Stress::pascals(0.0),
shear_modulus: Stress::pascals(3.0),
number_of_links: 4.0,
},
));
let (t, f, f_p) = model.minimize(
AppliedLoad::UniaxialStress(
|t: Quantity<Time>| {
let t = t.value();
if t < 0.25_f64.exp() - 1.0 {
1.0 + t
} else if t < 0.25_f64.exp() - 1.0 + 0.12_f64.exp() - 1.0 {
let t0 = 0.25_f64.exp() - 1.0;
0.25_f64.exp() - (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
{
let t0 = 0.25_f64.exp() - 1.0 + 0.12_f64.exp() - 1.0 - 1.0;
0.25_f64.exp() - 0.12_f64.exp() + (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 0.245_f64.exp()
- 1.0
{
let t0 =
0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp() - 1.0;
0.4992_f64.exp() - (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
{
let t0 = 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 0.245_f64.exp()
- 1.0;
0.3147_f64.exp() + (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
{
let t0 = 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0;
0.7500_f64.exp() - (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
+ 0.713_f64.exp()
- 1.0
{
let t0 = 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0;
0.5184_f64.exp() + (t - t0)
} else if t < 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
+ 0.713_f64.exp()
- 1.0
+ 0.555_f64.exp()
- 1.0
{
let t0 = 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
+ 0.713_f64.exp()
- 1.0;
1.0004_f64.exp() - (t - t0)
} else {
let t0 = 0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp()
- 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
+ 0.713_f64.exp()
- 1.0
+ 0.555_f64.exp()
- 1.0;
0.6818_f64.exp() + (t - t0)
}
},
&[
Time::seconds(0.0),
Time::seconds(
0.25_f64.exp() - 1.0 + 2.0 * (0.12_f64.exp() - 1.0) + 0.31_f64.exp() - 1.0
+ 2.0 * (0.245_f64.exp() - 1.0)
+ 0.385_f64.exp()
- 1.0
+ 0.363_f64.exp()
- 1.0
+ 0.713_f64.exp()
- 1.0
+ 0.555_f64.exp()
- 1.0
+ 0.55_f64.exp()
- 1.0,
),
],
),
DormandPrince::default(),
NewtonRaphson::default(),
)?;
for (t_i, (f_i, s_i)) in t.iter().zip(f.iter().zip(f_p.iter())) {
let (f_p_i, others) = s_i.into();
let (others, eqps) = others.into();
let (_, others) = others.into();
let (others, eqps_1) = others.into();
let (_, eqps_2) = others.into();
let c_e = model.cauchy_stress(f_i, f_p_i)?;
println!(
"{}, {}, {}, {}, {}, {}",
t_i,
f_i[0][0].ln(),
c_e[0][0],
eqps,
eqps_1,
eqps_2,
)
}
Ok(())
}