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
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.



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

Happy I could help! :partying_face:

1 Like