How can I solve PDE with boundary condition?

1 view (last 30 days)
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 Comment
Kuifeng
Kuifeng on 18 Aug 2017
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

Sign in to comment.

Answers (2)

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

Precise Simulation
Precise Simulation on 24 Aug 2017
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 Comment
Riyadh Muttaleb
Riyadh Muttaleb on 30 Aug 2017
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,

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!