# CADET Tutorial 1 questions

I’m trying to learn to use CADET. I checked the example - CADET Introduction in Getting started. So far, I understood why certain things should be executed.

Next, I checked CADET Tutorial. The example `01_generating_flow_demonstration` is not so hard to understand.

The first two exercises in `02_generating_flow_exercises` were not so hard too.

However, I am getting confused with the bonus exercises where multiple inlets were introduced. Let me refer to the first bonus.

``````model = create_dynflow_template(n_comp=2)

model.root.input.solver.sections.nsec = 2
model.root.input.solver.sections.section_times = [0.0, 1.0, 2.0] # min
model.root.input.solver.sections.section_continuity = [0, 0]

model.root.input.model.unit_000.sec_000.const_coeff = [0.0, 0.5]    # mol / m^3
model.root.input.model.unit_001.sec_000.const_coeff = [2.0, 1.0]    # mol / m^3

model.root.input.solver.user_solution_times = np.linspace(0, 2.0, 1001)

model.root.input.model.connections.nswitches = 2
model.root.input.model.connections.switch_000.section = 0
model.root.input.model.connections.switch_000.connections = [
0, 2, -1, -1, 1,
1, 2, -1, -1, 0,
]

model.root.input.model.connections.switch_001.section = 1
model.root.input.model.connections.switch_001.connections = [
0, 2, -1, -1, 0,
1, 2, -1, -1, 1,
]

run_simulation(model)
plot_dynflow_results(model)
``````

Here, the `const_coeff` for two components are `[0.0, 0.5]`. So basically, the concentration of the first component in section 1 is zero, while 0.5 for the second component.
So I played around with the flow rate of the first section, specifically, this piece of command below:

``````model.root.input.model.connections.switch_000.connections = [
0, 2, -1, -1, 1,
1, 2, -1, -1, 0,
]
``````

Because the concentration of the first component is zero, it doesn’t matter if the flow rate is zero or not.

1. Why the flow rate `Q0` of second component is 0, but we still have the inlet for it in the first section? The same for the second section. Why the flow rate `Q0` of first component is 0, but we still have the inlet for it in the second section?

2. If I use the setting below (in tutorial), I get this concentration profile.

``````model.root.input.model.connections.switch_000.connections = [
0, 2, -1, -1, 1,
1, 2, -1, -1, 0,
]
``````

However, if I change `Q0` of the second component to 1, I got the concentration profile below.

Now the concentration of the first component in the section 1 starts at 1, while ~ 0.7 for second component. This is where I don’t understand.

For the second bonus exercise, I have a few questions.

``````model = create_dynflow_template(n_comp=1, enable_dynflow=True)

model.root.input.solver.sections.nsec = 3
model.root.input.solver.sections.section_times = [0.0, 1.0, 2.0, 3.0] # min
model.root.input.solver.sections.section_continuity = [0, 0, 0]

model.root.input.model.unit_000.sec_000.const_coeff = [0]    # mol / m^3
model.root.input.model.unit_001.sec_000.const_coeff = [1]    # mol / m^3

model.root.input.solver.user_solution_times = np.linspace(0, 3.0, 1001)

model.root.input.model.connections.nswitches = 3
model.root.input.model.connections.switch_000.section = 0
model.root.input.model.connections.switch_000.connections = [
0, 2, -1, -1, 1, -1, 0, 0,
1, 2, -1, -1, 0, 1.0, 0, 0,
]

model.root.input.model.connections.switch_001.section = 1
model.root.input.model.connections.switch_001.connections = [
1, 2, -1, -1, 1, -1, 0, 0,
]

model.root.input.model.connections.switch_002.section = 2
model.root.input.model.connections.switch_002.connections = [
0, 2, -1, -1, 0, 1, 0, 0,
1, 2, -1, -1, 1.0, -1.0, 0, 0,
]

run_simulation(model)
plot_dynflow_results(model)
``````
1. We have only two units representing as inlet, and one unit as outlet. Why do have three switches? Where is the third switch (valve)?

2. The concentration of the first component is declared zero here
`model.root.input.model.unit_000.sec_000.const_coeff = [0] # mol / m^3`
Why do we still have the concentration profile for it?

3. It seems to me the way we declare the concentration `p_i( t )` by `model.root.input.model.unit_001.sec_000.const_coeff = [1] # mol / m^3`

or `Q` by `model.root.input.model.connections.switch_001.connections`

could be used to manipulate the inlet profile. I could manually calculate the inlet profile for the former aka the specification of network connection is in short format, including 5 columns.

However, I can’t comprehend how the inlet concentration could be constructed if the long format is used aka
`[UnitOpID from, UnitOpID to, Component from, Component to, volumetric flow rate, linear flow rate coefficient, quadratic flow rate coefficient, cubic flow rate coefficient]`

Could anyone tell me if they are actually different and how we could manually verify for the latter?

Thank you so much for your time.

Hey Hoang,
sorry for the late reply, we were quite busy with preparations of our workshop.

I’m not sure I entirely understand your post because I think you might have some misconceptions of how things work under the hood.

In CADET, you can independently specify volumetric flow rates (using switches) and concentration profiles (using the inlets) using third order polynomials. Both can be varied over time by changing the coefficients in different sections.

The goal of the exercise was to show that for some situations, you can either set

• constant flow rate (using the connections/switches) and varying concentrations
• or constant concentrations and varying flow rates (using the connections/switches)

Just to be clear, this is the structure of the matrix:

``````[unit_index_from, unit_index_to, component_index_from, component_index_to, flow_rate]
``````

If you set `component_index_from` and `component_index_to` to `-1`, then all components will be connected. In really almost all cases, this is what you want. You only need to modify this if two units have different order of components of a different number of components.

You don’t set flow rate for components but rather for inlets which have component concentrations (which could of course also be 0).

In case you mean “inlet” instead of “component”, it does matter because if a concentration is 0, it would just dilute all units downstream.

If a flow rate is zero, then it does not matter and you can omit the line from the matrix.

Think about “switches” as a set of connections of unit operations. In each section, the units can be connected differently. This is why you also need to specify in which section each “switch” is active.

As I mentioned, concentrations are not set here. Only flow rates.

If you have any more questions, please let me know.

Hi Jo,

This is what I don’t understand.

``````model.root.input.model.unit_000.sec_000.const_coeff = [0.0, 0.5]    # mol / m^3
``````

This is concentrations for two component for `unit_000` or inlet for `sec_000`.

``````model.root.input.model.connections.switch_000.connections = [
0, 2, -1, -1, 1,
1, 2, -1, -1, 0,
]
``````

So, flow rate is set 1 for `unit_000` here and 0 for `unit_001`. So if there is no flow rate from `unit_001`, why we still have the concentration of second component in the first section?

The reason I asked this is that later you mentioned that

Did I understand the configuration correctly? If not, could you please elaborate on this one a bit more?

Many thanks, Jo.

I’m sorry mate, I cannot reproduce your issue.

Can you send us the entire config please?