-
Notifications
You must be signed in to change notification settings - Fork 1
Extends elastic models with anisotropic support. #41
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
Conversation
Introduces `AnisoElastic` and `IsoElastic` types and allows combination of isotropic and anisotropic models. It adds `MultiElastic` and `MultiAnisoElastic` to enable combination of multiple elastic models. It also enhances the TransverseIsotropy models to use the new `AnisoElastic` type.
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Updates the test to use defined variables, resolving an error.
miguelmaso
left a comment
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.
It looks very good. The only concern from the point of view of design is that I'd keept the composed elastic as the sum of two isotropic models (current behaviour).
The main purpose of isotropic composition is to compose isochoric and volumteric parts like
On the other hand, viscous branches and isotropic directions are used to be expressed as vectors, MultiAnisoElastic.
In my opinion, when there is only one direction, iso + aniso1 internally should be interpreted as iso + [aniso] (like I posted in #40). On the contrary, if we allow ((iso1 + aniso1) + iso2 + aniso2) we would end with a recursive structure that will make very difficult to pass the tuple/list of direction.
To sumup, we must block the syntax iso + aniso1 + aniso2.
From the point of view of style, I'd moved anisotropic models to another file, but this is a minor question that can be left to another moment.
| function (obj::MultiElastic{<:AnisoElastic,<:AnisoElastic})(Λ::Float64=1.0) | ||
| DΨ1 = obj.Model1(Λ) | ||
| DΨ2 = obj.Model2(Λ) | ||
| Ψ, ∂Ψ, ∂∂Ψ = map((ψ1,ψ2) -> (x,N) -> ψ1(x,N) + ψ2(x,N), DΨ1, DΨ2) | ||
| return (Ψ, ∂Ψ, ∂∂Ψ) | ||
| end | ||
| function (obj::MultiElastic{<:IsoElastic,<:AnisoElastic})(Λ::Float64=1.0) | ||
| DΨ1 = obj.Model1(Λ) | ||
| DΨ2 = obj.Model2(Λ) | ||
| Ψ, ∂Ψ, ∂∂Ψ = map((ψ1,ψ2) -> (x,N) -> ψ1(x) + ψ2(x,N), DΨ1, DΨ2) | ||
| return (Ψ, ∂Ψ, ∂∂Ψ) | ||
| end | ||
| function (obj::ComposedElasticModel)(Λ::Float64=1.0) | ||
| function (obj::MultiElastic{<:AnisoElastic,<:IsoElastic})(Λ::Float64=1.0) | ||
| DΨ1 = obj.Model1(Λ) | ||
| DΨ2 = obj.Model2(Λ) | ||
| Ψ, ∂Ψ, ∂∂Ψ = map((ψ1,ψ2) -> (x,N) -> ψ1(x,N) + ψ2(x), DΨ1, DΨ2) | ||
| return (Ψ, ∂Ψ, ∂∂Ψ) | ||
| end | ||
| function (obj::MultiElastic{<:IsoElastic,<:IsoElastic})(Λ::Float64=1.0) |
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'm very afraid of this: there are two possible ways to do the same thing. Typically, it'll end with bringing headaches
Changes the direct comparison in the tests to use `isapprox` with a relative tolerance. This increases the stability and reliability of the tests by accounting for potential floating-point precision issues.
| struct ComposedElasticModel <: Elasto | ||
| Model1::Elasto | ||
| Model2::Elasto | ||
| struct MultiElastic{A,B} <: Elasto |
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.
After the conversations, I propose to name it as ComposedIsoElastic
There is an idiomatic reason:
- Composed ->
+ - Multi ->
Tuple
| function (obj::MultiElastic{<:AnisoElastic,<:AnisoElastic})(Λ::Float64=1.0) | ||
| DΨ1 = obj.Model1(Λ) | ||
| DΨ2 = obj.Model2(Λ) | ||
| Ψ, ∂Ψ, ∂∂Ψ = map((ψ1,ψ2) -> (x,N) -> ψ1(x,N) + ψ2(x,N), DΨ1, DΨ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.
avoid map when there are only two variables. The code will be easer to read.
Implements composition of iso and aniso elastic models. Allows combining models for more complex material behaviors. Introduces `ComposedIsoElastic` and `ComposedAnisoElastic` to handle the combinations. Composition of AnisoElastic models is not allowed to avoid recurrence.
|
@miguelmaso The following API supports the combination of: struct ComposedIsoElastic <: IsoElastic
Model1::IsoElastic
Model2::IsoElastic
Kinematic
function ComposedIsoElastic(model1::IsoElastic,model2::IsoElastic)
new(model1,model2,model1.Kinematic)
end
function (obj::ComposedIsoElastic)(Λ::Float64=1.0)
Ψ1, ∂Ψu1, ∂Ψuu1 = obj.Model1(Λ)
Ψ2, ∂Ψu2, ∂Ψuu2 = obj.Model2(Λ)
Ψ(x)=Ψ1(x)+Ψ2(x)
∂Ψ(x)=∂Ψu1(x)+∂Ψu2(x)
∂∂Ψ(x)=∂Ψuu1(x)+∂Ψuu2(x)
return (Ψ, ∂Ψ, ∂∂Ψ)
end
end
function (+)(Model1::IsoElastic, Model2::IsoElastic)
ComposedIsoElastic(Model1,Model2)
end
struct ComposedAnisoElastic <: AnisoElastic
Model1::IsoElastic
Model2::AnisoElastic
Kinematic
function ComposedAnisoElastic(model1::IsoElastic,model2::AnisoElastic)
new(model1,model2,model1.Kinematic)
end
function (obj::ComposedAnisoElastic)(Λ::Float64=1.0)
DΨ1 = obj.Model1(Λ)
DΨ2 = obj.Model2(Λ)
Ψ, ∂Ψ, ∂∂Ψ = map((ψ1,ψ2) -> (x,N) -> ψ1(x) + ψ2(x,N), DΨ1, DΨ2)
return (Ψ, ∂Ψ, ∂∂Ψ)
end
end
function (+)(Model1::IsoElastic, Model2::AnisoElastic)
ComposedAnisoElastic(Model1,Model2)
end
function (+)(Model1::AnisoElastic, Model2::IsoElastic)
ComposedAnisoElastic(Model2,Model1)
end |
Allows combining IsoElastic and AnisoElastic constitutive models, creating a composed anisotropic elastic model. This provides a more flexible way to define material behavior. Removes commented-out code and unused variables.
miguelmaso
left a comment
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.
Nice!
Introduces
AnisoElasticandIsoElastictypes and allows combination of isotropic and anisotropic models. It addsMultiElasticandMultiAnisoElasticto enable combination of multiple elastic models. It also enhances the TransverseIsotropy models to use the newAnisoElastictype.