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

How to stop continuation after detecting a specified number of branch points? #56

Closed
dchang24 opened this issue May 6, 2022 · 3 comments

Comments

@dchang24
Copy link

dchang24 commented May 6, 2022

I'm not sure if this is the right place to ask this question. If not, please direct me to the appropriate place to ask.

So I'm using continuation to find equilibrium solutions to an ODE. It will go through start_point -> branch1 (a fold point) -> branch2 (another fold point) -> branch3 (a fold point) -> start_point. Due to symmetry of the problem, the first half (start_point->branch1->branch2) is essentially the same as the second half (branch2->branch3->start_point). The solutions are just mirror reflection of the other. Is there a way to force continuation to stop the process after detecting two fold points (ends at branch2) since the second half of the solution is just duplicate of the first?

@rveltz
Copy link
Member

rveltz commented May 6, 2022

Yes, it is possible. The function finaliseSolution in the options of continuation allows to stop the continuation.

You can pass something like (not tested)

finaliseSolution = (z, tau, step, contResult; kwargs...) -> begin
    # contResult is the current branch
    # number of fold points
    nbfold = sum(x -> x.type==:fold, contResult.specialpoint)
   return nbfold < 3 # condition to continue the computation of the branch
end

@dchang24
Copy link
Author

dchang24 commented May 6, 2022

Thanks. I managed to get it work with the above code after making some slight modifications:

finaliseSolution = (z, tau, step, contResult; kwargs...) -> begin

    if length(contResult.specialpoint) > 0  # next line throws error if it is empty
        nbfold = sum(x -> x.type==:fold, contResult.specialpoint)
        return nbfold < 2  # I want to stop right after finding the 2nd fold point
    else
        return true
    end
end

@dchang24 dchang24 closed this as completed May 6, 2022
@rveltz
Copy link
Member

rveltz commented May 6, 2022

great!

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

No branches or pull requests

2 participants