HI
hi
I am trying to solve two partial differential equation by converting it first into ODEs using finite difference and using ODE15s solver,but getting some error, pl help
What I have tried:
clc
clear all
m=50;
delx=1/(m-1);
h_int=0.0005e7;
final_time=1e7;
N_samples=(final_time/h_int)+1;
t0=0;
tf=final_time;
p_mat=zeros(m,N_samples);
p_mat(:,1)=2*10^5;
[t,p_mat] = ode15s(@GH,[t0 tf],p_mat(:,1));
T_mat=zeros(m,N_samples);
T_mat(:,1)=273;
[t,T_mat] = ode15s(@GH,[t0 tf],T_mat(:,1));
plot(t, p_mat);
xlabel('time'),ylabel('pressure');
plot(t, T_mat);
xlabel('time'),ylabel('Temp');
%%
function F_X= GH(t,p,T)
m=50;
delx=1/(m-1);
F_X=zeros(m,2);
dp_dt(i)=zeros(m,1);
dT_dt(i)=zeros(m,1);
% F_X = zeros(m,1);
% for i=1 and m
k=0.98*10^-12;
mu=0.001;
phi=0.4;
K1=k/((1-phi)*mu);
K2=1;
pg=2*10^5;
ph=30*10^5;
p(1)=pg;
p(m)=ph;
T(1)=273;
T(m)=283;
for i=2:m-1
dp_dt(i)=K1*((p(i+1)-2*p(i)+p(i-1))/(delx)^2);% K1 is k/(1-phi)*mu
dT_dt(i)=K2*((T(i+1)-2*T(i)+T(i-1))/(delx)^2);
F_X=[dp_dt(i) dT_dt(i)]';
end
end