Skip to content

Commit 9e643f5

Browse files
change parameterized functions
1 parent d8ed0ca commit 9e643f5

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/ode_premade_problems.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ prob_ode_2Dlinear_notinplace = ODEProblem(f_2dlinear_notinplace,rand(4,2),(0.0,1
129129
lotka = @ode_def_nohes LotkaVolterra begin
130130
dx = a*x - b*x*y
131131
dy = -c*y + d*x*y
132-
end a=>1.5 b=>1.0 c=>3.0 d=1.0
132+
end a b c d
133133

134134
"""
135135
Lotka-Voltera Equations
@@ -141,14 +141,14 @@ Lotka-Voltera Equations
141141
142142
with initial condition ``x=y=1``
143143
"""
144-
prob_ode_lotkavoltera = ODEProblem(lotka,[1;1],(0.0,1.0))
144+
prob_ode_lotkavoltera = ODEProblem(lotka,[1.0,1.0],(0.0,1.0),[1.5,1.0,3.0,1.0])
145145

146146
## Fitzhugh-Nagumo
147147

148148
fitz = @ode_def_nohes FitzhughNagumo begin
149149
dv = v - v^3/3 -w + l
150150
dw = τinv*(v + a - b*w)
151-
end a=0.7 b=0.8 τinv=(1/12.5) l=0.5
151+
end a b τinv l
152152
"""
153153
Fitzhugh-Nagumo
154154
@@ -159,13 +159,13 @@ Fitzhugh-Nagumo
159159
160160
with initial condition ``v=w=1``
161161
"""
162-
prob_ode_fitzhughnagumo = ODEProblem(fitz,[1.0;1.0],(0.0,1.0))
162+
prob_ode_fitzhughnagumo = ODEProblem(fitz,[1.0;1.0],(0.0,1.0),(0.7,0.8,1/12.5,0.5))
163163

164164
#Van der Pol Equations
165165
van = @ode_def_noinvhes VanDerPol begin
166166
dy = μ*(1-x^2)*y - x
167167
dx = 1*y
168-
end μ=>1.
168+
end μ
169169

170170
"""
171171
Van der Pol Equations
@@ -181,9 +181,8 @@ with ``μ=1.0`` and ``u0=[0,\\sqrt{3}]``
181181
182182
Non-stiff parameters.
183183
"""
184-
prob_ode_vanderpol = ODEProblem(van,[0;sqrt(3)],(0.0,1.0))
184+
prob_ode_vanderpol = ODEProblem(van,[0;sqrt(3)],(0.0,1.0),1.0)
185185

186-
van_stiff = VanDerPol=1e6)
187186
"""Van der Pol Equations
188187
189188
```math
@@ -197,15 +196,15 @@ with ``μ=10^6`` and ``u0=[0,\\sqrt{3}]``
197196
198197
Stiff parameters.
199198
"""
200-
prob_ode_vanderpol_stiff = ODEProblem(van_stiff,[0;sqrt(3)],(0.0,1.0))
199+
prob_ode_vanstiff = ODEProblem(van,[0;sqrt(3)],(0.0,1.0),1e6)
201200

202201
# ROBER
203202

204203
rober = @ode_def_noinvjac Rober begin
205204
dy₁ = -k₁*y₁+k₃*y₂*y₃
206205
dy₂ = k₁*y₁-k₂*y₂^2-k₃*y₂*y₃
207206
dy₃ = k₂*y₂^2
208-
end k₁=>0.04 k₂=>3e7 k₃=>1e4
207+
end k₁ k₂ k₃
209208

210209
"""
211210
The Robertson biochemical reactions:
@@ -224,7 +223,7 @@ Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Probl
224223
225224
Usually solved on `[0,1e11]`
226225
"""
227-
prob_ode_rober = ODEProblem(rober,[1.0;0.0;0.0],(0.0,1e11))
226+
prob_ode_rober = ODEProblem(rober,[1.0;0.0;0.0],(0.0,1e11),(0.04,3e7,1e4))
228227

229228
# Three Body
230229
const threebody_μ = parse(BigFloat,"0.012277471"); const threebody_μ′ = 1 - threebody_μ
@@ -268,7 +267,7 @@ rigid = @ode_def_noinvjac RigidBody begin
268267
dy₁ = I₁*y₂*y₃
269268
dy₂ = I₂*y₁*y₃
270269
dy₃ = I₃*y₁*y₂
271-
end I₁=>-2 I₂=>1.25 I₃=>-.5
270+
end I₁ I₂ I₃
272271

273272
"""
274273
Rigid Body Equations
@@ -291,7 +290,7 @@ or Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Pr
291290
292291
Usually solved from 0 to 20.
293292
"""
294-
prob_ode_rigidbody = ODEProblem(rigid,[1.0,0.0,0.9],(0.0,20.0))
293+
prob_ode_rigidbody = ODEProblem(rigid,[1.0,0.0,0.9],(0.0,20.0),(-2.0,1.25,-0.5))
295294

296295
# Pleiades Problem
297296

src/sde_premade_problems.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ f = @ode_def_nohes LorenzSDE begin
137137
dx = σ*(y-x)
138138
dy = x*-z) - y
139139
dz = x*y - β*z
140-
end σ=>10. ρ=>28. β=>2.66
140+
end σ ρ β
141141

142142
σ = (du,u,p,t) -> begin
143143
for i in 1:3
@@ -157,7 +157,7 @@ dz &= (x*y - β*z)dt + αdW_t \\\\
157157
158158
with ``σ=10``, ``ρ=28``, ``β=8/3``, ``α=3.0`` and inital condition ``u0=[1;1;1]``.
159159
"""
160-
prob_sde_lorenz = SDEProblem(f,σ,ones(3),(0.0,10.0))
160+
prob_sde_lorenz = SDEProblem(f,σ,ones(3),(0.0,10.0),(10.0,28.0,2.66))
161161

162162

163163
f = (u,p,t) -> (1/3)*u^(1/3) + 6*u^(2/3)
@@ -249,7 +249,7 @@ function oval2ModelExample(;largeFluctuations=false,useBigs=false,noiseLevel=1)
249249
nSO=2.
250250
nzo=2.
251251
GE = 1.
252-
f = function (t,y,dy)
252+
f = function (dy,y,p,t)
253253
# y(1) = snailt
254254
# y(2) = SNAIL
255255
# y(3) = miR34t
@@ -291,12 +291,12 @@ function oval2ModelExample(;largeFluctuations=false,useBigs=false,noiseLevel=1)
291291
dy[19]=kOp*y[18]-kd_Op*y[19]
292292
end
293293

294-
σ1 = function (t,y,)
294+
σ1 = function (,y,p,t)
295295
dσ[1] = noiseLevel*1.5y[1]
296296
dσ[18]= noiseLevel*6y[18]
297297
end
298298

299-
σ2 = function (t,y,)
299+
σ2 = function (,y,p,t)
300300
dσ[1] = 0.02y[1]
301301
dσ[16]= 0.02y[16]
302302
dσ[18]= 0.2y[18]

0 commit comments

Comments
 (0)