None Notebook

This notebook contains material from CBE30338; content is available on Github.

< 2.3 Blending Tank Simulation | Contents | Tag Index | 2.5 Hare and Lynx Population Dynamics >

Open in Colab

Download

2.4 Continuous Product Blending

This case study is modeled after an actual process used to prepare an over-the-counter pediatric medication. The situation has been simplified to the dissolution of a single active ingredient into a suspension, and adapted to continouous rather than batch operation.

The process objective is to mix an active ingredient $A$ into a suspension $S$, providing enough time to fully mix and dissolve components coming from both streams. The feed concentration of $A$ is 200 grams/liter. Process requirements include:

The outlet from the tank is fed directly to a packaging line. The flow demand can vary due to changes in speed of the packaging equipment.

2.4.1 Preliminary Control Analysis

2.4.1.1 Parameters

Quantity Symbol Value Units
Feed Concentration $c_{A,f}$ 200 g/liter
Maximum Tank Operating Capacity $V$ 15,000 liters
Minimum Tank Operating Capacity $V$ 8,000 liters

2.4.1.2 Control Objectives

2.4.1.3 Classification of Variables

What are the disturbances variables (DV), manipulated variables (MV), and controlled variables (CV)?

Variable Symbol Classification
Outlet Flow $q_{out}$ DV
Feed Flow $q_A$ MV
Water Makeup Flow $q_W$ MV
Product Concentration $c_A$ CV
Volume $V$ CV

In this case, we can assume the controlled variables are directly measureable.

2.4.1.4 Degrees of Freedom Analysis

At steady-state the balance equations become algebraic equations

\begin{align} 0 & = \bar{q}_A + \bar{q}_S - \bar{q}_{out} \\ & \\ 0 & = \bar{q}_A c_{A,f} - \bar{q}_{out}\bar{c}_A \end{align}

There are a total of five variables in these two equations. So we need to find at least three more specifciations or constraints to determine values for these variables.

Additional pieces of information we have are the process specifications

\begin{align} \frac{\bar{q}_{out}}{\bar{V}} & = 96 \mbox{ hours} \\ c_{A,f} & = 200 \mbox{ g/liter} \\ \bar{q}_{out} & = \mbox{ set by the downstream demand} \\ \bar{c}_A & = 8 \mbox{ g/liter} \end{align}

This is a total of four new equations for steady-state. The new equations introduced an additional variable $\bar{V}$. This provides six variables in six equations provided we know the downstream demand.

2.4.1.5 Steady State

Let's assume a constant output demand $\bar{q}_{out}$ = 125 liters/hr. The equations may then be solved in order:

\begin{align} c_{A,f} & = 200 \mbox{ g/liter} \\ \bar{c}_A & = 8 \mbox{ g/liter} \\ \bar{V} & = 96\ \bar{q}_{out} = 12,000 \mbox{ liters}\\ \bar{q}_A & = \frac{\bar{q}_{out}\bar{c}_A}{c_{A,f}} = 5 \mbox{ liters/hr}\\ \bar{q}_S & = \bar{q}_{out} - \bar{q}_A = 120 \mbox{ liters/hr} \end{align}
  exercise

2.4.1.6 Exercise 1. Determine Operating Range

Solve the steady-state equations for other values of $\bar{q}_{out}$. Given a maximum tank operating capacity of 15,000 liters, what is the largest possible value of $\bar{q}_{out}$ which still meets process specifications? If the minimum tank operating capacity is 8,000 liters, what is the minimum value of $\bar{q}_{out}$?

2.4.2 Modeling

The balance equations are

\begin{align} \frac{dV}{dt} & = q_A + q_S - q_{out} \\ \frac{d(Vc_A)}{dt} & = q_A c_{A,f} - q_{out}c_A \end{align}

where we have made the assumption of constant density among all of the streams, and of complete and uniform mixing in the stirred tank.

For simulation, it is useful to isolate the derivatives of $V$ and $c_A$ on the left-hand side of these differential equations. Using the chain rule

\begin{align} \frac{dV}{dt} & = q_A + q_S - q_{out} \\ V\frac{dc_A}{dt} + c_A\frac{dV}{dt} & = q_A c_{A,f} - q_{out}c_A \end{align}

Substituting the first equation into the second gives

\begin{align} \frac{dV}{dt} & = q_A + q_S - q_{out} \\ V\frac{dc_A}{dt} + c_A\left(q_A + q_S - q_{out}\right) & = q_A c_{A,f} - q_{out}c_A \end{align}

Rearranging terms, and dividing the second equation by $V$, gives us the final version of a dynamical model.

\begin{align} \frac{dV}{dt} & = q_A + q_S - q_{out} \\ \frac{dc_A}{dt} & = \frac{q_A}{V} \left(c_{A,f} - c_A\right) - \frac{q_S}{V} c_A \end{align}

