Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method

Lecture



Perform the construction of a model of a dynamic system in the form of differential equations and its calculation by the Euler method using an example.

Example. Let the system of two material bodies A and B with different thermal properties be investigated (see fig. 11.1). The system is in contact with a support with a temperature T p and placed in an external environment with a temperature T c . Interested in the process of changing the temperature of bodies.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.1. System interacting
bodies in the problem of heat conduction

As can be seen, in the course of life in the system, four indicators change (may change): the temperatures of bodies A , B , T с , T p . This means that we are dealing with four time-dependent variables (since variables change their values ​​with time). We introduce these variables: X 1 ( t ), X 2 ( t ), X 3 ( t ), X 4 ( t ).

To build a mathematical model of this system, we reflect the heat transfer process in the form of a dependency graph (Fig. 11.2).

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.2. Dependency graph
system variables

If we mean the variables X 1 ( t ), X 2 ( t ), X 3 ( t ), X 4 ( t ), then the graph will look like it is shown in Fig. 11.3.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.3. Dependency graph
model variables

The arrow from A to B denotes the change in temperature X 2 ( t ) of object B under the influence of object A. It is clear that a row of arrows (for example, from B to T c , from A to T p , etc.) is absent, that is, there is no effect of some parameters on others: body B is not able to heat the open atmosphere significantly, and body A - massive and potentially endless support. Strictly speaking, there is such an influence, but it is so insignificant that it is reasonable to neglect it.

Since there are four variables, we need at least four laws describing their change. In general terms, considering which variables each indicator depends on, we get:

  • for body A, we have the dependence of temperature X 1 ( t ) on body temperature B and the temperature of the atmosphere T с : d X 1 ( t ) / d t = f 1 ( X 2 ( t ), X 3 ( t ));
  • for body B we have the dependence of temperature X 2 ( t ) on body temperature A , temperature of the atmosphere T с and supports T п : d X 2 ( t ) / d t = f 2 ( X 1 ( t ), X 3 ( t ), X 4 ( t )).

The arrows in the corresponding circle indicate the number of influencing parameters, and where they come from determines the specific names of the variables.

For the environment, the law has the form: X 3 ( t ) = const, that is, the atmosphere temperature T с does not depend on the other components of this system and, accordingly, does not change. For a support, the law has the form: X 4 ( t ) = const, that is, the support temperature T n does not depend on the other components of this system and, accordingly, does not change.

The system of laws in the first approximation is formed. It remains to determine their specific form: to reveal what the values ​​of the expressions f 1 and f 2 are . Since we are dealing with a system that depends on its past behavior at each subsequent step, we used differential equations to describe it .

The basic dynamic law for describing the change of a variable (the equation of motion) is:

d X ( t ) / d t = w ( x ( t ), y ( t ), z ( t ), ...).

The physical meaning of the recording is as follows. The derivative on the left side of the equation, by definition, shows how much X changes with a change in time t . In engineering, such a change is called speed, pace, trend. So, to write the law of variable change in differential equations, you must specify the rate of change of variables.

First consider the first equation:

d X 1 ( t ) / d t = f 1 ( X 1 ( t ), X 2 ( t ), X 3 ( t )).

The appearance of X 1 on the right side means that the rate of temperature change depends on its own state of the body. What is f 1 ? Is a function that binds the variables X 1 , X 2 , X 3 to each other. That is, the variables are connected to each other by operation signs.

Take a look at the graph in fig. 11.3. What pairs of variables interact? The arrows connect X 1 ( t ) with X 2 ( t ), X 1 ( t ) with X 3 ( t ), that is, there are two processes that affect speed. We consider the heat transfer processes of bodies. It is known that the two processes of heat transfer are independent, that is, they do not control each other. This means that the results of the two processes can be added, they seem to overlap each other. Indeed, the heat transferred from one body is added to the heat transferred from the other. Thus, we have:

d X 1 ( t ) / d t = g 1 ( X 1 ( t ), X 2 ( t )) + g 2 ( X 1 ( t ), X 3 ( t )).

