Dynamic volume flow rate from data

Hello everyone,

Since Cadet version 4.3.0 allows modelling of dynamic flow rates i am trying to implement a dynamic volume flow rate via time step from a dataset.
My profil data is stored in a “.csv” file. The first column are time points and the second column is the volume flow rate. Via the cubic function in the “CONNECTION GROUP” i want to evaluate the volume flow at a given time as well as linear interpolate values between timepoints by the “LINEAR FLOW RATE COEFFICIENT”.
Here is the part of the sourcecode:

 ####### Sections and Switches  #######

volume_flow_profile = np.loadtxt('D:path_to_/volume_flow_profile.csv', delimiter=',')

time = volume_flow_profile[:,0]
volume_flow = volume_flow_profile[:,1]
    
n_sections = len(time)-1
section_times = [time[0]]

for i in range(n_sections):

        switch_index = 'switch_{0:03d}'.format(i)

        flow = volume_flow[i]
        slope = (volume_flow[i+1] - volume_flow[i]) / (time[i+1] - time[i])

        model.root.input.model.connections[switch_index].section = i
        model.root.input.model.connections[switch_index].connections = [
            
            0, 1, -1, -1, flow, slope, 0, 0,
            1, 2, -1, -1, flow, slope, 0, 0
        ]
        
        section_times.append(time[i+1])   
    
model.root.input.model.connections.connections_include_dynamic_flow = 1
model.root.input.solver.sections.nsec = n_sections
model.root.input.solver.sections.section_times = section_times                                            model.root.input.solver.sections.section_continuity = [0]        
model.root.input.model.connections.nswitches = n_sections-1                                                                                 

The simulation is running without error but the result is not correct and I want to ask if:

  1. Maybe the ‚CONNECTIONS_INCLUDE_PORTS‘ should be active or
  2. Probably there is something wrong with the ‚valve configuration‘ ?

Furthermore the Inlet concentration (c_feed) should be conctant:

model.root.input.model.unit_000.sec_000.const_coeff = c_feed

Because of nsec = n_sections (>1), i tried to replace the inlet concentration by:

model.root.input.model.unit_000[switch_index].const_coeff = c_feed

and inserting it in the for loop. But the result seems to be the same.

I would really appreciate it if someone could help me.
Thanks in advance.

Hello Pit,

at first glance this looks alright. Could you please provide the csv file, as well as the rest of the model?

Also, it would be helpful to know what exactly you would expect to change. If the inlet concentration profile is constant, you will also “measure” a constant concentration, regardless of the flow rate. Only if there are dynamic changes (depending on initial conditions and boundary conditions) will the flow rate have an effect. For this, we need more information about your system.

Best

Johannes

Hello Johannes,

You are absolutely right. Honestly, it was a mistake from my side and i “measured” the constant concentration which obviously is not influenced by the dynamic flow rate. I am sorry for the confusion.

Kind Regards
Pit

Happy I could help! :partying_face:

1 Like

Hi.

Could anyone let me know how to plot the Dynamic flow rate as a function of time. Is this something that CADET usually outputs, apart from Concentration profiles? Thanks

Hi,

yes, this is possible. You can use Events in CADET-Process to modify the flow_rate of Inlet unit operations. You can also add a full profile from a time series (see here).

1 Like

Thank you. How do you achieve the same via Cadet - Python?

Hi nyousuf,

In CADET-Python, you can access the flow rates via the CONNECTIONS parameter in the input group, under model.connections.switch_XXX. These entries define the connections between units and the corresponding volumetric flow rates for each switch state.

To plot the flow rates over time, you need to determine which switch is active at each time point based on the section times and then extract the flow rates from the corresponding switch_XXX. This is not handled automatically in CADET-Python, so you would need to write helper functions for it, which CADET-Process does under the hood as well.

For more details on the structure of CONNECTIONS, see the CADET documentation:
https://cadet.github.io/v5.1.X/interface/system.html#group-input-model-connections-switch-xxx

Best,
Hannah