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

BifurcationKit Extension (take 2) #2321

Merged
merged 3 commits into from
Oct 17, 2023
Merged

BifurcationKit Extension (take 2) #2321

merged 3 commits into from
Oct 17, 2023

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Oct 17, 2023

New version of: #2300

Enables this workflow:

using ModelingToolkit
using BifurcationKit

# Define ODEFunction
begin
    @variables t x(t) y(t)
    @parameters μ α
    eqs = [0 ~ μ*x - x^3 + α*y,
           0 ~ -y]
    @named nsys = NonlinearSystem(eqs, [x, y], [μ, α])
end

# Define other bifurcation inputs
begin
    p_span = (-4.0, 6.0)
    bif_par = μ
    plot_var = x
    p_start ==> -1.0, α => 1.0]
    u0_guess = [x => 1.0, y => 1.0]
end

# Creates a BifurcationProblem.
# This dispatch is what is implemented here, then it is BK stuff all the way.
bprob = BifurcationProblem(nsys, u0_guess, p_start, bif_par; plot_var=plot_var, jac=false)

# Sets bifurcation parameters
opt_newton = NewtonPar(tol = 1e-9, max_iterations = 20)
opts_br = ContinuationPar(dsmin = 0.001, dsmax = 0.05, ds = 0.01,
	max_steps = 100, nev = 2, newton_options = opt_newton,
	p_max = p_span[2], p_min = p_span[1],
	detect_bifurcation = 3, n_inversion = 4, tol_bisection_eigenvalue = 1e-8, dsmin_bisection = 1e-9)

# Creates the bifurcation diagram.
bf = bifurcationdiagram(bprob, PALC(), 2, (args...) -> opts_br; bothside=true)

# You can plot the diagram like
using Plots
plot(bf; putspecialptlegend=false, markersize=2, plotfold=false, title = "#branches = $(size(bf))")

@TorkelE
Copy link
Member Author

TorkelE commented Oct 17, 2023

The error seems to be the same one as previously. Not sure about the Project.toml, the version here is the same (ignoring the BifurcationKit parts) as the one in this MTK repo.

@ChrisRackauckas ChrisRackauckas merged commit 285cbac into SciML:master Oct 17, 2023
21 of 33 checks passed
@YingboMa
Copy link
Member

We shouldn't merge unformatted PRs. It's not that hard to run it.

@TorkelE
Copy link
Member Author

TorkelE commented Oct 27, 2023

I thought JuliaFormatter was currently broken, and we were awaiting it to be fixed to run it?

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.

3 participants