Thermodynamics

Thermodynamics

Problem (1): 

Early explorers often estimated altitude by measuring the temperature
of boiling water. Use the following two equations to make a table that modern-day
hikers could use for the same purpose.

wherep is atmospheric pressure in inches of mercury, Tb is boiling temperature in
oF, and h is altitude in feet. The table should have two columns, the first altitude andthe second boiling temperature. The altitude should range between -500 ft and 10,000 ft at increment of 500 ft.

Problem (2): 

A person at point A spots a child in trouble at point B across the riveras shown:

The person can run at a speed of 8.6 ft/s and can swim at a speed of 3.9 ft/s. In orderto reach the child in the shortest time the person runs to point C and then swims topoint B, as shown above. Write a MATLAB program that determines the distance xto point C that minimizes the time the person can reach the child. In the programdefine a vector x with values ranging from 0 to 5,000 with increments of 1. Use thisvector to calculate the corresponding values of time t. Plot x versus t with properlabel, title, and legend. Then use MATLAB’s built-in function min to find the valueof x that corresponds to the shortest time.

Problem (3): The pressure drop Dpin Pascal (Pa) for a fluid flowing in a pipe witha sudden increase in diameter is given by:

Where ρ is the density of fluid, v, the velocity of the flow, and d and D are defined
in the figure above. Write a program in a script file that calculates the pressure dropDp. When the script is calculated, it requests the user to input the density in kg/m3,the velocity in m/s, and values of the non-dimensional ratio d/D as a vector. Theprogram displays the inputted values of ρ and v followed by a table with values ofd/D in the first column and the corresponding values of Dpin the second column.Execute the program assuming flow of gasoline (ρ = 737 kg/m3) at v = 5 m/s and thefollowing ratios of dimensionless d/D =0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3.

Problem (4):

The net heat exchange by radiation from plate 1 with radius b to plate2 with radius a that are separated by a distance c is given by:

whereT1 and T2 are the absolute temperatures of the plates, σ = 5.669 × 10-8W/(m2
K4) is the Stefan-Boltzmann constant, and F1-2is a shape factor which, for the
arrangement in the figure, is given by:

Where X = a / c, Y = c / b, and Z = 1 + (1 + X 2) Y 2. Write a script file that calculatesthe heat exchange q. For input the program asks the user to enter values for T1, T2,a, b, and c. For output the program prints a summary of the geometry andtemperatures and then prints the values of q. Use the script to calculate the resultsfor T1 = 400K, T2 = 600K, a = 1 m, b = 2 m, and c = 0.1, 1, and 10 m. 

Problem (5):

Plot the function in the domain 0 ≤ x ≤ 4. Notice thatthe function has a vertical asymptote at x = 2. Plot the function by creating twovectors for the domain of x. The first vector (name it x1) includes elements from 0to 1.9, and the second vector (name it x2) includes elements from 2.1 to 4. For eachx vector create a y vector (name then y1 and y2) with the corresponding values of yaccording to the function. To plot the function make two curves in the same plot (x1vs. y1, and x2 vs. y2).

Problem (6):

The force F (in N) acting between a particle with a charge q and around disk with a radius R and a charge Q is given by the equation:

whereis the permittivity constant and z is the distance tothe particle. Consider the case where Q = 9.4 × 10-6C, q = 2.4 × 10-5C, and R = 0.1m. Make a plot of F as a function of z for 0 ≤ z ≤ 0.3 m. Use MATLAB’s built-infunction max to find the maximum value of F and the corresponding distance z.

Problem (7): The height and speed of a projectile shoot at a speed v0at an angle θ
as a function of time are given by:

where g = 9.81 m/s2. Determine the time that the projectile will hit the ground and
plot the height and the speed as a function of time (two plots on one page) for the
case that v0= 200 m/s and θ = 70o. Add titles and label the axis.

Problem (8):

The position x as a function of time of a particle that moves along astraight line is given by:

