Skip to content

Commit 1680440

Browse files
committed
update
1 parent 2804db1 commit 1680440

File tree

4 files changed

+16
-53
lines changed

4 files changed

+16
-53
lines changed

docs/src/catalyst_applications/homotopy_continuation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ hc_steady_states(wilhelm_2009_model, ps; u0)
6060

6161
## Final notes
6262
- `hc_steady_states` supports any systems where all rates are systems of rational polynomials (such as Hill functions with integer Hill coefficients).
63-
63+
- When providing initial conditions to compute conservation laws, values are only required for those species that are part of conserved quantities. If this set of species is unknown, it is recommended to provide initial conditions for all species.
6464
- Additional arguments provided to `hc_steady_states` are automatically passed to HomotopyContinuation's `solve` command. Use e.g. `show_progress=false` to disable the progress bar.
6565
---
6666

6767
## [Citation](@id homotopy_continuation_citation)
68-
If you use this functionality in your reasearch, please cite the following paper to support the authors of the HomotopyContinuation package:
68+
If you use this functionality in your research, please cite the following paper to support the authors of the HomotopyContinuation package:
6969
```
7070
@inproceedings{HomotopyContinuation.jl,
7171
title={{H}omotopy{C}ontinuation.jl: {A} {P}ackage for {H}omotopy {C}ontinuation in {J}ulia},

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Arguments:
99
- `rs::ReactionSystem`: The reaction system for which we want to find the steady states.
1010
- `ps`: The parameter values for which we want to find the steady states.
1111
- `filter_negative=true`: If set to true, solutions with any species concentration <neg_thres is removed from the output.
12-
- `neg_thres=-1e-20`: Determine the minimum values for which a species concentration is to be considred non-negative. Species conentrations ``> neg_thres`` but `< 0.0` are set to `0.0`.
13-
- `u0=nothing`: Initial conditions for which we want to find the steady states. For systems with conservation laws this are required to compute conserved quantities.
12+
- `neg_thres=-1e-20`: Determine the minimum values for which a species concentration is to be considered non-negative. Species concentrations ``> neg_thres`` but `< 0.0` are set to `0.0`.
13+
- `u0=nothing`: Initial conditions for which we want to find the steady states. For systems with conservation laws this are required to compute conserved quantities. Initial conditions are not required for all species, only those involved in conserved quantities (if this set is unknown, it is recommended to provide initial conditions for all species).
1414
- `kwargs...`: any additional arguments (like `show_progress= true`) are passed into HomotopyContinuation.jl's `solve` call.
1515
1616
Examples
@@ -41,10 +41,10 @@ function Catalyst.hc_steady_states(rs::ReactionSystem, ps; filter_negative=true,
4141
return (filter_negative ? filter_negative_f(sols; neg_thres) : sols)
4242
end
4343

44-
# For a given reaction system, paraemter values, and initial conditions, find the polynomial that HC solves to find steady states.
44+
# For a given reaction system, parameter values, and initial conditions, find the polynomial that HC solves to find steady states.
4545
function steady_state_polynomial(rs::ReactionSystem, ps, u0)
4646
ns = convert(NonlinearSystem, rs; remove_conserved = true)
47-
pre_varmap = map(pair -> pair, [symmap_to_varmap(rs,u0); symmap_to_varmap(rs,ps)])
47+
pre_varmap = map(pair -> pair, [symmap_to_varmap(rs,u0)..., symmap_to_varmap(rs,ps)...])
4848
conservationlaw_errorcheck(rs, pre_varmap)
4949
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns); defaults = ModelingToolkit.defaults(ns))
5050
p_dict = Dict(parameters(ns) .=> p_vals)
@@ -58,9 +58,9 @@ end
5858
# If u0s are not given while conservation laws are present, throws an error.
5959
function conservationlaw_errorcheck(rs, pre_varmap)
6060
vars_with_vals = Set(p[1] for p in pre_varmap)
61-
isempty(intersect(species(rs), vars_with_vals)) || return
61+
any(s -> s in vars_with_vals, species(rs)) && return
6262
isempty(conservedequations(rs)) ||
63-
error("The system has conservation laws but initial conditions were not provided for all species.")
63+
error("The system has conservation laws but initial conditions were not provided for some species.")
6464
end
6565

6666
# Unfolds a function (like mm or hill).
@@ -105,12 +105,12 @@ function remove_denominators(expr)
105105
return remove_denominators(arguments(s_expr)[1])
106106
end
107107
if operation(s_expr) == +
108-
return +(remove_denominators.(arguments(s_expr))...)
108+
return sum(remove_denominators(arg) for arg in arguments(s_expr))
109109
end
110110
return s_expr
111111
end
112112

113-
# HC orders the solution vector according to the lexiographic values of the variable names. This reorders the output acording to the species index in the reaction system species vector.
113+
# HC orders the solution vector according to the lexicographic values of the variable names. This reorders the output according to the species index in the reaction system species vector.
114114
function reorder_sols!(sols, ss_poly, rs::ReactionSystem)
115115
var_names_extended = String.(Symbol.(HC.variables(ss_poly)))
116116
var_names = [Symbol(s[1:prevind(s, findlast('_', s))]) for s in var_names_extended]

src/miscellaneous_functions.jl

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/extensions/homotopy_continuation.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import HomotopyContinuation
66

77
# Tests for network without conservation laws.
88
# Tests for Symbol parameter input.
9-
# Tests for Symbolics initial condiiton input.
9+
# Tests for Symbolics initial condition input.
1010
# Tests for different types (Symbol/Symbolics) for parameters and initial conditions.
1111
# Tests that attempts to find steady states of system with conservation laws, while u0 is not provided, gives an error.
1212
let
@@ -47,8 +47,9 @@ let
4747
end
4848

4949
# Tests that reordering is correct.
50-
# Tests corectness in presence of default values.
51-
# Tests where some defaul values are overwritten with other values
50+
# Tests correctness in presence of default values.
51+
# Tests where some default values are overwritten with other values.
52+
# Tests where input ps/u0 are tuples with mixed types.
5253
let
5354
rs_1 = @reaction_network begin
5455
@parameters kX1=1.0 kX2=2.0 kY1=12345.0
@@ -57,8 +58,8 @@ let
5758
(kY1,kY2), Y1 <--> Y2
5859
(kZ1,kZ2), Z1 <--> Z2
5960
end
60-
ps = [:kY1 => 1.0, :kY2 => 3.0, :kZ1 => 1.0, :kZ2 => 4.0]
61-
u0_1 = [:Y1 => 1.0, :Y2 => 3.0, :Z1 => 10.0, :Z2 =>40.0]
61+
ps = (:kY1 => 1.0, :kY2 => 3, :kZ1 => 1.0, :kZ2 => 4.0)
62+
u0_1 = (:Y1 => 1.0, :Y2 => 3, :Z1 => 10, :Z2 =>40.0)
6263

6364
ss_1 = sort(hc_steady_states(rs_1, ps; u0=u0_1, show_progress=false), by=sol->sol[1])
6465
@test ss_1 [[0.2, 0.1, 3.0, 1.0, 40.0, 10.0]]

0 commit comments

Comments
 (0)