Skip to content

feat: ImplicitDiscreteSystem #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove Next and Prev
  • Loading branch information
vyudu committed Mar 10, 2025
commit a98397ca205309603e87f2c12433ffd49cfd0296
13 changes: 0 additions & 13 deletions src/discretedomain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ Base.literal_pow(f::typeof(^), D::Shift, ::Val{n}) where {n} = Shift(D.t, D.step

hasshift(eq::Equation) = hasshift(eq.lhs) || hasshift(eq.rhs)

"""
Next(x)

An alias for Shift(t, 1)(x).
"""
Next(x) = Shift(t, 1)(x)
"""
Prev(x)

An alias for Shift(t, -1)(x).
"""
Prev(x) = Shift(t, -1)(x)

"""
hasshift(O)

Expand Down
6 changes: 3 additions & 3 deletions src/systems/discrete_system/implicit_discrete_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,17 @@ function generate_function(
iv = get_iv(sys)
# Algebraic equations get shifted forward 1, to match with differential equations
exprs = map(equations(sys)) do eq
_iszero(eq.lhs) ? distribute_shift(Next(eq.rhs)) : (eq.rhs - eq.lhs)
_iszero(eq.lhs) ? distribute_shift(Shift(iv, 1)(eq.rhs)) : (eq.rhs - eq.lhs)
end

# Handle observables in algebraic equations, since they are shifted
obs = observed(sys)
shifted_obs = Symbolics.Equation[distribute_shift(Next(eq)) for eq in obs]
shifted_obs = Symbolics.Equation[distribute_shift(Shift(iv, 1)(eq)) for eq in obs]
obsidxs = observed_equations_used_by(sys, exprs; obs = shifted_obs)
extra_assignments = [Assignment(shifted_obs[i].lhs, shifted_obs[i].rhs)
for i in obsidxs]

u_next = map(Next, dvs)
u_next = map(Shift(iv, 1), dvs)
u = dvs
build_function_wrapper(
sys, exprs, u_next, u, ps..., iv; p_start = 3, extra_assignments, kwargs...)
Expand Down