@@ -187,6 +187,34 @@ function Base.showerror(io::IO, e::NonSolverError)
187
187
println (io, TruncatedStacktraces. VERBOSE_MSG)
188
188
end
189
189
190
+ const NOISE_SIZE_MESSAGE = """
191
+ Noise sizes are incompatible. The expected number of noise terms in the defined
192
+ `noise_rate_prototype` does not match the number of noise terms in the defined
193
+ `AbstractNoiseProcess`. Please ensure that
194
+ size(prob.noise_rate_prototype,2) == length(prob.noise.W[1]).
195
+
196
+ Note: Noise process definitions require that users specify `u0`, and this value is
197
+ directly used in the definition. For example, if `noise = WienerProcess(0.0,0.0)`,
198
+ then the noise process is a scalar with `u0=0.0`. If `noise = WienerProcess(0.0,[0.0])`,
199
+ then the noise process is a vector with `u0=0.0`. If `noise_rate_prototype = zeros(2,4)`,
200
+ then the noise process must be a 4-dimensional process, for example
201
+ `noise = WienerProcess(0.0,zeros(4))`. This error is a sign that the user definition
202
+ of `noise_rate_prototype` and `noise` are not aligned in this manner and the definitions should
203
+ be double checked.
204
+ """
205
+
206
+ struct NoiseSizeIncompatabilityError <: Exception
207
+ prototypesize:: Int
208
+ noisesize:: Int
209
+ end
210
+
211
+ function Base. showerror (io:: IO , e:: NoiseSizeIncompatabilityError )
212
+ println (io, NOISE_SIZE_MESSAGE)
213
+ println (io, " size(prob.noise_rate_prototype,2) = $(e. prototypesize) " )
214
+ println (io, " length(prob.noise.W[1]) = $(e. noisesize) " )
215
+ println (io, TruncatedStacktraces. VERBOSE_MSG)
216
+ end
217
+
190
218
const PROBSOLVER_PAIRING_MESSAGE = """
191
219
Incompatible problem+solver pairing.
192
220
For example, this can occur if an ODE solver is passed with an SDEProblem.
@@ -1278,6 +1306,11 @@ function check_prob_alg_pairing(prob, alg)
1278
1306
throw (DirectAutodiffError ())
1279
1307
end
1280
1308
1309
+ if prob isa SDEProblem && prob. noise_rate_prototype != = nothing &&
1310
+ prob. noise != = nothing && size (prob. noise_rate_prototype,2 ) != length (prob. noise. W[1 ])
1311
+ throw (NoiseSizeIncompatabilityError (size (prob. noise_rate_prototype,2 ), length (prob. noise. W[1 ])))
1312
+ end
1313
+
1281
1314
# Complex number support comes before arbitrary number support for a more direct
1282
1315
# error message.
1283
1316
if ! SciMLBase. allowscomplex (alg)
0 commit comments