We reveal the structure of the remaining expressions g 1 and g 2 . It is very convenient that g 1 does not depend on g 2 in any way and can be considered separately. This separation is possible because the processes g 1 and g 2 are independent. Process g 1 goes on regardless of whether or not process g 2 goes on . Process independence and linearity (additivity) of expressions are related concepts. So: since the processes g 1 and g 2 are independent, we forget for some time g 2 .

What mark should be placed between X 1 ( t ) and X 2 ( t ) in the expression g 1 ? Possible options:

X 1 ( t ) + X 2 ( t );
X 2 ( t ) - X 1 ( t );
X 1 ( t ) - X 2 ( t );
X 1 ( t ) · X 2 ( t );
X 1 ( t ) / X 2 ( t );
X 2 ( t ) / X 1 ( t );
X 1 ( t ) ^ X 2 ( t );
X 2 ( t ) ^ X 1 ( t )

and further more complex, for example, X 1 2 ( t ) · cos ( X 2 ( t )) / exp ( X 1 ( t )). The researcher will start with the most simple expressions - nature is simple. And only if the simplest expressions do not satisfy the researcher, he proceeds to more complex versions of the description.

What was just said above was elevated in system engineering to the rank of the principle: “do not introduce entities without need” (Occam's principle).

So, let: d X 1 ( t ) / d t = X 1 ( t ) + X 2 ( t ). What are the quality options for this physical system?

  • X 1 ( t )> X 2 ( t ). Body A is warmer than body B. Heat flow upon contact of two bodies is directed from A to B. Body A transfers heat to body B. That is, in the process of contact, the value of X 1 ( t ) falls - decreases. (We are interested in the future namely X 1 ( t ), and not X 2 ( t ) - see the equation: d X 1 ( t ) / d t ). Let us see whether this is so in the hypothesis equation d X 1 ( t ) / d t = X 1 ( t ) + X 2 ( t )? The sum X 1 ( t ) + X 2 ( t ) can take both positive and negative values, therefore, the value of d X 1 ( t ) / d t can also be both positive and negative, and this, in turn , means that X 1 ( t ) either grows or falls. But this contradicts the physical picture, which was considered just above: we concluded that, under the condition X 1 ( t )> X 2 ( t ), X 1 ( t ) can only decrease. Therefore, the variant of the hypothesis d X 1 ( t ) / d t = X 1 ( t ) + X 2 ( t ) is unacceptable and it is necessary to try another one.

Now let d x 1 ( t ) / dt = X 2 ( t ) - X 1 ( t ). What are the quality options for this physical system?

  • X 1 ( t )> X 2 ( t ). Body A is warmer than body B. Heat flow upon contact of two bodies is directed from A to B. Body A transfers heat to body B. That is, in the process of contact, the value of X 1 ( t ) falls - decreases. Let's see if this is in the equation? X 1 ( t )> X 2 ( t ), that is, X 2 ( t ) - X 1 ( t ) <0, therefore, d X 1 ( t ) / d t <0, therefore, X 1 ( t ) falls . The conclusion does not contradict the physical picture. So, while this option is acceptable and it is necessary to check it on other quality situations.
  • X 1 ( t ) < X 2 ( t ). Body A is colder than body B. The heat flow from the contact of two bodies is directed from B to A. That is, in the process of contact, the value of X 1 ( t ) increases - increases. Let's see if this is in the equation? X 1 ( t ) < X 2 ( t ), that is, X 2 ( t ) - X 1 ( t )> 0, therefore, d X 1 ( t ) / d t > 0, therefore, X 1 ( t ) grows . The conclusion does not contradict the physical picture. So, while this option is acceptable and it is necessary to check it further.
  • X 1 ( t ) = X 2 ( t ). Body temperature A is equal to body temperature B. The heat flux at the contact of two bodies is zero. That is, the value of X 1 ( t ) does not change - the body A does not give up and does not receive heat. Let's see if this is in the equation? X 1 ( t ) = X 2 ( t ), therefore, X 2 ( t ) - X 1 ( t ) = 0, therefore, d X 1 ( t ) / d t = 0, therefore, X 1 ( t ) is not is changing. The conclusion does not contradict the physical picture. This means that this option is accepted, since it correctly (so far only qualitatively!) Reflects the physical picture in all cases.

There are no other options for the existence of the system, and consideration ends.

Having forgotten for some time about g 1 , it is also possible to consider g 2 , which is proposed to be done by the reader independently. In the end, we get:

d X 1 ( t ) / d t = ( X 2 ( t ) - X 1 ( t )) + ( X 3 ( t ) - X 1 ( t )).

Further. Since, firstly, for different materials the temperature difference affects the rate of change in body temperature in a different way and, secondly, the speed of the two processes (for two different pairs of materials) can be different, then we correct the model using the coefficient of thermal conductivity, which plays the role of the amplifier (attenuator) processes. This is the coefficient of influence of communication on the object. When K = 0, there is no influence, communication is disabled. At K = 0.0001, the effect is weak. With K = 1000, the effect of communication is enormous. It is clear that the coefficient is in the process expression: K ? ( X 2 ( t ) - X 1 ( t )), where « ? "Means the sign of some operation, namely, the multiplication operation. This operation gives the dependence of one member on the other (in our case, K on X 2 ( t ) - X 1 ( t )).

When K = 0, whatever value the expression X 2 ( t ) - X 1 ( t ) takes , the result K · ( X 2 ( t ) - X 1 ( t )) gives 0. At K = 0.1, the value of the expression is forcibly weakened 10 times. The same is true of the expression X 2 ( t ) - X 1 ( t ) - this is natural, because the general expression K · ( X 2 ( t ) - X 1 ( t )) is symmetrical. This means that the multiplicative connection models the property of nonlinearity and interdependence of processes (one can negate the action of the other). Addition does not possess such a property.

As a result, the model has the form:

d X 1 ( t ) / d t = K 21 · ( X 2 ( t ) - X 1 ( t )) + K 31 · ( X 3 ( t ) - X 1 ( t )).

At the end, check the dimensions of the equation; the dimension of the left side must coincide with the dimension of the right. We only recall that the derivative has the dimension of the index X divided by the unit of time.

Now we are able to synthesize similarly the second equation (we recommend checking the correctness of this equation on our own):

d X 2 ( t ) / d t = K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t )).

