Загрузка страницы

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
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
28 августа 2020 г. 12:18:01
00:24:52
Яндекс.Метрика