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

[WIP] Relaxation Runge-Kutta #2227

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fbf962d
just ideas for relaxation
Theozeud Apr 26, 2024
dc25f21
Update ideas_for_relaxation.jl
Theozeud Apr 26, 2024
575826a
Update ideas_for_relaxation.jl
Theozeud Apr 27, 2024
cdb53c9
Update ideas_for_relaxation.jl
Theozeud Apr 28, 2024
7e2b73a
Update ideas_for_relaxation.jl
Theozeud Apr 28, 2024
d0f8a22
try_implementation_tsit5_for_relaxation
Theozeud Apr 28, 2024
229438f
progress relaxation
Theozeud Apr 28, 2024
9384053
Merge branch 'SciML:master' into relaxation
Theozeud Apr 28, 2024
a796157
all implement but failed compilation
Theozeud Apr 28, 2024
eeda5a7
Merge branch 'relaxation' of https://github.com/Theozeud/OrdinaryDiff…
Theozeud Apr 28, 2024
b3617ad
compilation works but not tests
Theozeud Apr 29, 2024
945b9d3
Merge branch 'SciML:master' into relaxation
Theozeud Apr 29, 2024
ef5238b
code change structure works
Theozeud Apr 30, 2024
cb94460
Merge branch 'relaxation' of https://github.com/Theozeud/OrdinaryDiff…
Theozeud Apr 30, 2024
4323a68
fix mistakes
Theozeud Apr 30, 2024
12e4a7a
improvement for regression
Theozeud May 1, 2024
e35d9fa
clean up
Theozeud May 27, 2024
7fada13
Merge branch 'master' into relaxation_method
Theozeud May 27, 2024
653436b
try test without relaxation
Theozeud May 28, 2024
730d4e1
copy tist5 for non constant cache
Theozeud May 30, 2024
db28be6
fix tsit5_for_relaxation with non constant cache
Theozeud May 30, 2024
2ffd004
first try of implementation of the relaxation step
Theozeud Jun 3, 2024
a180073
add notes on some thoughts
Theozeud Jun 5, 2024
52f4461
add some tools
Theozeud Jun 7, 2024
b4d9c40
add some tools
Theozeud Jun 7, 2024
a01bc2a
bound_dt
Theozeud Jun 8, 2024
3fd63fd
trying to use Roots.jl instead of OptimizationOptimJL.jl
Theozeud Jun 9, 2024
e926a61
test relaxation on oscillator
Theozeud Jun 9, 2024
2789e9f
work at the beginning for harmonic oscillator but there is bug in lon…
Theozeud Jun 9, 2024
89c10f3
add some problem for later
Theozeud Jun 11, 2024
2c387d8
some change in the modif_step!
Theozeud Jun 11, 2024
83bd06c
fix bug
Theozeud Jun 11, 2024
8ff5be9
first test to compare relaxation with no relaxation
Theozeud Jun 12, 2024
5138202
Create benchmark in time.ipynb
Theozeud Jun 13, 2024
c884132
Test FSAL-R
Theozeud Jun 13, 2024
fa0d5c3
add more examples
Theozeud Jun 13, 2024
3287f82
Relaxation v2
Theozeud Jun 14, 2024
1111c38
New way with PerformStepCallBack
Theozeud Jun 14, 2024
44ea89d
new structure runs
Theozeud Jun 15, 2024
9af57f8
Merge pull request #4 from Theozeud/relaxation_new_version
Theozeud Jun 15, 2024
3d06894
all last modif
Theozeud Jun 15, 2024
f6557b4
Merge pull request #5 from Theozeud/relaxation_new_version
Theozeud Jun 15, 2024
ac1943d
almost all work well except R-FSAL which needs
Theozeud Jun 15, 2024
5c9b8e6
find a way to make R-FSAL work
Theozeud Jun 15, 2024
2b0fb0a
do each examples of the paper with different FSAL
Theozeud Jun 16, 2024
f208a53
small fix
Theozeud Jun 17, 2024
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
3 changes: 2 additions & 1 deletion src/OrdinaryDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ include("perform_step/prk_perform_step.jl")
include("perform_step/pdirk_perform_step.jl")
include("perform_step/dae_perform_step.jl")
include("perform_step/qprk_perform_step.jl")
include("perform_step/test_for_relaxation_perform_step.jl")

