Skip to content

Commit 39518d2

Browse files
authored
fix: get_linear_response docstring (#444)
1 parent ebbb69b commit 39518d2

File tree

11 files changed

+61
-27
lines changed

11 files changed

+61
-27
lines changed

.github/workflows/Documentation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ permissions:
1616
pages: write
1717
id-token: write
1818
statuses: write
19+
pull-requests: read # Required when using `push_preview=true`
1920

2021
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2122
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
1313
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1414
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1515
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
16-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1716
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
1817
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
1918
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

docs/make.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ using SteadyStateDiffEq
1616
TimeEvolution = Base.get_extension(HarmonicSteadyState, :TimeEvolution)
1717
ModelingToolkitExt = Base.get_extension(HarmonicBalance, :ModelingToolkitExt)
1818
SteadyStateDiffEqExt = Base.get_extension(HarmonicSteadyState, :SteadyStateDiffEqExt)
19+
HarmonicBalanceExt = Base.get_extension(HarmonicSteadyState, :HarmonicBalanceExt)
1920

2021
bib = CitationBibliography(
2122
joinpath(@__DIR__, "src", "refs.bib");
@@ -34,6 +35,17 @@ include("make_md_examples.jl")
3435

3536
include("pages.jl")
3637

38+
# Create remotes for Documenter
39+
using Pkg
40+
remotes = Dict()
41+
for ext in [QuestBase, HarmonicSteadyState]
42+
str = string(ext)
43+
status = sprint(io -> Pkg.status(str; io=io))
44+
version = match(r"(v[0-9].[0-9]+.[0-9]+)", status)[1]
45+
gh_moi = Documenter.Remotes.GitHub("QuantumEngineeredSystems", str * ".jl")
46+
remotes[pkgdir(ext)] = (gh_moi, version)
47+
end
48+
3749
makedocs(;
3850
sitename="HarmonicBalance.jl",
3951
authors="Quest group",
@@ -46,6 +58,7 @@ makedocs(;
4658
SteadyStateDiffEqExt,
4759
HarmonicSteadyState.LinearResponse,
4860
PlotsExt,
61+
HarmonicBalanceExt,
4962
],
5063
format=DocumenterVitepress.MarkdownVitepress(;
5164
repo="github.com/QuantumEngineeredSystems/HarmonicBalance.jl",
@@ -54,6 +67,7 @@ makedocs(;
5467
),
5568
checkdocs=:exports,
5669
pages=pages,
70+
remotes=remotes,
5771
source="src",
5872
build="build",
5973
draft=(!CI),

docs/src/examples/cumulants_KPO.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ To compute the steady states of the KPO, we use `HarmonicBalance`. We define the
3636
````@example cumulants_KPO
3737
fixed = (U => 0.001, κ => 0.002)
3838
varied = (Δ => range(-0.03, 0.03, 100), G => range(1e-5, 0.02, 100))
39-
problem_c1 = HarmonicSteadyState.HomotopyContinuationProblem(eqs_completed_RWA, param, varied, fixed)
39+
problem_c1 = HarmonicSteadyState.HomotopyContinuationProblem(
40+
eqs_completed_RWA, param, varied, fixed
41+
)
4042
````
4143

4244
This gives us the phase

docs/src/examples/harmonic_oscillator_KB_vs_HB.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ harmonic_eq = rearrange_standard(harmonic_eq)
2828
````@example harmonic_oscillator_KB_vs_HB
2929
varied = (ω => range(0.1, 1.9, 200)) # range of parameter values
3030
fixed = (ω0 => 1.0, γ => 0.05, F => 0.1) # fixed parameters
31-
result_krylov1 = get_steady_states(krylov_eq1, varied, fixed)
32-
result_krylov2 = get_steady_states(krylov_eq2, varied, fixed)
33-
result_harmonic = get_steady_states(harmonic_eq, varied, fixed);
31+
show_progress = false # show progress bar
32+
result_krylov1 = get_steady_states(krylov_eq1, varied, fixed; show_progress)
33+
result_krylov2 = get_steady_states(krylov_eq2, varied, fixed; show_progress)
34+
result_harmonic = get_steady_states(harmonic_eq, varied, fixed; show_progress);
3435
nothing #hide
3536
````
3637

@@ -80,9 +81,13 @@ plot(
8081
),
8182
plot_linear_response(
8283
result_harmonic, x, 1; Ω_range=range(0.1, 1.9, 200), title="Harmonic"
84+
),
85+
plot_linear_response(
86+
result_harmonic, x, 1; Ω_range=range(0.1, 1.9, 200), title="Exact", order=2
8387
);
84-
layout=(3, 1),
88+
layout=(4, 1),
8589
clims=(0, 250),
90+
size=(800, 600),
8691
)
8792
````
8893

docs/src/examples/state_dependent_perturbation.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Let us load the following packages into our environment:
1111
````@example state_dependent_perturbation
1212
using HarmonicBalance, Plots;
1313
HB = HarmonicBalance;
14+
HSS = HarmonicSteadyState;
1415
crange = (0, 9);
1516
nothing #hide
1617
````
@@ -19,15 +20,15 @@ Later, we will need to classify the solutions of our perturbation. To make this
1920

2021
````@example state_dependent_perturbation
2122
function my_classify_default!(result)
22-
my_classify_solutions!(result, HB.is_physical, "physical")
23-
my_classify_solutions!(result, HB.is_stable, "stable")
24-
return HB.order_branches!(result, ["physical", "stable"]) # shuffle the branches to have relevant
23+
my_classify_solutions!(result, HSS.is_physical, "physical")
24+
my_classify_solutions!(result, HSS.is_stable, "stable")
25+
return HSS.order_branches!(result, ["physical", "stable"]) # shuffle the branches to have relevant
2526
end
26-
function my_classify_solutions!(res::HB.Result, f::Function, name::String)
27+
function my_classify_solutions!(res::HSS.Result, f::Function, name::String)
2728
values = my_classify_solutions(res, f)
2829
return res.classes[name] = values
2930
end
30-
function my_classify_solutions(res::HB.Result, f::Function)
31+
function my_classify_solutions(res::HSS.Result, f::Function)
3132
values = similar(res.solutions, BitVector)
3233
for (idx, soln) in enumerate(res.solutions)
3334
values[idx] = [
@@ -72,8 +73,8 @@ We sweep over the system where we both increase the drive frequency $\omega$ and
7273

7374
````@example state_dependent_perturbation
7475
res = 80
75-
fixed = HB.OrderedDict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005)
76-
varied = HB.OrderedDict((ω => range(0.99, 1.01, res), λ => range(1e-6, 0.03, res)))
76+
fixed = HSS.OrderedDict(ω0 => 1.0, α => 1.0, J => 0.005, γ => 0.005)
77+
varied = HSS.OrderedDict((ω => range(0.99, 1.01, res), λ => range(1e-6, 0.03, res)))
7778
method = TotalDegree()
7879
result_ωλ = get_steady_states(harmonic_normal, method, varied, fixed; show_progress=false);
7980
plot_phase_diagram(result_ωλ; class="stable")
@@ -206,7 +207,7 @@ plot_phase_diagram(result_ωλ_antisym; class=["stable", "not_zero"])
206207
We filter the non-zero amplitude solution and store it in a matrix $A$:
207208

208209
````@example state_dependent_perturbation
209-
branch_mat = findfirst.(HB._get_mask(result_ωλ_antisym, ["stable", "not_zero"], []))
210+
branch_mat = findfirst.(HSS._get_mask(result_ωλ_antisym, ["stable", "not_zero"], []))
210211
A = map(CartesianIndices(result_ωλ_antisym.solutions)) do idx
211212
branch = branch_mat[idx]
212213
if isnothing(branch)
@@ -242,7 +243,7 @@ permutation = first.(
242243
param_ranges = collect(values(varied))
243244
input_array = collect(Iterators.product(param_ranges..., values(fixed)...))
244245
input_array = getindex.(input_array, [permutation])
245-
input_array = HB.tuple_to_vector.(input_array)
246+
input_array = HSS.tuple_to_vector.(input_array)
246247
input_array = map(idx -> push!(input_array[idx], A[idx]...), CartesianIndices(input_array));
247248
nothing #hide
248249
````
@@ -251,8 +252,8 @@ Solving for the steady states of the dressed symmetric mode:
251252

252253
````@example state_dependent_perturbation
253254
function solve_perturbed_system(prob, input)
254-
result_full = HB.ProgressMeter.@showprogress map(input_array) do input
255-
HB.HomotopyContinuation.solve(
255+
result_full = HSS.ProgressMeter.@showprogress map(input_array) do input
256+
HSS.HomotopyContinuation.solve(
256257
prob.system;
257258
start_system=:total_degree,
258259
target_parameters=input,
@@ -261,22 +262,22 @@ function solve_perturbed_system(prob, input)
261262
)
262263
end
263264
264-
rounded_solutions = HB.HomotopyContinuation.solutions.(result_full)
265-
solutions = HB.pad_solutions(rounded_solutions)
265+
rounded_solutions = HSS.HomotopyContinuation.solutions.(result_full)
266+
solutions = HSS.pad_solutions(rounded_solutions)
266267
267268
jacobian = HarmonicBalance.get_Jacobian(harmonic_tmp)
268269
J_variables = cat(prob.variables, collect(keys(varied)), [ua, va]; dims=1)
269-
compiled_J = HB.compile_matrix(jacobian, J_variables; rules=fixed)
270-
compiled_J = HB.JacobianFunction(HB.solution_type(solutions))(compiled_J)
271-
result = HB.Result(
270+
compiled_J = HSS.compile_matrix(jacobian, J_variables; rules=fixed)
271+
compiled_J = HSS.JacobianFunction(HSS.solution_type(solutions))(compiled_J)
272+
result = HSS.Result(
272273
solutions,
273274
varied,
274275
fixed,
275276
prob,
276277
Dict(),
277278
zeros(Int64, size(solutions)...),
278279
compiled_J,
279-
HB.seed(method),
280+
HSS.seed(method),
280281
)
281282
282283
my_classify_default!(result)

docs/src/examples/steady_state_sweep.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ EditURL = "../../../examples/steady_state_sweep.jl"
66

77
````@example steady_state_sweep
88
using HarmonicBalance, SteadyStateDiffEq, ModelingToolkit
9-
using BenchmarkTools, Plots, StaticArrays, OrdinaryDiffEq, LinearAlgebra
9+
using BenchmarkTools, Plots, StaticArrays, LinearAlgebra
10+
using OrdinaryDiffEqRosenbrock, OrdinaryDiffEqTsit5
1011
using HarmonicBalance: OrderedDict
1112
1213
@variables α ω ω0 F γ η t x(t);

docs/src/manual/API.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ Private = false
8989
Order = [:function]
9090
```
9191

92+
```@autodocs
93+
Modules = [Base.get_extension(HarmonicSteadyState, :HarmonicBalanceExt)]
94+
Private = false
95+
Order = [:function]
96+
```
97+
9298
```@docs
9399
HarmonicBalance.get_Jacobian
94100
```

docs/src/manual/linear_response.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ HarmonicSteadyState.LinearResponse.Lorentzian
3434

3535
Setting `order > 1` increases the accuracy of the response spectra. However, unlike for the Jacobian, here we must perform a matrix inversion for each response frequency.
3636

37+
```@autodocs; canonical=false
38+
Modules = [Base.get_extension(HarmonicSteadyState, :HarmonicBalanceExt)]
39+
Private = false
40+
Order = [:function]
41+
```
42+
3743
```@docs; canonical=false
38-
HarmonicSteadyState.LinearResponse.get_linear_response
3944
HarmonicSteadyState.LinearResponse.ResponseMatrix
4045
HarmonicSteadyState.LinearResponse.get_response
4146
```

examples/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
88
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
99
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1010
NonlinearSolveHomotopyContinuation = "2ac3b008-d579-4536-8c91-a1a5998c2f8b"
11-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1211
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
1312
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
1413
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

0 commit comments

Comments
 (0)