Skip to content
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

make compiling Jacobian optional #210

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

make compiling Jacobian optional #210

wants to merge 3 commits into from

Conversation

oameye
Copy link
Member

@oameye oameye commented Aug 6, 2024

No description provided.

@oameye
Copy link
Member Author

oameye commented Aug 7, 2024

using BenchmarkTools
using HarmonicBalance;
HB = HarmonicBalance;
# using Plots

@variables α Δ ω0 δ F γ η t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) + η * x^2 * d(x, t) ~
        F * (cos((ω0 + δ - Δ / 2) * t) + cos((ω0 + δ + Δ / 2) * t)),
    x,
)

add_harmonic!(diff_eq, x, ω0 + δ - Δ / 2)
# add_harmonic!(diff_eq, x, ω0 + δ + Δ/2)
# add_harmonic!(diff_eq, x, ω0 + δ)

resolution = 10
δ_range = range(-0.05 * 1.25, 0.01 * 1.25, 10);
fixed ==> 1.25, γ => 0.002, ω0 => 41.140, α => -3.2, η => 0.0078, F => 20)
varied_δF ==> δ_range)

harmonic_eq = get_harmonic_equations(diff_eq)
prob = HB.Problem(harmonic_eq)

swept_parameters = HB.ParameterRange(varied_δF)
fixed_parameters = HB.ParameterList(fixed)
unique_fixed = HB.filter_duplicate_parameters(swept_parameters, fixed_parameters)
J = HB._compile_Jacobian(prob, swept_parameters, unique_fixed)
# @btime HB._compile_Jacobian($prob, $swept_parameters, $unique_fixed) # 71 ms
# result_δF = get_steady_states(harmonic_eq, varied_δF, fixed);
@btime result_δF = get_steady_states($harmonic_eq, $varied_δF, $fixed);

@oameye oameye marked this pull request as draft August 7, 2024 22:32
)

add_harmonic!(diff_eq, x, ω0 + δ - Δ / 2)
add_harmonic!(diff_eq, x, ω0 + δ + Δ/2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
add_harmonic!(diff_eq, x, ω0 + δ + Δ/2)
add_harmonic!(diff_eq, x, ω0 + δ + Δ / 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant