MATLAB Answers

3D diffusion equation in cylinder

123 views (last 30 days)
Hi everyone, I am new in Matlab and I need some help. I want know if there is a way to solve the PDE for diffusion in a cylinder with 2 cm radius and 10 cm height.
thanks

  0 Comments

Sign in to comment.

Accepted Answer

Precise Simulation
Precise Simulation on 22 Nov 2017
Edited: Precise Simulation on 22 Nov 2017
Modelling and simulation of convection and diffusion for a 3D cylindrical (and other) domains is possible with the Matlab Finite Element FEM Toolbox , either by using the built-in GUI or as a m-script file as shown below.
% Set up 3D cylindric domain.
fea.sdim = { 'x' 'y' 'z' };
fea.grid = cylgrid( 4, 3, 20, 0.02, 0.1 );
% plotgrid( fea ) % Plot mesh.
% Add covection and diffusion physics mode.
fea = addphys( fea, @convectiondiffusion, {'C'} );
% Define diffusion coefficient.
fea.phys.cd.eqn.coef{2,end} = {'d_coef'};
fea.expr = { 'c', {'1.23'} ;
'd_coef', {'(1+c)^2/((1+c)^2+1)'} };
% Set reaction source term to 1e3.
fea.phys.cd.eqn.coef{6,end} = {1e3};
% Use C = -1 on side boundaries, and insulation
% flux boundary conditions on the top and bottom.
fea.phys.cd.bdr.sel = [ 3 1 1 1 1 3 ];
[fea.phys.cd.bdr.coef{1,end}{2:5}] = deal(-1);
% Check, parse, and solve problem with stationary solver.
fea = parsephys( fea );
fea = parseprob( fea );
fea.sol.u = solvestat( fea );
% Postprocessing.
postplot( fea, 'sliceexpr', 'C' )
title( 'Concentration, C' )

  3 Comments

camila guerra
camila guerra on 19 May 2018
hola trate de utilizar tu programacion y me aparece un error y discula esta programacion si es para la seguunda ley de fick verdad en 3 dimenciones
camila guerra
camila guerra on 19 May 2018
hi try to use your programming and I get an error and apologize for this programming if it is for the second law of true fick in 3 dimensions
Precise Simulation
Precise Simulation on 8 Jun 2018
The script example program above should work without error (what was the error message you got?).
To model Fick's second law of diffusion you typicall replace the expression in d_coef with whatever your diffusion coefficient is.

Sign in to comment.

More Answers (1)

Torsten
Torsten on 30 May 2017
If you have experience with the discretization of partial differential equations, you can write your own MATLAB code.
Otherwise, I'd suggest you use the PDE toolbox.
Best wishes
Torsten.

  0 Comments

Sign in to comment.

Sign in to answer this question.