All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
--------------------------------------------------------------------------------------------- clear all;close all;clc;% analytical function =(e.^x)*cos(x) % analytical_derivative%f\'\'(x)= (-)*2*(e.^x)*sin(x)x=linspace(pi/3,pi/2,10);for i=1:10 analytical_derivative(i)= (-2)*(exp(x(i)))*(sin(x(i)));end dx=pi/40; e=exp(1);%fourth…
Om Yadav
updated on 26 Jan 2018
---------------------------------------------------------------------------------------------
clear all;
close all;
clc;
% analytical function =(e.^x)*cos(x)
% analytical_derivative
%f\'\'(x)= (-)*2*(e.^x)*sin(x)
x=linspace(pi/3,pi/2,10);
for i=1:10
analytical_derivative(i)= (-2)*(exp(x(i)))*(sin(x(i)));
end
dx=pi/40;
e=exp(1);
%fourth order approximation
for i=1:10
centeral_differincing =((0.0833*(exp(x(i)-(2*dx))*cos(x(i)-(2*dx))))+(1.333*(exp(x(i)-dx)*cos(x(i)-dx)))+(2.5*(exp(x(i))*cos(x(i))))+(1.333*(exp(x(i)+dx)*cos(x(i)+dx)))+(0.0833*(exp(x(i)+(2*dx))*cos(x(i)+(2*dx)))))/(dx.^2);
%fourth order approximation
skewed_right_differincing =((0.0833*(e.^x(i))*cos(x(i)))+(1.333*(e.^(x(i)+dx)*cos(x(i)+dx)))+(2.5*(e.^(x(i)+(2*dx))*cos(x(i)+(2*dx))))+(1.333*(e.^(x(i)+(3*dx))*cos(x(i))+(3*dx))))+(0.0833*(e.^(x(i)+(4*dx))*cos(x(i)+(4*dx))))/(dx^.2);
% fourth_order approximation
skewed_left_differincing= (2.9167*(e.^x(i))*cos(x(i)))+(8.667*(e.^(x(i)-dx)*cos(x(i)-dx)))+(9.5*(e.^(x(i)-(2*dx))*cos(x(i)-(2*dx))))+(4.667*(e.^(x(i)-(3*dx))*cos(x(i)-(3*dx))))+(0.9167*(e.^(x(i)+(4*dx))*cos(x(i)+(4*dx))))/(dx.^2);
end
error_first_order = abs(skewed_right_differincing-analytical_derivative);
second_order = abs(centeral_differincing-analytical_derivative);
error_fourth_order = abs(skewed_left_differincing-analytical_derivative);
axis([-2 2 -8 -2]);
plot(error_first_order,analytical_derivative );
hold on;
plot (second_order,analytical_derivative);
hold on;
plot (error_fourth_order,analytical_derivative);
hold on;
grid on
xlabel(\'numerical\');
ylabel(\'analytical solution\');
legend(\'error_first_order\',\'second_order\',\'error_fourth_order\');
---------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
The above graph represents the plot that compares the absolute error between the above-mentioned schemes. The graph shows that the higher the values of the order lower the error values. The forward difference values give single step-predictor values of the finite method. In the forward difference value, a large number of iteration gives the high accuracy with the reference. similarly, the backward differencing value gives the accuracy values with the reference value.The values for FDS and BDS increases with the increase in the values of dx of the solution.
----------------------------------------------------------------------------------------------
A common idea that arises from the CFD asserts that the precision order of numerical schemes degrades as soon as control volumes. A skewed scheme is useful because high skewness of mesh elements involves consistency problems in the discretization of second derivative or diffusive flux.The skew schemed can give the accurate value with the help of the reference grid point values of the approximations whereas the CD can\'t give the accurate value as the problem.
--------------------------------------------------------------------------------------------------------
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Simulation of Flow through a pipe in OpenFoam part 2
Objective: Write a Matlab program that takes an angle as input and generates a blockMesh file for the given angle 10,25,45 degree. To compare the above results and discuss findings Calculation and Assumption Reynolds Number: 2100 Radius of pipe (r) :0.005 dynamics viscosity of water: 1.002 X 10^-3…
19 May 2019 05:23 AM IST
Simulation of Flow through a pipe in OpenFoam part 1
Objective: To write a program in Matlab that can generate the computational mesh automatically for any wedge angle and grading schemes To show that the velocity profile matches with the Hagen Poiseuille\'s equation For a baseline mesh To show that the velocity profile is fully developed Post process…
19 May 2019 05:22 AM IST
BlockMesh Drill down challenge
The main objective is to use the icoFOAM solver to simulate the flow through a backward facing step. Initially, The geometry is generated for a variation of the incompressible cavity flow problem in OpenFOAM.The mesh is generated according to the need of the structure|(i.e with or without grading). …
07 Feb 2019 01:44 PM IST
Simulation of a 1D Super-sonic nozzle flow simulation using Macormack Method
The objective in this project is to write code to solve the 1D supersonic nozzle flow equations using the Macormack Method. The governing equations for both conservative and nonconservative are solved and compared. Also, the iteration number and computational time are compared until the final…
01 Nov 2018 12:39 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.