The velocity v(t) of the particle is determined by the derivative of x(t) with respect
to t, and the acceleration a(t) is determined by the derivative of v(t) with respect to
t. Derive the expression for the velocity and acceleration of the particle, and make
plots of the position, velocity, and acceleration as a function of time for 0 ≤ t ≤ 8 s.
Use the subplot command to make the three plots on the same page with the plot of
the position on the top, the velocity in the middle, and the acceleration at the bottom.Label the axis appropriately with the correct units.

Problem (9): The ideal gas equation states that where P is the pressure, V isthe volume, T is the temperature, R = 0.08206 (L atm)/(mol K) is the gas constant,and n is the number of moles. Real gases, especially at high pressure, deviate fromthis behavior. Their response can be modeled with the van der Waals

equationwhere a andb are material constants. For CO2a = 3.592 L2atm/mol2,and b = 0.04267 L/mol. Make one figure that displays two plots of V versus P for0.065 ≤ V ≤ 1 L. In one plot the pressure is calculated using the ideal gas equationand the other by using the van der Waals equation. Label the axes and display alegend.

Problem (10):

Biological oxygen demand (BOD) is a measure of the relative oxygendepletion effect of a waste contaminant and is widely used to assess the amount ofpollution in a water source. The BOD in the effluent (Lcin mg/L) of a rock filterwithout recirculation is given by:

Where L0is the influent BOD (mg/L), D is the depth of the filter (m), and Q is the
hydraulic flow rate [L/(m2-day)]. Assuming Q = 300 L/(m2-day) plot the effluent
BOD as a function of the depth of the filter (100 ≤ D ≤ 2000 m) for L0= 5, 10, and
20 mg/L. Make the three plots in one figure. Label the axes and display a legend.

Solution 

clc;

clear;

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 1 *******************************’)

fprintf(‘\n *****************************************************’)

format compact

h=-500:500:10000;

p=29.921*(1-6.8753*10^-6*h);

T=49.16*log(p)+44.932;

fprintf(‘\n Altitude   Temperature\n’)

for i=1:size(h,2)

disp([‘  ‘,num2str(h(i)),’     ‘, num2str(T(i))])

end

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 2 *******************************’)

fprintf(‘\n *****************************************************\n’)

x = 0:5000;

time = (10000-x)./8.6 + sqrt(x.^2 + 3000^2)./3.9;

figure(1)

plot(x,time);

xlabel(‘x (ft)’)

ylabel(‘time (sec)’)

title(‘x distance vs time taken’)

legend(‘Time taken’)

[M,I] = min(time);

disp([‘Value of x for minimum time = ‘,num2str(x(I)),’ ft.’])

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 3 *******************************’)

fprintf(‘\n *****************************************************\n’)

prompt = ‘Please input the value of density in kg/m^3\n’;

rho = input(prompt);

prompt = ‘Please input the value of velocity in m/s\n’;

vel = input(prompt);

prompt = ‘Please input the values of ratio of diameter\n’;

diaRatio = input(prompt);

delta_p = 0.5*(1-diaRatio.^2).^2 *rho*vel^2;

fprintf(‘\n d/D   Pressure Change\n’)

for i=1:size(diaRatio,2)

disp([‘ ‘,num2str(diaRatio(i)),’     ‘, num2str(delta_p(i))])

end

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 4 *******************************’)

fprintf(‘\n *****************************************************\n’)

prompt = ‘Please input the value of T1\n’;

T1 = input(prompt);

prompt = ‘Please input the value of T2\n’;

T2 = input(prompt);

prompt = ‘Please input the value of a\n’;

a = input(prompt);

prompt = ‘Please input the value of b\n’;

b = input(prompt);

prompt = ‘Please input the value of c\n’;

c = input(prompt);

s = 5.669*10^-8;

X = a./c; Y = c./b; Z = 1+(1+X.^2).*Y.^2;

F = 0.5*(Z-sqrt(Z.^2 – 4*(X.*Y).^2));

