0% found this document useful (0 votes)
9 views6 pages

Assumptions

The document outlines the process for sizing valves and modeling flow between four tanks (FC23, FC24, FC25, FC26) using a PI controller in a simulation environment. It details the equations for flow rates, valve openings, and dynamic balances for tank levels, along with the implementation of a PI controller for maintaining desired tank levels. Additionally, it provides a structured approach for simulating the system using MATLAB or similar software, including initial conditions and necessary calculations for flow rates and valve operations.

Uploaded by

Paul Kolobetso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Assumptions

The document outlines the process for sizing valves and modeling flow between four tanks (FC23, FC24, FC25, FC26) using a PI controller in a simulation environment. It details the equations for flow rates, valve openings, and dynamic balances for tank levels, along with the implementation of a PI controller for maintaining desired tank levels. Additionally, it provides a structured approach for simulating the system using MATLAB or similar software, including initial conditions and necessary calculations for flow rates and valve operations.

Uploaded by

Paul Kolobetso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Assumptions & Clarifications:

1. Valve Sizing Cv: Eq (2) is used to size the valve, determining Cv_max. The valve has
linear characteristics, so Cv(u) = u * Cv_max, where u is the control signal (0 to 1).
2. Flow Equation (1) Interpretation: f = K * Cv(u) * sqrt(h_i - h_j + y).
o K: Given flow constant (0.239).
o Cv(u): The actual valve coefficient at opening u. This is u * Cv_max.
o h_i: Level in the upstream tank.
o h_j: Level in the downstream tank. For flow out of the final tank (like f2 from
FC24 or f4 from FC26), h_j can be considered 0 if discharging to a fixed level
datum (e.g., atmospheric pressure at the outlet pipe elevation).
o y: Difference in height. Figure 2 indicates y=1m. For flow between tanks (e.g.,
f1), this is the static head difference aiding flow if tank 1's outlet is y above tank
2's inlet. For flow from the last tank (e.g., f2), if its outlet is y above the discharge
datum, then y contributes to the head. The diagram suggests y=1m is a general
elevation advantage for the outlets.
o We will use max(0, term) for the sqrt(term) to prevent errors if the head term
becomes negative, implying zero flow in such cases.

Constants and Calculated Values:

• K = 0.239 (flow constant for connecting pipe, units will be sqrt(bar)/sqrt(m) for
consistency)
• D = 14.27 m (tank diameter)
• Tank Area A = π * (D/2)² = π * (14.27/2)² ≈ π * (7.135)² ≈ 159.93 m²
• Average flowrate f_avg = 500 L/s = 0.5 m³/s = 0.5 * 3600 m³/hr = 1800 m³/hr
• Pressure drop for valve sizing ΔP = 20 kPa = 0.2 bar
• Specific gravity SG = 1 (water)
• Static head y = 1 m

Valve Sizing (to find Cv_max):


Valves are sized for f_avg = 1800 m³/hr at u=0.5 (50% open).
From Eq (2): Cv_at_50%_open = 1.16 * f_avg * sqrt(SG / ΔP)
Cv_at_50%_open = 1.16 * 1800 * sqrt(1 / 0.2) = 1.16 * 1800 * sqrt(5) ≈ 2088 * 2.236 ≈ 4670.21
The units of this Cv are (m³/hr)/sqrt(bar).
Since Cv(u) = u * Cv_max and Cv(0.5) = Cv_at_50%_open:
Cv_max = Cv_at_50%_open / 0.5 = 4670.21 / 0.5 ≈ 9340.42 (m³/hr)/sqrt(bar)

Now, let's look at the flow equation f = K * Cv(u) * sqrt(head_m).


f [m³/hr] = K [sqrt(bar)/sqrt(m)] * (u * Cv_max [(m³/hr)/sqrt(bar)]) * sqrt(head [m])
This makes the units consistent.
So, the effective flow coefficient for the model equations will be K_eff = K * Cv_max.
K_eff = 0.239 * 9340.42 ≈ 2232.36 (m³/hr)/sqrt(m)

