How can I solve PDE with boundary condition?

1 次查看(过去 30 天)
Hi All, I do have Ws dC/dz + Kc d2C/dz2 - X=0 where Ws and X are constant Z from (0 to 5 step 0.5) and I do have Kc values each 0.5 m,
How can I solve this PDE with Matlab, using B.C. (C at 0= 10) and (C at 5 =0)
Thanks in advance
Riyadh
  1 个评论
Kuifeng
Kuifeng 2017-8-18
Example answer, Ref to Chap 5, Part 5.2 Steady 1D Convection and diffusion of 'An introduction to computational fluid dynamics 2nd edition' by Versteeg and Malalasekera

请先登录,再进行评论。

回答(2 个)

Torsten
Torsten 2017-8-18
Use "bvp4c".
By the way: this is a second-order ODE, not a PDE.
Best wishes
Torsten.

Precise Simulation
Precise Simulation 2017-8-24
Alternatively, if you still prefer to solve it as a PDE, you can quite easily input and solve it with the FEATool Multiphysics FEM Finite Element toolbox directly in Matlab. The small m-script below shows how this can be achieved
% FEATool FEA problem definition.
fea.sdim = {'z'}; % Space coordinate/dimension name.
fea.dvar = {'C'}; % Dependent variable name.
fea.sfun = {'sflag1'}; % 1st order P1 FEM shape function.
s_eqn = 'Ws*Cz + Kc*Cz_z - X = 0'; % String equation definition.
fea.eqn = parseeqn( s_eqn, fea.dvar, fea.sdim );
fea.grid = linegrid( 10, 0, 5 ); % Line grid/mesh.
fea.coef = { 'Ws' 1; 'Kc' '2*z'; 'X' '3' }; % Equation coefficents/expressions.
fea.bdr.d = {10 0}; % Dirichlet BCs.
fea.bdr.n = {[] []}; % (Optional) Neumann BCs.
% Check, parse, and solve FEA problem.
fea = parseprob( fea );
fea.sol.u = solvestat( fea );
% Postprocess and visualize solution.
postplot( fea, 'surfexpr', 'C' )
  1 个评论
Riyadh Muttaleb
Riyadh Muttaleb 2017-8-30
Sorry for late response, In was in small vacation, I tried to implement the m-script, but an error says that "Undefined function or variable 'parseeqn'"
Thank you,

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by