Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/lincomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ the output at vertex 1, input at vertex 2, and leaks at vertices 3 and 4 as foll
julia> using StructuralIdentifiability

julia> ode = linear_compartment_model([[2, 4], [1, 3], [2, 4], [1, 3]], outputs = [1], inputs = [2], leaks = [2, 3])
x4' = x1*a_4_1 + x3*a_4_3 - x4*a_1_4 - x4*a_3_4
x3' = x2*a_3_2 - x3*a_2_3 - x3*a_4_3 - x3*a_0_3 + x4*a_3_4
x1' = -x1*a_2_1 - x1*a_4_1 + x2*a_1_2 + x4*a_1_4
x2' = x1*a_2_1 - x2*a_1_2 - x2*a_3_2 - x2*a_0_2 + x3*a_2_3 + u2
x3' = x2*a_3_2 - x3*a_2_3 - x3*a_4_3 - x3*a_0_3 + x4*a_3_4
x4' = x1*a_4_1 + x3*a_4_3 - x4*a_1_4 - x4*a_3_4
y1 = x1
```
"""
Expand Down Expand Up @@ -85,6 +85,8 @@ function linear_compartment_model(graph; inputs = [], outputs = [], leaks = [])
)

return ODE{QQMPolyRingElem}(
Array{QQMPolyRingElem}(x_vars),
Array{QQMPolyRingElem}([str_to_var("y$i", R) for i in outputs]),
x_equations,
y_equations,
Array{QQMPolyRingElem}([str_to_var("u$i", R) for i in inputs]),
Expand Down
12 changes: 12 additions & 0 deletions test/bodies/linear_compartment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,16 @@ include(joinpath(@__DIR__, "..", "shared", "test_setup.jl"))
result = assess_identifiability(ode, funcs_to_check = collect(keys(correct)))
@test correct == result
end

ode = linear_compartment_model(
[[2, 4], [1, 3], [2, 4], [1, 3]],
outputs = [1],
inputs = [2],
leaks = [2, 3],
)
@test map(string, ode.x_vars) == ["x1", "x2", "x3", "x4"]
@test map(string, ode.y_vars) == ["y1"]
printed = sprint(show, ode)
@test startswith(printed, "x1'")
@test occursin(r"^x1'.*\nx2'.*\nx3'.*\nx4'.*\ny1 ="s, printed)
end
Loading