-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c204376
commit afe414d
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
""" function collate(acset, column_names::Vector{Symbol}) | ||
Create a collage of two Decapodes that simulates with boundary conditions. | ||
``` | ||
""" | ||
function collate(equations, boundaries, uwd, symbols) | ||
# TODO: This is assuming only "restriction"-type morphisms. | ||
|
||
f = SummationDecapode{Any, Any, Symbol}() | ||
# TODO: Double-check | ||
copy_parts!(f, equations, (:Var, :TVar, :Op1, :Op2, :Σ, :Summand, :Sum)) | ||
|
||
# TODO: This sets restrictions as Op1s. They are actually Op2s. i.e. Use `bv`. | ||
for b in boxes(uwd) | ||
ps = incident(uwd, b :box) | ||
ev = first(ps) | ||
bv = last(ps) | ||
var = incident(f, ev, :name) | ||
b_var = add_part!(f, :Var, type=f[var, :type], name=f[var, :name]) | ||
f[var, :name] = Symbol("r_" * string(f[var, :name])) | ||
add_part!(f, :Op1, src=b_var, tgt=var, op1=uwd[b, :name]) | ||
end | ||
|
||
f | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Test | ||
using Decapodes | ||
using Catlab | ||
using Catlab.WiringDiagrams | ||
using Catlab.Programs | ||
using Catlab.CategoricalAlgebra | ||
|
||
|
||
# TODO: Special names for morphisms that match a method of grabbing boundary | ||
# simplices. | ||
|
||
# TODO: Initial conditions. | ||
# - This will mean that we need to return both a masked Decapode, and a means of pluggin initial data in for physical quantities, replacing `constuct`. | ||
# TODO: Temporal boundary conditions. | ||
# TODO: General boundaries i.e. arbitrary functions of solutions. | ||
|
||
# TODO: Add test with empty boundary Decapode. | ||
|
||
# Test simple boundary masks. | ||
DiffusionDynamics = @decapode begin | ||
C::Form0 | ||
∂ₜ(C) == ∘(d,⋆,d,⋆)(C) | ||
end | ||
DiffusionBoundaries = @decapode begin | ||
(Cb1, Cb2, Zero)::Form0 | ||
end | ||
|
||
DiffusionMorphism = @relation () begin | ||
rb1(C, Cb1) | ||
rb2(C, Cb2) | ||
rb3(Ċ, Zero) | ||
end | ||
|
||
DiffusionCollage = collate(DiffusionMorphism, | ||
DiffusionDynamics, DiffusionBoundaries, [ | ||
(:C, :Cb1), | ||
(:C, :Cb2), | ||
(:Ċ, :Zero)]) | ||
|
||
# Note: Since the order does not matter in which rb1 and rb2 are applied, it | ||
# seems informal to state that one goes before the other. | ||
# It might be better to provide a semantics for incident edges a la: | ||
#Diffusion = @decapode begin | ||
# C::Form0 | ||
# #∂ₜ(C) == rb3(∘(d,⋆,d,⋆)(rb1(C))) | ||
# #∂ₜ(C) == rb3(∘(d,⋆,d,⋆)(rb2(C))) | ||
#end | ||
|
||
Diffusion = @decapode begin | ||
C::Form0 | ||
∂ₜ(C) == rb3(∘(d,⋆,d,⋆)(rb2(rb1(C)))) | ||
end | ||
|
||
@test_fails is_isomorphic(DiffusionCollage, Diffusion) |