q = s*pi*b^2*F.*(T1^4 – T2^4);

disp([‘T1 = ‘,num2str(T1),’,T2 = ‘, num2str(T2)])

disp([‘a = ‘,num2str(a),’,b = ‘, num2str(b),’,c = ‘, num2str(c)])

disp([‘q = ‘,num2str(q)])

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 5 *******************************’)

fprintf(‘\n *****************************************************\n’)

x1 = 0:0.01:1.9;

x2 = 2.1:0.01:4;

y1 = (x1.^2-6*x1+7)./(x1.^3-8);

y2 = (x2.^2-6*x2+7)./(x2.^3-8);

figure(2)

plot(x1,y1,x2,y2)

xlabel(‘x’)

ylabel(‘y’)

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 6 *******************************’)

fprintf(‘\n *****************************************************\n’)

e0 = 0.885*10^-12;

Q = 9.4*10^-6;

q = 2.4*10^-5;

R = 0.1;

z = 0:0.01:0.3;

F = Q*q*z./(2*e0).*(1 – z./(sqrt(z.^2 + R^2)));

figure(3)

plot(z,F)

xlabel(‘z (m)’)

ylabel(‘F (N)’)

[M,I] = max(F);

disp([‘Maximum value for force = ‘,num2str(M),’ N.’, …

newline,’Z value for maximum force = ‘,num2str(z(I)),’ m.’])

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 7 *******************************’)

fprintf(‘\n *****************************************************\n’)

time = [];

height = [];

velocity = [];

theta = 70*pi/180;

timestep = 0.1;

v0 = 200;

g = 9.81;

n=0;

while(true)

t = n*timestep;

h = v0*t*sin(theta) – g*t^2/2;

v = sqrt(v0^2 – 2*v0*g*t*sin(theta) + g^2*t^2);

time = [time t];

height = [height h];

velocity = [velocity v];

if h<0

break

end

n=n+1;

end

figure(4)

plot(time,height)

xlabel(‘time(sec)’)

ylabel(‘height(m)’)

figure(5)

plot(time,velocity)

xlabel(‘time(sec)’)

ylabel(‘velocity(m/s)’)

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 8 *******************************’)

fprintf(‘\n *****************************************************\n’)

syms t

x = 8 –  4*t^3*exp(-0.4*t) + 2*t^2;

v = diff(x);

a = diff(v);

time = 0:0.01:8;

x_values = subs(x,t,time);

v_values = subs(v,t,time);

a_values = subs(a,t,time);

figure(6)

subplot(3,1,1)

plot(time,x_values)

xlabel(‘Time’)

ylabel(‘Position’)

subplot(3,1,2)

plot(time,v_values)

xlabel(‘Time’)

ylabel(‘Velocity’)

subplot(3,1,3)

plot(time,a_values)

xlabel(‘Time’)

ylabel(‘Acceleration’)

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 9 *******************************’)

fprintf(‘\n *****************************************************\n’)

R = 0.08206;

T = 300;

n = 1;

a = 3.592;

b = 0.04267;

V = 0.065:0.001:1;

PI = n*R*T./V;

PV = n*R*T./(V – n*b) – n^2*a./(V.^2);

figure(7)

plot(PI,V,PV,V);

xlabel(‘Pressure’)

ylabel(‘Volume’)

legend(‘Ideal gas equation’,’Van der Walls equation’)

fprintf(‘\n *****************************************************’)

fprintf(‘\n Solution to Problem 10 *******************************’)

fprintf(‘\n *****************************************************\n’)

Q = 300;

D = 100:2000;

L0 = [5 10 20];

figure(8)

for i=1:size(L0,2)

LC = L0(1,i)./(1+(2.5*D.^(2/3)/sqrt(Q)));

plot(D,LC)

hold on

end

xlabel(‘Depth (m)’)

ylabel(‘BOD (mg/L)’)

legend(‘L0 = 5 mg/L’,’L0 = 10 mg/L’,’L0 = 20 mg/L’)

hold off