2.4.3 Simulation

2.4.3.1 Step 1. Imports

We start the simulation by importing necessary Python libraries.

2.4.3.2 Step 2. Parameter Values

It is good coding practice to include all relevant parameter values in single block of code. This makes it easier for users of your code to understand what values are relevant to the problem, and to adjust and maintain your code. No 'magic' numbers should appear later in your code.

2.4.3.3 Step 3. Computing Steady State

A good modeling practice is to begin with the determination of a nominal steady state. By nominal we mean operating conditions representative of typical, desired behavior of the process in question, and should be computed based on the parameter values given above.

2.4.3.4 Step 4. Process Model Equations

In our case the model consists of a system of two differential equations. For simulation with the Python function odeint, the model is encapsulated into a Python function that accepts two arguments.

2.4.3.5 Step 5. Numerical Solution of the Process Model

This block does the numerically intensive portion of the simulation. Here we establish values for all degrees of freedeom, specify initial conditions, and thne proceed to compute a history of the process behavior. The history is broken into discrete time step which is a bit more work now, but will later provide a means to test implementations of control algorithms.

For the first simulation, it usually a good idea to pick an initial condition that will yield a known result. In this case we start a simulation at steady state.

2.4.3.6 Step 6. Visualization and Analysis

To simplify future simulations, here we define a function to plot the results stored in the simulation record. The function plot_history(history, labels) takes two arguments. The first argument is the data history recorded during the course of the simulation, where the first element is assumed to be time. The second argument is a list of labels corresponding to each of the recorded variables.

  exercise

2.4.3.7 Exercise 2. Explore Dynamical Behavior

Let's explore the behavior of this mixing tank under different assumptions. We'll explore the following cases:

  1. The startup concentration of $A$ is $c_A = 0$. How long before the mixer is producing an acceptable product?
  2. The outlet flow increases by 10%. How long before the product is out of spec?
  3. The outlet flow decreases by 10%. How long before the product is out of spec?

The following cell shows how you might get started with first question.

2.4.4 Control Residence Time

From the exercises above, we know even small changes in the outlet flowrate results in substantial loss due to out-of-spec product. Let's try a control strategy in which we change in the suspension flowrate, $q_S$, to compensate for excursions from the desired value of residence time.

We'll try proportional control where the change in $q_S$ is proportional to the difference of the residence time from the setpoint.

\begin{align} q_S - \bar{q}_S = - K \left(\frac{V}{q_{out}} - \frac{\bar{V}}{\bar{q}_{out}}\right) \end{align}

The negative sign is there because we expect a negative deviation in flowrate is needed to compensate for a positive deviation in residence time. This can be written more directly as

\begin{align} q_S = \bar{q}_S - K \left(\frac{V}{q_{out}} - \frac{\bar{V}}{\bar{q}_{out}}\right) \end{align}

In the following cell we will decrease qout by 10%, and attempt to find a value for $K$ that provides satisfactory control.

2.4.5 Control Concentration

As shown above, it isn't enough to control only residence time. In fact, controlling residence time in response to a decrease in output causes the outlet concentration to increase beyond the product quality limits. We propose to fix this problem by controlling $q_A$, the inlet flow of $A$. A proportional control rule is given by

\begin{align} q_A & = \bar{q}_A - K \left(c_A - \bar{c}_A \right) \end{align}

where, again, we predict a decrease in $q_A$ is needed to compensate for a positive excursion in $c_A$.

  exercise

2.4.6 Exercise 3.

The algebraic formulae given above do not include any limits on flowrate. Suppose the flowrate $q_s$ is limited to 0 to 200 liters/hour, and the flowrate $q_a$ is limited to 0 to 20 liters/hour. Modify the code above to incorporate those limits. Now try to find the minimum time necessary to bring the tank from initial concentration of 0 to state where it is producing an acceptable product.

2.4.7 Proportional-Integral Control

The above control laws do a reasonable job of control, but do not return the system to a desired steady-state operating condition. How can we modify the control laws?

\begin{align} q_A & = \bar{q}_A - K_p \left(c_A - \bar{c}_A \right) - K_i \int_0^t \left(c_A - \bar{c}_A \right) dt \end{align}

The second term will integrate any constant offset to produce a constantly changing value. So the only possible steady-state is when $c_A = \bar{c}_A$.

  exercise

2.4.8 Exercise 4.

Write an expression for the proportional-integral control of residence time. Implement the control, and 'tune' the control constants until you get satisfactory feedback control for a 10% reduction in demand. By satisfactory we mean:

Is it possible to meet these control specifications?

< 2.3 Blending Tank Simulation | Contents | Tag Index | 2.5 Hare and Lynx Population Dynamics >

Open in Colab

Download