0% found this document useful (0 votes)
0 views3 pages

Assignment

The document contains MATLAB code addressing various problems related to petroleum engineering, including calculations for mixture density, flow rates, gas law, reaction rates, viscosity, temperature profiles, and vapor pressure curves. Each section provides specific calculations and outputs relevant to the petroleum industry. The code also includes comments on the significance and implications of the results obtained.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views3 pages

Assignment

The document contains MATLAB code addressing various problems related to petroleum engineering, including calculations for mixture density, flow rates, gas law, reaction rates, viscosity, temperature profiles, and vapor pressure curves. Each section provides specific calculations and outputs relevant to the petroleum industry. The code also includes comments on the significance and implications of the results obtained.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1 % PROBLEM 1.

Basic Operations and Variables(Petroleum Mixture Density)


2 % densities of the components in kg/m^3
3 density_crude = 850;
4 density_gasoline = 720;
5 density_kerosene = 780;
6 % volume fractions
7 v_crude = 0.4;
8 v_gasoine = 0.35;
9 v_kerosene = 0.25;
10
11 % Calculate the mixture density
12
13 mixture_density = (density_crude * v_crude) + (density_gasoline * v_gasoine) + (density_kerosene
* v_kerosene);
14 fprintf('Mixture density = %.2f kg/m^3\n',mixture_density );
15
16 % PROBLEM [Link] and Matrices(Refinery Flow Rates)
17 % Flow rates of crude oil streams(Barrels/day)
18
19 flow_rates = [5000 3000 4000];
20 %blending_ratios
21
22 blending_ratios =[2;1;3];
23
24 % matrix multiplication
25
26 total_blended_flow = flow_rates*blending_ratios;
27 fprintf('Total blended flow rate = %.0f barrels/day\n', total_blended_flow);
28
29 % SIGNIFICANCE = It shows the total flow rate after applying the given blending ratios to the
three crude-oil streams.
30
31
32 % PROBLEM 3. Numerical Expressions(Gas Law Calculations)
33
34
35 % given values
36 n = 2; % moles
37 R = 8.314; % J/(mol-K)
38 T = 350; % K
39 V = .05; % m^3
40
41 % CALCULATE PRESSURE
42 P = (n*R*T)/V;
43 fprintf('Pressure = %.4f Pa\n', P);
44
45 % comment on accuracy: MATLAB uses double precision by default, and its result matches the
manual calculation exactly.
46
47
48 % PROBLEM 4. Symbolic Operations(Reaction Rate Equations)
49
50 % define symbolic variables
51
52 syms CA
53
54 % DEFINE REACTION RATE
55
56 k = 0.1;
57 r = k*CA^2;
58
59 % SUBSTITUTE VALUES
60
61 r_value = subs(r, CA, .5);
62 fprintf('Reaction rate = %.3f mol/L.s\n', r_value);
63
64 % relevance to reaction kinetics : This is a second-order reaction because
65 % the rate depends on C^[Link], if the concentration of reactant A
66 % increases, the reaction rate increases with the square of the
67 % concentration. for example, doubling ca would make the reaction rate four times larger
68
69
70 % PROBLEM 5. User defined Function(Viscosity Calculations)
71
72 function mu = viscosity(T)
73 A = 0.001; %Pa.s
74 B = 1000; %K
75
76 mu = A*exp(B/T);
77 end
78 T1 = 300; %K
79 T2 = 400; %K
80
81 mu1 = viscosity(T1);
82 mu2 = viscosity(T2);
83 fprintf('Viscosity at 300 K = %.3f Pa.s\n', mu1);
84 fprintf('Viscosity at 400 K = %.3f Pa.s\n', mu2);
85
86 % comment : As temperature increases, viscosity decreases. Lower viscosity allows the fluid to
flow more easily through pipelines and generally reduces the resistance to flow.
87
88
89
90 % PROBLEM 6. Loops ( Temperature Profile in a Reactor)
91
92 T0 = 300; % Initial temperature (K)
93
94 x = 0:0.1:1; % Reactor length
95
96 T = zeros(1,11); % Store temperature values
97
98 for i = 1:11
99 T(i) = T0 + 50*x(i) - 10*x(i)^2;
100 end
101
102 fprintf('x Temperature (K)\n');
103
104 for i = 1:11
105 fprintf('%.1f %.2f K\n', x(i), T(i));
106 end
107
108
109 % PROBLEM 7. Plotting (Vapour pressure curve)
110
111 A = 7.0;
112 B = 1200;
113 C = 220;
114
115 T = 50:1:150; % Temperature in °C
116
117 % Antoine equation
118 P = 10.^(A - B./(T + C));
119
120 % Quick plot using ezplot
121 ezplot(@(T) 10.^(A - B./(T + C)), [50 150]);
122
123 % Customized plot
124 figure;
125 plot(T, P, 'LineWidth', 2);
126
127 xlabel('Temperature (°C)');
128 ylabel('Vapor Pressure (mmHg)');
129 title('Vapor Pressure vs Temperature');
130 grid on;
131
132 % Save the plot
133 saveas(gcf, 'vapor_pressure.png');
134
135

You might also like