The equation for changing the temperature of the atmosphere: d X 3 ( t ) / d t = 0. That is, X 3 = const ( X 3 does not change).

The equation for the temperature of the support: d X 4 ( t ) / d t = 0. That is, X 4 = const ( X 4 does not change).

The entire system of equations in the collection has the form:
d X 1 ( t ) / d t = K 21 · ( X 2 ( t ) - X 1 ( t )) + K 31 · ( X 3 ( t ) - X 1 ( t ));
d X 2 ( t ) / d t = K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t ));
d X 3 ( t ) / d t = 0;
d X 4 ( t ) / d t = 0.

For physical reasons, it is clear: how much heat flows from A to B , as much heat flows to B from A , that is, K 21 = K 12 .

It remains to add specific values ​​of thermal conductivity coefficients ( K 12 = K 21 , K 31 , K 32 , K 42 ) and the initial state of the system to the record of the general model:

X 1 (0) = a ,
X 2 (0) = b ,
X 3 (0) = c ,
X 4 (0) = d ,

where a , b , c , d are numbers indicating the temperature of the corresponding object at time t = 0.

Thus, a system of ordinary differential equations in the canonical form of the only independent time variable is constructed.

SYSTEM - because there are several equations.
ORDINAL - the derivative is ordinary, not private, because one time variable is used.
DIFFERENTIAL - an expression for the derivative dX / dt is found in the equation.
EQUATIONS - in expressions there is an equalization sign.
In canonical form , the derivative does not stand under the sign of any function; it occurs once and only in the left side of the equation. On the right side, there are no derivatives.
The ONLY one is the variable by which the derivative is taken, one in all equations (time t).
INDEPENDENT VARIABLE - the variable t no longer depends on any variables and changes by itself.

ANY DYNAMIC SYSTEM CAN BE LEAD TO THIS VIEW!

