Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand conservation law tests #907

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Jun 4, 2024

Adds additional tests of conservation laws, especially relating to when attempting to simulate them.

Only non-test change is that

convert(JumpSystem, rs; remove_conserved = true)

now throws an ArgumentError (as opposed to a generic error). The reason was that this was I could write a test to check that it does throw a specific error (and not just one from wrong input).

@@ -653,7 +653,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
spatial_convert_err(rs::ReactionSystem, JumpSystem)

(remove_conserved !== nothing) &&
error("Catalyst does not support removing conserved species when converting to JumpSystems.")
throw(ArgumentError("Catalyst does not support removing conserved species when converting to JumpSystems."))
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensuring that this is a ArgumentError allow us to write a better test later on (since we can test for that as opposed to Exception, which could be generated by other stuff).

@@ -71,7 +71,7 @@ let
Set([:p, :k1, :k2, :k3, :k4, :k5, :k6, :d])
basic_test(reaction_networks_hill[1], 4, [:X1, :X2],
[:v1, :v2, :K1, :K2, :n1, :n2, :d1, :d2])
basic_test(reaction_networks_constraint[1], 6, [:X1, :X2, :X3],
basic_test(reaction_networks_conserved[1], 6, [:X1, :X2, :X3],
Copy link
Member Author

Choose a reason for hiding this comment

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

I named the reaction_networks_constraint networks that when I didn't really know about the terminology that well. Changde the names to something better.

(k1, k2), X1 ↔ X2
(k3, k4), X2 ↔ X3
(k5, k6), X3 ↔ X1
end
reaction_network_constraints[1] = [1 1 1]
reaction_network_conslaws[1] = [1 1 1]
Copy link
Member Author

Choose a reason for hiding this comment

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

Also a new better name

sol2 = solve(oprob2; saveat = 1.0)
@test all(sol1[osys.X1 + osys.X2] .== 2.0)
@test all(sol2[osys.X1 + osys.X2] .== 4.0)
end
Copy link
Member Author

Choose a reason for hiding this comment

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

I also wanted to have a test checking

rn = @reaction_network begin
    @parameters k[1:2]
    @species X(t)[1:2]
    (k[1],k[2]), X[1] <--> X[2]
end

when conservation laws are eliminated (would be cool if it worked, but think there's an error). However, testing this took really long time. Might be related to the problem we saw earlier, but not sure.

@TorkelE TorkelE merged commit 076837d into master Jun 4, 2024
7 checks passed
@TorkelE TorkelE deleted the conservation_laws_test_expansion branch June 4, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants