Skip to content

Commit

Permalink
Merge pull request #36 from SciML/aj/mtk
Browse files Browse the repository at this point in the history
create_param using mtk metadata
  • Loading branch information
ChrisRackauckas authored Apr 6, 2021
2 parents c4b4a9d + f2147ba commit 4d522b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CellMLToolkit"
uuid = "03cb29e0-1ef4-4721-aa24-cf58a006576f"
authors = ["Shahriar Iravanian <[email protected]>"]
version = "2.3.0"
version = "2.3.1"

[deps]
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
Expand All @@ -16,7 +16,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
EzXML = "1.1"
HTTP = "0.9"
MathML = "0.1.5"
MathML = "0.1"
Memoize = "0.4"
ModelingToolkit = "5.14"
OrdinaryDiffEq = "5.52"
Expand Down
12 changes: 8 additions & 4 deletions src/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const mathml_ns = "http://www.w3.org/1998/Math/MathML"

create_var(x) = Num(Variable(Symbol(x))).val
create_var(x, iv) = Num(Variable{Symbolics.FnType{Tuple{Any},Real}}(Symbol(x)))(iv).val
create_param(x) = Num(Sym{ModelingToolkit.Parameter{Real}}(Symbol(x))).val
function create_param(x)
p = Sym{Real}(Symbol(x))
ModelingToolkit.toparam(p)
p
end

to_symbol(x::Symbol) = x
to_symbol(x::AbstractString) = Symbol(x)
Expand Down Expand Up @@ -157,7 +161,7 @@ function translate_connections(doc::Document, systems, class)
sys2 = systems[c2]
for w in variables_of.(list_connection_variables(k))
v1, v2 = Symbol.(w)
if class[make_var(c1,v1)] && class[make_var(c2,v2)] && Symbol(sys1.iv) != v1
if class[make_var(c1,v1)] && class[make_var(c2,v2)]
var1 = getproperty(sys1, v1)
var2 = getproperty(sys2, v2)
push!(a, var1 ~ var2)
Expand All @@ -181,7 +185,7 @@ function pre_substitution(doc::Document, comp, class)
vars = to_symbol.(list_component_variables(comp))

states = [create_var(x) => create_var(x, ivₚ) for x in vars if class[make_var(comp,x)]]
params = [create_var(x) => create_param(x) for x in vars if !class[make_var(comp,x)] && x != ivₘ]
params = [create_var(x) => create_param(x) for x in vars if !class[make_var(comp,x)] && !isequal(x, ivₘ)]
ivsub = [create_var(ivₘ) => ivₚ]

return states params ivsub
Expand Down Expand Up @@ -287,7 +291,7 @@ function process_component(doc::Document, comp, class)
end

ivₚ = get_ivₚ(doc)
ps = [last(x) for x in values(pre_sub) if last(x) isa Sym && last(x) != ivₚ]
ps = [last(x) for x in values(pre_sub) if last(x) isa Sym && !isequal(last(x), ivₚ)]
states = [last(x) for x in values(pre_sub) if !(last(x) isa Sym)]

ODESystem(eqs, ivₚ, states, ps; name=to_symbol(comp))
Expand Down

2 comments on commit 4d522b5

@anandijain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/33676

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.3.1 -m "<description of version>" 4d522b527a38e22ba2d2b548840c3f9b7f000e2b
git push origin v2.3.1

Please sign in to comment.