Skip to content

Commit

Permalink
Merge branch 'master' into balance
Browse files Browse the repository at this point in the history
  • Loading branch information
LalitChauhan56 committed Aug 4, 2023
2 parents ca53de4 + 1cb5abc commit d6ec643
Showing 1 changed file with 1 addition and 84 deletions.
85 changes: 1 addition & 84 deletions test/miscellaneous_tests/compound_macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let

@test isequal([C, H, O], components(C6H12O2))
@test isequal([6, 12, 2], coefficients(C6H12O2))
@test isequal([C => 6, H => 12, O => 2], Catalyst.component_coefficients(C6H12O2))
@test isequal([C => 6, H => 12, O => 2], Catalyst.component_coefficients(C6H12O2))
@test all(!iscompound(i) for i in components(C6H12O2))
end

Expand Down Expand Up @@ -74,9 +74,6 @@ let
@compound C6H12O2_1(t) 6s 12H 2O
@compound C6H12O2_2(t) 6C 12H 2O

@test iscompound(C6H12O2_1)
@test iscompound(C6H12O2_2)

@test isequal(components(C6H12O2_1), components(C6H12O2_2))
@test isequal(coefficients(C6H12O2_1), coefficients(C6H12O2_2))
end
Expand All @@ -96,83 +93,3 @@ let
@test isequal(coefficients(C10H12)[1], 2)
end

let
@variables t
@species H(t)

alpha = 2
@compound H2_1(t) alpha*H
@compound H2_2(t) 2H

@test iscompound(H2_1)
@test iscompound(H2_2)

@test isequal(components(H2_1),components(H2_2))
@test isequal(coefficients(H2_1),coefficients(H2_2))
end

let
@variables t
@parameters alpha = 2
@species H(t)

@compound H2_1(t) alpha*H
@compound H2_2(t) 2H

@test iscompound(H2_1)
@test iscompound(H2_2)

@test isequal(components(H2_1),components(H2_2))
@test isequal(coefficients(H2_1), @parameters alpha = 2)
end

let
@variables t
@species A(t)
B = A
@compound A2(t) 2A
@compound B2(t) 2B

@test iscompound(A2)
@test iscompound(B2)

@test isequal(components(A2),components(B2))
@test isequal(coefficients(A2), coefficients(B2))
end

#Check that balancing works.
let
@variables t
@parameters k
@species H(t) O(t)
@compound H2(t) 2H
@compound O2(t) 2O
@compound H2O(t) 2H 1O

rx = Reaction(k,[H2,O2],[H2O])

@test isequal(create_matrix(rx),[2 0 -2; 0 2 -1; 0 0 1;])
@test isequal(get_stoich(rx),[2, 1, 2])

balanced_rx = Reaction(k,[H2,O2],[H2O],[2,1],[2])
@test isequal(balanced_rx, balance(rx))

end

let
@variables t
@parameters k
@species C(t) H(t) O(t)
@compound O2(t) 2O
@compound CO2(t) 1C 2O
@compound H2O(t) 2H 1O
@compound C6H12O6(t) 6C 12H 6O

rx = Reaction(k,[CO2,H2O],[C6H12O6,O2])

@test isequal(create_matrix(rx),[ 1 0 -6 0; 2 1 -6 -2; 0 2 -12 0; 0 0 0 1;])
@test isequal(get_stoich(rx),[6, 6, 1, 6])

balanced_rx = Reaction(k,[CO2,H2O],[C6H12O6,O2],[6, 6], [1,6])
@test isequal(balanced_rx, balance(rx))
end

0 comments on commit d6ec643

Please sign in to comment.