Skip to content

Commit 7b816cc

Browse files
committed
save progress
1 parent fcae9d2 commit 7b816cc

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

test/reactionsystem_structure/hybrid_equation_reaction_systems.jl

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ let
538538
osol_messy[[:S, :I, :R, :M, :H]] osol_ordered[[:S, :I, :R, :M, :H]]
539539
end
540540

541+
541542
### DSL Tests ###
542543

543544
# Check that a hybrid CRN/DAE created programmatically and via the DSL are identical.
@@ -546,8 +547,8 @@ end
546547
# Checks that generated system contents are correct, and ODE simulations are identical.
547548
let
548549
# Creates the model programmatically.
549-
@species X1(t) X2(t) X3(t) X_tot(t)
550-
@variables V(t)=5.0 [description="Volume"] N(t) X_conc(t)
550+
@species X1(t) X2(t) X3(t)
551+
@variables V(t)=5.0 [description="Volume"] N(t) X_conc(t) X_tot(t)
551552
@parameters p k1 k2 d v n x_scale::Float32
552553
eqs = [
553554
Reaction(p, nothing, [X1])
@@ -563,8 +564,7 @@ let
563564

564565
# Creates the model via the DSL.
565566
rs_dsl = @reaction_network hybrid_rs begin
566-
@species X_tot(t)
567-
@variables X_conc(t) V(t)=5.0 [description="Volume"]
567+
@variables X_conc(t) V(t)=5.0 [description="Volume"] X_tot(t)
568568
@parameters v n x_scale::Float32
569569
@equations begin
570570
D(V) ~ X3/(1+X3) - v*V
@@ -580,31 +580,29 @@ let
580580

581581
# Checks that models are identical. Also checks that they have the correct content.
582582
@test rs_prog == rs_dsl
583+
@test getdescription(rs_dsl.V) == "Volume"
584+
@test getdefault(rs_dsl.V) == 5.0
585+
@test unwrap(rs_dsl.x_scale) isa BasicSymbolic{Float32}
583586

584587
@test issetequal(parameters(rs_dsl), [p, k1, k2, d, v, n, x_scale])
585-
@test issetequal(species(rs_dsl), unknowns(rs_dsl)[1:4])
586-
@test issetequal(unknowns(rs_dsl)[1:4], [X1, X2, X3, X_tot])
587-
@test issetequal(unknowns(rs_dsl)[5:7], [V N X_conc])
588+
@test issetequal(species(rs_dsl), unknowns(rs_dsl)[1:3])
589+
@test issetequal(unknowns(rs_dsl)[1:3], [X1, X2, X3])
590+
@test issetequal(unknowns(rs_dsl)[4:7], [V, N, X_conc, X_tot])
588591
@test issetequal(reactions(rs_dsl), equations(rs_dsl)[1:4])
589592
@test issetequal(equations(rs_dsl)[1:4], eqs[1:4])
590593
@test issetequal(equations(rs_dsl)[5:7], eqs[5:7])
591594

592-
@test getdescription(rs_dsl.V) == "Volume"
593-
@test getdefault(rs_dsl.V) == 5.0
594-
@test unwrap(rs_dsl.x_scale) isa BasicSymbolic{Float32}
595595

596596
# Checks that the models can be simulated and yield identical results.
597597
# Test most likely redundant, but seem useful to have one test like this to be sure.
598598
u0 = [X1 => 0.1, X2 => 0.2, X3 => 0.2, X_tot => 0.6, N => 10.0, X_conc => 10.0]
599-
tspan = (0.0, 10.0)
600599
ps = [p => 1.0, k1 => 1.2, k2 => 1.5, d => 2.0, v => 0.2, n => 0.5, x_scale => 2.0]
601-
602-
@test_broken begin # ODEs become overdetermined.
603-
oprob_prog = ODEProblem(rs_prog, u0, tspan, ps; structural_simplify = true)
604-
oprob_dsl = ODEProblem(rs_dsl, u0, tspan, ps; structural_simplify = true)
605-
@test solve(oprob_prog, Tsit5()) == solve(oprob_dsl, Tsit5())
606-
end
600+
oprob_prog = ODEProblem(rs_prog, u0, (0.0, 10.0), ps; structural_simplify = true)
601+
oprob_dsl = ODEProblem(rs_dsl, u0, (0.0, 10.0), ps; structural_simplify = true)
602+
@test solve(oprob_prog, Rosenbrock23()) == solve(oprob_dsl, Rosenbrock23())
607603
end
604+
605+
608606
### Error Tests ###
609607

610608
# Checks that various erroneous hybrid system declarations yield errors.

0 commit comments

Comments
 (0)