Important note. The work done above to confirm the hypotheses contained in the model of this example, of course, does not prove the absolute correctness of the adopted model. Checks can be continued. If at the next test the hypothesis is rejected, then the model should be clarified again . One of the additional checks may be, for example, checking for openness of the system. Perform this check.

Note that above we got an open system , that is, one whose total heat is not constant, but may change. This is evident from the asymmetry of the arrows on the graph. Let us check this fact mathematically, formally, for which we add the left sides of all equations and, separately, the right sides. On the left we have the following:

d X 1 ( t ) / d t + d X 2 ( t ) / d t + d X 3 ( t ) / d t + d X 4 ( t ) / d t

or

d ( X 1 ( t ) + X 2 ( t ) + X 3 ( t ) + X 4 ( t )) / d t

or

d X systems ( t ) / d t .

On the right side we have the following:

K 21 · ( X 2 ( t ) - X 1 ( t )) + K 31 · ( X 3 ( t ) - X 1 ( t )) + K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t ))

or (given that K 21 = K 12 )

K 31 · ( X 3 ( t ) - X 1 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t )) .

And finally, together:

d X of the system ( t ) / d t = K 31 · ( X 3 ( t ) - X 1 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t )),

which means that the left side is clearly non-zero and there is a leak or heat influx into the system from the outside.

In the case of a closed system, the equations would be:
d X 1 ( t ) / d t = K 21 · ( X 2 ( t ) - X 1 ( t )) + K 31 · ( X 3 ( t ) - X 1 ( t ));
d X 2 ( t ) / d t = K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t ));
d X 3 ( t ) / d t = K 13 · ( X 1 ( t ) - X 3 ( t )) + K 23 · ( X 2 ( t ) - X 3 ( t )) + K 43 · ( X 4 ( t ) - X 3 ( t ));
d X 4 ( t ) / d t = K 24 · ( X 2 ( t ) - X 4 ( t )) + K 34 · ( X 3 ( t ) - X 4 ( t )).

When added, this gives: d X of the system ( t ) / d t = 0 is the equation of a closed system into which nothing flows from outside and from which nothing flows. Although changes occur within the system (redistribution of heat), the total temperature of the system is unchanged. Neither the first model (open system model) nor the second model (closed system model) are “bad”. Simply achieved various goals, given the different views of the researcher about the processes of the system as a whole.

The dynamic system , which we considered above, is a general case. It is very important that you can always get a static system out of it , for which you need to demand: X i ( t + Δ t ) = X i ( t ), with the result that we have: d X i ( t ) / d t = 0. In other words, the entry X i ( t + Δ t ) = X i ( t ) means that the past is equal to the present, that is, the state of the system does not change. Then from the equations remains:
K 21 · ( X 2 ( t ) - X 1 ( t )) + K 31 · ( X 3 ( t ) - X 1 ( t )) = 0
K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t )) = 0

These are static equations.

After building the base system, the researcher may introduce additional structural elements into the system of bodies. Add, for example, a heater (see fig. 11.4).

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.4. System of interacting bodies
with a weak heater in the heat conduction problem

The graph will change, since an additional object - a heater will act on the body B. Denote its temperature by the variable X 5 ( t ) (see fig. 11.5).

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.5. Dependency graph of variables
weak heater models

Changes in the record will apply only to the second equation describing the change in the variable X 2 over time. In addition, we need the heater equation, since an additional variable X 5 ( t ) (the top of the graph) has appeared in the system and the law of its change must be determined.

When writing the equation, it is necessary to distinguish whether the heat source is weak or strong.

We first consider the hypothesis of a weak source. Pay attention: if the heater warms more strongly than body B , then, of course, body B heats up from the heater, but if the heater at some moment turns out to be colder than body B , then body B itself gives off heat to the heater, strange as it may seem nor seemed to.

Since such a source of energy can not only heat up other bodies, but also heat itself from them, it is called weak. That is, the services of such an energy source can be waived, since it is in an equal position with other bodies, can influence them and may experience their influence. Other bodies cannot influence a strong source, and it itself - can influence them, BINDING THEM TO I WILL WILL OF CERTAINLY.