So, the flow equations will be of the form: f = K_eff * u * sqrt(head_m)


Question 1: Modelling FC23 & FC24

1.1) Determine the opening of V₁ (u1)

• FC23 level h1 = 3.5 m (maintained, implies steady state for this calculation).
• FC24 level h2 = 3 m (desired height).
• At steady state, inflow to FC23 equals outflow f1. This outflow must be the average flow
rate if h1 is maintained for average conditions. So, f1 = f_avg = 1800 m³/hr.
• Flow f1 is from FC23 to FC24: f1 = K_eff * u1 * sqrt(max(0, h1 - h2 + y))
1800 = 2232.36 * u1 * sqrt(max(0, 3.5 - 3 + 1))
1800 = 2232.36 * u1 * sqrt(0.5 + 1)
1800 = 2232.36 * u1 * sqrt(1.5)
1800 = 2232.36 * u1 * 1.2247
1800 ≈ 2733.98 * u1
u1 = 1800 / 2733.98 ≈ 0.6584
So, V₁ opening u1 ≈ 0.6584 (or 65.84%).

1.2) Determine the dynamic balances for h₁ and h₂.


The general form of a mass balance for a tank is A * dh/dt = inflow - outflow.

• For Tank FC23 (level h₁):


A * dh1/dt = f_in(t) - f1(t)
where f1(t) = K_eff * u1 * sqrt(max(0, h1(t) - h2(t) + y))
u1 is fixed at the value calculated in 1.1 (≈ 0.6584).
So, dh1/dt = (1/A) * [f_in(t) - K_eff * u1 * sqrt(max(0, h1(t) - h2(t) + y))]
• For Tank FC24 (level h₂):
A * dh2/dt = f1(t) - f2(t)
where f1(t) is the same as above.
f2(t) is the flow out of FC24, controlled by V2 (opening u2(t)). Assuming it discharges to
a point where h_j = 0 effectively.
f2(t) = K_eff * u2(t) * sqrt(max(0, h2(t) + y)) (Here, h_i = h2, h_j = 0)
So, dh2/dt = (1/A) * [K_eff * u1 * sqrt(max(0, h1(t) - h2(t) + y)) - K_eff * u2(t) *
sqrt(max(0, h2(t) + y))]

Summary of Dynamic Equations for Q1.2:


Constants:
A ≈ 159.93 m²
K_eff ≈ 2232.36 (m³/hr)/sqrt(m)
y=1m
u1 ≈ 0.6584

Equations:

1. dh1/dt = (1/159.93) * [f_in(t) - 2232.36 * 0.6584 * sqrt(max(0, h1(t) - h2(t) + 1))]


2. dh2/dt = (1/159.93) * [2232.36 * 0.6584 * sqrt(max(0, h1(t) - h2(t) + 1)) - 2232.36 *
u2(t) * sqrt(max(0, h2(t) + 1))]

u2(t) will be determined by the PI controller in Question 2. f_in(t) comes from Flow.csv.

Question 2: Simulation FC23 & FC24

You'll need Matlab or similar software (Python with SciPy/NumPy).

2.1) Create a simulation with PI controller for V2.

• System ODEs: The two dh/dt equations from Q1.2.


