PDE Toolbox - Convection in Diffusion Equation

조회 수: 16 (최근 30일)
Andrew Ferguson
Andrew Ferguson 2020년 1월 21일
댓글: Gobinda Debnath 2023년 7월 23일
I'm trying to add a convection term to solve a diffusion PDE using the PDE Toolbox. I'm defining the PDE as:
specifyCoefficients(model,'Face',2,'m',0,'d',1,'c',Da,'a',0,'f',@fcoeff);
and have the following at the end of my code:
function f = fcoeff(location,state)
y = location.y./h;
x = location.x./L;
v = va;
f = -(v.*state.ux.*state.time + v.*state.uy.*state.time);
end
However, whenever I try to run the code I get the following error:
Error using pde.CoefficientAssignment/checkCoefFcnHdlArgCounts (line 499)
Function specifying a coefficient must accept two
input arguments and return one output argument.
Error in pde.CoefficientAssignment/checkFcnHdlArgCounts (line 272)
self.checkCoefFcnHdlArgCounts(self.f, systemsize, ndims);
Error in pde.CoefficientAssignment (line 104)
obj.checkFcnHdlArgCounts(systemsize, numdims);
Error in pde.PDEModel/specifyCoefficients (line 143)
coef = pde.CoefficientAssignment(self.EquationCoefficients,argsToPass{:});
Error in Dry_Air (line 49)
specifyCoefficients(model,'Face',2,'m',0,'d',1,'c',Da,'a',0,'f',@fcoeff);
I don't understand the error because as I see it I am ipnuting two arguments and am returning one output. Whenever I take away the function for 'f' on the RHS of the PDE my code works perfectly. Any help would be much appreciated!

채택된 답변

Ravi Kumar
Ravi Kumar 2020년 1월 21일
It looks like your function errored without returning one onput. Most likely the error could have been due to 'va' being out of scope for the function fcoeff.
Regards,
Ravi
  댓글 수: 4
Andrew Ferguson
Andrew Ferguson 2020년 1월 21일
Thanks! Adding in h and L worked!
Gobinda Debnath
Gobinda Debnath 2023년 7월 23일
Hello Andrew ferguson and ravi sir, i am new to matlab, can i get a sample code for convection-diffusion term equation, in matlab how to handle convection term, please help me on this, thank you

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by