File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
lib/ModelingToolkitBase/src/systems Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,13 @@ struct System <: IntermediateDeprecationSystem
326326 error()
327327 end
328328 N1 == Neq || throw(IllFormedNoiseEquationsError(N1, Neq))
329+ if noise_eqs != = nothing && ! isempty(brownians)
330+ throw(ArgumentError(
331+ " A system cannot have both `noise_eqs` and `brownians` specified. " *
332+ " Use either `noise_eqs` (a matrix of noise coefficients) or " *
333+ " `brownians` (symbolic brownian variables in equations), but not both."
334+ ))
335+ end
329336 check_equations(equations(continuous_events), iv)
330337 check_subsystems(systems)
331338 end
Original file line number Diff line number Diff line change @@ -120,19 +120,21 @@ function scalarized_vars(vars)
120120end
121121
122122function _mtkcompile(sys:: AbstractSystem ; kwargs... )
123- # TODO : convert noise_eqs to brownians for simplification
124- if has_noise_eqs(sys) && get_noise_eqs(sys) != = nothing
125- sys = noise_to_brownians(sys; names = :αₘₜₖ)
126- end
123+ # For systems with jumps, skip full structural simplification to preserve
124+ # variables that only appear in jumps.
127125 if ! isempty(jumps(sys))
128- # For systems with jumps, skip full structural simplification to preserve
129- # variables that only appear in jumps. But if brownians are present,
130- # we still need to extract them into noise_eqs for SDEProblem construction.
126+ # If brownians are present, extract them to noise_eqs for SDEProblem construction.
127+ # If noise_eqs is already set, return as-is (no need to convert).
131128 if ! isempty(brownians(sys))
132129 return extract_brownians_to_noise_eqs(sys)
133130 end
134131 return sys
135132 end
133+
134+ # For non-jump systems, convert noise_eqs to brownians for simplification
135+ if has_noise_eqs(sys) && get_noise_eqs(sys) != = nothing
136+ sys = noise_to_brownians(sys; names = :αₘₜₖ)
137+ end
136138 if isempty(equations(sys)) && ! is_time_dependent(sys) && ! _iszero(cost(sys))
137139 return simplify_optimization_system(sys; kwargs... ):: System
138140 end
You can’t perform that action at this time.
0 commit comments