538
538
osol_messy[[:S , :I , :R , :M , :H ]] ≈ osol_ordered[[:S , :I , :R , :M , :H ]]
539
539
end
540
540
541
+
541
542
# ## DSL Tests ###
542
543
543
544
# Check that a hybrid CRN/DAE created programmatically and via the DSL are identical.
546
547
# Checks that generated system contents are correct, and ODE simulations are identical.
547
548
let
548
549
# 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)
551
552
@parameters p k1 k2 d v n x_scale:: Float32
552
553
eqs = [
553
554
Reaction (p, nothing , [X1])
563
564
564
565
# Creates the model via the DSL.
565
566
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)
568
568
@parameters v n x_scale:: Float32
569
569
@equations begin
570
570
D (V) ~ X3/ (1 + X3) - v* V
@@ -580,31 +580,29 @@ let
580
580
581
581
# Checks that models are identical. Also checks that they have the correct content.
582
582
@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}
583
586
584
587
@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 ])
588
591
@test issetequal (reactions (rs_dsl), equations (rs_dsl)[1 : 4 ])
589
592
@test issetequal (equations (rs_dsl)[1 : 4 ], eqs[1 : 4 ])
590
593
@test issetequal (equations (rs_dsl)[5 : 7 ], eqs[5 : 7 ])
591
594
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}
595
595
596
596
# Checks that the models can be simulated and yield identical results.
597
597
# Test most likely redundant, but seem useful to have one test like this to be sure.
598
598
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 )
600
599
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 ())
607
603
end
604
+
605
+
608
606
# ## Error Tests ###
609
607
610
608
# Checks that various erroneous hybrid system declarations yield errors.
0 commit comments