EMI_CanRejectStep (EMI Function)
- Updated2023-03-14
- 1 minute(s) read
EMI_CanRejectStep (EMI Function)
Owning Class: Zero Crossings
Requires: Control Design and Simulation Module
Prototype
char EMI_CanRejectStep(emiRef model);
Description
Checks whether an ordinary differential equation (ODE) solver can reject the current step. A variable step-size ODE solver can reject a time step if the current step size is greater than the minimum step size. Fixed step-size ODE solvers cannot reject time steps. You can call this function only within the EMI_CB_CheckStepAcceptance function.
Inputs
| Name | Description |
|---|---|
| model | Specifies a reference to the external model. Use this reference as an input to other EMI functions. Do not modify model directly. |
Return Value
Returns a non-zero value if the ODE solver can reject the current time step. Otherwise, this function returns 0.
Details
You can use this function to implement a custom algorithm for detecting zero crossings.
Examples
/* pseudo code of a custom algorithm for detecting zero crossings */
void EMI_CB_CheckStepAcceptance(emiRef model) {
if (condition_exists_for_rejection) {
if (EMI_CanRejectStep(model)) {
EMI_RejectStep(model, new_step_size);
}
else {
EMI_RequestCallbackToResetStates(model);
}
}
}
Related Topics
EMI_CB_CheckStepAcceptance
EMI_RejectStep
EMI_RequestCallbackToResetStates