# Tutor profile: Jingying C.

## Questions

### Subject: Physics (Thermodynamics)

The question is given: "For the desuperheater, liquid water at state 1 is injected into a stream of superheated vapor entering at state 2. As a result, saturated vapor exits at state 3... Ignoring stray heat transfer and kinetic and potential energy effects, determine the mass flow rate of the incoming superheated vapor, in kg/min." And the steady state data at each state is given by: T1=20 C, p1=0.3 MPa, m'1=6.37 kg/min T2=200 C, p2=0.3 MPa p3=0.3 MPa, Saturated vapor I know that by conservation of mass, the mass flow rate is conserved m'1+m'2=m'3 I don't know what data I need to calculate the answer, especially when I'm only given one mass flow rate in the setup.

When you don't know what to find, the safe thing to do it to find them all. I know this sounds a lot, but the equation would suggest what variables exist; once you know the variables, try to find all of those values at every state. For the steady state, the energy rate balance equation for a heat exchanger is $$0=\dot{Q_{cv}}+\sum_{i}^{}\dot{m_i}h_i-\sum_{e}^{}\dot{m_e}h_e$$ Since heat transfer is ignored, the equation simplifies to $$0=\dot{m_1}h_1+\dot{m_2}h_2-\dot{m_3}h_3$$ Which suggests that we need $$h$$ at each state. Now you have two equations with two unknowns, where you can solve for $$\dot{m_3}$$.

### Subject: MATLAB

Write Matlab codes to approximate $$\int_{-1}^{1} x e^x dx$$ using the Simpson’s rule. Obtain the approximation for $$n=10$$ steps. I don't know how to write the code for Simpson's rule because of how it alternates between 4 and 2.

The Simpson's rule is given by $$\int_{a}^{b} f(x)d \approx \frac{h}{3}(f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+...+4f(x_{n-1})+f(x_n))$$ Note that the summation in the parenthesis is the sum of the sets $$f(x_0)+4f(x_1)+f(x_2)$$ $$f(x_2)+4f(x_3)+f(x_4)$$ $$f(x_4)+4f(x_5)+f(x_6)$$ etc... So I need the index under the $$4f(x)$$ be odd numbers and the index in $$f(x)$$ be even numbers. First creates a function for Simpson's rule in Matlab platform and initializes some variables: $$function [I]=simpson(x0,xn,n)$$ where the variables are x0 - lower bound of the integration interval. xn - upper bound of the integration interval. n - number of iterations. I - result of integral approximation using the Simpson's rule. Initialization: $$h=(xn-x0)/n; $$ is the step size $$I=0;$$ to initialize a result variable $$xv=x0:h:xn;$$ is the x value vectors Review that 2 times any number, $$2n$$, gives an even number and $$2n-1$$ gives an odd number, I will use these expressions to call the x values in the vector xv. Be careful that Matlab index starts from 1 (one step forward from our own index), so xv(1) is actually $$x_0$$, therefore I need the index under the $$4f(x)$$ be even numbers instead and vice versa. Iteration: $$for \space i=1:n/2$$ (n is divide by 2 because it will be multiply by 2 in the iteration) $$\space\space\space\space I=I+h/3*(func(xv(2*i-1))+4*func(xv(2*i))+func(xv(2*i+1)));$$ $$end \space \%for \space loop$$ $$end \space \%function$$ In the iteration, $$func$$ is the external function or subfunction that outputs $$f(x)$$ as specified by the problem; here it is $$x e^x$$ and I will leave that for you to write. We can check the iteration. when i=1, $$2i-1=1, 2i=2, 2i+1=3$$; take one step back to return to our own index, $$func$$ evaluates $$f(x_0)+4f(x_1)+f(x_2)$$. when i=2, $$2i-1=3, 2i=4, 2i+1=5$$; so $$func$$ evaluates $$f(x_2)+4f(x_3)+f(x_4)$$. when i=10/2=5, $$2i-1=9, 2i=10, 2i+1=11$$; so $$func$$ evaluates $$f(x_8)+4f(x_9)+f(x_{10})$$.

### Subject: Partial Differential Equations

Given that the heat distribution inside a uniform sphere of radius $$a$$ can be modeled by $$\frac{\partial u}{\partial t}=\frac{1}{r^2} \frac{\partial}{\partial r}(r^2\frac{\partial u}{\partial r})$$ in the spherical coordinate, how do I apply separation of variables to find $$u$$?

To apply the separation of variables method, assume that $$u(r,t)$$ is the multiple of two independent functions: $$u(r,t)=g(r) h(t)$$. Substitute $$g$$ and $$h$$ into the PDE. $$\frac{\partial (gh)}{\partial t}=\frac{1}{r^2} \frac{\partial}{\partial r}(r^2\frac{\partial (gh)}{\partial r})$$ Because $$g$$ is a function of r only, partial derivative $$\frac{\partial}{\partial t}$$ treats $$g$$ as a constant; similar reason applies to $$\frac{\partial}{\partial r}$$ where $$h$$ will be the "constant". So $$g\frac{\partial (h)}{\partial t}=\frac{1}{r^2} \frac{\partial}{\partial r}(r^2h\frac{\partial (g)}{\partial r})$$ I can move the $$h$$ on the right side out of the derivative operator since it's only a function of $$t$$. Partial derivatives will now be ordinary derivative since the function inside the derivative is a function of only the differential variable. $$g\frac{dh}{d t}=\frac{h}{r^2} \frac{d}{d r}(r^2\frac{dg}{d r})$$ DIvide the above equation by $$gh$$ $$\frac{1}{h}\frac{dh}{d t}=\frac{1}{gr^2} \frac{d}{d r}(r^2\frac{dg}{d r})$$ We can see that the left side is a function of the variable $$t$$ only, and the right side is a function of r only. Two functions of different variables can equal to each other only when they both equal to a constant; we called that a "separation constant". $$\frac{1}{h}\frac{dh}{d t}=\frac{1}{gr^2} \frac{d}{d r}(r^2\frac{dg}{d r})=-\lambda$$ This gives two ODEs $$\frac{1}{h}\frac{dh}{d t}=-\lambda$$ and $$\frac{1}{gr^2} \frac{d}{d r}(r^2\frac{dg}{d r})=-\lambda$$ Note that the $$-$$ in front of $$\lambda$$ is not necessary, but it can turn the expression of g into an eigenfunction and simplify the solving process. Lastly, simplify the two expressions $$\frac{dh}{d t}+\lambda h=0$$ and $$\frac{d}{d r}(r^2\frac{dg}{d r})+\lambda gr^2=0$$

## Contact tutor

needs and Jingying will reply soon.