You are on page 1of 25

CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Project 1: Modeling of a Heated Tank

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 1 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Project 1
Table of Contents

Background ................................................................................................................................... 3
Objective(s).................................................................................................................................... 4
Approach ....................................................................................................................................... 5
Symbols and Given Data ............................................................................................................ 7
Calculations .................................................................................................................................. 8
Summary of Results ................................................................................................................... 13
Discussion ................................................................................................................................... 15
References ................................................................................................................................... 15
Source Code ................................................................................................................................ 15

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 2 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Figure 1. Electrically Heated Water Tank (Seborg, Edgar et al. 2011)


Background
In the modeling and control of chemical processes, the hardware employed to measure
process variables introduces dynamic lags and noise. These factors must be accounted for to
obtain an accurate assessment of the state of the process. In this project, the effects of
sensor/actuator dynamics, transport delay, noise, and filtering on the dynamic response of the
hot water heater outlet temperature are investigated.

The model derived for Problem 3.7.15 of Riggs et al. (2020) is expanded to include these
effects. For the base case, consider that the hot-water heater is well mixed and has a water
holdup of V=30 gallons. Assume that initially the water temperature is 120°F. At time equal to
zero, hot water is withdrawn at rate of F = w  = 5 gallons per minute and 5 gallons per
minute of cold water at 60°F are simultaneously added. (w is the mass flow rate of the water).
Assume that the heat addition rate to the hot-water heater is constant at 6 x 104 BTU/h and is
applied at the instant the hot water is removed from the tank. Please see Figure 1 for a
schematic of the process.

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 3 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Objective(s)
1. Scenario 1: Simulate the base case, obtaining a plot of the tank outlet temperature T as a
function of time from 0 to 100 minutes. Only include the dynamics of the tank itself. Identify
the following parameters. Use the identified parameter values for the subsequent scenarios.
a. process time constant, min
b. process gain, ∆℉/𝐵𝑇𝑈/𝑚𝑖𝑛
c. time for temperature to drop to 90°F, min
d. time to new steady state, minutes
2. Scenario 2: To Scenario 1 add a control valve on the inlet stream and a thermocouple on the
tank outlet. Incorporate the valve (𝜏𝑣 =10 sec) and sensor dynamics (𝜏𝑠 =75 sec) to the modeling
equations. Co-plot the tank temperature with and without the valve/sensor dynamics from 0
to 100 minutes.
3. Scenario 3: Add to Scenario 2 a thermocouple transport delay of 1 minute. Add the time
course of the tank temperature including the transport delay to the plot of Scenario 2. Hint:
For a signal 𝑠(𝑡), its delayed version 𝑠𝑑 (𝑡) with delay value 𝜃 is defined as (where 𝑠0 is intial value of
𝑠(𝑡))
𝑠0 𝑖𝑓 𝑡 < 𝜃
𝑠𝑑 (𝑡) = {
𝑠(𝑡 − 𝜃) 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
4. Scenario 4: Contaminate the signal in Scenario 3 with noise corresponding to the repeatability
of a thermocouple in a thermowell. Use equation 3.8.1 (p. 134) of your text to generate the
added noise. If needed, employ a sampling time of 1 minute. Add the time course of the tank
temperature including the noise to the plot of Scenario 3. The equation 3.8.1 is (where
standard deviation 𝜎 is obtained from Table 2.4 as in your homework, 𝑥𝑛 is a random number
between 0 and 1)
1.961𝜎(𝑥𝑛 − 0.5)
𝑦𝑛 =
[(𝑥𝑛 + 0.002432)(1.002432 − 𝑥𝑛 )]0.203
5. Scenario 5: Apply a digital exponential filter EWMA to the signal from Scenario 4, using the
heuristic for setting the filtering time constant. Employ a sampling time of 1 minute. Add the
time course of the tank temperature including the filter to the plot of Scenario 4.
6. Scenario 6: Compute the sum of the squared errors (SSE) for the filtered and unfiltered signals
from Scenarios 4 and 5 over the range of 50 to 100 minutes. Do this for several different sets
SSE f
of random numbers. What is the upper bound for the ratio
SSEnf ?

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 4 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Approach (Procedures for modeling only the tank)


(1) State the modeling objectives and the end use of the model:

i. The objective of this project is to quantitatively assess different process control


configurations to a heated tank by developing a set of equations using a lumped
parameter model.
ii. The end use of the model is to optimize the operation of the hot water heater to lower
temperature variations and minimize energy consumption.

(2) List all your assumptions:


i. There is no mass generation.
ii. Constant volume in the reactor.
iii. Similar density in the product stream, inside tank, and feed stream.
iv. Mass flow rate in is equal to mass flow out, therefore, volume hold-up is
constant.
v. Heat loss is negligible.
vi. Constant heat addition rate.

(3) Determine whether spatial variations are important. State whether macroscopic or
microscopic method should be used, and whether you should get an ODE or PDE:

Spatial variations of process variables are not important in this case since there are no
substantial temperature gradients within the tank. The macroscopic method, lumped-parameter
model, will be used to model the system as a whole without considering spatial variations in
detail. Since the model uses macroscopic modelling, we will use Ordinary Differential
Equations.

(4) Write appropriate conservation equations (mass, mole, energy and so forth). Do not
forget initial conditions:

No generation of mass
𝐺 = 0, 𝜔𝑖 − 𝜔 = 0 (1)
Balance of mass:
(𝑑(𝜌𝑉))
=0 (2)
𝑑𝑇

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 5 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Energy balance equation


̂ = 𝑑𝐻
𝑑𝑈 ̂ = 𝐶𝑣 𝑑𝑇 = 𝐶𝑝 𝑑𝑇 (3)
Equilibrium relations:
̂
𝑈 = 𝜌𝑉𝑈 (4)

̂
𝑑𝑈
= 𝜌𝑉𝐶𝑝 𝑑𝑇 (5)
𝑑𝑇

̂ = 𝐶𝑝 (𝑇 − 𝑇𝑟𝑒𝑓 )
𝐻 (6)

𝑑𝑈
̂) + 𝑄
= −∆(𝑤𝐻 (7)
𝑑𝑇

Substituting these equations gives the following final model.


𝜌𝑉𝐶𝑣 𝑑(𝑇−𝑇𝑟𝑒𝑓 )
= 𝑤[𝐶𝑝 (𝑇𝑖 − 𝑇𝑟𝑒𝑓 )] − 𝑤[𝐶𝑝 (𝑇 − 𝑇𝑟𝑒𝑓 )] + 𝑄 (8)
𝑑𝑇

𝑑𝑇𝑟𝑒𝑓
= 0, 𝐶𝑣 = 𝐶𝑝 (9)
𝑑𝑡

(5) Perform degree of freedom analysis. Hint: process variables with given values can be
considered as constants.

There is no additional degree of freedom. The total number of unknown variables is one (T(t).
Number of equations is also one. Hence, degree of freedom (DOF) = 1 -1 = 0. Therefore, degree
of freedom analysis will be straightforward.

(6) Simplify the model in the form of standard ODE. Plug in values to compute time
constant, and process gain analytically based on your model. Hint: for a generic first-order
𝑑𝑦(𝑡)
ODE 𝜏 + 𝑦(𝑡) = 𝐾𝑢 + 𝑑(𝑡) where 𝑦(𝑡) is output and 𝑢(𝑡) is a constant step input, and
𝑑𝑡
d(t) is disturbance independent of u(t) and y(t), Then the time constant is 𝜏, and gain is 𝐾. Do
not forget initial conditions.

𝑑𝑇
𝑀𝐶𝑝 𝑑𝑡 = 𝑤[𝐶𝑝 (𝑇𝑖 − 𝑇)] + 𝑄 (10)

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 6 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

𝑑𝑇̂ (𝐹𝑠𝑝𝑒𝑐 ∗𝜌∗(𝑇1 −𝑇)) 𝑄


= + (11)
𝑑𝑡 𝜔 𝐶𝑣 ∗𝜔

Symbols and Given Data (List Symbols and Data for the Model Established Above)

Table 1. List of Symbols and Given Data

Symbol Description

𝐾𝑝 process gain

𝑄 Heat rate (6 x 1014 BTU/hr)


𝐹𝑠𝑝𝑒𝑐 Volumetric flow rate in (5 gal/min)
𝐹 Volumetric flow rate (gal/min)
𝐶𝑣 Heat capacity of water (constant volume)
𝜔 Mass flow rate
𝜏𝑣
Valve time constant
𝜏𝑡𝑠
Sensor time constant
𝜏𝑝
Process time constant
𝜌
Density of water
α
Dimensionless parameter
𝑦𝑛
Noise correlation
𝑋𝑛
Random number
𝑉
Volume (30 gallons)
𝑇
Temperature
𝑇𝑠𝑛
Temperature of sensor with noise
𝑇𝑠𝑠
Steady state temperature
𝑇𝑠

𝑇𝑓 Sensor temperature

Temperature of filter sensor signal


𝑇1
Temperature of cold water

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 7 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

𝑆𝑆𝐸𝑛𝑓 Sum of squared errors for unfiltered signals

𝑆𝑆𝐸𝑓 Sum of squared errors for filtered signals

Calculations
For each scenario, list your calculation procedures and the model (represented by
symbols not numbers) to be simulated, show the figure plot. Use your obtained time
constant or gain from the plots for all scenarios.

(1) Scenario 1:

First, we can find the time constant using the model below.
62.4
𝜌∗𝑉 𝜌∗𝑉 ( ) ∗ 30𝑔𝑎𝑙
𝜏𝑝 = = = 7.48052 = 6 𝑚𝑖𝑛𝑢𝑡𝑒𝑠
𝜔 𝜌 ∗ 𝐹𝑠𝑝𝑒𝑐 62.4 5𝑔𝑎𝑙
( ) ∗ min
7.48052
The density is divided by 7.48052 to change it to gal from ft3

We can then compute process gain as below.


1 1 °F
𝐾𝑝 = = = 0.0239
𝜔 ∗ 𝐶𝑣 41.708 𝑙𝑏 ∗ 1 𝐵𝑇𝑈 BTU
min 𝑙𝑏 ∙ °𝐹 min
To get the time required for temperature to drop to 90°F, we will extrapolate the results from
plot 1,

9: 92.0007

X: 90

11: 89.7378
(90 − 89.7378)(11 − 9)
𝑋= + 9 = 10.77 𝑚𝑖𝑛
92.0007 − 89.7378
Time until a steady state is reached.

𝑇𝑠𝑠 = 𝑇(100) ∗ 0.05% + 𝑇(100) = 83.976 ∗ 0.00005 + 83.976 = 84.02°𝐹

From this, linear interpolation is used to find the exact time.

45: 85.9976

X: 84.0180

40: 84.0245

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 8 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

(84.018 − 83.998)(40 − 45)


𝑋= + 45 = 40.81 𝑚𝑖𝑛
84.025 − 83.998
Figure 1: Tank Temperature vs. Time

(2) Scenario 2:

The dynamic model for the process is given by:

𝑑𝑇 (𝐹𝑠𝑝𝑒𝑐 ∗ 𝜌 ∗ (𝑇1 − 𝑇)) 𝑄


= +
𝑑𝑡 𝜔 𝐶𝑣 ∗ 𝜔
1
5∗8.342∗(60−𝑇) 6∗104 ∗
Solving this further gives: + 1∗41.708 = 4.79 𝑥 10−5 (60 − 𝑇)℉ + 23.976℉
60
41.708

The dynamic model of the actuator:

𝑑𝐹 𝐹𝑠𝑝𝑒𝑐 − 𝐹
=
𝑑𝑡 𝜏𝑣
𝑔𝑎𝑙
5−𝐹 (5−𝐹)
min
Solving this gives: 1 = 0.16667 min
10∗
60

Dynamic model of the sensor is given by:

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 9 of 7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

𝑑𝑇𝑠 𝑇 − 𝑇𝑠
=
𝑑𝑡 𝜏 𝑇𝑠

Solving this:
(𝑇 − 𝑇𝑠 )℉ (𝑇 − 𝑇𝑠 )℉
=
1 1.25 min
75sec ∗ 60

Figure 2: Tank Temperature vs time with and without valve

(3) Scenario 3:

From scenario 2, the dynamic model for the actuator was:


𝑔𝑎𝑙
𝑑𝐹 𝐹𝑠𝑝𝑒𝑐 − 𝐹 (5 − 𝐹) min
= =
𝑑𝑡 𝜏𝑣 0.16667 min

The dynamic model for the process will be:

𝑑𝑇 (𝐹𝑠𝑝𝑒𝑐 ∗ 𝜌 ∗ (𝑇1 − 𝑇)) 𝑄


= +
𝑑𝑡 𝜔 𝐶𝑣 ∗ 𝜔

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 10 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Incorporating a transport delay of 1 minute, the dynamic model of the actuator will be:

If 𝑡𝑖𝑚𝑒 ≤ 1 𝑚𝑖𝑛,
𝑑𝑇𝑠
=0
𝑑𝑡
Otherwise,
𝑑𝑇𝑠 𝑇 − 𝑇𝑠 (𝑇 − 𝑇𝑠 )℉
= =
𝑑𝑡 𝜏 𝑇𝑠 1.25 min

Figure 3: A plot of Tank temperature vs time with and without delay

(4) Scenario 4:

The contribution of sensor noise will assume a Gaussian form for white noise, which is
represented by:

1.961σ(xn − 0.5)
𝑦𝑛 =
[(xn + 0.002432)(1.002432 − xn )]0.203
Here:

𝑥𝑛 = 𝑟𝑎𝑛𝑑𝑜𝑚 𝑛𝑢𝑚𝑏𝑒𝑟𝑠 𝑓𝑟𝑜𝑚 0 𝑡𝑜 1, This is generated 100 times, yielding 100 values for yn

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 11 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

σ = 0.9

Figure 4: A plot of temperature vs time with and without noise.

(5) Scenario 5:

Applying a digital exponential filter EWMA to the signal from Scenario 4 using the
following equation.

𝑇𝑓 (𝑖) = (𝛼 × 𝑇𝑠𝑛 (𝑖)) + (1 − 𝛼)(𝑇𝑓 (𝑖 − 1)

Here,
∆𝑡
𝛼 𝑖𝑠 𝑎 𝑑𝑖𝑚𝑒𝑛𝑠𝑖𝑜𝑛𝑙𝑒𝑠𝑠 𝑝𝑎𝑟𝑎𝑚𝑒𝑡𝑒𝑟 𝑟𝑒𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑒𝑑 𝑏𝑦 𝜏
𝑓 +∆𝑡

𝑖 = 2,3,4,5, … ,101.
𝑇𝑓 (𝑖) = 𝑜𝑢𝑡𝑝𝑢𝑡 𝑜𝑓 𝑓𝑖𝑙𝑡𝑒𝑟𝑒𝑑 𝑡𝑒𝑚𝑝𝑒𝑟𝑎𝑡𝑢𝑟𝑒

The first output of temperature to be filtered 𝑇𝑓 (1) is 120°F.

To compute the filtered temperature from 1 to 100 in the equation above, we will use a
for loop (2:101)

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 12 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Figure 5: a plot of temperature vs time with and without filter

(6) Scenario 6:

The equation below was used to compute the sum of squared errors from 50 to 100 minutes.
𝑛
2
∑(𝑦𝑖 − 𝑓(𝑥𝑖 ))
𝑖=1

To analyze scenario 3 to 5, we will use SSE for filtered signal.


101
2
∑(𝑇𝑓 − 𝑇𝑠 ) = 17.348
𝑖=1

The equation below is the SSE for the unfiltered signal, which analyzes scenario 4 to 5.
101

∑ (𝑇𝑠𝑛 − 𝑇𝑠 )2 = 38.975
𝑖=51

The ratio between the two SSEs is given by:


𝑆𝑆𝐸𝑓 17.348
= = 0.4451
𝑆𝑆𝐸𝑛𝑓 38.975

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 13 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Summary of Results

The process time constant was found to be 6 minutes. The process gain was 0.0240°𝐹/𝐵𝑇𝑈/𝑚𝑖𝑛
The system requires 10.77 minutes to drop to 90 °F while it needs approximately 40.82 to reach a
steady state. SSE for filtered signal is 17.348 while SSE for unfiltered signal is 38.975. This gives
a ratio of 0.4451 between the two SSEs.

Figure 6: Plots of different temperatures vs time

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 14 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

Discussion

In scenario 1, the temperature starts at 120°F and reduces exponentially over time due to
cooling of the hot water in the tank. The reduction follows an exponential decay curve, with a
time constant of 6 minutes. Introducing the valve adds dynamics to the system, leading to a
slight variation in temperature at the initial stages. Temperature takes slightly longer to achieve
a new steady state. Adding noise increases oscillation, making it less smooth compared to
others. Filtering the system tries to smoothen it, reducing the variations due to noise.

References

Riggs, J. B. K. M. N. and J. S. A. (2020). Chemical and bio-process control. 5th Edition.


Austin, Texas, Ferret Publishing.
Seborg, D. E., T. F. Edgar, et al. (2011). Process dynamics and control. Hoboken, N.J., John
Wiley & Sons.

Source Code

% Scenario 1: Temperature Response without Dynamics

% Define parameters for Scenario 1

tau_p = 6; % Process time constant (minutes)

K_p = 0.0239; % Process gain (°F/BTU/min)

X1 = 10.77; % Time for temperature to drop to 90°F (minutes)

X2 = 40.81; % Time to new steady state (minutes)

% Time vector

t = 0:0.1:100; % Time from 0 to 100 minutes

% Temperature response for Scenario 1

T1 = 120 - K_p * (1 - exp(-t / tau_p)); % Temperature without dynamics


This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 15 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

% Plot Scenario 1

figure;

plot(t, T1, 'b', 'LineWidth', 2);

title('Scenario 1: Temperature vs Time');

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

grid on;

% Scenario 2: Temperature Response with and without Valve Dynamics

% Define parameters for Scenario 1

tau_p = 6; % Process time constant (minutes)

K_p = 0.0239; % Process gain (°F/BTU/min)

X1 = 10.77; % Time for temperature to drop to 90°F (minutes)

X2 = 40.81; % Time to new steady state (minutes)

% Define parameters for valve dynamics

tau_v = 10; % Valve time constant (seconds)

% Time vector

t = 0:0.1:100; % Time from 0 to 100 minutes

% Initialize variables for both cases

T1 = zeros(size(t)); % Temperature with valve dynamics

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 16 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

T2 = zeros(size(t)); % Temperature without valve dynamics

F = zeros(size(t)); % Flow rate through the control valve

% Set the initial temperature to 120°F

T1(1) = 120;

T2(1) = 120;

% Simulate Scenario 1 with and without valve dynamics

for i = 2:length(t)

dt = t(i) - t(i - 1);

% Calculate control valve dynamics

dF = (5 - F(i - 1)) / tau_v;

F(i) = F(i - 1) + dF * dt;

% Calculate tank temperature with valve dynamics

dT1 = (5 * 8.342 * (60 - T1(i - 1)) / 41.708 + (6e4 * 1/60) / (1 * 41.708)) * dt;

T1(i) = T1(i - 1) + dT1;

% Calculate tank temperature without valve dynamics

dT2 = (5 * 8.342 * (60 - T2(i - 1)) / 41.708 + (6e4 * 1/60) / (1 * 41.708)) * dt;

T2(i) = T2(i - 1) + dT2;

end

% Plot Scenario 1 with and without valve dynamics on the same graph

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 17 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

figure;

plot(t, T1, 'b', 'LineWidth', 2, 'DisplayName', 'w/ valve');

hold on;

plot(t, T2, 'r', 'LineWidth', 2, 'DisplayName', 'w/o valve');

xlabel('Time (min)');

ylabel('Temperature (°F)');

legend('show');

grid on;

% Scenario 3: Temperature Response with and without Transport Delay

% Define parameters for Scenario 1

tau_p = 6; % Process time constant (minutes)

K_p = 0.0239; % Process gain (°F/BTU/min)

X1 = 10.77; % Time for temperature to drop to 90°F (minutes)

X2 = 40.81; % Time to new steady state (minutes)

% Define parameters for the transport delay

transport_delay = 1; % Transport delay (minutes)

% Time vector for Scenario 1

t1 = 0:0.1:X2; % Time from 0 to X2 minutes

% Temperature response for Scenario 1 without dynamics

T1 = 120 - K_p * (1 - exp(-t1 / tau_p));

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 18 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

% Time vector for Scenario 3, including transport delay

t3 = X2:0.1:100;

% Initialize the temperature response vectors

T3 = zeros(size(t3));

T1_short = T1(1:length(t1)); % Temperature response without transport delay

% Add the transport delay to the temperature response in Scenario 1

for i = 1:length(t3)

if t3(i) >= X2 + transport_delay

index = round((t3(i) - X2 - transport_delay) * 10) + 1; % Account for the transport delay

if index <= length(t1)

T3(i) = T1(index);

else

T3(i) = T1(end);

end

end

end

% Plot Scenario 3 with and without transport delay

figure;

plot(t3, T3, 'b', 'LineWidth', 2, 'DisplayName', 'w/ delay');

hold on;

plot(t1, T1_short, 'r', 'LineWidth', 2, 'DisplayName', 'w/o delay');

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 19 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

legend('show');

grid on;

% Scenario 4: Temperature Response with Noise

% Define parameters for Scenario 1

tau_p = 6; % Process time constant (minutes)

K_p = 0.0239; % Process gain (°F/BTU/min)

X1 = 10.77; % Time for temperature to drop to 90°F (minutes)

X2 = 40.81; % Time to new steady state (minutes)

% Define parameters for the transport delay

transport_delay = 1; % Transport delay (minutes)

% Time vector for Scenario 1

t1 = 0:0.1:X2; % Time from 0 to X2 minutes

% Temperature response for Scenario 1 without dynamics

T1 = 120 - K_p * (1 - exp(-t1 / tau_p));

% Time vector for Scenario 3, including transport delay

t3 = X2:0.1:100;

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 20 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

% Initialize the temperature response vectors

T3 = zeros(size(t3));

T1_short = T1(1:length(t1)); % Temperature response without transport delay

% Add the transport delay to the temperature response in Scenario 1

for i = 1:length(t3)

if t3(i) >= X2 + transport_delay

index = round((t3(i) - X2 - transport_delay) * 10) + 1; % Account for the transport delay

if index <= length(t1)

T3(i) = T1(index);

else

T3(i) = T1(end);

end

end

end

% Generate noise with the given equation

sampling_time = 1; % Sampling time in minutes

sigma = 0.9; % Standard deviation σ

% Create noise vector to match the length of t3

noise = zeros(size(t3));

for i = 1:length(t3)

x_n = rand(); % Generate a random number between 0 and 1

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 21 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

noise(i) = (1.961 * sigma * (x_n - 0.5)) / (((x_n + 0.002432) * (1.002432 - x_n))^0.203);

end

% Add noise to the temperature response

T3_noisy = T3 + noise;

% Plot Scenario 3 with noise and exponential decay

figure;

plot(t3, T3_noisy, 'b', 'LineWidth', 2, 'DisplayName', 'w/ noise');

hold on;

plot(t3, T3, 'r', 'LineWidth', 2, 'DisplayName', 'w/o noise');

xlabel('Time (min)');

ylabel('Temperature (°F)');

legend('show');

grid on;

% Scenario 5: Applying an EWMA Filter to Scenario 4

% Load the data from Scenario 4

load('scenario4.mat'); % Assuming you have saved the data from Scenario 4

% Set the filtering time constant (heuristic method)

alpha = 0.2;

% Apply the EWMA filter

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 22 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

T4_filtered = zeros(size(T4));

T4_filtered(1) = T4(1);

for i = 2:length(T4)

T4_filtered(i) = alpha * T4(i) + (1 - alpha) * T4_filtered(i - 1);

end

% Plot Scenario 4 with the EWMA filter

figure;

plot(t4, T4, 'r', 'LineWidth', 2, 'DisplayName', 'w/o filter');

hold on;

plot(t4, T4_filtered, 'b', 'LineWidth', 2, 'DisplayName', 'w/ filter');

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

legend('show');

grid on;

Summary

% Load data from Scenario 1 to Scenario 5

load('scenario1_data.mat');

load('scenario2_data.mat');

load('scenario3_data.mat');

load('scenario4_data.mat');

load('scenario5_data.mat');

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 23 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

% Create a single figure for all scenarios

figure;

% Scenario 1

subplot(5,1,1);

plot(t1, T1, 'b', 'LineWidth', 2);

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

grid on;

% Scenario 2

subplot(5,1,2);

plot(t2, T2, 'g', 'LineWidth', 2);

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

grid on;

% Scenario 3

subplot(5,1,3);

plot(t3, T3_noisy, 'm', 'LineWidth', 2, 'DisplayName', 'w/ noise');

hold on;

plot(t3, T3, 'r', 'LineWidth', 2, 'DisplayName', 'w/o noise');

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

legend('show');

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 24 of
7
CHE 4353 Project 1 Name: Mason Campbell Signature: ______________________

grid on;

% Scenario 4

subplot(5,1,4);

plot(t4, T4, 'k', 'LineWidth', 2, 'DisplayName', 'Original Signal');

hold on;

plot(t4, T4_filtered, 'c', 'LineWidth', 2, 'DisplayName', 'Filtered Signal (EWMA)');

title('Scenario 4: Temperature with EWMA Filter');

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

legend('show');

grid on;

% Scenario 5

subplot(5,1,5);

plot(t5, T5_filtered, 'y', 'LineWidth', 2, 'DisplayName', 'Filtered Signal (EWMA)');

xlabel('Time (minutes)');

ylabel('Temperature (°F)');

legend('show');

grid on;

% Adjust the overall plot spacing

tightfig;

This project is adapted from a previous process control project by Dr. Ted Wiesner. Page 25 of
7

You might also like