I'm learning GEKKO and I was wondering how to simulate a process and then control with some disturbances variables involved.
Let's pick a simple heat exchanger for example, where I'm trying to heat up a water stream from 100ºC to 110ºC using a heat source from a steam of 6,5 bar.
Let's assume the only heat source comes from the condensation of steam, so our mass balance would be:
Q = m_s * lamb_s = m_w * Cp * d(T_out - T-in)dt
Where m_s: steam mass flow lamb_s: steam latent heat m_w: water mass flow Cp: water specific heat T_out: Water temperature out T_in: water temperature in
Now, I want to control T_out with m_s with a constant setpoint for T_out of 110ºC. But I want to be able to step m_w and T_in. I get that it's easy to step m_w because it is indepent of time, but how do I step T_in if in the equation it is time relative (dT_in/dt) ? If I'm stepping T_in, I cant cut it from the equation, right?
THis is what I've tried this, where I thought that dT_in/dt would only not be 0 when I'm stepping it.:
Tia[300] = -10 +273.15 Ti_in = m.Param(value=Tia) # K
m.Equation(T_out.dt() == (1.0/(m_wCp))(m_s * lamb_s)) + Ti_in)
BUt the response was a step in T_out.
I also tried writing in the equation Ti_in as T_in.dt(), but I got AttributeError: dt, I guess it's because I'm defining it as a parameter?
The equation for an energy balance is:
where
massis the fluid mass in the control volume andT_in,m_sare independent inputs to the model.T_incan be defined as an input disturbance andm_sas the manipulated variable. Here is an example script that demonstrates this in a Model Predictive Control application with a step in theT_indisturbance.Here is the complete script: