Skip to content
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

Update decapodes_examples.jl #15

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions docs/literate/composite_models_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ h = AMR.Header("harmonic_oscillator",
"v1.0")

# The easiest way to write down a DecaExpr is in our DSL and calling the parser.
# This formula is $$∂ₜ(∂ₜ(x)) = -kx$$.
dexpr = DiagrammaticEquations.parse_decapode(quote
X::Form0{Point}
V::Form0{Point}
Expand All @@ -72,7 +73,10 @@ end
# That gave us the first model
d1 = ASKEMDecaExpr(h, dexpr)

# The second model is:
# The second model is given by:
# $$ ∂ₜQ = κ*V + λ(Q - Q₀) $$
#
#
d2 = ASKEMDecaExpr(
AMR.Header("fricative_heating",
"modelreps.io/SummationDecapode",
Expand Down Expand Up @@ -125,7 +129,10 @@ uwdʰ = UWDExpr([v, Q], [Statement(:drag, [v, Q₊]), Statement(:cooling, [Q₋,
# Our three primitive subsystems are each composed of one equation. Of course at this scale of complexity, you don't
# need to do compositional specification, you can just compose them in your head and write down the composite.
# But this is a tutorial, so we are building a very simple model as a composite of atomic models (one equation each).

#
# The formula for drag is
# $$ Q₊ == κ*V $$
#
drag = ASKEMDecaExpr(
AMR.Header("DragHeat", "modelreps.io/SummationDecapode", "velocity makes it get hot", "SummationDecapode", "v1.0"),
DiagrammaticEquations.parse_decapode(quote
Expand All @@ -137,6 +144,9 @@ drag = ASKEMDecaExpr(
end)
)

# Our cooling formula is
# $$ Q₋ == λ(Q-Q₀) $$

cooling = ASKEMDecaExpr(
AMR.Header("NetwonCooling", "modelreps.io/SummationDecapode", "heat dissipates to the enviornment", "SummationDecapode", "v1.0"),
DiagrammaticEquations.parse_decapode(quote
Expand All @@ -149,6 +159,8 @@ cooling = ASKEMDecaExpr(
end)
)

# Linear Superposition is just $$T == X + Y$$

superposition = ASKEMDecaExpr(
AMR.Header("LinearSuperpositon", "modelreps.io/SummationDecapode", "variables be addin", "SummationDecapode", "v1.0"),
DiagrammaticEquations.parse_decapode(quote
Expand Down
4 changes: 3 additions & 1 deletion docs/literate/decapodes_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using ACSets.JSONACSets
using DiagrammaticEquations
using Test

# Build the heder object describing the model.
# Build the header object describing the model.

h = AMR.Header("harmonic_oscillator",
"modelreps.io/DecaExpr",
Expand All @@ -27,6 +27,8 @@ h = AMR.Header("harmonic_oscillator",
"v1.0")

# The easiest way to write down a DecaExpr is in our DSL and calling the parser.
# This example is $$x'' = -kx$$. We have manual transformed this into first order ODE
# by introducing a velocity variable for $$x'$$.
dexpr = DiagrammaticEquations.parse_decapode(quote
X::Form0{Point}
V::Form0{Point}
Expand Down
Loading