Interested in linking to "Simulation, the game we all can play!"?
You may use the Headline, Deck, Byline and URL of this article on your Web site. To link to this article, select and copy the HTML code below and paste it on your own Web site.
12/20/2004
x_dot(1) = n_in - n_out
x_dot(2) = (1 / tau_v) * (u(Index) - xnew(2))
x_dot(3) = (Psp(Index) - P_tank)
‘ These are the integration equations
If j = 1 Then
For i = 1 To ssv
k1(i) = step * x_dot(i)
xnew(i) = x(i) + k1(i) / 2
Next
End If
If j = 2 Then
For i = 1 To ssv
k2(i) = step * x_dot(i)
xnew(i) = x(i) + k2(i) / 2
Next
End If
If j = 3 Then
For i = 1 To ssv
k3(i) = step * x_dot(i)
xnew(i) = x(i) + k3(i)
Next
End If
If j = 4 Then
For i = 1 To ssv
k4(i) = step * x_dot(i)
x(i) = x(i) + (1 / 6) * (k1(i) + 2 * k2(i) + 2 * k3(i) + k4(i)) ' Calculated next state
Next
End If
Next
' calculate the new outlet pressure by calculating the mass in tank p=nRT/V
P_tank = (x(1) / MW) * R_gas * t / vol
Using the Control System as a Simulator
In many cases where the user is only interested in simulating hydraulic or thermal systems, or where chemical reactions are simplified or ignored, the control system itself can be modified to provide the simulated process. The following example illustrates this, the controller is diagramed in figure 2 and the simulation is shown in figure 3. Assume that using an internal cooling coil cools a heat-jacketed vessel. The temperature is controlled by the amount of cooling water through the coil and the heat is controlled to keep the flow it a high enough value it facilitate good heat transfer.
Modifying the control program can simply be done adding the required function blocks to calculate the heat transfer. The cooling heat value can be subtracted from the heating heat value and be totalized. The resultant total functions as an integrator, which is the heat value in BTU/minute, This can be converted to a temperature reading.
In the simulation blocks the following functions are simply calculated:
The cooling flow, F_COIL, is equal to K*(TV-104) where TV-104 in percent.
The heat transfer coefficient, U_COIL, is equal to a K0 + K1*(TV-104).
The coil outlet temperature is calculated by a heat balance across the coil is equal to the heat flowing through the coil:
Q_COIL1 = U_COIL * A *( (TI-104R) – (TOUTCOIL + Tincoil) /2 ) =
F_COIL * (TOUTCOIL – Tincoil)
Solving the above for TOUTCOIL:
TOUTCOIL =
(U_COIL * A ((TI-104R) – (Tincoil/2) + F_COIL*Tincoil) / (F_COIL + U_COIL*A/2)
The heat transferred through the coil, Q_COIL1, is equal to F_COIL*(TCOILOUT – Tincoil) / 60.
Tincoil is a constant of 529.7 DegR.
The electrical power percentage, P-104, is converted to heat in BTUs. This value is as lagged by a first order lag equal to the thermal time constant across the jacket, tau.
Q_ELECT = K*(P-104)* (1.0 - e-t/tau )
The Q_COIL is a lagged value of the calculated Q_COIL1.
Once the electrical heat and cooling heat values are calculated, the subtracted element, D, subtracts the cooling heat from the electrical heat. This heat value is then totalized. The controlled variable, TI-104, is finally calculated in degrees C. The temperature in degrees R, TI-104R, is calculated also.
ControlGlobal.com is exclusively dedicated to the global process automation market. We report on developing industry trends, illustrate successful industry applications, and update the basic skills and knowledge base that provide the profession's foundation.