Skip to content

Commit

Permalink
export the limit cycle module (#192)
Browse files Browse the repository at this point in the history
* export the limit cycle module

* add commented test
  • Loading branch information
oameye authored Jun 14, 2024
1 parent 437fc05 commit a1c2c61
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/HarmonicBalance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export plot_linear_response, plot_rotframe_jacobian_response

include("modules/LimitCycles.jl")
using .LimitCycles
export get_cycle_variables
export add_pairs!
export get_limit_cycles

include("modules/KrylovBogoliubov.jl")
using .KrylovBogoliubov
Expand Down
6 changes: 5 additions & 1 deletion src/modules/LimitCycles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ using DocStringExtensions
include("LimitCycles/gauge_fixing.jl")
include("LimitCycles/analysis.jl")

end
export get_cycle_variables
export add_pairs!
export get_limit_cycles

end
3 changes: 0 additions & 3 deletions src/modules/LimitCycles/gauge_fixing.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export get_cycle_variables
export add_pairs!

using HarmonicBalance: is_rearranged, rearrange_standard, _remove_brackets
using HarmonicBalance.LinearResponse: get_implicit_Jacobian, get_Jacobian
import HarmonicBalance: is_stable, is_physical, is_Hopf_unstable, order_branches!,
Expand Down
32 changes: 29 additions & 3 deletions test/limit_cycle.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HarmonicBalance
import HarmonicBalance.LinearResponse.plot_linear_response
import HarmonicBalance.LimitCycles.get_limit_cycles


@testset "van der Pol oscillator " begin
Expand All @@ -16,13 +15,40 @@ import HarmonicBalance.LimitCycles.get_limit_cycles
HarmonicBalance.LimitCycles._choose_fixed(harmonic_eq, ω_lc)

fixed = ();
varied = μ => range(1, 5, 5)
varied = μ => range(2, 3, 2)

result = get_limit_cycles(harmonic_eq, varied, fixed, ω_lc; show_progress=false, seed=SEED)

@test sum(any.(classify_branch(result, "stable"))) == 4
@test sum(any.(classify_branch(result, "unique_cycle"))) == 1

plot(result, y="ω_lc")
plot_linear_response(result, x, branch=1, Ω_range=range(0.9, 1.1, 2), order=1)
plot_linear_response(result, x, branch=1, Ω_range=range(2.4, 2.6, 2), order=1)
end

# takes to long
# @testset "coupled modes" begin
# @variables F, ω, ω_lc, t, x(t), y(t)

# eqs = [d(x,t,2) + 1.0^2*x - x^3 - 0.006*y ~ F*cos(ω*t),
# d(y,t,2) + 1.005^2*y - y^3 - 0.006*x ~ 0]

# # differential equations
# diffeq = DifferentialEquation(eqs, [x,y])

# # specify the harmonic ansatz for x and y: x = u(T) cos(ωt) + v(T) sin(ωt)
# add_harmonic!(diffeq, x, ω)
# add_harmonic!(diffeq, y, ω)
# add_harmonic!(diffeq, x, ω + ω_lc)
# add_harmonic!(diffeq, y, ω + ω_lc)
# add_harmonic!(diffeq, x, ω - ω_lc)
# add_harmonic!(diffeq, y, ω - ω_lc)

# harmonic_eq = get_harmonic_equations(diffeq);

# fixed = (F => 0.0015)
# varied = (ω => range(0.992, 0.995, 2))

# # results
# result = get_limit_cycles(harmonic_eq, varied, fixed, ω_lc; threading=true)
# end

0 comments on commit a1c2c61

Please sign in to comment.