It is clear that in the equation for body B there will appear an additional term similar to the previously considered ones:

d X 2 ( t ) / d t = K 12 · ( X 1 ( t ) - X 2 ( t )) + K 32 · ( X 3 ( t ) - X 2 ( t )) + K 42 · ( X 4 ( t ) - X 2 ( t )) + K 52 · ( X 5 ( t ) - X 2 ( t )).

The equation of the heater can be written as:

d X 5 ( t ) / d t = ( K · U ( t ) - X 5 ( t )) / L + K 25 · ( X 2 ( t ) - X 5 ( t )),

where U ( t ) is the supply voltage of the source.

The initial conditions X 5 (0) and the source function U ( t ) must be specified:

X 5 (0) = h ,
U ( t ) = f ( t ).

The equation relates the cause (voltage of the power supply) and the effect (temperature of the heater). The properties of this element are such that when entering the operating mode, the heater maintains a constant temperature. When the heater is turned on, the working temperature is set over time, gradually increasing, when the source is turned off, the heater gradually cools down. It is obvious that the process of heating and cooling the heater is inertial. In fact, to describe these properties of the heater, it suffices to write down the aperiodic law ( which we discussed earlier in lecture 04) of the change in its temperature X 5 ( t ) with respect to the input U ( t ), which we did. The equation takes into account the gain K between the input U ( t ) and the output X 5 ( t ), the inertia of the heating process L and the heat transfer coefficient K 25 between the bodies X 2 ( t ) and X 5 ( t ).

Now consider the hypothesis of a strong heater. Это случай, когда нагреватель устроен таким образом, что излученная им энергия не может отразиться телом B , или если энергия от тела B не может попасть к нагревателю, или если тело B не может «отказаться» от услуг нагревателя (см.рис. 11.6).

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.6. Система взаимодействующих тел
с сильным нагревателем в задаче теплопроводности

In fig. 11.7 изображен граф зависимостей для данного случая.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.7. Граф зависимости переменных
модели с сильным нагревателем

Обратите внимание: неважно, нагрет ли нагреватель сильнее тела B или нет — тело B будет получать от него энергию в любом случае, причем, в том объеме, в каком эту энергию будет выделять нагреватель. В уравнении тела B появится дополнительное слагаемое:

d X 2 ( t )/d t = K 12 · ( X 1 ( t ) – X 2 ( t )) + K 32 · ( X 3 ( t ) – X 2 ( t )) + K 42 · ( X 4 ( t ) – X 2 ( t )) + K 52 · X 5 ( t ).

Уравнение нагревателя может быть записано так:

d X 5 ( t )/d t = f ( t ).

Начальные условия X 5 (0) и функция работы источника f ( t ) должны быть заданы:

X 5 (0) = h .

Но вернемся к расчету движения во времени динамической системы, для которой есть все необходимые данные, есть начальное состояние ( X i (0) = const). Можно по формулам (с использованием метода Эйлера, см. лекцию 10) вычислить скорость ее изменения и новое состояние:

новое состояние := старое состояние + скорость · отрезок времени .

Формально эта запись выглядит так:

d x ( t )/d t = f ( x ( t ))

или (в дискретной форме)

[ x ( t + Δ t ) – x ( t )]/Δ t = f ( x ( t ))

и, окончательно,

x ( t + Δ t ) = x ( t ) + f ( x ( t )) · Δ t .

Зная новое состояние и считая его уже достигнутым, то есть старым состоянием , используем ту же формулу (подставляя, конечно, в нее уже новые значения). И так продолжаем, прибавляя все новый отрезок времени, двигаясь во времени.

Итак, мы перешли к вопросу о методе расчета дифференциальных моделей. Методом решения дифференциальных уравнений, в общем случае, является интегрирование их по независимой переменной времени t . Простейшим методом численного интегрирования дифференциальных уравнений является метод Эйлера (см. лекцию 10).

