@@ -52,24 +52,18 @@ function get_net_stoich(rs, specmap)
52
52
end
53
53
54
54
# given a ReactionStruct and a species map construct a MassActionJump
55
- function make_majump (rs, specmap, ratemap, params)
55
+ function make_majump (rs, specmap, ratemap, params, param_context )
56
56
reactant_stoich = get_substrate_stoich (rs, specmap)
57
57
net_stoich = get_net_stoich (rs, specmap)
58
58
if isempty (net_stoich)
59
59
error (" Empty net stoichiometry vectors for mass action reactions are not allowed." )
60
60
end
61
61
62
- # populate dummy context with params as local variables
63
- Dummy = Module ()
64
- for (param, index) in ratemap
65
- Base. eval (Dummy, :($ param = $ (params[index])))
66
- end
67
-
68
62
if typeof (rs. rate_org) == Symbol
69
63
rateconst = params[ratemap[rs. rate_org]]
70
64
elseif typeof (rs. rate_org) == Expr
71
- # eval in Dummy , in case Expr depends on params
72
- rateconst = Base. eval (Dummy , rs. rate_org)
65
+ # eval in param_context , in case Expr depends on params
66
+ rateconst = Base. eval (param_context , rs. rate_org)
73
67
elseif typeof (rs. rate_org) <: Number
74
68
rateconst = rs. rate_org
75
69
else
@@ -86,9 +80,16 @@ function network_to_jumpset(rn, specmap, ratemap, params)
86
80
majumpvec = Vector {typeof(empty_majump)} ()
87
81
cjumpvec = Vector {ConstantRateJump} ()
88
82
83
+ # populate dummy module with params as local variables
84
+ # (for eval-ing parameter expressions)
85
+ param_context = Module ()
86
+ for (param, index) in ratemap
87
+ Base. eval (param_context, :($ param = $ (params[index])))
88
+ end
89
+
89
90
for (i,rs) in enumerate (rn. reactions)
90
91
if rs. is_pure_mass_action
91
- push! (majumpvec, make_majump (rs, specmap, ratemap, params))
92
+ push! (majumpvec, make_majump (rs, specmap, ratemap, params, param_context ))
92
93
else
93
94
push! (cjumpvec, rn. jumps[i])
94
95
end
0 commit comments