Skip to content

Commit 83b1d73

Browse files
Updates
1 parent d30601e commit 83b1d73

File tree

3 files changed

+18
-56
lines changed

3 files changed

+18
-56
lines changed

benchmarks/DynamicalODE/Henon-Heiles_energy_conservation_benchmark.jmd

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,20 @@ In order to separate these two, we will use `iip` for the in-place names and `oo
1919
using OrdinaryDiffEq, Plots, DiffEqCallbacks
2020
using SciMLBenchmarks
2121
using TaylorIntegration, LinearAlgebra, StaticArrays
22-
23-
# Set plotting formats
2422
gr(fmt=:png)
2523
default(fmt=:png)
2624

2725
T(p) = 1//2 * norm(p)^2
28-
V(q) = 1//2 * (q[1]^2 + q[2]^2 + 2*q[1]^2 * q[2] - 2//3 * q[2]^3)
29-
H(p, q, params) = T(p) + V(q)
26+
V(q) = 1//2 * (q[1]^2 + q[2]^2 + 2q[1]^2 * q[2]- 2//3 * q[2]^3)
27+
H(p,q, params) = T(p) + V(q)
3028

31-
function iip_dq(dq, p, q, params, t)
29+
function iip_dq(dq,p,q,params,t)
3230
dq[1] = p[1]
3331
dq[2] = p[2]
3432
end
3533

36-
function iip_dp(dp, p, q, params, t)
37-
dp[1] = -q[1] * (1 + 2 * q[2])
34+
function iip_dp(dp,p,q,params,t)
35+
dp[1] = -q[1] * (1 + 2q[2])
3836
dp[2] = -q[2] - (q[1]^2 - q[2]^2)
3937
end
4038

@@ -46,7 +44,7 @@ function oop_dq(p, q, params, t)
4644
end
4745

4846
function oop_dp(p, q, params, t)
49-
dp1 = -q[1] * (1 + 2 * q[2])
47+
dp1 = -q[1] * (1 + 2q[2])
5048
dp2 = -q[2] - (q[1]^2 - q[2]^2)
5149
@SVector [dp1, dp2]
5250
end
@@ -58,33 +56,19 @@ function hamilton(du, u, p, t)
5856
dq, q = @views u[3:4], du[3:4]
5957
dp, p = @views u[1:2], du[1:2]
6058

61-
dp[1] = -q[1] * (1 + 2 * q[2])
59+
dp[1] = -q[1] * (1 + 2q[2])
6260
dp[2] = -q[2] - (q[1]^2 - q[2]^2)
6361
dq .= p
6462

6563
return nothing
6664
end
6765

68-
function manifold_jacobian!(J, u)
69-
p, q = u[1:2], u[3:4]
70-
71-
J[1, 1] = p[1]
72-
J[1, 2] = p[2]
73-
74-
J[1, 3] = q[1] + 4 * q[1] * q[2]
75-
J[1, 4] = q[2] + 2 * q[1]^2 - 2 * q[2]^2
76-
77-
J[2:4, :] .= 0
78-
79-
nothing
80-
end
81-
8266
function g(resid, u, p)
8367
resid[1] = H([u[1], u[2]], [u[3], u[4]], nothing) - E
8468
resid[2:4] .= 0
8569
end
8670

87-
const cb = ManifoldProjection(g; nlsolve = (f,u0,p) -> (res = nlsolve(f, u0; ftol=1e-13); res.zero), manifold_jacobian=manifold_jacobian!)
71+
const cb = ManifoldProjection(g, nlopts=Dict(:ftol => 1e-13))
8872
const E = H(iip_p0, iip_q0, nothing)
8973
```
9074

benchmarks/DynamicalODE/Manifest.toml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.10.5"
3+
julia_version = "1.10.4"
44
manifest_format = "2.0"
55
project_hash = "268db6928ccffd4d6f79409a36ddb0a44c29d12b"
66

@@ -385,15 +385,10 @@ version = "6.158.3"
385385
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
386386

387387
[[deps.DiffEqCallbacks]]
388-
deps = ["DataStructures", "DiffEqBase", "ForwardDiff", "Functors", "LinearAlgebra", "Markdown", "NonlinearSolve", "Parameters", "RecipesBase", "RecursiveArrayTools", "SciMLBase", "StaticArraysCore"]
389-
git-tree-sha1 = "19dbd44d18bbfdfcf5e56c99cea9b0ed23df350a"
388+
deps = ["ConcreteStructs", "DataStructures", "DiffEqBase", "DifferentiationInterface", "Functors", "LinearAlgebra", "Markdown", "RecipesBase", "RecursiveArrayTools", "SciMLBase", "StaticArraysCore"]
389+
git-tree-sha1 = "7f700fa4fb6e55f4672f8218ef228107245a2e9d"
390390
uuid = "459566f4-90b8-5000-8ac3-15dfb0a30def"
391-
version = "3.9.1"
392-
393-
[deps.DiffEqCallbacks.weakdeps]
394-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
395-
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
396-
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
391+
version = "4.0.0"
397392

