tag:www.mathworks.com,2005:/matlabcentral/fileexchange/feedMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File ExchangeUser-contributed code library2014-12-25T06:11:13-05:00226531100tag:www.mathworks.com,2005:FileInfo/466372014-05-16T11:40:09Z2014-12-25T07:00:22ZA Simple Finite Volume Solver for MatlabA simple yet general purpose FVM solver for transient convection diffusion PDE<p>A simple Finite volume tool
<br />This code is the result of the efforts of a chemical/petroleum engineer to develop a simple tool to solve the general form of convection-diffusion equation:
<br />α∂ϕ/∂t+∇.(uϕ)+∇.(−D∇ϕ)+βϕ=γ
<br />on simple uniform mesh over 1D, 1D axisymmetric (radial), 2D, 2D axisymmetric (cylindrical), and 3D domains.
<br />The code accepts Dirichlet, Neumann, and Robin boundary conditions (which can be achieved by changing a, b, and c in the following equation) on a whole or part of a boundary:
<br />a∇ϕ.n+bϕ=c.
<br />It also accepts periodic boundary conditions.
<br />The main purpose of this code is to serve as a handy tool for those who try to play with mathematical models, solve the model numerically in 1D, compare it to analytical solutions, and extend their numerical code to 2D and 3D with the minimum number of modifications in the 1D code.
<br />The discretizaion schemes include
<br /> * central difference
<br /> * upwind scheme for convective terms
<br /> * TVD schemes for convective terms</p>
<p>A short html document is available to get you started. Simply type
<br />showdemo FVTdemo
<br />after downloading and extracting the code.</p>
<p>A few calculus functions (divergence, gradient, etc) and averaging techniques (arithmetic average, harmonic average, etc) are available, which can be helpful specially for solving nonlinear or coupled equations or implementing explicit schemes.</p>
<p>I have used the code to solve coupled nonlinear systems of PDE. You can find some of them in the Examples/advanced folder.</p>
<p>There are a few functions in the 'PhysicalProperties' folder for the calculation of the physical properties of fluids. Some of them are not mine, which is specified inside the file.</p>
<p>I'll try to update the documents regularly, in the github repository. Please give me your feedback/questions by writing a comment in my weblog: <<a href="http://fvt.simulkade.com/">http://fvt.simulkade.com/</a>>
<br />Special thanks: I vastly benefited from the ideas behind Fipy <<a href="http://www.ctcms.nist.gov/fipy/">http://www.ctcms.nist.gov/fipy/</a>>, a python-based finite volume solver.</p>
<p>To start the solver, download and extract the zip archive, open and run 'FVToolStartUp' function.
<br />To see the code in action, copy and paste the following in your Matlab command window:</p>
<p>clc; clear;
<br />L = 50; % domain length
<br />Nx = 20; % number of cells
<br />m = createMesh3D(Nx,Nx,Nx, L,L,L);
<br />BC = createBC(m); % all Neumann boundary condition structure
<br />BC.left.a(:) = 0; BC.left.b(:)=1; BC.left.c(:)=1; % Dirichlet for the left boundary
<br />BC.right.a(:) = 0; BC.right.b(:)=1; BC.right.c(:)=0; % Dirichlet for the right boundary
<br />D_val = 1; % value of the diffusion coefficient
<br />D = createCellVariable(m, D_val); % assign the diffusion coefficient to the cells
<br />D_face = harmonicMean(m, D); % calculate harmonic average of the diffusion coef on the cell faces
<br />Mdiff = diffusionTerm(m, D_face); % matrix of coefficients for the diffusion term
<br />[Mbc, RHSbc] = boundaryCondition(m, BC); % matix of coefficients and RHS vector for the BC
<br />M = Mdiff + Mbc; % matrix of cefficients for the PDE
<br />c = solvePDE(m,M, RHSbc); % send M and RHS to the solver
<br />visualizeCells(m, c); % visualize the results</p>
<p>You can find some animated results of this code in my youtube channel:
<br /><a href="https://www.youtube.com/user/processsimulation/videos">https://www.youtube.com/user/processsimulation/videos</a></p>Ehsanhttp://www.mathworks.com/matlabcentral/fileexchange/authors/383541MATLAB 8.3 (R2014a)MATLAB35710falsetag:www.mathworks.com,2005:FileInfo/488302014-12-21T08:22:51Z2014-12-25T04:33:33ZHelical Ince Gaussian HologramsProduces computer generated Helical Ince Gaussian holograms for spatial light modulators<p>This is a GUI so you'll need both the .fig and .m files together in the same folder. Open the .m file and run to access the GUI. Have fun.
<br />This code was created in 2004 by Dr James Strohaber and is based upon his work in holography. The work also appears in his dissertation If you use this code, cite the author! This code produces computer generated holograms of helical Ince Gaussian modes of the paraxial wave equation. The holograms can be used on spatial light modulators (SLMs). This code requires the subroutines: cart2ellip.m, Cee.m. Ceu.m, See.m, Seu.m, Oeig.m, Eeig.m. Instructions: (1) goto "LCD Specifications" and enter the number of pixels and LCDsize of your SLM. This code assumes the pixel density in both the x and y direction are the same. (2) goto "Input Parameters" and enter the location you wish to same the holograms. (3) Enter the mode numbers, grating constant, modulation depth and waist of the IG beam you wish to create. To use this code as a function, comment all of the Input parameters and uncomment the function command.</p>James Strohaberhttp://www.mathworks.com/matlabcentral/fileexchange/authors/537472MATLAB 8.4 (R2014b)MATLABfalsetag:www.mathworks.com,2005:FileInfo/488442014-12-22T13:04:31Z2014-12-25T04:04:58ZBit-Plane SlicingThis code is used for demonstration of bit-plane slicing<p>This code is used for demonstration of bit-plane slicing. The image given as input is sliced into 8 bit planes and each plane is displayed. Also the original image is reconstructed from these bit planes.</p>Akshay Bhosalehttp://www.mathworks.com/matlabcentral/fileexchange/authors/222499MATLAB 7.6 (R2008a)falsetag:www.mathworks.com,2005:FileInfo/488452014-12-22T13:14:16Z2014-12-25T04:04:22ZContrast StretchingThis code is used for demonstration of Contrast Stretching<p>This code is used for demonstration of Contrast Stretching. In the code the minimum intensity value of pixel of input image is mapped to 0, whereas the maximum intensity value of pixel of input image is mapped to 255. The intermediate values of pixels of input image are proportionally (linearly).</p>Akshay Bhosalehttp://www.mathworks.com/matlabcentral/fileexchange/authors/222499MATLAB 7.14 (R2012a)falsetag:www.mathworks.com,2005:FileInfo/488462014-12-22T13:22:27Z2014-12-25T04:03:32ZIntensity Level Slicing (2-level)This code is used for demonstration of Intensity Level Slicing (2-level)<p>This code is used for demonstration of Intensity Level Slicing (2-level). In this code, the pixels in a particular intensity range, specified by user, are highlighted (255-white) and the pixels out of range are made 0.</p>Akshay Bhosalehttp://www.mathworks.com/matlabcentral/fileexchange/authors/222499MATLAB 7.8 (R2009a)falsetag:www.mathworks.com,2005:FileInfo/488472014-12-22T13:27:05Z2014-12-25T04:02:56ZIntensity Level SlicingThis code is used for demonstration of Intensity Level Slicing<p>This code is used for demonstration of Intensity Level Slicing. In this code, the pixels in a particular intensity range, specified by user, are highlighted (255-white) and the pixels out of range are left unchanged.</p>Akshay Bhosalehttp://www.mathworks.com/matlabcentral/fileexchange/authors/222499MATLAB 7.6 (R2008a)falsetag:www.mathworks.com,2005:FileInfo/488692014-12-24T14:54:53Z2014-12-25T04:01:58ZHistogram EquilizationThis code is used for demonstration of Histogram Equilization<p>In this code an image is read and the histogram of this image is plotted. Then the process of histogram equalization is applied on original image and then transformed image and its histogram are plotted.</p>Akshay Bhosalehttp://www.mathworks.com/matlabcentral/fileexchange/authors/222499MATLAB 7.12 (R2011a)falsetag:www.mathworks.com,2005:FileInfo/488512014-12-22T20:41:28Z2014-12-25T02:57:17ZBessel Beam HologramsProduces computer generated Bessel Beam holograms for spatial light modulators<p>This is a GUI so you'll need both the .fig and .m files together in the same folder. Open the .m file and run to access the GUI. Have fun.
<br />This code was created in 2004 by Dr James Strohaber and is based upon his work in holography. The work also appears in his dissertation If you use this code, cite the author! This code produces computer generated holograms of Bessel beams of the Helmholtz equation . The holograms can be used on spatial light modulators (SLMs). The equation for the scalar amplitude of a Besssel beam with mode number n, and beam waist w0 is of the form BB(n)~J_n(ar)*exp(i*n*theta) Instructions: (1) goto "LCD Specifications" and enter the number of pixels and LCDsize of your SLM. This code assumes the pixel density in both the x and y direction are the same. (2) goto "Input Parameters" and enter the location you wish to same the holograms. (3) Enter the mode numbers, grating constant, modulation depth and waist of bessel beam you wish to create. To use this code as a function, comment all of the Input parameters and uncomment the function command.</p>James Strohaberhttp://www.mathworks.com/matlabcentral/fileexchange/authors/537472MATLAB 8.4 (R2014b)MATLABfalsetag:www.mathworks.com,2005:FileInfo/488262014-12-21T06:31:49Z2014-12-25T01:58:32ZHelical Laguerre Gaussian HologramsProduces computer generated Helical Laguerre Gaussian holograms for spatial light modulators<p>This is a GUI so you'll need both the .fig and .m files together in the same folder. Open the .m file and run to access the GUI. Have fun.
<br />This code was created in 2004 by Dr James Strohaber and is based upon his work in holography. The work also appears in his dissertation. If you use this code, cite the author! This code produces computer generated holograms of helical Laguerre Gaussian modes of the paraxial wave equation. The holograms can be used on spatial light modulators (SLMs). The equation for the scalar amplitude of a Laguerre Gaussian beam at z=0 with angular mode number L, radial mode number p, and beam waist w0 is LG(L,p)~L(L,p)*(sqrt(2)*r/w0)^(abs(L))*exp(-(r/w0)^2) *exp(iL*theta) . Instructions: (1) goto "LCD Specifications" and enter the number of pixels and LCDsize of your SLM. This code assumes the pixel density in both the x and y direction are the same. (2) goto "Input Parameters" and enter the location you wish to same the holograms. (3) Enter the mode numbers, grating constant, modulation depth and waist of the LG beam you wish to create. To use this code as a function, comment all of the Input parameters and uncomment the function command.</p>James Strohaberhttp://www.mathworks.com/matlabcentral/fileexchange/authors/537472MATLAB 8.4 (R2014b)MATLABfalsetag:www.mathworks.com,2005:FileInfo/488292014-12-21T07:05:23Z2014-12-25T01:01:42ZHermite Gaussian HologramsProduces computer generated Hermite Gaussian holograms for spatial light modulators<p>This is a GUI so you'll need both the .fig and .m files together in the same folder. Open the .m file and run to access the GUI. Have fun.
<br />This code was created in 2004 by Dr James Strohaber and is based upon his work in holography. The work also appears in his dissertation If you use this code, cite the author! This code produces computer generated holograms of the Hermite Gaussian modes of the paraxial wave equation. The holograms can be used on spatial light modulators (SLMs). The equation for the scalar amplitude of a Hermite Gaussian beam at z=0 with mode number n and m and beam waist w0 is HG(n,m)=(N_nm)*H_n(sqrt(2)x/w0)H_m(sqrt(2)y/w0)exp(-(r/w0)^2), where N_nm is a normalization constant Instructions: (1) goto "LCD Specifications" and enter the number of pixels and LCDsize of your SLM. This code assumes the pixel density in both the x and y direction are the same. (2) goto "Input Parameters" and enter the location you wish to same the holograms. (3) Enter the mode numbers, grating constant, modulation depth and waist of the HG beam you wish to create. To use this code as a function, comment all of the Input parameters and uncomment the function command.</p>James Strohaberhttp://www.mathworks.com/matlabcentral/fileexchange/authors/537472MATLAB 8.4 (R2014b)MATLABfalse