Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is it right answer? Create a graphical output of a mathematical model using arbitrary variables and Python code, but you must use a PID controller.

Is it right answer? Create a graphical output of a mathematical model using arbitrary variables and Python code, but you must use a PID controller.
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
# Constants
R =287.1 # Gas constant [Nm/kgK]
T =293 # Temperature inside the chamber [K]
V =0.8 # Volume of the chamber [L]
k =1.4 # Adiabatic coefficient
p_atm =101325 # Atmospheric pressure [Pa]
S_v =15.1 # Nominal pumping speed of the vacuum pump [m^3/h]
p_v =0.7 # Ultimate gas pressure of the vacuum pump [Pa]
V_t =1.3 # Volume inside the bellows [L]
# Variables
D =1 # Diameter of valve port
A_cu =1 # Effective cross-sectional areas of the HSVs for the charging units
A_du =1 # Effective cross-sectional areas of the HSVs for the discharging units
alpha =1 # Correction coefficient of the flow area of the valve port
sigma =0.5 # Critical pressure ratio
d =1 # Duty cycles for the process
# PID Controller Parameters
Kp =0.1
Ki =0.01
Kd =0.01
# Initial conditions
p0= p_atm
p_t0= p_atm
Q_m1=0
Q_m2=0
Q_mv =0
x_vm =0
# Time points
t = np.linspace(0,10,1000)
epsilon =0.000001 # Small time offset to avoid division by zero at t=0
# Pressure Differential Equation
def model(y, t):
p, p_t, Q_m1, Q_m2, Q_mv, x_vm = y
f1=(k * Q_m1* R * T)/ V
f2=(k * R * T)/ V_t
Q_m = Q_m1- Q_m2
f3=(p_t * S_v)/(R * T)*(1- p_v / p_t)
t_safe = t + epsilon # Use t_safe instead of t to avoid division by zero
dpdt = f1- Kp *(p - p0)- Ki *(p - p0)* t_safe - Kd *(p - p0)/ t_safe
dp_tdt = f2*(Q_m2- Q_mv)
dQ_m1dt =0.0404* A_cu * p_atm / np.sqrt(T)* f(p, p_atm)* d_cu(t)
dQ_m2dt =0.0404* A_du * p / np.sqrt(T)* f(p, p_t)* d_du(t)
dQ_mvdt = f3
dx_vmdt =0.0404* np.pi * alpha * D * x_vm * p / np.sqrt(T)* f(p, p_t)* d
return [dpdt, dp_tdt, dQ_m1dt, dQ_m2dt, dQ_mvdt, dx_vmdt]
# Function f(p1, p2)
def f(p1, p2):
ratio = p2/(p1*(1- sigma))
if ratio = sigma:
return 1
else:
adjusted_ratio = max(1- ratio **2,0) # Ensure the value under the square root is non-negative
return np.sqrt(adjusted_ratio)
# Duty cycles
def d_cu(t):
return 0.5 # Duty cycles for the process of charging
def d_du(t):
return 0.5 # Duty cycles for the process of discharging
# Solve ODE
y0=[p0, p_t0, Q_m1, Q_m2, Q_mv, x_vm]
y = odeint(model, y0, t)
# Plot results
plt.figure(figsize=(10,5))
plt.plot(t, y[:,0],'r', label='p')
plt.plot(t, y[:,1],'b', label='p_t')
plt.legend(loc='best')
plt.xlabel('Time (s)')
plt.ylabel('Pressure (Pa)')
plt.title('Pressure Control')
plt.grid()
plt.show()
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

List the functional consequences of PTSD.

Answered: 1 week ago