Skip to content

Allowing affect! to set values on a time interval instead of at a time point #245

@WenyinWei

Description

@WenyinWei

Is your feature request related to a problem? Please describe.

Hi, everyone, DifferentialEquations.jl is awesome and efficient. I am trying to implement an affect! function to set values u[i] on a time interval instead of a single time point so that the delay differential equation module can work when I introduce, during integration, new particles whose history can be set by the callback function. Thanks a lot if you can consider making it possible to allow an affect! function to influence the state values of an integrator on a time interval, or if you have any other elegant workarounds to solving this.

Describe the solution you’d like

Instead of setting values only at one time point by a usual affect! function,

function affect!(integrator)
    integrator.u[2] = -integrator.u[2]
end

set its values for a whole time interval:

function affect!(integrator)
    #  here integrator is a DDE one (delay differential equation integrator) or others
    for integrator.t in a custom time span, e.g. [the timepoint of callback - 1.0, the timepoint of callback]:
        integrator.u .= (some custom function)
    end
end

Describe alternatives you’ve considered

Repeatedly invoke a one-time affect! in the time interval, but this probably has too much overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions