Skip to content
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

Set u_modified in DAE initialization if the u was changed #1969

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions src/initialize_dae.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
integrator.u .= nlsol.u
failed = nlsol.retcode != ReturnCode.Success
end
u_modified!(integrator, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default assumption. What's a case where this makes a difference?

recursivecopy!(integrator.uprev, integrator.u)
if alg_extrapolates(integrator.alg)
recursivecopy!(integrator.uprev2, integrator.uprev)
Expand Down Expand Up @@ -233,6 +234,7 @@
olddt
failed = nlsolvefail(nlsolver)
@.. broadcast=false integrator.u=integrator.uprev + z
u_modified!(integrator, true)

Check warning on line 237 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L237

Added line #L237 was not covered by tests
else
nlequation_oop = @closure (u, _) -> begin
update_coefficients!(M, u, p, t)
Expand All @@ -258,6 +260,7 @@
integrator.u = nlsol.u
failed = nlsol.retcode != ReturnCode.Success
end
u_modified!(integrator, true)

Check warning on line 263 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L263

Added line #L263 was not covered by tests

integrator.uprev = copy(integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down Expand Up @@ -320,6 +323,7 @@
reltol = integrator.opts.reltol)

integrator.u = nlsol.u
u_modified!(integrator, true)

Check warning on line 326 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L326

Added line #L326 was not covered by tests
recursivecopy!(integrator.uprev, integrator.u)
if alg_extrapolates(integrator.alg)
recursivecopy!(integrator.uprev2, integrator.uprev)
Expand Down Expand Up @@ -367,6 +371,7 @@
reltol = integrator.opts.reltol)

integrator.u = nlsol.u
u_modified!(integrator, true)

Check warning on line 374 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L374

Added line #L374 was not covered by tests

integrator.uprev = copy(integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down Expand Up @@ -443,6 +448,7 @@
nlprob = NonlinearProblem(nlfunc, alg_u, p)
nlsol = solve(nlprob, nlsolve; abstol = alg.abstol, reltol = integrator.opts.reltol)
alg_u .= nlsol
u_modified!(integrator, true)

recursivecopy!(integrator.uprev, integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down Expand Up @@ -512,6 +518,7 @@
else
integrator.u = u
end
u_modified!(integrator, true)

Check warning on line 521 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L521

Added line #L521 was not covered by tests

integrator.uprev = copy(integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down Expand Up @@ -573,6 +580,7 @@

@. du = ifelse(differential_vars, nlsol.u, du)
@. u = ifelse(differential_vars, u, nlsol.u)
u_modified!(integrator, true)

recursivecopy!(integrator.uprev, integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down Expand Up @@ -630,6 +638,7 @@
integrator.u = u
integrator.du = du
end
u_modified!(integrator, true)

Check warning on line 641 in src/initialize_dae.jl

View check run for this annotation

Codecov / codecov/patch

src/initialize_dae.jl#L641

Added line #L641 was not covered by tests

integrator.uprev = copy(integrator.u)
if alg_extrapolates(integrator.alg)
Expand Down
Loading