Hey Lukas,
to create an inlet profile from experimental data, you need to configure the piecewise cubic polynomials of the Inlet Unit Operation. For this purpose, you create a separate section for every ‘piece’.
To automate that, you can use some helper function. Assuming some arrays for time
and data_points
,
import numpy as np
time = np.arange(5)
data_points = np.array([
[0.0, 0.0],
[0.0, 0.1],
[0.5, 0.2],
[1.0, 0.1],
[0.5, 0.0],
[0.0, 0.0]
])
you can write a helper function that adds them to the cadet config object.
def linear_interpolation(cadet, time, data_points):
n_sections = len(time) - 1
cadet.root.input.model.unit_000.unit_type = 'INLET'
cadet.root.input.model.unit_000.ncomp = data_points.shape[1]
cadet.root.input.model.unit_000.inlet_type = 'PIECEWISE_CUBIC_POLY'
section_times = [time[0]]
for i in range(n_sections):
section_index = 'sec_{0:03d}'.format(i)
cadet.root.input.model.unit_000[section_index].const_coeff = data_points[i,:]
slope = (data_points[i+1,:] - data_points[i,:])/(time[i+1] - time[i])
cadet.root.input.model.unit_000[section_index].lin_coeff = slope
section_times.append(time[i+1])
cadet.root.input.solver.sections.section_times = section_times
Instead of manually calculating the coefficients, you can also replace this section and use something like the splines module from scipy.
Then you would call this function later when actually doing the configuration.
from cadet import Cadet
cadet = Cadet()
#
# All of the regular config stuff
#
linear_interpolation(cadet, time, data_points)
Unfortunately, this is currently not possible and there is already an open issue on Github describing exactly this problem. The current implementation is still an artefact from the time when CADET could just simulate single columns but it has become cumbersome now that networks of unit operations are possible and CADET is generally used for more dynamic processes, and scheduling. I do agree that it would be good to overhaul the way in which sections are defined in CADET and replace it with something ‘per unit’. Then internally, CADET would have to construct its own time line of events by iterating over all units.
Alternatively, you can also develop some preprocessor which does exactly that for you. For many things, CADET-Process already provides functionality for defining events independently, but unfortunately Inlets (and dynamic flow rates) are still missing.