398393
[[deps.DiffEqNoiseProcess]]
399394
deps = ["DiffEqBase", "Distributions", "GPUArraysCore", "LinearAlgebra", "Markdown", "Optim", "PoissonRandom", "QuadGK", "Random", "Random123", "RandomNumbers", "RecipesBase", "RecursiveArrayTools", "ResettableStacks", "SciMLBase", "StaticArraysCore", "Statistics"]
@@ -469,9 +464,9 @@ version = "0.6.16"
469464

470465
[[deps.DispatchDoctor]]
471466
deps = ["MacroTools", "Preferences"]
472-
git-tree-sha1 = "810cae95ca4db1c563be2d7d38fa9b7289d302db"
467+
git-tree-sha1 = "453df2ce2aef7de59c69a56d31dcd2ec3384dd77"
473468
uuid = "8d63f2c5-f18a-4cf2-ba9d-b3f60fc568c8"
474-
version = "0.4.16"
469+
version = "0.4.17"
475470
weakdeps = ["ChainRulesCore", "EnzymeCore"]
476471

477472
[deps.DispatchDoctor.extensions]
@@ -779,9 +774,9 @@ version = "0.73.8+0"
779774

780775
[[deps.GenericLinearAlgebra]]
781776
deps = ["LinearAlgebra", "Printf", "Random", "libblastrampoline_jll"]
782-
git-tree-sha1 = "f47136cac29a9b7a8a88dbce1195394978091edb"
777+
git-tree-sha1 = "c4f9c87b74aedf20920034bd4db81d0bffc527d2"
783778
uuid = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
784-
version = "0.3.13"
779+
version = "0.3.14"
785780

786781
[[deps.GenericSchur]]
787782
deps = ["LinearAlgebra", "Printf"]
@@ -2720,7 +2715,7 @@ version = "0.15.2+0"
27202715
[[deps.libblastrampoline_jll]]
27212716
deps = ["Artifacts", "Libdl"]
27222717
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
2723-
version = "5.11.0+0"
2718+
version = "5.8.0+1"
27242719

27252720
[[deps.libdecor_jll]]
27262721
deps = ["Artifacts", "Dbus_jll", "JLLWrappers", "Libdl", "Libglvnd_jll", "Pango_jll", "Wayland_jll", "xkbcommon_jll"]

benchmarks/DynamicalODE/Quadrupole_boson_Hamiltonian_energy_conservation_benchmark.jmd

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,6 @@ function iip_dq(dq, p, q, params, t)
2929
dq[2] = A * p[2]
3030
end
3131

32-
function manifold_jacobian!(J, u)
33-
p₁, p₂ = u[1], u[2]
34-
q₁, q₂ = u[3], u[4]
35-
36-
q₁_sq = q₁^2
37-
q₂_sq = q₂^2
38-
q_sum_sq = q₁_sq + q₂_sq
39-
40-
J[1,1] = A * p₁
41-
J[1,2] = A * p₂
42-
J[1,3] = A * q₁ + (B/√2) * (3q₂_sq - 3q₁_sq) + D * q₁ * q_sum_sq
43-
J[1,4] = A * q₂ + (B/√2) * 6q₁q₂ + D * q₂ * q_sum_sq
44-
J[2:4,:] .= 0
45-
46-
nothing
47-
end
48-
4932
function iip_dp(dp, p, q, params, t)
5033
dp[1] = -A * q[1] - 3 * B / sqrt(2) * (q[2]^2 - q[1]^2) - D * q[1] * (q[1]^2 + q[2]^2)
5134
dp[2] = -q[2] * (A + 3 * sqrt(2) * B * q[1] + D * (q[1]^2 + q[2]^2))
@@ -84,7 +67,7 @@ function g(resid, u, p)
8467
end
8568

8669
const E = H(iip_p0, iip_q0, nothing)
87-
const cb = ManifoldProjection(g; nlsolve = (f,u0) -> (res = nlsolve(f, u0; ftol=1e-13); res.zero), manifold_jacobian=manifold_jacobian!)
70+
const cb = ManifoldProjection(g, nlopts=Dict(:ftol=>1e-13));
8871
```
8972

9073
For the comparison we will use the following function

0 commit comments

Comments
 (0)