C/C++ 编程代写
当前位置:以往案例 > >案例C:Fundamentals of Engineering Computati
2019-04-16


The study of chemical reactors is an important part of Chemical Engineering. The transient response of a chemical reactor is the change in the concentration of a chemical substance in the reactor when the concentration of an input flow is changed.


Most of the chemical engineering applications will focus on mass balances for reactors. The mass balance is derived from the conservation of mass and states that inputs into the system minus the outputs from a system gives the accumulation of the mass in the system.


Accumulation = inputs − outputs (Equation 1)


The mass balance can be used for engineering problem solving by expressing the inputs and outputs in terms of measurable variables and parameters. For ple, to apply mass balance to a conservative substance (that is, one that does not increase or decrease due to chemical transformations) in a reactor (Figure 1), the rate at which mass flows into the reactor through the inflow pipe and out of the reactor through the outflow pipe must be quantified. This can be done by taking the product of the flow rate Q (in cubic meters per minute) and the substance concentration c (in milligrams per cubic meter) for each pipe. Thus the input to the system is Qcin and the output from the system is Qc.




Figure 1 – Simple reactor with single input and single output


We are interested in the transient response (how the concentration of a substance in a reactor changes with time) of a completely mixed reactor (that is the concentration of the substance is the same throughout the reactor). To do this, we first develop a mathematical expression for the accumulation of mass in the reactor. For a constant-volume reactor (where the volume of liquid does not change), it can be simply formulated as




Accumulation

0 V dc dt



(Equation 2)




where V = constant volume and c = concentration in the reactor. Thus, a mathematical formulation for accumulation is volume times the derivative of c with respect to t; the equation represents how the accumulation of the chemical substance changes with respect to the change in concentration.


The accumulation expressed in Equation 2 can be incorporated into a general mass balance framework. It can then be used to simulate the dynamics of a single reactor and a system of reactors. Only the single reactor shown in Figure 1 is considered. When the input flow and output flow rates are the same the volume in the reactor remains constant. The concentration of




the output flow, c, is the same as the concentration of the substance in the reactor, that is, when input equals output the masse is conserved in the reactor (no accumulation occurs).


Equations (1) and (2) can be combined to represent the mass balance for a single reactor shown in Figure 1:

V dc = Qc – Qc (Equation 3)

dt in


Equation (3) can be used to determine transient or time-variable response for the reactor, that is, how the concentration of the substance in the reactor can change over time, for a given initial concentration, c0 (at time t=0) and the given flow concentrations cin (in the input flow) and c (reactor concentration). Applying calculus to Equation (3), the analytical solution for the change in reactor concentration over time is:

c (t ) = c

(1 – e – ( Q /V ) t ) + c e–( Q /V )t

(Equation 4)

in

0

For ple, if cin = 50 mg/m3, Q = 5 m3/min, V = 100 m3, and c0 = 10 mg/m3, the change in concentration over time becomes:




c (t ) = 50(1 – e

–0.05 t

) +10e

–0.05t

(Equation 5)




Although an analytical solution is possible for some applications, it may become challenging or even impossible to find one for many problems. Numerical methods can be used to provide solutions directly from the differential equations. A simple numerical method for solving differential equations is Euler’s method.


Given a normal form for a differential equation where the term on the right contains no derivative terms:




dx

= f ( x)

dt



(Equation 6)




Euler’s method provides a difference equation of the following form:



dx

=

x

– x

= f (x )

t =i

i +1

i

dt

Dt

i

x

= x + f (x )Dt

i +1

i

i



(Equation 7)



Applying Equation (7) to Equation (3), the difference equation for change in reactor concentration becomes:




V dc = Qcin – Qc dt

dc

=

æ Qc

– Qc ö

ç

in

÷

dt

V

è

ø

c

= c +

æ Qc

– Qc

ö

Dt

ç

in

i

÷

i +1

i

V

è

ø






(Equation 8)



where the concentration ci+1 and ci represent concentrations of the chemical substance in the reactor at times ti+1 and ti respectively. Thus for given values of c0 at time t0, it is possible to compute all values of ci as time is incremented by Δt (which gives the values of t1, t2, t3, …).


Develop software that allows the user to study the transient response of the simple reactor shown in Figure 1. The user will provide the following input values: flow Q, the input flow substance concentration cin, the initial value of the substance concentration at time t = 0, c0, and the final time that defines the range of time over which the response is to be studied (i.e. between t = 0 and t = tf). The transient response is plotted for the given values.




The software will plot 2 curves, one that shows the analytical solution, and another that shows the response time calculated using Euler’s numerical method (for Euler’s method, the user must provide a time increment value). In addition to the plot, the software shall display on the console all input values provided by the user.


When new input values are given, the user is given the option to save them into a file; up to five sets of values can be stored. Thus when the software starts the user can elect to use one of the stored value sets or enter a new set of values.


Experiment with different step sizes to see how the compare the numerical solution to the analytical solution; report the differences in your Testing and Verification section.


在线提交订单