include("dense/generic_dense.jl")
include("dense/interpolants.jl")
Expand Down Expand Up @@ -377,7 +378,7 @@ export FunctionMap, Euler, Heun, Ralston, Midpoint, RK4, ExplicitRK, OwrenZen3,
OwrenZen5,
BS3, BS5, RK46NL, DP5, Tsit5, DP8, Vern6, Vern7, Vern8, TanYam7, TsitPap8,
Vern9, Feagin10, Feagin12, Feagin14, CompositeAlgorithm, Anas5, RKO65, FRK65, PFRK87,
RKM, MSRK5, MSRK6, Stepanov5, SIR54, QPRK98, PSRK4p7q6, PSRK3p6q5, PSRK3p5q4
RKM, MSRK5, MSRK6, Stepanov5, SIR54, QPRK98, PSRK4p7q6, PSRK3p6q5, PSRK3p5q4, Tsit5_for_relaxation

export SSPRK22, SSPRK33, KYKSSPRK42, SSPRK53, SSPRK53_2N1, SSPRK53_2N2, SSPRK53_H, SSPRK63,
SSPRK73, SSPRK83, SSPRK43, SSPRK432,
Expand Down
1 change: 1 addition & 0 deletions src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
alg_order(alg::OwrenZen5) = 5
alg_order(alg::DP5) = 5
alg_order(alg::Tsit5) = 5
alg_order(alg::Tsit5_for_relaxation) = 5

Check warning on line 591 in src/alg_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/alg_utils.jl#L591

Added line #L591 was not covered by tests
alg_order(alg::DP8) = 8
alg_order(alg::Vern6) = 6
alg_order(alg::Vern7) = 7
Expand Down
13 changes: 13 additions & 0 deletions src/algorithms/explicit_rk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,19 @@
Tsit5(stage_limiter!, step_limiter!, False())
end

Base.@kwdef struct Tsit5_for_relaxation{StageLimiter, StepLimiter, Thread} <:
OrdinaryDiffEqAdaptiveAlgorithm
stage_limiter!::StageLimiter = trivial_limiter!
step_limiter!::StepLimiter = trivial_limiter!
thread::Thread = False()
end

# for backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

backwards compatibility with what?

function Tsit5_for_relaxation(stage_limiter!, step_limiter! = trivial_limiter!)
Tsit5_for_relaxation(stage_limiter!, step_limiter!, False())

Check warning on line 373 in src/algorithms/explicit_rk.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/explicit_rk.jl#L372-L373

Added lines #L372 - L373 were not covered by tests
end


