Skip to content

Commit 6bc11c7

Browse files
Merge pull request #3258 from AayushSabharwal/as/sde-simplify
fix: retain system data on `structural_simplify` of `SDESystem`
2 parents 22be186 + 9c1bed9 commit 6bc11c7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

docs/src/examples/modelingtoolkitize_index_reduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Specifically, for a pendulum with unit mass and length $L$, which thus has
5656
kinetic energy $\frac{1}{2}(v_x^2 + v_y^2)$,
5757
potential energy $gy$,
5858
and holonomic constraint $x^2 + y^2 - L^2 = 0$.
59-
The Lagrange multiplier related to this constraint is equal to half of $T$,
59+
The Lagrange multiplier related to this constraint is equal to half of $T$,
6060
and represents the tension in the rope of the pendulum.
6161

6262
As a good DifferentialEquations.jl user, one would follow

src/systems/systems.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = fal
154154
end
155155

156156
noise_eqs = StructuralTransformations.tearing_substitute_expr(ode_sys, noise_eqs)
157-
return SDESystem(full_equations(ode_sys), noise_eqs,
157+
return SDESystem(Vector{Equation}(full_equations(ode_sys)), noise_eqs,
158158
get_iv(ode_sys), unknowns(ode_sys), parameters(ode_sys);
159-
name = nameof(ode_sys), is_scalar_noise, observed = observed(ode_sys))
159+
name = nameof(ode_sys), is_scalar_noise, observed = observed(ode_sys), defaults = defaults(sys),
160+
parameter_dependencies = parameter_dependencies(sys))
160161
end
161162
end

test/dde.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ prob = SDDEProblem(hayes_modelf, hayes_modelg, [1.0], h, tspan, pmul;
7676
constant_lags = (pmul[1],));
7777
sol = solve(prob, RKMil(), seed = 100)
7878

79-
@variables x(..)
79+
@variables x(..) delx(t)
8080
@parameters a=-4.0 b=-2.0 c=10.0 α=-1.3 β=-1.2 γ=1.1
8181
@brownian η
8282
τ = 1.0
83-
eqs = [D(x(t)) ~ a * x(t) + b * x(t - τ) + c +* x(t) + γ) * η]
83+
eqs = [D(x(t)) ~ a * x(t) + b * x(t - τ) + c +* x(t) + γ) * η, delx ~ x(t - τ)]
8484
@mtkbuild sys = System(eqs, t)
85+
@test ModelingToolkit.has_observed_with_lhs(sys, delx)
8586
@test ModelingToolkit.is_dde(sys)
8687
@test !is_markovian(sys)
8788
@test equations(sys) == [D(x(t)) ~ a * x(t) + b * x(t - τ) + c]

0 commit comments

Comments
 (0)