Borrar filtros
Borrar filtros

Enforcing values in ODE solver

2 visualizaciones (últimos 30 días)
Pulkit
Pulkit el 27 de Feb. de 2024
Comentada: Pulkit el 29 de Feb. de 2024
I am trying to solve a stiff ode with ode15s. There is a variable for which there exists a physical constraint due to which it cannot exceed a certain maximum (the allowed maximum also changes with other variables).
I could use events to stop the ode integration and reset the variable but there is a regime where the event persists for some time so, I don't know if exiting the solver each time after just one iteration is efficient.
I also tried using global variables, so that I can always manually control it but then it becomes unphysical when solver rejects a step and goes back.
Is there a way to apply the constraint within the solver? Is there some other solver that could help or would it be better to write one by myself?
Thanks!
  1 comentario
Torsten
Torsten el 28 de Feb. de 2024
Editada: Torsten el 28 de Feb. de 2024
I could use events to stop the ode integration and reset the variable but there is a regime where the event persists for some time so, I don't know if exiting the solver each time after just one iteration is efficient.
This is only possible if you define the event as a discontinuous function, and this is not allowed. An allowed event function has a zero crossing without remaining in the state.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Feb. de 2024
Use events, and remember that events are only detected when a value crosses the trigger, and are not detected when the system starts in that state.
  1 comentario
Pulkit
Pulkit el 29 de Feb. de 2024
Oh in that case, I don't think i can make use of built in solvers. The variable reaching a maximum is not a one-time event but a whole regime that would persist for some time. Thanks for the reply.

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by