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

Adding an additional Callback function #146

Closed
lakshaya17 opened this issue Jan 15, 2024 · 1 comment
Closed

Adding an additional Callback function #146

lakshaya17 opened this issue Jan 15, 2024 · 1 comment
Labels

Comments

@lakshaya17
Copy link

lakshaya17 commented Jan 15, 2024

Hey,

I am trying to add one or two more callback functions for a 3D model. I am considering the stopping condition to be x and y are equal to zero or all x, y ,z are equal to zero. For some reason, I am not able to get results. Should it be like the following code?

condition_1(u, t, integrator) = u[1]
cb_1 = ContinuousCallback(condition_1, terminate!)

condition_2(u, t, integrator) = u[2] 
cb_2 = ContinuousCallback(condition_2, terminate!)

# condition_3(u, t, integrator) = u[3]
# cb_3 = ContinuousCallback(condition_3, terminate!)

cb_p = CallbackSet(cb_1, cb_2)
# cb_p = CallbackSet(cb_1, cb_2, cb_3)

Also, what if I want to make all 6 states equal to zero? For example, when x = 0 then x_dot = 0.

In anticipation of your reply.

Regards

@ChrisRackauckas
Copy link
Member

I am considering the stopping condition to be x and y are equal to zero or all x, y ,z are equal to zero.

Inside of the affect! function, just check that the other value is sufficiently close to zero. You only need one condition for that. What you wrote there is x or y or z is zero.

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

No branches or pull requests

2 participants