Skip to content

Commit 520049e

Browse files
authored
precompile parametron example (#198)
* precompile parametron example * tag version 0.10.1 * run tests on 1.11 * update CI workflow to use 'pre' version for testing
1 parent bf55b85 commit 520049e

File tree

5 files changed

+63
-5
lines changed

5 files changed

+63
-5
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
strategy:
2525
matrix:
2626
version:
27+
- 'pre'
2728
- '1.10'
2829
# - '1.9'
2930
# - 'nightly'

Project.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HarmonicBalance"
22
uuid = "e13b9ff6-59c3-11ec-14b1-f3d2cc6c135e"
33
authors = ["Jan Kosata <kosataj@phys.ethz.ch>", "Javier del Pino <jdelpino@phys.ethz.ch>", "Orjan Ameye <orjan.ameye@hotmail.com>"]
4-
version = "0.10.0"
4+
version = "0.10.1"
55

66
[deps]
77
BijectiveHilbert = "91e7fc40-53cd-4118-bd19-d7fcd1de2a54"
@@ -17,6 +17,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1717
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1818
Peaks = "18e31ff7-3703-566c-8e60-38913d67486b"
1919
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
20+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2021
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
2122
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
2223
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -39,32 +40,32 @@ BijectiveHilbert = "0.3.0"
3940
DSP = "0.7.9"
4041
DelimitedFiles = "1.9"
4142
Distances = "0.10.11"
42-
Documenter = "1.4"
4343
DocStringExtensions = "0.9.3"
44+
Documenter = "1.4"
4445
ExplicitImports = "1.6"
4546
FFTW = "1.8"
4647
HomotopyContinuation = "2.9"
47-
JLD2 = "0.4.48"
4848
JET = "0.9"
49+
JLD2 = "0.4.48"
4950
Latexify = "0.16"
5051
ModelingToolkit = "9.17"
5152
NonlinearSolve = "3.12"
5253
OrderedCollections = "1.6"
5354
OrdinaryDiffEq = "v6.82"
5455
Peaks = "0.5"
5556
Plots = "1.39"
57+
PrecompileTools = "1.2"
5658
ProgressMeter = "1.7.2"
5759
SteadyStateDiffEq = "2"
5860
SymbolicUtils = "2.0"
5961
Symbolics = "5.30"
60-
6162
julia = "1.10.0"
6263

6364
[extras]
6465
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
66+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
6567
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
6668
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
67-
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
6869
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
6970
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
7071
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"

benchmark/parametron.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using HarmonicBalance
2+
3+
using Random
4+
const SEED = 0xd8e5d8df
5+
Random.seed!(SEED)
6+
7+
@variables Ω γ λ F x θ η α ω0 ω t T ψ
8+
@variables x(t)
9+
10+
natural_equation =
11+
d(d(x, t), t) +
12+
γ * d(x, t) +
13+
Ω^2 * (1 - λ * cos(2 * ω * t + ψ)) * x +
14+
α * x^3 +
15+
η * d(x, t) * x^2
16+
forces = F * cos* t + θ)
17+
dEOM = DifferentialEquation(natural_equation + forces, x)
18+
add_harmonic!(dEOM, x, ω)
19+
20+
@time harmonic_eq = get_harmonic_equations(dEOM; slow_time=T, fast_time=t);
21+
@time prob = HarmonicBalance.Problem(harmonic_eq)
22+
23+
fixed ==> 1.0, γ => 1e-2, λ => 5e-2, F => 0, α => 1.0, η => 0.3, θ => 0, ψ => 0)
24+
varied = ω => range(0.9, 1.1, 20)
25+
@time res = get_steady_states(prob, varied, fixed; show_progress=false)

src/HarmonicBalance.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const HC = HomotopyContinuation
1616
using Plots: Plots, plot, plot!, savefig, heatmap, Plot
1717
using Latexify: Latexify, latexify
1818

19+
using PrecompileTools: @setup_workload, @compile_workload
20+
1921
# default global settings
2022
IM_TOL::Float64 = 1E-6
2123
function set_imaginary_tolerance(x::Float64)
@@ -71,4 +73,14 @@ export get_krylov_equations
7173
include("modules/FFTWExt.jl")
7274
using .FFTWExt
7375

76+
@setup_workload begin
77+
# Putting some things in `@setup_workload` instead of `@compile_workload` can reduce the size of the
78+
# precompile file and potentially make loading faster.
79+
@compile_workload begin
80+
# all calls in this block will be precompiled, regardless of whether
81+
# they belong to your package or not (on Julia 1.8 and higher)
82+
include("precompilation.jl")
83+
end
84+
end
85+
7486
end # module

src/precompilation.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@variables Ω γ λ F x θ η α ω0 ω t T ψ
2+
@variables x(t)
3+
4+
natural_equation =
5+
d(d(x, t), t) +
6+
γ * d(x, t) +
7+
Ω^2 * (1 - λ * cos(2 * ω * t + ψ)) * x +
8+
α * x^3 +
9+
η * d(x, t) * x^2
10+
forces = F * cos* t + θ)
11+
dEOM = DifferentialEquation(natural_equation + forces, x)
12+
add_harmonic!(dEOM, x, ω)
13+
14+
harmonic_eq = get_harmonic_equations(dEOM; slow_time=T, fast_time=t);
15+
prob = HarmonicBalance.Problem(harmonic_eq)
16+
17+
fixed ==> 1.0, γ => 1e-2, λ => 5e-2, F => 0, α => 1.0, η => 0.3, θ => 0, ψ => 0)
18+
varied = ω => range(0.9, 1.1, 20)
19+
res = get_steady_states(prob, varied, fixed; show_progress=false)

0 commit comments

Comments
 (0)