How do I solve a heat transfer PDE problem with multiple parameter input values and plot all results in one graph?
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm trying to solve the following code for three different values of "Tinj", 20, 80 and 120 degrees C, and then plot the results for each temperature on the same plot to show the difference between them. Tinj calls on values from an excel file (attached) that pulls up corresponding values for density, specific heat, viscosity, etc. This is the code I have so far:
------------------------------------------------------------
function parabolic
global pr cp k cw pw v
global Tinj Tres
%-----------------define parameters
Tinj = 20; %Injection temperature, C ...how to include 20, 80 and 120??
Tres = 264; %initial reservoir temp, C
Rres = 500; %reservoir radius, aka distance between wells, m
rwell = 0.1; %wellbore radius, m
A = pi()*(Rres^2); %x-sectional area of reservoir, m2
awell = pi()*(rwell^2); %x-sectional area of well, m2
por = 0.10; %reservoir porosity
kr = 2.11; %thermal condcution basalt coeff., W/m-K
pr = 2800; %Density of reservoir rock, kg/m^3
cr = 840; %specific heat of basalt, Ws/kgC
q = 60; %injection rate, kg/s
tend = 86400000; %time period, seconds
time = tend/86400; %time in days
%------------Calling fluid properties from excel sheet
temps = xlsread('fluidproperties','A3:A26');
density = xlsread('fluidproperties','B3:B26');
specific_heat = xlsread('fluidproperties','C3:C26');
viscosity = xlsread('fluidproperties','D3:D26');
conductivity = xlsread('fluidproperties','E3:E26');
pw = interp1(temps,density,Tinj);
cw = interp1(temps,specific_heat,Tinj);
vw = interp1(temps,viscosity,Tinj);
kw = interp1(temps,conductivity,Tinj);
%------------calculating reservoir parameters
cp = (por*cw*pw)+((1-por)*(cr*pr)); %average volumetric heat capacity of the reservoir, kJ/m^3-C
v = q/(pw*A*por); %true velocity of injected fluid, m/s
k = (kw*por)+kr*(1-por);%average thermal conductivity in reservoir
m = 1; %for cylindrical model
t = linspace(1,tend,200);
x = linspace(0,Rres,200);
%---------------SOLVE PDE---------------------
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
Temperature = sol(:,:,1);
%outlet = Temperature(end) %final temperature at end of reservoir at Tend
%--------------Plot temp vs. distance
figure, plot(x,Temperature(end,:))
title(strcat('Temperature Distribution at t = ', num2str(time)))
xlabel('Distance (m)')
ylabel('Temperature (C)')
%-------------Plot temperature vs. time
figure, plot(t,Temperature(:,end))
title('Temperature over time at point x = 0')
xlabel('Time (s)')
ylabel('Temperature (C)')
% ----------PDE FUNCTION---------------
function [c,f,s] = pdex1pde(x,t,u,DuDx)
global cp k cw pw v
c = cp;
f = k*DuDx;
s = -cw*pw*v;
% ---INITIAL CONDITIONS FUNCTION---
function u0 = pdex1ic(x)
global Tres
u0 = Tres;
% -------BOUNDARY CONDITIONS FUNCTION---------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
%l = 'left side', in this case center, r = 'right side' in this case outer boundary
global Tinj Tres
pl = Tinj; %injection temperature
ql = 1;
pr = ur-Tres;
qr = 1;
----------------------------------------------------
How would I get a plot of Distance vs. Temperature or Time vs. Temperature with three different distributions corresponding to the 20, 80 and 120 deg C injection temperatures?
Thanks!!
댓글 수: 0
답변 (1개)
Fernando Fernandes
2019년 10월 6일
Hey morning, Did u finish your code? I'm working in a similar problem and I'm really new in matlab. Could you send your whole code here?
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!