Обратите внимание. При вычислении по методу Эйлера необходимо вычислять значения всех параметров системы параллельно , так как производная в каждый момент времени отдельного параметра зависит как от значения самого параметра в данный момент времени, так и от значения другого параметра в этот момент времени.

Рассмотрим практически применение метода Эйлера для расчета процесса изменения температур тел системы. Зададим значения коэффициентов модели: K 12 = K 21 = 0.2, K 31 = 0.1, K 32 = 0.05, K 42 = 0.1. Зададим начальные условия системы (в момент времени t = 0): X 1 (0) = 30° C, X 2 (0) = 70° C, X 3 (0) = 22° C, X 4 (0) = 15° C. Выбираем шаг моделирования Δ t равный, например, 0.2 с. Примем конечное значение времени моделирования за T k = 4 с.

Подставим значения коэффициентов:
X 1 ( t + Δ t ) = X 1 ( t ) + [0.2 · ( X 2 ( t ) – X 1 ( t )) + 0.1 · (22 – X 1 ( t ))] · Δ t
X 2 ( t + Δ t ) = X 2 ( t ) + [0.2 · ( X 1 ( t ) – X 2 ( t )) + 0.05 · (22 – X 2 ( t )) + 0.1 · (15 – X 2 ( t ))] · Δ t

и приступаем к моделированию. Процесс моделирования и численные значения отражены в табл. 11.1.

Table 11.1.
Таблица расчета изменения значений
переменных системы во времени
t d X 1 ( t )/d t d X 2 ( t )/d t X 1 ( t ) X 2 ( t )
0.0 7.20 –15.90 thirty 70
0.2 6.13 –14.50 31.44 66.82
0.4 5.18 –13.24 32.67 63.92
0.6 4.34 –12.10 33.70 61.27
0.8 3.60 –11.08 34.57 58.85
1.0 2.94 –10.16 35.29 56.63
1.2 2.36 –9.33 35.88 54.60
1.4 1.84 –8.59 36.35 52.74
1.6 1.39 –7.91 36.72 51.02
1.8 0.99 –7.30 37.00 49.44
2.0 0.64 –6.75 37.19 47.97
2.2 0.33 –6.25 37.32 46.62
2.4 0.06 –5.80 37.39 45.37
2.6 –0.18 –5.39 37.40 44.21
2.8 –0.38 –5.02 37.36 43.13
3.0 –0.56 –4.69 37.29 42.13
3.2 –0.71 –4.38 37.18 41.19
3.4 –0.85 –4.10 37.03 40.31
3.6 –0.96 –3.85 36.86 39.49
3.8 –1.06 –3.62 36.67 38.72
4.0 –1.14 –3.41 36.46 38.00

Во времени поведение системы будет выглядеть так, как показано на рис. 11.8.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.8. Расчетные траектории поведения
системы тел в задаче теплопроводности

Заметим, что на рис. 11.8 показана не вся траектория, а только ее часть. Рассчитайте всю траекторию, подумайте и ответьте на следующие вопросы:

  • почему графики в итоге при большом времени рассмотрения стремятся к числу 18.5;
  • почему значение переменной X 1 сначала увеличивается, а потом падает;
  • почему графики имеют переломы производных;
  • что надо изменить в условиях задачи, чтобы график X 1 все время убывал?

В зависимости от реализации «машины», на которой автоматически будет имитироваться процесс, запись может выглядеть по-разному.

Формальная математическая запись

Приведем ниже вариант формальной математической записи для случая открытой системы тел со слабым нагревателем.

dX 1 (t)/dt = K 21 · (X 2 (t) – X 1 (t)) + K 31 · (X 3 (t) – X 1 (t))
dX 2 (t)/dt = K 12 · (X 1 (t) – X 2 (t)) + K 32 · (X 3 (t) – X 2 (t)) + K 42 · (X 4 (t) – X 2 (t)) + K 52 · (X 5 (t) – X 2 (t))
dX 3 (t)/dt = 0
dX 4 (t)/dt = 0
dX 5 (t)/dt = (K · U(t) – X 5 (t))/L + K 25 · (X 2 (t) – X 5 (t))
X 1 (0) = a
X 2 (0) = b
X 3 (0) = c
X 4 (0) = d
X 5 (0) = h
U(t) = f(t)
K 12 = 0.2; K 21 = 0.2; K 31 = 0.1; K 32 = 0.05; K 42 = 0.1; K 52 = 0.4; K 25 = 0.4; K = 1; L = 1
T k = 4

