Engee documentation

Initial equations of the physical modeling language Engee

The usual equations are performed throughout the simulation process. Metadata [initial=true] allows you to specify additional equations that are performed only when the model is initialized.

To initialize a system of differential algebraic equations, only the usual component equations are not enough. Consider a system that contains continuous differential variables and continuous algebraic variables. For simulation, this system has degrees of freedom and must contain equations. The initialization task has up to additional unknowns that correspond to derivatives of variables. These additional unknowns can be satisfied when you set target values for block variables. The initial equations are another way to initialize the system.

In general, the maximum number of high priority target values that you can specify is equal to the number of additional unknowns in the initialization task. In addition to the unknowns from the differential variables, in the initialization task there is another unknown for each event variable. These additional unknowns determine the total maximum number of source equations and high priority target values. If there are too many high priority values, all of them cannot be satisfied.

Because by default the key value is initial for equations equal to false when declaring the usual equations, this metadata can be omitted:

@equations [initial=true] begin  # начальные уравнения
  [...]
end

@equations [initial=false] begin # обычные уравнения
  [...]
end

@equations begin # обычные уравнения
  [...]
end

The syntax of the initial equations is the same as that of ordinary equations, except that der(x) in the initial equations, it is considered as an unknown value and is solved during initialization.

When including structures assert In the initial equations, their predicate conditions are checked only once, after solving the initialization problem (before the simulation starts). Use these checks to protect against initializing the model with non-physical values.

Most often, the initial equations are set to initialize the system in steady-state mode, for example:

@engeemodel C begin

    @parameters begin
        a = -5, [unit="1/s"]
        b = -2, [unit="1/s"]
    end

    @outputs begin
        x = 5
        y = 10
    end

    @equations begin
       der(x) ~ a*x + b*y
       der(y) ~ b*y
    end

    @equations [initial=true] begin
       der(x) ~ 0
       der(y) ~ 0
    end

end

At the time of initialization, the equations have the form:

       der(x) ~ 0
       der(y) ~ 0
       der(x) ~ a*x + b*y
       der(y) ~ b*y

For the rest of the simulation, the equations have the form:

       der(x) ~ a*x + b*y
       der(y) ~ b*y