AmesimKnowledge

solvers-numerics

Implementation in a submodel

The calculations inside the submodel are slightly modified by the discontinuity handling principle. Since the main objective is the solver convergence, any physical equation must be smoothly extrapolated even out of its domain of application, in order to prevent sharp change in state derivatives.

Figure 12: partial curve extrapolation

Handling discontinuity in a submodel first requires the access to the discontinuity flag. In Component Customization, the option “submodel requires discontinuities flag” must be selected.

Figure 13: Component Customization discontinuity flag option

The result on the generated code is the “flag” integer argument sent to the calculation function.

Copy

void saturation_(int *n, double *y, double *x, double rp[2],
                 int ic[1], int *flag)

The current status of the submodel (equation C1 or C2) must be preserved between consecutive calls to the calculation function. For that reason, it must be stored in a memory place specific for each submodel that can be recovered during the integration. This is the role of “integer stores”. The number of integer stores in Component Customization must be set to a non-zero value.

Figure 14: integer store setting

When the submodel contains some integer stores, an integer array “ic” is added to the argument list of the initialization and calculation functions.

Copy

void saturation_(int *n, double *y, double *x, double rp[2],
                 int ic[1], int *flag)

The following examples are based on a saturation submodel, limiting the input signal x in the range [xmin, xmax]. xmin and xmax are real parameters of the submodel. The curve below is the characteristic curve of the saturation.

The following examples are based on a saturation submodel, limiting the input signal x in the range [xmin, xmax]. xmin and xmax are real parameters of the submodel. The curve below is the characteristic curve of the saturation.

Figure 15: saturation characteristics

The saturation distinguishes 3 different possible working modes.

  • X is higher than xmax

  • X is lower than xmin

  • X is between xmin and xmax.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.TB121_Discontinuity_Handling/xid1849188 · retrieved 2026-07-17