BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
573 stars 102 forks source link

Warning: there is insufficient data in CSV file 49.15.163.82_gk_model6.csv #91

Closed Saurabh-Srivastavaa closed 3 years ago

Saurabh-Srivastavaa commented 3 years ago

m= GEKKO() tf=40 m.time=np.linspace(0,tf,2tf+1) print(m.time) step=np.zeros(2tf+1) step[3:40]=2 step[40:]=5

PID Controller

Kc = 15 tauI = 2 tauD = 1 OP_0 = 0.0 OP = m.Var(value=0) PV = m.Var(value=0) SP = m.Param(value=step) err= m.Intermediate(SP-PV) Intgl=m.Var(value=0) m.Equation(Intgl.dt()==err) m.Equation(OP==OP_0+Kcerr+(Kc/tauI)Intgl-KctauDPV.dt())

Process Model

Kp=0.5 tauP=10 m.Equation(tauPPV.dt()+PV==KpOP)

m.options.IMODE=4 m.solve()

This is the code which I am using. But I am getting error, there is insufficient data. How to resolve and move ahead.

APMonitor commented 3 years ago

Here is modified code with results for OP, PV, and SP:

pid

from gekko import GEKKO
import numpy as np
m= GEKKO(remote=False)
tf=40
m.time=np.linspace(0,tf,2*tf+1)
step=np.zeros(2*tf+1)
step[3:40]=2
step[40:]=5
Kc = 15
tauI = 2
tauD = 1
OP_0 = 0.0
OP = m.Var(value=0)
PV = m.Var(value=0)
SP = m.Param(value=step)
err= m.Intermediate(SP-PV)
Intgl=m.Var(value=0)
m.Equation(Intgl.dt()==err)
m.Equation(OP==OP_0+Kc*err+(Kc/tauI)*Intgl-Kc*tauD*PV.dt())
Kp=0.5
tauP=10
m.Equation(tauP*PV.dt()+PV==Kp*OP)
m.options.IMODE=4
m.solve()

import matplotlib.pyplot as plt
plt.plot(m.time,OP.value)
plt.plot(m.time,PV.value)
plt.plot(m.time,SP.value)
plt.show()