[Python] scipy solve_ivp event gives result but does not terminate the simulation

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am experiencing some problems with events in scipy solve_ivp. The event is triggered, and I can get the event times from the results, but somehow the simulation is not terminated and result.status does not change. Maybe someone can give me some pointers what to try or has experienced the same problem and found a solution?

    result.t_events: [array([11.77036535, 13.83038927])]

    result.status: 0

    def tester(t, y, cond1, cond2):
    if y[3] > cond1 and max(y) > cond2:
    val = cond2 - max(y)
    else:
    val = 1
    return val

    tester.terminal = True
    tester.direction = -1

    result = solve_ivp(fun = lambda t, y: func(t,y, para_dict), t_span = tspan, y0 = InitialValues, method = "RK45", dense_output = True, events = lambda t, y: tester(t, y, cond1, cond2))

    print(result.t_events)
    print(result.status)

    Continue reading...

Compartilhe esta Página