필터 지우기
필터 지우기

How to set this time derivative boundary condition using MOL?

조회 수: 7 (최근 30일)
Hashim
Hashim 2023년 7월 17일
편집: Torsten 2023년 7월 17일
LHS = Left hand side aka
BC = Boundary condition
Hi,
I have a system of coupled raection diffusion PDEs as such.
For my species I have a LHS at such as
I am trying to solve this using the method of lines by using ODE15s solver for which I have written the function as such. But I do not know how to incorporate the term into the script and how to assign it to be my LHS boundary condition.
k1=0.073317274764052;
k2=1.052512778689219e-04;
tau=0.466500000000000;
tau_2=0.699700000000000;
dchi=0.100000000000000;
N=11;
tspan_2=linspace(tau, tau_2, N);
[t, CmBC] = ode15s(@(t, Cm2) BCodefun(t, Cm2, k1, k2, dchi), tspan_2, 0.9, []);
function dCdt2BC = BCodefun(t, CmBC, k1, k2, dchi)
dCdt2BC = (k1/k2).*(((CmBC).*(CmBC^2-CmBC))/dchi);
end
This gives me a 1*11 matrix (code till above should function). You can see below how I am using a multi point approximation to set a no flux BC at my left hand. I am not sure how to assign my ODE output as my left hand side BC in my MOL implementation.
% What I have been using to set a no flux boundary condition on the LHS
Cm2(1) = (-Cm2(3)+4*Cm2(2))./3;
% WHat I think I should do to set the output from my ODE solution to set my
% LHS BC
Cm2(1) = CmBC;
Function definitions in a script must appear at the end of the file.
Move all statements after the "BCodefun" function definition to before the first local function definition.
  댓글 수: 9
Hashim
Hashim 2023년 7월 17일
There is no in this boundary condition implementation only . Also, just to clarify I am using N to discretize both the spatial as well as the temporal domain.
This is what I am trying to do Cm2 being .
[t, Cm2(1)] = ode15s(@(t, Cm2) BCodefun(t, Cm2, k1, k2, dchi), tspan_2, 1, []);
function dCdt2BC = BCodefun(t, Cm2, k1, k2, dchi)
dCdt2BC = (k1/k2).*((Cm2-Cm2)/dchi)*(Cm2^2-Cm2);
end
If I go your route I get the following error.
Index exceeds the number of array elements. Index must not exceed 1.
Error in PcWise_NDOCP_Pulse2v0/fpde2/BCodefun (line 133)
dCdt2BC = (k1/k2).*((Cm2(2)-Cm2(1))/dchi)*(Cm2(1)^2-Cm2(1));
Error in PcWise_NDOCP_Pulse2v0>@(t,Cm2)BCodefun(t,Cm2,k1,k2,dchi) (line 123)
[t, Cm2(1)] = ode15s(@(t, Cm2) BCodefun(t, Cm2, k1, k2, dchi), tspan_2, 1, []);
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 153)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in PcWise_NDOCP_Pulse2v0/fpde2 (line 123)
[t, Cm2(1)] = ode15s(@(t, Cm2) BCodefun(t, Cm2, k1, k2, dchi), tspan_2, 1, []);
Error in PcWise_NDOCP_Pulse2v0>@(t,C2)fpde2(t,C2,alpha,kappa,eta,gamma,mu,k1,k2,dchi,N,tspan_2) (line 104)
[t, C2] = ode15s(@(t, C2) fpde2(t, C2, alpha, kappa, eta, gamma, mu, k1, k2, dchi, N, tspan_2), tspan_2, IC2, []);
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 153)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in PcWise_NDOCP_Pulse2v0 (line 104)
[t, C2] = ode15s(@(t, C2) fpde2(t, C2, alpha, kappa, eta, gamma, mu, k1, k2, dchi, N, tspan_2), tspan_2, IC2, []);
Needless to say my implementation isn't working either.
Torsten
Torsten 2023년 7월 17일
편집: Torsten 2023년 7월 17일
Reread how the method-of-lines works to solve partial differential equations.
As I wrote you don't solve for a single unknown value of the concentration field as you seem to try with the command
[t, Cm2(1)] = ode15s(@(t, Cm2) BCodefun(t, Cm2, k1, k2, dchi), tspan_2, 1, []);
but for the complete profile of C_m_ox and C_s over the spatial domain.
That's why I wrote you have 2*N solution variables where N is the number of spatial discretization points.
As far as I know, the following PDE solver similar to pdepe supports ODEs as boundary conditions:
Maybe you want to test it for your problem.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 PDE Solvers에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by