Skip to content

Commit

Permalink
chaneg names
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed May 21, 2024
1 parent 8d36e4b commit 73f4682
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/network_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,21 @@ end

### Conservation Laws ###

# Implements the `conservationquantity` parameter metadata.
# Implements the `conserved` parameter metadata.
struct ConservedParameter end
Symbolics.option_to_metadata_type(::Val{:conserved}) = ConservationQuantity
Symbolics.option_to_metadata_type(::Val{:conserved}) = ConservedParameter

"""
isconservationquantity(p)
isconserved(p)
Checks if the input parameter (`p`) is a conserved quantity (i.e. have the `conservationquantity`)
Checks if the input parameter (`p`) is a conserved quantity (i.e. have the `conserved`)
metadata.
"""
isconservationquantity(x::Num, args...) = isconservationquantity(Symbolics.unwrap(x), args...)
function isconservationquantity(x, default = false)
isconserved(x::Num, args...) = isconserved(Symbolics.unwrap(x), args...)
function isconserved(x, default = false)
p = Symbolics.getparent(x, nothing)
p === nothing || (x = p)
Symbolics.getmetadata(x, ConservationQuantity, default)
Symbolics.getmetadata(x, ConservedParameter, default)
end

"""
Expand Down Expand Up @@ -653,7 +653,7 @@ function cache_conservationlaw_eqs!(rn::ReactionSystem, N::AbstractMatrix, col_o
depidxs = col_order[(r + 1):end]
depspecs = sts[depidxs]
constants = MT.unwrap.(MT.scalarize(only(
@parameters $(CONSERVED_CONSTANT_SYMBOL)[1:nullity] [conservationquantity=true])))
@parameters $(CONSERVED_CONSTANT_SYMBOL)[1:nullity] [conserved=true])))

conservedeqs = Equation[]
constantdefs = Equation[]
Expand Down
16 changes: 8 additions & 8 deletions test/network_analysis/conservation_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ let
@test isapprox(g2[istsidxs, :], g3)
end

### ConservedQuantity Metadata Tests ###
### ConservedParameter Metadata Tests ###

# Checks that `conservationquantity` metadata is added correctly to parameters.
# Checks that the `isconservationquantity` getter function works correctly.
# Checks that `conserved` metadata is added correctly to parameters.
# Checks that the `isconserved` getter function works correctly.
let
# Creates ODESystem with conserved quantities.
rs = @reaction_network begin
Expand All @@ -156,9 +156,9 @@ let
end
osys = convert(ODESystem, rs; remove_conserved = true)

# Checks that the correct parameters have the `conservationquantity` metadata.
@test Catalyst.isconservationquantity(osys.Γ[1])
@test Catalyst.isconservationquantity(osys.Γ[2])
@test !Catalyst.isconservationquantity(osys.k1)
@test !Catalyst.isconservationquantity(osys.k2)
# Checks that the correct parameters have the `conserved` metadata.
@test Catalyst.isconserved(osys.Γ[1])
@test Catalyst.isconserved(osys.Γ[2])
@test !Catalyst.isconserved(osys.k1)
@test !Catalyst.isconserved(osys.k2)
end

0 comments on commit 73f4682

Please sign in to comment.