This repository provides a Python interface to a modified Fortran program of the Tennessee Eastman Process (TEP) Control Test Problem provided by gmxavier. Users of this modified version should cite it as:
G. M. Xavier and J. M. de Seixas, "Fault Detection and Diagnosis in a Chemical Process using Long Short-Term Memory Recurrent Neural Network", 2018 International Joint Conference on Neural Networks (IJCNN), 2018, pp. 1-8, doi: 10.1109/IJCNN.2018.8489385.
In order to use it properly, you should build the fortran program from source using f2py. You may refer to the instructions below to build it yourself or, if you are on a linux system, you may try the file provided in this repository, which was compiled on a linux machine according to:
$ uname -srvmpio
Linux 4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
# modules
import numpy as np
from tep2py import tep2py
# matrix of disturbances
idata = np.zeros((5,20))
# instantiate tep2py object for given `idata`
tep = tep2py(idata)
# run simulation
tep.simulate()
# retrieve simulated data as DataFrame
print(tep.process_data)
# retrieve table of disturbances
print(tep.info_disturbance)
# retrieve table of variables
print(tep.info_variable)
See this for more details.
-
Create a signature file from fortran source code by running:
$ python -m numpy.f2py src/tep/temain_mod.f src/tep/teprob.f -m temain_mod -h temain_mod-auto.pyf
-
Explicit what are the intent of the arguments of the target functions (use
intent(in)
andintent(out)
attribute) . You should do this by editing the signature filetemain_mod-auto.pyf
.The final version is:
subroutine temain(npts,nx,idata,xdata,verbose) ! in :temain_mod:temain.f integer, intent(in) :: npts integer, intent(in) :: nx integer dimension(nx,20), intent(in), depend(nx) :: idata double precision dimension(nx,52),depend(nx), intent(out) :: xdata integer, intent(in) :: verbose
-
Build the extension module by running:
python -m numpy.f2py -c temain_mod-smart.pyf src/tep/temain_mod.f src/tep/teprob.f
-
Import the module in python:
import temain_mod