@doc explicit_rk_docstring(
"Hairer's 8/5/3 adaption of the Dormand-Prince Runge-Kutta method. (7th order interpolant).",
"DP8",
Expand Down
45 changes: 45 additions & 0 deletions src/caches/low_order_rk_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,44 @@
Base.Experimental.silence!(Tsit5Cache)
end

@cache struct Tsit5Cache_for_relaxation{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Copy link
Contributor

Choose a reason for hiding this comment

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

could this just use the Tsit5Cache?

Thread} <: OrdinaryDiffEqMutableCache
u::uType
uprev::uType
k1::rateType
k2::rateType
k3::rateType
k4::rateType
k5::rateType
k6::rateType
k7::rateType
utilde::uType
tmp::uType
atmp::uNoUnitsType
stage_limiter!::StageLimiter
step_limiter!::StepLimiter
thread::Thread
end

function alg_cache(alg::Tsit5_for_relaxation, u, rate_prototype, ::Type{uEltypeNoUnits},

Check warning on line 470 in src/caches/low_order_rk_caches.jl

View check run for this annotation

Codecov / codecov/patch

src/caches/low_order_rk_caches.jl#L470

Added line #L470 was not covered by tests
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
k3 = zero(rate_prototype)
k4 = zero(rate_prototype)
k5 = zero(rate_prototype)
k6 = zero(rate_prototype)
k7 = zero(rate_prototype)
utilde = zero(u)
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
tmp = zero(u)
Tsit5Cache_for_relaxation(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp,

Check warning on line 485 in src/caches/low_order_rk_caches.jl

View check run for this annotation

Codecov / codecov/patch

src/caches/low_order_rk_caches.jl#L474-L485

Added lines #L474 - L485 were not covered by tests
alg.stage_limiter!, alg.step_limiter!, alg.thread)
end

@cache struct RK46NLCache{uType, rateType, TabType, StageLimiter, StepLimiter, Thread} <:
OrdinaryDiffEqMutableCache
u::uType
Expand Down Expand Up @@ -547,6 +585,13 @@
Tsit5ConstantCache()
end

function alg_cache(alg::Tsit5_for_relaxation, u, rate_prototype, ::Type{uEltypeNoUnits},

Check warning on line 588 in src/caches/low_order_rk_caches.jl

View check run for this annotation

Codecov / codecov/patch

src/caches/low_order_rk_caches.jl#L588

Added line #L588 was not covered by tests
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
Tsit5ConstantCache_for_relaxation()

Check warning on line 592 in src/caches/low_order_rk_caches.jl

View check run for this annotation

Codecov / codecov/patch

src/caches/low_order_rk_caches.jl#L592

Added line #L592 was not covered by tests
end

@cache struct DP5Cache{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Thread} <: OrdinaryDiffEqMutableCache
u::uType
Expand Down
14 changes: 11 additions & 3 deletions src/integrators/type.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mutable struct DEOptions{absType, relType, QT, tType, Controller, F1, F2, F3, F4, F5, F6,
F7, tstopsType, discType, ECType, SType, MI, tcache, savecache,
disccache}
disccache, MT}
maxiters::MI
save_everystep::Bool
adaptive::Bool
Expand Down Expand Up @@ -46,6 +46,7 @@ mutable struct DEOptions{absType, relType, QT, tType, Controller, F1, F2, F3, F4
force_dtmin::Bool
advance_to_tstop::Bool
stop_at_next_tstop::Bool
modif::MT
end

TruncatedStacktraces.@truncate_stacktrace DEOptions
Expand Down Expand Up @@ -134,6 +135,12 @@ mutable struct ODEIntegrator{algType <: Union{OrdinaryDiffEqAlgorithm, DAEAlgori
stats::SciMLBase.DEStats
initializealg::IA
differential_vars::DV

u_propose::uType
u_changed::uType
dt_has_changed::Bool
dt_changed::tType

fsalfirst::FSALType
fsallast::FSALType

Expand All @@ -155,7 +162,8 @@ mutable struct ODEIntegrator{algType <: Union{OrdinaryDiffEqAlgorithm, DAEAlgori
accept_step, isout, reeval_fsal, u_modified,
reinitialize, isdae,
opts, stats,
initializealg, differential_vars) where {algType, IIP, uType,
initializealg, differential_vars,
u_propose, u_changed, dt_has_changed, dt_changed) where {algType, IIP, uType,
duType, tType, pType,
eigenType, EEstT,
tTypeNoUnits, tdirType,
Expand All @@ -177,7 +185,7 @@ mutable struct ODEIntegrator{algType <: Union{OrdinaryDiffEqAlgorithm, DAEAlgori
do_error_check,
event_last_time, vector_event_last_time, last_event_error,
accept_step, isout, reeval_fsal, u_modified, reinitialize, isdae,
opts, stats, initializealg, differential_vars) # Leave off fsalfirst and last
opts, stats, initializealg, differential_vars, u_propose, u_changed, dt_has_changed, dt_changed) # Leave off fsalfirst and last
end
end

Expand Down
200 changes: 200 additions & 0 deletions src/perform_step/test_for_relaxation_perform_step.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
function initialize!(integrator, ::Tsit5ConstantCache_for_relaxation)
integrator.kshortsize = 7
integrator.k = typeof(integrator.k)(undef, integrator.kshortsize)
integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal
integrator.stats.nf += 1

Check warning on line 5 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L1-L5

Added lines #L1 - L5 were not covered by tests

# Avoid undefined entries if k is an array of arrays
integrator.fsallast = zero(integrator.fsalfirst)
integrator.k[1] = integrator.fsalfirst
@inbounds for i in 2:(integrator.kshortsize - 1)
integrator.k[i] = zero(integrator.fsalfirst)
end
integrator.k[integrator.kshortsize] = integrator.fsallast

Check warning on line 13 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L8-L13

Added lines #L8 - L13 were not covered by tests
end


function perform_step!(integrator, cache::Tsit5ConstantCache_for_relaxation, repeat_step = false)

Check warning on line 17 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L17

Added line #L17 was not covered by tests

# Variable to know if dt has changed during perform_step
integrator.dt_has_changed = false

Check warning on line 20 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L20

Added line #L20 was not covered by tests

# computations! will only contain the mathematical scheme
# i.e the computations of the u(t+dt)
# the result is store not in integrator.u but integrator.u_propose
computations!(integrator, cache, repeat_step)

Check warning on line 25 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L25

Added line #L25 was not covered by tests

# modif_step! enables to modify the step like when we want to perform a relaxation
# for this we give a new struture that can be defined either by us for already known
# modification we want to do or by a user (see below)
modif_step!(integrator)

Check warning on line 30 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L30

Added line #L30 was not covered by tests

# finalize_step! will do staff related to the solver like integrator.stats, register integrator.fsal
# and register integrator.u
finalize_step!(integrator, cache)

Check warning on line 34 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L34

Added line #L34 was not covered by tests
end


@muladd function computations!(integrator, ::Tsit5ConstantCache_for_relaxation, repeat_step = false)
@unpack t, dt, uprev, u, f, p = integrator
T = constvalue(recursive_unitless_bottom_eltype(u))
T2 = constvalue(typeof(one(t)))
@OnDemandTableauExtract Tsit5ConstantCacheActual T T2
k1 = integrator.fsalfirst
a = dt * a21
k2 = f(uprev + a * k1, p, t + c1 * dt)
k3 = f(uprev + dt * (a31 * k1 + a32 * k2), p, t + c2 * dt)
k4 = f(uprev + dt * (a41 * k1 + a42 * k2 + a43 * k3), p, t + c3 * dt)
k5 = f(uprev + dt * (a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4), p, t + c4 * dt)
g6 = uprev + dt * (a61 * k1 + a62 * k2 + a63 * k3 + a64 * k4 + a65 * k5)
k6 = f(g6, p, t + dt)
u = uprev + dt * (a71 * k1 + a72 * k2 + a73 * k3 + a74 * k4 + a75 * k5 + a76 * k6)
k7 = f(u, p, t + dt)
integrator.k[1] = k1
integrator.k[2] = k2
integrator.k[3] = k3
integrator.k[4] = k4
integrator.k[5] = k5
integrator.k[6] = k6
integrator.k[7] = k7
integrator.u_propose = u

Check warning on line 60 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L38-L60

Added lines #L38 - L60 were not covered by tests

if integrator.opts.adaptive
utilde = dt *

Check warning on line 63 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L62-L63

Added lines #L62 - L63 were not covered by tests
(btilde1 * integrator.k[1] + btilde2 * integrator.k[2] + btilde3 * integrator.k[3] + btilde4 * integrator.k[4] + btilde5 * integrator.k[5] +
btilde6 * integrator.k[6] + btilde7 * integrator.k[7])
atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol,

Check warning on line 66 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L66

Added line #L66 was not covered by tests
integrator.opts.reltol, integrator.opts.internalnorm, t)
integrator.EEst = integrator.opts.internalnorm(atmp, t)

Check warning on line 68 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L68

Added line #L68 was not covered by tests
end
end


function modif_step!(integrator)

Check warning on line 73 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L73

Added line #L73 was not covered by tests

# Perform the modifications
if !(integrator.opts.modif isa Nothing)
integrator.opts.modif(integrator)

Check warning on line 77 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L76-L77

Added lines #L76 - L77 were not covered by tests

# Here we check the validity of chaging dt if it has changed
# if it is valid integrator.changed_valid will be true, if not it will be false
changed_valid = true
if integrator.dt_has_changed

Check warning on line 82 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L81-L82

Added lines #L81 - L82 were not covered by tests
# check dt in [dtmin, dtmax]
# things related to tstops
# surely other things
if changed_valid
integrator.u_propose = integrator.u_changed
integrator.dt = integrator.dt_changed
else

Check warning on line 89 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L86-L89

Added lines #L86 - L89 were not covered by tests
# print error or warning
end
end
end
end


function finalize_step!(integrator, cache::Tsit5ConstantCache_for_relaxation)
@unpack t, dt, uprev, u_propose, f, p = integrator
integrator.u = u_propose
integrator.fsallast = f(u_propose, p, t + dt)

Check warning on line 100 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L97-L100

Added lines #L97 - L100 were not covered by tests

integrator.stats.nf += 7

Check warning on line 102 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L102

Added line #L102 was not covered by tests
end


## Non Constant cache
function initialize!(integrator, cache::Tsit5Cache_for_relaxation)
integrator.kshortsize = 7
integrator.fsalfirst = cache.k1
integrator.fsallast = cache.k7 # setup pointers
resize!(integrator.k, integrator.kshortsize)

Check warning on line 111 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L107-L111

Added lines #L107 - L111 were not covered by tests
# Setup k pointers
integrator.k[1] = cache.k1
integrator.k[2] = cache.k2
integrator.k[3] = cache.k3
integrator.k[4] = cache.k4
integrator.k[5] = cache.k5
integrator.k[6] = cache.k6
integrator.k[7] = cache.k7
integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal
integrator.stats.nf += 1
return nothing

Check warning on line 122 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L113-L122

Added lines #L113 - L122 were not covered by tests
end


function perform_step!(integrator, cache::Tsit5Cache_for_relaxation, repeat_step = false)

Check warning on line 126 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L126

Added line #L126 was not covered by tests

# Variable to know if dt has changed during perform_step
integrator.dt_has_changed = false

Check warning on line 129 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L129

Added line #L129 was not covered by tests

# computations! will only contain the mathematical scheme
# i.e the computations of the u(t+dt)
# the result is store not in integrator.u but integrator.u_propose
computations!(integrator, cache, repeat_step)

Check warning on line 134 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L134

Added line #L134 was not covered by tests

# modif_step! enables to modify the step like when we want to perform a relaxation
# for this we give a new struture that can be defined either by us for already known
# modification we want to do or by a user (see below)
modif_step!(integrator)

Check warning on line 139 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L139

Added line #L139 was not covered by tests

# finalize_step! will do staff related to the solver like integrator.stats, register integrator.fsal
# and register integrator.u
finalize_step!(integrator, cache)

Check warning on line 143 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L143

Added line #L143 was not covered by tests
end

@muladd function computations!(integrator, cache::Tsit5Cache_for_relaxation, repeat_step = false)
@unpack t, dt, uprev, u_propose, f, p = integrator
T = constvalue(recursive_unitless_bottom_eltype(u_propose))
T2 = constvalue(typeof(one(t)))
@OnDemandTableauExtract Tsit5ConstantCacheActual T T2
@unpack k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp, stage_limiter!, step_limiter!, thread = cache
a = dt * a21
@.. broadcast=false thread=thread tmp=uprev + a * k1
stage_limiter!(tmp, f, p, t + c1 * dt)
f(k2, tmp, p, t + c1 * dt)
@.. broadcast=false thread=thread tmp=uprev + dt * (a31 * k1 + a32 * k2)
stage_limiter!(tmp, f, p, t + c2 * dt)
f(k3, tmp, p, t + c2 * dt)
@.. broadcast=false thread=thread tmp=uprev + dt * (a41 * k1 + a42 * k2 + a43 * k3)
stage_limiter!(tmp, f, p, t + c3 * dt)
f(k4, tmp, p, t + c3 * dt)
@.. broadcast=false thread=thread tmp=uprev +

Check warning on line 162 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L146-L162

Added lines #L146 - L162 were not covered by tests
dt * (a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4)
stage_limiter!(tmp, f, p, t + c4 * dt)
f(k5, tmp, p, t + c4 * dt)
@.. broadcast=false thread=thread tmp=uprev +

Check warning on line 166 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L164-L166

Added lines #L164 - L166 were not covered by tests
dt * (a61 * k1 + a62 * k2 + a63 * k3 + a64 * k4 +
a65 * k5)
stage_limiter!(tmp, f, p, t + dt)
f(k6, tmp, p, t + dt)
@.. broadcast=false thread=thread u_propose = uprev +

Check warning on line 171 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L169-L171

Added lines #L169 - L171 were not covered by tests
dt * (a71 * k1 + a72 * k2 + a73 * k3 + a74 * k4 +
a75 * k5 + a76 * k6)
stage_limiter!(u_propose, integrator, p, t + dt)
step_limiter!(u_propose, integrator, p, t + dt)

Check warning on line 175 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L174-L175

Added lines #L174 - L175 were not covered by tests

f(k7, u_propose, p, t + dt)

Check warning on line 177 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L177

Added line #L177 was not covered by tests

if integrator.opts.adaptive
@.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde2 * k2 +

Check warning on line 180 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L179-L180

Added lines #L179 - L180 were not covered by tests
btilde3 * k3 + btilde4 * k4 +
btilde5 * k5 + btilde6 * k6 +
btilde7 * k7)
calculate_residuals!(atmp, utilde, uprev, u_propose, integrator.opts.abstol,

Check warning on line 184 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L184

Added line #L184 was not covered by tests
integrator.opts.reltol, integrator.opts.internalnorm, t,
thread)
integrator.EEst = integrator.opts.internalnorm(atmp, t)

Check warning on line 187 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L187

Added line #L187 was not covered by tests
end
return nothing

Check warning on line 189 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L189

Added line #L189 was not covered by tests
end

function finalize_step!(integrator, cache::Tsit5Cache_for_relaxation)
@unpack t, dt, u_propose, u, f, p = integrator
@unpack k7, stage_limiter!, step_limiter!, thread = cache
@.. broadcast=false thread=thread u = u_propose
stage_limiter!(u, integrator, p, t + dt)
step_limiter!(u, integrator, p, t + dt)
f(k7, u_propose, p, t + dt)
integrator.stats.nf += 7

Check warning on line 199 in src/perform_step/test_for_relaxation_perform_step.jl

View check run for this annotation

Codecov / codecov/patch

src/perform_step/test_for_relaxation_perform_step.jl#L192-L199

Added lines #L192 - L199 were not covered by tests
end
Loading
Loading