При реализации на математической машине среды Stratum эта запись будет дополнена элементами (функциями) ввода и вывода информации и командами управления (например, «стоп»), а часть элементов будет спрятана (например, при задании начальных условий).

Иногда (когда это удобно) начальные условия могут быть помещены внутрь уравнений. Для этого в следующей записи мы воспользуемся дельта-функцией Дирака (см. лекцию 31).

dX 1 (t)/dt = K 21 · (X 2 (t) – X 1 (t)) + K 31 · (X 3 (t) – X 1 (t)) + a · delta(t)
dX 2 (t)/dt = K 12 · (X 1 (t) – X 2 (t)) + K 32 · (X 3 (t) – X 2 (t)) + K 42 · (X 4 (t) – X 2 (t)) + K 52 · (X 5 (t) – X 2 (t)) + b · delta(t)
dX 3 (t)/dt = c · delta(t)
dX 4 (t)/dt = d · delta(t)
dX 5 (t)/dt = (K · U(t) – X 5 (t))/L + K 25 · (X 2 (t) – X 5 (t)) + h · delta(t)
U(t) := f(t)
K 12 := 0.2; K 21 := 0.2; K 31 := 0.1; K 32 := 0.05; K 42 := 0.1; K 52 := 0.4; K 25 := 0.4; K := 1; L := 1;
T k := 4
t: = t + Δt
osc2d(T, X 1 )
stop(T > T k )

Напомним, что osc2d( T , X 1 ) — функция, рисующая на экране точку с координатами T и X 1 для каждого момента времени. Выше данная функция приведена условно: в действительности надо использовать несколько функций для настройки окон, масштаба изображения, цвета, толщины, стиля линии и тому подобного. Подробно реализацию двухмерного осциллографа в среде «Stratum-2000» вы можете посмотреть в тексте имиджа OSCSpace2D.

Приведенный выше вариант формальной математической записи подразумевает, что весь код заключен в рамках одного элемента (имиджа, если использовать термины среды «Stratum-2000»). Будет гораздо более наглядно, если распределить код по отдельным элементам, связав их между собой связями (см. рис. 11.9) — в этом случае структура проекта останется обозримой; кроме того, если потребуется изменить что-то в одном из блоков, то такой подход позволит не менять код в остальных блоках. Еще один плюс такого подхода — отдельные «кирпичики» схемы могут быть применены неоднократно в готовом виде в виде копии имиджа.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.9. Схема проекта в среде Stratum-2000, реализующего полную
модель теплопроводности системы тел с элементами интерфейса

Алгоритмическая реализация

В случае реализации на алгоритмической машине следует воспользоваться алфавитом алгоритмов: блоками начала и конца алгоритма, ввода-вывода информации, задания начальных условий, вычислительными блоками, блоками условия, конструкциями цикла. In fig. 11.10представлена блок-схема алгоритма, имитирующего теплообмен между телами.

  Construction of a dynamic system model in the form of differential equations and its calculation by the Euler method
Fig. 11.10. Блок-схема алгоритма, имитирующего теплообмен между телами

Заметьте, что для реализации нам понадобились следующие инструменты:

  • устройства ввода информации (для задания параметров модели, параметров метода расчета, задания начальных условий процесса);
  • устройство вывода информации;
  • вычислительные блоки для реализации математических формул;
  • цикл для имитации течения времени.

В теле цикла присутствуют:

  • счетчик времени;
  • условие выхода из цикла для контроля за временем моделирования;
  • блок задания внешних воздействий;
  • unit for calculating increments;
  • unit for calculating the new state of the system;
  • block output current conditions.

In one way or another, the above blocks are necessarily present in each algorithm of this type.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

System modeling

Terms: System modeling