• Input f_in(t): Load data from Flow.csv. This will likely be a time series. You'll need to
interpolate f_in values if the ODE solver time steps don't align with the CSV. Assume
Flow.csv has two columns: time (in hours, to match f_in units of m³/hr) and flow rate
(m³/hr).
• PI Controller for V2 (controls u2 based on h2):
o Setpoint for h2: h2_sp = 3 m.
o Error: e(t) = h2_sp - h2(t).
o PI control law: u2(t) = u2_bias + Kp * e(t) + Ki * ∫e(t)dt.
▪ u2_bias: Steady-state opening for V2 when h2 = 3m and flow is f_avg =
1800 m³/hr.
1800 = K_eff * u2_bias * sqrt(h2_sp + y)
1800 = 2232.36 * u2_bias * sqrt(3 + 1)
1800 = 2232.36 * u2_bias * sqrt(4)
1800 = 2232.36 * u2_bias * 2
1800 = 4464.72 * u2_bias
u2_bias = 1800 / 4464.72 ≈ 0.4032
▪ Kp, Ki: Proportional gain and integral gain. These need to be tuned. Start
with reasonable values (e.g., Kp around 0.1-1, Ki related to Kp/τI where τI
is a guessed integral time). Trial and error or tuning rules (like Ziegler-
Nichols on a simplified model) are needed.
o Saturation: u2(t) must be limited to [0, 1].
o Anti-windup: If u2(t) saturates, stop accumulating the integral term (or use a
more advanced anti-windup scheme).
• Initial Conditions:
o h1(0): Could be 3.5 m (steady-state assumption for V1 design).
o h2(0): Could be 3.0 m (the setpoint).
o Integral of error for PI: ∫e(t)dt at t=0 is 0.
• Simulation Time: Determined by the time range in Flow.csv.

Matlab Implementation Sketch:

% Constants
A = 159.93;
K_eff = 2232.36;
y_const = 1.0;
u1_fixed = 0.6584;
h2_setpoint = 3.0;
u2_bias = 0.4032;

% PI Parameters (NEEDS TUNING)


Kp = 0.5; % Example
Ki = 0.1; % Example

% Load Flow.csv (time in hours, flow_in in m^3/hr)


% flow_data = readmatrix('Flow.csv');
% time_csv = flow_data(:,1);
% f_in_csv = flow_data(:,2);

% ODE function
function dXdt = tank_odes(t, X, Kp, Ki, u1_fixed, K_eff, A, y_const,
h2_setpoint, u2_bias, time_csv, f_in_csv)
h1 = X(1);
h2 = X(2);
integral_e2 = X(3); % Integral of error for h2 controller

% Interpolate f_in(t)
f_in_t = interp1(time_csv, f_in_csv, t, 'linear', 'extrap');

% Calculate f1
head1 = h1 - h2 + y_const;
if head1 < 0, head1 = 0; end % Prevent sqrt of negative
f1 = K_eff * u1_fixed * sqrt(head1);

% PI Controller for u2
e2 = h2_setpoint - h2;
u2_output = u2_bias + Kp * e2 + Ki * integral_e2;

% Saturation and Anti-windup for u2


u2_saturated = min(max(u2_output, 0), 1);

d_integral_e2_dt = e2;
if (u2_output > 1 && e2 > 0) || (u2_output < 0 && e2 < 0)
d_integral_e2_dt = 0; % Basic anti-windup: stop integrating if
saturated and error pushes further
end
u2 = u2_saturated;

% Calculate f2
head2 = h2 + y_const;
if head2 < 0, head2 = 0; end
f2 = K_eff * u2 * sqrt(head2);

% ODEs
dh1dt = (1/A) * (f_in_t - f1);
dh2dt = (1/A) * (f1 - f2);

dXdt = [dh1dt; dh2dt; d_integral_e2_dt];


end

% Initial conditions
X0 = [3.5; 3.0; 0]; % h1(0), h2(0), integral_e2(0)
% Simulation time span (e.g., from Flow.csv)
% t_span = [min(time_csv) max(time_csv)];

% Solve ODE
% [t_sol, X_sol] = ode45(@(t,X) tank_odes(t, X, Kp, Ki, u1_fixed, K_eff, A,
y_const, h2_setpoint, u2_bias, time_csv, f_in_csv), t_span, X0);

% Extract results: h1_sol = X_sol(:,1); h2_sol = X_sol(:,2);


% Recalculate f1, f2, u2 for plotting using the solution X_sol and t_sol

You would then plot to show that h2 is maintained near 3m.

2.2) Plot h₁, h₂, f₁, f₂.

