Skip to content

Commit fad0dd8

Browse files
committed
Merge remote-tracking branch 'origin/master' into io
2 parents 81f06b4 + 0783668 commit fad0dd8

File tree

5 files changed

+11
-100
lines changed

5 files changed

+11
-100
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
4-
version = "3.14.0"
4+
version = "3.14.1"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/systems/diffeqs/odesystem.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var_from_nested_derivative(x,i=0) = x.op isa Differential ? var_from_nested_deri
8484
iv_from_nested_derivative(x) = x.op isa Differential ? iv_from_nested_derivative(x.args[1]) : x.args[1].op
8585
iv_from_nested_derivative(x::Constant) = missing
8686

87-
function ODESystem(eqs; kwargs...)
87+
function ODESystem(eqs, iv=nothing; kwargs...)
8888
# NOTE: this assumes that the order of algebric equations doesn't matter
8989
diffvars = OrderedSet{Variable}()
9090
allstates = OrderedSet{Variable}()
@@ -93,13 +93,15 @@ function ODESystem(eqs; kwargs...)
9393
diffeq = Equation[]
9494
algeeq = Equation[]
9595
# initial loop for finding `iv`
96-
iv = nothing
97-
for eq in eqs
98-
if !(eq.lhs isa Constant) # assume eq.lhs is either Differential or Constant
99-
iv = iv_from_nested_derivative(eq.lhs)
96+
if iv === nothing
97+
for eq in eqs
98+
if !(eq.lhs isa Constant) # assume eq.lhs is either Differential or Constant
99+
iv = iv_from_nested_derivative(eq.lhs)
100+
break
101+
end
100102
end
101103
end
102-
iv === nothing && throw(ArgumentError("No differential variable detected."))
104+
iv === nothing && throw(ArgumentError("Please pass in independent variables."))
103105
for eq in eqs
104106
for var in vars(eq.rhs for eq eqs)
105107
var isa Variable || continue

src/systems/reaction/reactionsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function assemble_diffusion(rs, noise_scaling; combinatoric_ratelaws=true)
213213
species_to_idx = Dict((x => i for (i,x) in enumerate(rs.states)))
214214

215215
for (j,rx) in enumerate(rs.eqs)
216-
rlsqrt = sqrt(oderatelaw(rx; combinatoric_ratelaw=combinatoric_ratelaws))
216+
rlsqrt = sqrt(abs(oderatelaw(rx; combinatoric_ratelaw=combinatoric_ratelaws)))
217217
(noise_scaling!==nothing) && (rlsqrt *= noise_scaling[j])
218218
for (spec,stoich) in rx.netstoich
219219
i = species_to_idx[spec]

test/benchmark.jl

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

test/mass_matrix.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ eqs = [D(y[1]) ~ -k[1]*y[1] + k[3]*y[2]*y[3],
99
0 ~ y[1] + y[2] + y[3] - 1]
1010

1111
sys = ODESystem(eqs,t,y,k)
12+
@test_throws ArgumentError ODESystem(eqs,y)
1213
M = calculate_massmatrix(sys)
1314
@test M == [1 0 0
1415
0 1 0

0 commit comments

Comments
 (0)