0

I have a Python Gekko application to estimate and control disturbances to an industrial polymer manufacturing process (UNIPOL polyethylene). The approach is to update the unknown catalyst activity to minimize the difference between the measured and predicted production rate. The catalyst activity is then used in production control. The predicted production rate is based on heat exchanged with cooling water. The problem that I'm running into is that sometimes the production rate measurements are not good because of intermittent issues associated with the measurements (flow meter, temperatures) and calculations during large transients. The distributed control system (Honeywell Experion with TDC3000) has appropriate protections against bad measurements and reports a value but with bad status. How can I use the available good measurements but ignore the intermittent bad measurements in Python Gekko? I don't have example code that I can share due to proprietary issues, but it is similar to this TCLab exercise.

 for i in range(1,n):
     # Read temperatures in Celsius 
     T1m[i] = a.T1
     T2m[i] = a.T2

     # Insert measurements
     TC1.MEAS = T1m[i]
     TC2.MEAS = T2m[i]
     Q1.MEAS = Q1s[i-1]
     Q2.MEAS = Q2s[i-1]

     # Predict Parameters and Temperatures with MHE
     m.solve(disp=True) 

TCLab Moving Horizon Estimation

Can I use np.nan (NaN) as the measurement or is there another way to deal with bad data?

TexasEngineer
  • 684
  • 6
  • 15
  • 2
    It doesn't work to use `np.nan` to ignore the measurement. The objective becomes NaN so it is using that value if `TC1.MEAS = np.nan`. – Eric Hedengren Dec 28 '19 at 01:27

1 Answers1

0

For any bad data, you can set the feedback status FSTATUS to off (0) for FVs, MVs, SVs, or CVs.

if bad_measurements:
   TC1.FSTATUS = 0
   TC2.FSTATUS = 0
   Q1.FSTATUS = 0
   Q2.FSTATUS = 0
else:
   TC1.FSTATUS = 1
   TC2.FSTATUS = 1
   Q1.FSTATUS = 1
   Q2.FSTATUS = 1

Gekko eliminates the bad measurement from the time series model update but keeps the good data. For the CVs, it does this by storing and time-shifting the measurements and the value of fstatus for each one. The bad data eventually leaves the data horizon along with the FSTATUS=0 indicator. You can also have FSTATUS values between 0 and 1 if you want to filter the input data:

x=LSTVAL∗(1−FSTATUS)+MEAS∗FSTATUS

where LSTVAL is the last value, MEAS is the measurement, and x is the new filtered input for that measurement. More information on FSTATUS is in the documentation.

John Hedengren
  • 12,068
  • 1
  • 21
  • 25