• Use the simulation results (t_sol, h1_sol, h2_sol).


• Recalculate f1(t) and f2(t) using the solved h1(t), h2(t), and controller output u2(t).
• Plot h1 and h2 on the left y-axis.
• Plot f1 and f2 on the right y-axis.

2.3) Plot valve opening V₂ (%) and error.

• Recalculate u2(t) (controller output) and e2(t) = h2_setpoint - h2_sol(t).


• Plot u2(t) * 100 (for percentage) on the left y-axis.
• Plot e2(t) on the right y-axis.

2.4) Add FC25 and FC26.


The system now has 4 tanks in series.

• h3: level in FC25, h4: level in FC26.


• V3 (opening u3) controls flow f3 from FC25 to FC26.
• V4 (opening u4) controls flow f4 out of FC26.
• Position of V3 (u3): Set to maintain average flow. This is analogous to V1.
Assume desired steady state h3_ss = 3.5 m and h4_ss = 3.0 m for this calculation.
f3_avg = 1800 m³/hr.
f3 = K_eff * u3 * sqrt(max(0, h3 - h4 + y))
1800 = K_eff * u3 * sqrt(3.5 - 3.0 + 1)
This is the same calculation as for u1. So, u3 = u1 ≈ 0.6584.
• V4 controlled by PI for h4:
o Setpoint h4_sp = 3 m.
o Error e4(t) = h4_sp - h4(t).
o PI law for u4(t) = u4_bias + Kp4 * e4(t) + Ki4 * ∫e4(t)dt.
▪ u4_bias calculation is analogous to u2_bias. So, u4_bias = u2_bias ≈
0.4032.
▪ Kp4, Ki4 need tuning (can start with same values as for V2 controller, but
might need adjustment due to different dynamics).
o Saturation and anti-windup for u4(t).
• New Dynamic Equations:
3. dh3/dt = (1/A) * [f2(t) - f3(t)]
f3(t) = K_eff * u3 * sqrt(max(0, h3(t) - h4(t) + y))
4. dh4/dt = (1/A) * [f3(t) - f4(t)]
f4(t) = K_eff * u4(t) * sqrt(max(0, h4(t) + y))

Modified ODE function state vector: X = [h1; h2; integral_e2; h3; h4; integral_e4]
Initial conditions: h1(0)=3.5, h2(0)=3.0, int_e2(0)=0, h3(0)=3.5, h4(0)=3.0, int_e4(0)=0.
Simulate with the same f_in(t) from Flow.csv.

2.5) Plot heights of all four tanks.


Plot h1(t), h2(t), h3(t), h4(t) on the same graph against time.

2.6) Calculate Integrated Time Absolute Error (ITAE) for FC26.


This means for the control of h4.
ITAE = ∫ t * |e4(t)| dt = ∫ t * |h4_sp - h4(t)| dt

• Use the simulation results t_sol and h4_sol.


• Calculate abs_e4_t = t_sol .* abs(h4_setpoint - h4_sol).
• Numerically integrate abs_e4_t with respect to t_sol. In Matlab, use trapz(t_sol,
abs_e4_t).

General Tips for Simulation:

• Units: Be meticulous. If f_in is m³/hr, time should be in hours for dh/dt.


• ODE Solver: ode45 is generally good. You might need to adjust tolerances (odeset).
• PI Tuning: This is key. Poor tuning will give poor control.
o Start with Ki = 0 and tune Kp for a stable, reasonably fast response (may have
offset).
o Then introduce Ki (e.g., Ki = Kp / τI, where τI is roughly 2-4 times the dominant
period of oscillation observed with P-only control, or a fraction of the settling
time).
o Iterate. Anti-windup is important.
• Flow.csv: Ensure you know its time units and flow units. Convert if necessary. If it's
discrete points, interp1 is essential for the ODE solver.

This guide provides a structured approach to solving the assignment. The main challenge will be
implementing the simulation correctly in Matlab (or your chosen software) and tuning the PI
controllers. Good luck!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy