Skip to content

Commit 87e1c0c

Browse files
better errors on invalid alg interpretations
1 parent 04a3c5f commit 87e1c0c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/alg_utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ alg_interpretation(alg::RKMil{interpretation}) where {interpretation} = interpre
125125
alg_interpretation(alg::SROCK1{interpretation}) where {interpretation} = interpretation
126126
alg_interpretation(alg::RKMilCommute{interpretation}) where {interpretation} = interpretation
127127
alg_interpretation(alg::RKMilGeneral) = alg.interpretation
128-
alg_interpretation(alg::ImplicitRKMil{CS,AD,F,S,N,T2,Controller,interpretation}) where {CS,AD,F,S,N,T2,Controller,interpretation} = interpretation
128+
alg_interpretation(alg::ImplicitRKMil{CS,AD,F,FDT,ST,N,T2,Controller,interpretation}) where {CS,AD,F,FDT,ST,N,T2,Controller,interpretation} = interpretation
129129

130130
alg_interpretation(alg::RS1) = :Stratonovich
131131
alg_interpretation(alg::RS2) = :Stratonovich
@@ -263,8 +263,8 @@ OrdinaryDiffEq.get_chunksize(alg::StochasticDiffEqJumpNewtonDiffusionAdaptiveAlg
263263
end
264264

265265
@static if isdefined(OrdinaryDiffEq,:alg_difftype)
266-
OrdinaryDiffEq.alg_difftype(alg::Union{StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,FDT,Controller},
267-
StochasticDiffEqNewtonAlgorithm{CS,AD,FDT,Controller}}) where {CS,AD,FDT,Controller} = FDT
266+
OrdinaryDiffEq.alg_difftype(alg::Union{StochasticDiffEqNewtonAdaptiveAlgorithm{CS,AD,FDT,ST,Controller},
267+
StochasticDiffEqNewtonAlgorithm{CS,AD,FDT,ST,Controller}}) where {CS,AD,FDT,ST,Controller} = FDT
268268
end
269269

270270
alg_mass_matrix_compatible(alg::StochasticDiffEqAlgorithm) = false

src/perform_step/SROCK_perform_step.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
gₘ₋₂ = integrator.g(uᵢ₋₁,p,tᵢ₋₁)
7474
u += gₘ₋₂*W.dW
7575
end
76+
else
77+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
7678
end
7779

7880
if i < mdeg
@@ -163,6 +165,8 @@ end
163165
mul!(uᵢ₋₁,gₘ₋₂,W.dW)
164166
@.. u += uᵢ₋₁
165167
end
168+
else
169+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
166170
end
167171

168172
if i < mdeg

src/perform_step/low_order.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ end
179179
utilde = uprev + L*integrator.sqdt
180180
ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt)
181181
mil_correction = ggprime.*(W.dW.^2)./2
182+
else
183+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
182184
end
183185
u = K+L.*W.dW+mil_correction
184186
if integrator.opts.adaptive
@@ -207,6 +209,8 @@ end
207209
@.. tmp = (du2-L)/(2integrator.sqdt)*(W.dW^2 - dt)
208210
elseif alg_interpretation(integrator.alg) == :Stratonovich
209211
@.. tmp = (du2-L)/(2integrator.sqdt)*(W.dW^2)
212+
else
213+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
210214
end
211215
@.. u = K+L*W.dW + tmp
212216
if integrator.opts.adaptive
@@ -232,6 +236,8 @@ end
232236
@.. tmp = uprev + integrator.sqdt * L
233237
integrator.g(du2,tmp,p,t)
234238
@.. tmp = (du2-L)/(2integrator.sqdt)*(W.dW.^2)
239+
else
240+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
235241
end
236242
@.. u = K+L*W.dW + tmp
237243
if integrator.opts.adaptive

src/perform_step/sdirk.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
ggprime = (integrator.g(utilde,p,t).-L)./(integrator.sqdt)
3838
mil_correction = ggprime.*(integrator.W.dW.^2)./2
3939
gtmp += mil_correction
40+
else
41+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
4042
end
4143
end
4244

@@ -162,6 +164,8 @@ end
162164
integrator.g(gtmp3,z,p,t)
163165
@.. gtmp3 = (gtmp3-gtmp)/(integrator.sqdt) # ggprime approximation
164166
@.. gtmp2 += gtmp3*(dW.^2)/2
167+
else
168+
error("Alg interpretation invalid. Use either :Ito or :Stratonovich")
165169
end
166170
end
167171

0 commit comments

Comments
 (0)