Main

## Parameter Regression

The temperature of a subsea pipeline is measured as hot oil reservoir fluids (water mixed with hydrocarbon liquid and gas) begins flowing. The temperature transmitter (TT) is placed near the well-head at the Flowline End Termination (FLET).

The temperature of the fluid is important to monitor because of the potential for methane hydrates (water and methane) that have the potential to develop under high pressure and cold temperatures. Methanol is added to the fluid to prevent hydrate formation and buildup in the pipeline. If hydrates form and conglomerate, it could lead to pipeline plugging and costly remediation efforts or pipeline abandonment. The following data set is a measurement of fluid temperature during startup of well production. The temperature begins at subsea temperature of 3.6 Celsius and rises over many hours to the well fluid temperature. There is a link to the raw data below with a Python script that automatically downloads the data file and creates plots of the data.

Use the data to develop a first-order plus time delay model with adjustable parameters Kp, \tau_p, \theta_p. Use a graphical method and optimization method to obtain the unknown parameters and include the data and the two regression results on a single graph.

import pandas as pd
import matplotlib.pyplot as plt
# load wget, install if needed
try:
import wget
except:
import pip
pip.main(['install','wget'])
import wget

# rename file to data.csv
from shutil import move
move(filename,'data.csv')

# import data with pandas
time = 'Time (min)'
valve = 'Valve Position (% open)'
TC = 'Temperature (degC)'

# print temperature values
print(TC)
print(data[TC][0:5])
print('min: '+str(min(data[TC])))
print('max: '+str(max(data[TC])))

# plot data with pyplot
plt.figure()
plt.subplot(2,1,1)
plt.plot(data[time]/60.0,data[valve],'b--')
plt.ylabel(valve)

plt.subplot(2,1,2)
plt.plot(data[time]/60.0,data[TC],'r-')
plt.ylabel(TC)
plt.xlabel('Time (hr)')
plt.show()

Solution