Project

Dynamic response of Volume and Temperature of a well-mixed vessel.

Use a Mass, and Energy balance to describe the dynamic response in volume and temperature of a well-mixed vessel.

Mass Balance Equation:-

`\frac{dm}{dt} = rho\frac{d(V)}{dt} = \sum \dot V_{in} - \sum \dot V_{out}`

Energy Balance Equation:-

`m\,c_p\frac{dT}{dt} = \sum \dot m_{in} c_p \( T_{in} - T_{ref} ) - \sum \dot m_{out} c_p \( T_{out} - T_{ref} ) + Q + W_s`

The inlet (qf) and outlet (q) volumetric flowrates, and inlet temperature (Tf) can be adjusted. Initial conditions for the vessel are V= 3.0 L, and T=550 K. There is no reaction and no significant heat added by the mixer. There is a cooling jacket that can be used to adjust the outlet temperature. Show step changes in the process inputs.

# Response of Flow rate, Volume, and Temperature in Vessel

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint

# define mixing model
def vessel(x,t,q,qf,Tf):
    # Inputs (4):
    # qf  = Inlet Volumetric Flowrate (L/min)
    # q   = Outlet Volumetric Flowrate (L/min)
    # Tf  = Feed Temperature (K)

    # States (3):
    # Volume (L)
    V = x[0]
    # Temperature (K)
    T = x[1]

    # Parameters:
    

    # Mass balance: volume derivative
    dVdt = qf - q

    # Energy balance: temperature derivative
    # Chain rule: d(V*T)/dt = T * dV/dt + V * dT/dt
    dTdt = (qf*Tf - q*T)/V - (T*dVdt/V)

    # Return derivatives
    return [dVdt,dTdt]

# Initial Conditions for the States
V0 = 3.0
T0 = 550.0
y0 = [V0,T0]

# Time Interval (min)
t = np.linspace(0,20,200)

# Inlet Volumetric Flowrate (L/min)
qf = np.ones(len(t))* 7.2
qf[70:] = 7.1

# Outlet Volumetric Flowrate (L/min)
q = np.ones(len(t))*7.0

# Feed Temperature (K)
Tf = np.ones(len(t))*500.0
Tf[70:] = 525.0

# Storage for results
V  = np.ones(len(t))*V0

T  = np.ones(len(t))*T0

# Loop through each time step
for i in range(len(t)-1):
    # Simulate
    inputs = (q[i],qf[i],Tf[i])
    ts = [t[i],t[i+1]]
    y = odeint(vessel,y0,ts,args=inputs)
    # Store results
    V[i+1]  = y[-1][0]
    T[i+1]  = y[-1][1]
    # Adjust initial condition for next loop
    y0 = y[-1]

# Construct results and save data file
data = np.vstack((t,qf,q,Tf,V,T)) # vertical stack
data = data.T             # transpose data
np.savetxt('data.txt',data,delimiter=',')

# Plot the inputs and results
plt.figure()

plt.subplot(3,2,1)
plt.plot(t,qf,'b--',linewidth=3)
plt.plot(t,q,'b:',linewidth=3)
plt.ylabel('Flow Rates (L/min)')
plt.title(' Response of Flow Rates')
plt.legend(['Inlet','Outlet'],loc='best')


plt.subplot(3,2,5)
plt.plot(t,Tf,'k--',linewidth=3)
plt.ylabel('Tf (K)')
plt.legend(['Feed Temperature'],loc='best')
plt.title(' Response of Temperature')
plt.xlabel('Time (min)')

plt.subplot(3,2,2)
plt.plot(t,V,'b-',linewidth=3)
plt.ylabel('Volume (L)')
plt.title(' Response of Volume')
plt.legend(['Volume'],loc='best')


plt.subplot(3,2,6)
plt.plot(t,T,'k-',linewidth=3)
plt.ylabel('T (K)')
plt.legend(['Temperature'],loc='best')
plt.title(' Response of Temperature')
plt.xlabel('Time (min)')

plt.show()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.