Solving 2D Diffusion Equation using MATLAB | Lecture 7 | ICFDM
Now, we are writing a 2D code using MATLAB to solve the diffusion equation. Please write in the comments if you have any question.
#CFD #MATLAB #FluidDynamics #FluidMechanics #MechanicalEngineering #CFDusingMATLAB #NavierStokes #Finitedifferencemethod #Finitevolumemethod
Suggested readings:
1) Numerical Heat Transfer and Fluid Flow: Excellent book to get a hang of CFD/HT through finite volume methodology.
https://amzn.to/3mEYuSz
PS: The author invented SIMPLE method :)
2) An Introduction to Computational Fluid Dynamics: The Finite Volume Method: My goto book for advanced understanding of CFD concept and their applications.
https://amzn.to/3ehkQH4
PS: Excellent discussion on turbulence!
3) Computational Fluid Dynamics: An Introduction: Nail the finite differences with this book; my first-ever CFD book and that's what I recommend to anyone else as their first CFD read!
https://amzn.to/37ZHD9e
4) Fluid Mechanics: Revise your fundamentals through this excellently written book by Prof. White.
https://amzn.to/320BuFT
PS: It's not so fundamental, you'll also gain advanced understanding.
5) MATLAB: An Introduction with Applications: Handy guide to learn MATLAB effortlessly, can't recommend it enough:
https://amzn.to/3oGIrFM
The script is as follows:
_________________________________________________________________________________________
clear all
close all
clc
%% Defining the mesh
n_points = 51;
dom_size = 1;
h = dom_size/(n_points - 1);
%% Initialising the problem
y(n_points, n_points) = 0;
y(1,:) = 1;
y_new(n_points, n_points) = 0;
y_new(1,:) = 1;
error_mag = 1;
error_req = 1e-6;
iterations = 0;
%% Calculations
while error_mag (USE THE LARGER THAN SIGN HERE) error_req
for i = 2:(n_points-1)
for j = 2:(n_points-1)
y_new(i,j) = 0.25.*(y_new(i-1,j) + y(i+1,j) + y_new(i,j-1) + y(i,j+1));
iterations = iterations + 1;
end
end
% Calculation of error magnitude
error_mag = 0;
for i = 2:(n_points-1)
for j = 2:(n_points-1)
error_mag = error_mag + abs(y(i,j) - y_new(i,j));
end
end
% Assigning new to be old
y = y_new;
end
%% Plotting
x_dom = ((1:n_points)-1).*h;
y_dom = 1-((1:n_points)-1).*h;
[X,Y] = meshgrid(x_dom,y_dom);
contourf(X,Y,y, 12)
colorbar
Видео Solving 2D Diffusion Equation using MATLAB | Lecture 7 | ICFDM канала Tanmay Agrawal
#CFD #MATLAB #FluidDynamics #FluidMechanics #MechanicalEngineering #CFDusingMATLAB #NavierStokes #Finitedifferencemethod #Finitevolumemethod
Suggested readings:
1) Numerical Heat Transfer and Fluid Flow: Excellent book to get a hang of CFD/HT through finite volume methodology.
https://amzn.to/3mEYuSz
PS: The author invented SIMPLE method :)
2) An Introduction to Computational Fluid Dynamics: The Finite Volume Method: My goto book for advanced understanding of CFD concept and their applications.
https://amzn.to/3ehkQH4
PS: Excellent discussion on turbulence!
3) Computational Fluid Dynamics: An Introduction: Nail the finite differences with this book; my first-ever CFD book and that's what I recommend to anyone else as their first CFD read!
https://amzn.to/37ZHD9e
4) Fluid Mechanics: Revise your fundamentals through this excellently written book by Prof. White.
https://amzn.to/320BuFT
PS: It's not so fundamental, you'll also gain advanced understanding.
5) MATLAB: An Introduction with Applications: Handy guide to learn MATLAB effortlessly, can't recommend it enough:
https://amzn.to/3oGIrFM
The script is as follows:
_________________________________________________________________________________________
clear all
close all
clc
%% Defining the mesh
n_points = 51;
dom_size = 1;
h = dom_size/(n_points - 1);
%% Initialising the problem
y(n_points, n_points) = 0;
y(1,:) = 1;
y_new(n_points, n_points) = 0;
y_new(1,:) = 1;
error_mag = 1;
error_req = 1e-6;
iterations = 0;
%% Calculations
while error_mag (USE THE LARGER THAN SIGN HERE) error_req
for i = 2:(n_points-1)
for j = 2:(n_points-1)
y_new(i,j) = 0.25.*(y_new(i-1,j) + y(i+1,j) + y_new(i,j-1) + y(i,j+1));
iterations = iterations + 1;
end
end
% Calculation of error magnitude
error_mag = 0;
for i = 2:(n_points-1)
for j = 2:(n_points-1)
error_mag = error_mag + abs(y(i,j) - y_new(i,j));
end
end
% Assigning new to be old
y = y_new;
end
%% Plotting
x_dom = ((1:n_points)-1).*h;
y_dom = 1-((1:n_points)-1).*h;
[X,Y] = meshgrid(x_dom,y_dom);
contourf(X,Y,y, 12)
colorbar
Видео Solving 2D Diffusion Equation using MATLAB | Lecture 7 | ICFDM канала Tanmay Agrawal
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
2D Unsteady Diffusion Equation (Contd.) | Lecture 7.5 | ICFDMLab12_2: Wave Equation 2DLab10_3: Diffusion Eq 2D with Source2D Heat Transfer using MatlabNumerical Solution of 2D Laplace equation using Finite Difference Method (Iterative Technique )Two Dimensional (2D) Discretization of Diffusion Equation | Lecture 6 | ICFDMSolving 1D Diffusion Equation using MATLAB | Lecture 5 | ICFDMSolving 2D Unsteady Diffusion using MATLAB | Lecture 8| ICFDMFinite Difference Schemes for Advection and DiffusionMATLAB code for solving 2D Heat Conduction Problem: FTCS Finite Difference MethodThe hardest problem on the hardest testMatlab program with the explicit forward time centred space method for the diffusion equationTheory of Convection Diffusion Equations | Lecture 9 | ICFDMLid Driven Cavity Flow using SIMPLE Algorithm in MATLAB Part 1/3 | Lecture 19 | ICFDMHow to Numerically Solve a 1D Heat Equaiton ? ( MATLAB Script in Description)An Introduction to Reaction-Diffusion-Advection EquationMATLAB Solution of the Diffusion Equation | Lecture 73 | Numerical Methods for EngineersDetermination of Mode Shapes and Natural Frequencies of MDF Systems using MATLABLab12_1: Wave Equation 1D