-
-
Notifications
You must be signed in to change notification settings - Fork 224
[WIP] Relaxation through Controller #2283
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
Open
Theozeud
wants to merge
15
commits into
SciML:master
Choose a base branch
from
Theozeud:Relaxation-Controller
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+200
−2
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7abffe8
Relaxation implementation
Theozeud d879fa6
fix
Theozeud 41a7cdd
firsts tests
Theozeud ff3c707
Delete Project.toml
Theozeud da71cb6
Update harmonic_oscillator.jl
Theozeud 890481b
Create non_linear_oscillator.jl
Theozeud f252555
Create non_linear_pendulum.jl
Theozeud 1d9334e
Create time_dependant_harmonic_oscillator.jl
Theozeud eaea1d7
Update controllers.jl
Theozeud d81ef39
Update solve.jl
Theozeud 9dcf394
Create test.jl
Theozeud 3e1e1e3
Update controllers.jl
Theozeud bc348b5
fix test
Theozeud b4d076e
Change the place to update u in controllers to match better with tstops
Theozeud 5529b49
update tests
Theozeud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using OrdinaryDiffEq, DiffEqDevTools, LinearAlgebra | ||
|
||
printstyled("Harmonic Oscillator\n"; bold = true) | ||
|
||
dts = (1 / 2) .^ (6:-1:4) | ||
|
||
f = (u, p, t) -> [-u[2],u[1]] | ||
prob = ODEProblem( | ||
ODEFunction(f; analytic = (u0, p, t) -> [cos(t), sin(t)]), | ||
[1.0, 0.0], | ||
(0.0, 1.0)) | ||
|
||
invariant(x) = norm(x) | ||
|
||
# Convergence with the old method Tsit5() | ||
sim = test_convergence(dts, prob, Tsit5(), adaptive = true) | ||
println("order of convergence of Tsit5 without relaxation : "*string(sim.𝒪est[:final])) | ||
|
||
# Convergence with relaxation with FSAL-R, i.e f(uᵧ,ₙ₊₁) ≈ f(uᵧ,ₙ) + γ ( f(uₙ₊₁) - f(uᵧ,ₙ)) | ||
r = Relaxation(invariant) | ||
sim_relax = test_convergence(dts, prob, Tsit5(); relaxation = r, adaptive = true) | ||
println("order with relaxation with FSAL-R modification: "*string(sim_relax.𝒪est[:final])) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using OrdinaryDiffEq, DiffEqDevTools | ||
|
||
printstyled("Non linear harmonic oscillator\n"; bold = true) | ||
|
||
dts = (1 / 2) .^ (6:-1:4) | ||
|
||
f = (u, p, t) -> [-u[2]/(u[1]^2 + u[2]^2),u[1]/(u[1]^2 + u[2]^2)] | ||
prob = ODEProblem( | ||
ODEFunction(f; analytic = (u0, p, t) -> [cos(t), sin(t)]), | ||
[1.0, 0.0], | ||
(0.0, 1.0)) | ||
|
||
invariant(x) = norm(x) | ||
|
||
# Convergence with the method Tsit5() | ||
sim = test_convergence(dts, prob, Tsit5()) | ||
println("order of convergence of older perform_step! : "*string(sim.𝒪est[:final])) | ||
|
||
# Convergence with relaxation with FSAL-R, i.e f(uᵧ,ₙ₊₁) ≈ f(uᵧ,ₙ) + γ ( f(uₙ₊₁) - f(uᵧ,ₙ)) | ||
r = Relaxation(invariant) | ||
sim = test_convergence(dts, prob, Tsit5(); relaxation = r) | ||
println("order with relaxation with FSAL-R modification: "*string(sim.𝒪est[:final])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using OrdinaryDiffEq, DiffEqDevTools | ||
|
||
printstyled("Non Linear Pendulum\n"; bold = true) | ||
|
||
dts = (1 / 2) .^ (6:-1:4) | ||
|
||
f = (u, p, t) -> [-sin(u[2]), u[1]] | ||
prob = ODEProblem( | ||
f, | ||
[1.0, 0.0], | ||
(0.0, 1.0)) | ||
|
||
invariant(x) = x[1]^2/2 - cos(x[2]) | ||
|
||
test_setup = Dict(:alg => Vern9(), :reltol => 1e-14, :abstol => 1e-14) | ||
|
||
# Convergence with the method Tsit5() | ||
sim = analyticless_test_convergence(dts, prob, Tsit5(), test_setup) | ||
println("order of convergence of older perform_step! : "*string(sim.𝒪est[:final])) | ||
|
||
# Convergence with relaxation with FSAL-R, i.e f(uᵧ,ₙ₊₁) ≈ f(uᵧ,ₙ) + γ ( f(uₙ₊₁) - f(uᵧ,ₙ)) | ||
r = Relaxation(invariant) | ||
sim = analyticless_test_convergence(dts, prob, Tsit5(), test_setup; relaxation = r) | ||
println("order with relaxation with FSAL-R modification: "*string(sim.𝒪est[:final])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using OrdinaryDiffEq, DiffEqDevTools, Test, BenchmarkTools, LinearAlgebra | ||
|
||
f = (u, p, t) -> [-u[2],u[1]] | ||
prob = ODEProblem( | ||
ODEFunction(f; analytic = (u0, p, t) -> [cos(t), sin(t)]), | ||
[1.0, 0.0], | ||
(0.0, 1.0)) | ||
invariant(x) = norm(x) | ||
|
||
r = Relaxation(invariant) | ||
|
||
sol_relax = solve(prob, Tsit5(); relaxation = r) | ||
sol = solve(prob, Tsit5()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using OrdinaryDiffEq, DiffEqDevTools | ||
|
||
printstyled("Time-dependent harmonic oscillator\n"; bold = true) | ||
|
||
dts = (1 / 2) .^ (6:-1:4) | ||
|
||
f = (u, p, t) -> [-(1+0.5 * sin(t))*u[2], (1+0.5 * sin(t))*u[1]] | ||
prob = ODEProblem( | ||
ODEFunction(f; | ||
analytic = (u0, p, t)->[cos(0.5)*cos(t-0.5*cos(t))-sin(0.5)*sin(t-0.5*cos(t)), | ||
sin(0.5)*cos(t-0.5*cos(t))+cos(0.5)*sin(t-0.5*cos(t))]), | ||
[1.0, 0.0], | ||
(0.0, 1.0)) | ||
|
||
invariant(x) = norm(x) | ||
|
||
# Convergence with the method Tsit5() | ||
sim = test_convergence(dts, prob, Tsit5(), adaptative = true) | ||
println("order of convergence of older perform_step! : "*string(sim.𝒪est[:final])) | ||
|
||
# Convergence with relaxation with FSAL-R, i.e f(uᵧ,ₙ₊₁) ≈ f(uᵧ,ₙ) + γ ( f(uₙ₊₁) - f(uᵧ,ₙ)) | ||
r = Relaxation(invariant) | ||
sim = test_convergence(dts, prob, Tsit5(); relaxation = r, adaptative = true) | ||
println("order with relaxation with FSAL-R modification: "*string(sim.𝒪est[:final])) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.