0% found this document useful (0 votes)
63 views

A Toolkit For Computational Fluid Dynamics Using Spectral Element Method in Scilab

Spectral Methos for Fluid Dynamics applied with scilab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

A Toolkit For Computational Fluid Dynamics Using Spectral Element Method in Scilab

Spectral Methos for Fluid Dynamics applied with scilab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Materials Today: Proceedings xxx (xxxx) xxx

Contents lists available at ScienceDirect

Materials Today: Proceedings


journal homepage: www.elsevier.com/locate/matpr

A toolkit for computational fluid dynamics using spectral element


method in Scilab
Vishwanatha J S a,⇑, R.H.M. Somanath Swamy b, G. Mahesh b, H. Virupaksha Gouda b
a
NITTE (Deemed to be University), NMAM Institute of Technology, Department of Mechanical Engineering, Nitte 574110, Karnataka, India
b
RYM Engineering College, Ballari 583104, Karnataka, India

a r t i c l e i n f o a b s t r a c t

Article history: Computational Fluid Dynamics (CFD) is a discipline that solves a set of equations governing the fluid flow
Available online xxxx over any geometrical configuration. Three classes of solution techniques have emerged in CFD namely,
the finite difference techniques, the finite element methods, and the spectral techniques. The spectral-
Keywords: element method combines the generality of the finite element method with accuracy of spectral tech-
Computational Fluid Dynamics (CFD) niques. This technique makes use of a Lobatto nodal base. One of the advantages of using spectral ele-
Spectral Element method ment method is that a stable solution algorithms and high accuracy can be achieved with a low
Scilab
number of elements under a broad range of conditions. In the present study spectral element method
software library is developed and implemented using Scilab, which is a high-level, numerically oriented
programming language an also an open source. In the present study the software library of Scilab has
been used to develop a toolkit for one dimension steady diffusion equation, unsteady diffusion equation,
and Laplace’s equation. The accuracy of the spectral method has also been emphasized by comparing it
with the finite element method solution.
Copyright Ó 2023 Elsevier Ltd. All rights reserved.
Selection and peer-review under responsibility of the scientific committee of the International Confer-
ence on Smart and Sustainable Developments in Materials, Manufacturing and Energy Engineering.

1. Introduction disk shape domain using triangular elements by successive sub


division method. Over this domain two dimensions CFD problem
All fluid flow equations can be represented by partial differen- is solved. Spectral element implementation is illustrated by devel-
tial equation (P.D.E). These laws are based on laws of conservation oping toolkit for one steady diffusion equation and two dimen-
mass, momentum & energy. Obtaining analytical solutions for sional heat conduction equation i.e. Laplace’s equations [5–7].
these P.D.E’s is possible only in some simple cases after making
suitable assumptions. This directs the path towards numerical
approximations of governing P.D.E’s which paves the way towards 2. SCILAB description
the era of numerical simulation. Since approximations happen to
be a necessary evil for solutions of such P.D.E’s there are respective Scilab is a scientific software package for numerical computa-
errors generated [1]. tions providing a powerful open computing environment for engi-
Here the main focuses on the implementation of spectral ele- neering and scientific applications. It is capable of interactive
ment technique to CFD problem using Scilab and also developing calculations as well as automation of computations through pro-
a toolkit in form of library files for one and two dimension PDE gramming. It provides all basic operations on matrices through
equations. Scilab is a free open-source software package for scien- built-in functions so that the trouble of developing and testing
tific computation. In one dimension implementation, line domain code for basic operations are completely avoided [8–10].
is discritized into elements and spectral interpolation nodes [1– It has sophisticated data structures (including lists, polynomi-
4]. Over this discritized domain the one dimension CFD problem als, rational functions, linear systems. . .), an interpreter and a high
is solved. In two dimension implementation, grid is generated over level programming language. Scilab has been designed to be an
open system where the user can define new data types and opera-
⇑ Corresponding author. tions on these data types by using overloading. Scilab is used as a
E-mail address: [email protected] (V. J S). scripting language to test algorithms or to perform numerical com-

https://doi.org/10.1016/j.matpr.2023.04.341
2214-7853/Copyright Ó 2023 Elsevier Ltd. All rights reserved.
Selection and peer-review under responsibility of the scientific committee of the International Conference on Smart and Sustainable Developments in Materials,
Manufacturing and Energy Engineering.

Please cite this article as: V. J S, R.H.M. Somanath Swamy, G. Mahesh et al., A toolkit for computational fluid dynamics using spectral element method in
Scilab, Materials Today: Proceedings, https://doi.org/10.1016/j.matpr.2023.04.341
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx

putations. But it is also a programming language, and the standard DxN


¼r ð4:1Þ
Scilab library contains around 2000 Scilab coded functions. The Sci- Dx1
lab syntax is simple, and the use of matrices, which are the funda-
The expansion coefficient a is
mental object of scientific calculus, is facilitated through specific
functions and operators. These matrices can be of different types a ¼ r1=ðN1Þ ð4:2Þ
including real, complex, string, polynomial, and rational. Scilab is
mainly dedicated to scientific computing, and it provides easy in terms of r and N controls the element size expansion. The first
access to large numerical libraries from such areas as linear alge- element size is obtained from eqn.
bra, numerical integration, and optimization. It is also simple to 1a
Dx1 ¼ L ð4:3Þ
extend the Scilab environment. One can easily import new func- 1  aN
tionalities from external libraries into Scilab by using static or
Using and first element size other elements size are generated.
dynamic links. It is also possible to define new data types using Sci-
The generation of Lobatto interpolation nodes are done by using
lab structures and to overload standard operators for new data
zeros and weights of Lobatto polynomials. To produce element
types [11–14].
interpolation nodes the polynomial expansion order mi is intro-
duced on each and every individual element via Lobatto interpola-
3. Spectral element method tion nodes.

Finite volume, finite element, spectral and also finite difference c) Plotting of the solution
methods may be viewed as a specific application of the method of
weighted residuals. In general the method of weighted residuals The solution obtained here is element end nodes and the
employs expansion functions as basic functions for a truncated ser- Lobatto interpolation nodes. These are plotted using Scilab’s inbuilt
ies expansion of the solution of the partial differential equation. In plot function. The input data are, Domain length L = 1, Number of
order to ensure that the approximate solution, defined by the trun- elements N = 2, Ratio r = 3, Polynomial expansion order m1 = 6 for
cated series expansion, satisfies the differential equation as closely 1st element, and Polynomial expansion order m2 = 4 for 2nd
as possible, test functions are used to minimize the residual that is element.
formed when the approximate solution is substituted into the par- The discretization of a line domain is unsymmetrical. This gen-
tial differential equations. Traditionally the finite element method erates the element end nodes and global spectral nodes. The circle
has always used polynomial expansions and this may be attributed marks indicates the position of the element end nodes. The tilted
to the historical use of Taylor series expansions which allow ana- square mark indicates the position of the Lobatto interpolation
lytical functions to be expressed in terms of polynomials [3]. Poly- nodes. The total no of element end nodes generated are N + 1,
nomial functions also have the added advantage of discrete i.e. 3. The total no of Lobatto interpolation nodes are m1 + m2 +
integration rules which enable easy computer implementations 1,.i.e. 11. Since the element end nodes are coinciding with Lobatto
[4]. interpolation nodes the total nodes appeared in the plot is only 11.

4. Results and discussion 4.2. One dimension steady diffusion equation

The main focus here is to implement spectral element method Consider steady-state heat conduction through a rod length, L,
and develop library files for one dimension problem and two in the presence of a distributed source of heat due, for example,
dimensions problem using open source software. Scilab is open to a chemical reaction. We begin by introducing the  axis along
source software used for programming. This is an initial stage of the rod, and flux along it is given by Fick’s Law.
spectral element implementation in Scilab, the software library is
df
restricted to one and two dimension CFD problems. We have qðxÞ ¼ k ð4:4Þ
dx
developed the toolkit for one and two dimension CFD problem
by using this software library. The validation of this work is done where k is the thermal conductivity of the rod material and f(x) is
by comparing previous Matlab work as shown in Figs. 1–5. the temperature.
We shall assume that the boundary conditions specify:
4.1. Discretization of line and generation of spectral nodes. The heat flux at the left end of the rod located at,
 
df
A discretization is said to be unsymmetrical if element distribu- q0  k ð4:5Þ
dx x¼0
tion is asymmetric with respect to the interval midpoint.
The temperature at the right end of the rod located at x = L,
a) Input data
f ðx ¼ LÞ  f L ð4:6Þ
Input data consist of basic information which is must for a code Eqn. (4.4) expressed a Neumann boundary condition that is the
to perform desired operations and hence to give results. Here we condition on the derivative of the unknown function and the Eqn.
are giving input data in a file (*.sce) which consists of length of (4.5) expressed a Dirichlet boundary condition that is a condition
the domain, number of elements N, ratio r, polynomial expansion on the value of the unknown function. In the steady diffusion equa-
order mi for each individual element. tion problem the unknown vector, diffusion flux f, contains the
solution at all nodes is need to find out.
b) Discretization:
a) Data input
In this step a line segment is divided into a graded mesh of ele-
ments subtended between the left end-point and right end – point, Input data consist of basic information which is must for a code
variable ratio is the ratio of the length of the last element to the to perform desired operations and hence to give results. Here we
length of the first element as shown in eqn. are giving input data in a file (*.sce) which consists of length of
2
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx

Fig. 1. Spectral node distribution on two elements generated on a line domain.

interpolation nodes the connectivity matrix and the global nodes


are generated.

c) Specify the source and boundary conditions

Here we are assuming that the source term is a continuous


function and use the equation
x2
sðxÞ ¼ so expð5 Þ ð4:7Þ
L2
Where - s0is a constant, and 0  x  L.
The boundary conditions are used as in Eqs. (4.5) and (4.6).
Fig. 2. Steady one dimension with linear elements using Spectral element method.
d) System assembly

The computation of element mass and diffusion matrix is


depending upon the corresponding interpolation polynomial order
m. The element mass matrix is computed by using Lobatto integra-
tion quadrature equation.
Z X
1 kþ1
 
f ðnÞdn ffi f n ¼ zp wp ð4:8Þ
1 p¼1

Which generates the corresponding Lobatto integration points


and weights through Lobatto polynomials equation.
The element diffusion matrix is computed by using node differ-
entiation matrix, Lobatto integration quadrature and correspond-
ing Lobatto weights.
Assembly of the linear system of equation is done by generating
the global diffusion and global mass matrix through connectivity
matrix.
Fig. 3. Triangulation of disk for discretization level ndiv = 0.
e) Plot

the domain, number of elements N, ratio r, polynomial expansion Plotting is done using the Scilab’s inbuilt plot function.
order mi for each individual element, thermal conductivity k, heat Input data are:
generation q_0, flux at the boundary fL.
& Domain length, L = 1
b) Element node generation & Thermal conductivity, k = 1
& Heat generation, q_0 = -1.0
The domain discretization and generation of the Lobatto inter- & Flux at the boundary, fL = 0.0
polation nodes is the same as in section 4.3. Also from the Lobatto & Number of elements, N = 3

3
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx

Fig. 4. Triangulation of disk for discretization level ndiv = 1.

Fig. 5. Triangulation of disk for discretization level ndiv = 3.

& Ratio, r = 5 one hundred twenty – eight global nodes, NG = 128, is accurate
& Polynomial order for 1st element, np(1) = 2 only to the fourth significant figure. This shows the spectral ele-
& Polynomial order for 2nd element, np(2) = 2 ment method gives more accurate and convergence solution com-
& Polynomial order for 3rd element, np(3) = 4 pare to finite element method.
f) Result
4.3. Grid generation
The output plot is for the diffusion flux against the element end
nodes in this computation three elements are used with corre- In this work, disk like shape are considered as domain to imple-
sponding polynomial expansion are 2, 2, and 4. The crosses on ment spectral element method in two dimensions. The triangula-
the graph denote the computed nodal values at the interpolation tion technique is used for grid generation because of it’s
nodes. Table 1 Accuracy and convergence of the spectral element distinguish feature of successive subdivision. The refinement level
method compare to the Finite element method with linear is determined by the input flag ndiv
elements.
The result shows, comparison of the numerical solutions for a At ndiv = 0 produces ancestral 4 elements.
fixed global nodes, NG, clearly demonstrates the spectral element At ndiv = 1 produces ancestral 16 elements
method over the linear element method. For example, the spectral At ndiv = 2 produces ancestral 64 elements.
element solution with sixteen global nodes, NG = 16 i.e accurate to At ndiv = 3 produces ancestral 256 elements.
the fifth significant figure. Whereas finite element solution with

4
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx

Table 1
Accuracy and convergence of the spectral element method compare to the Finite element method with linear elements.

Spectral element method Linear finite element method


NE Np NG f(0) NE f(0)
3 1 5 2.443 2 2.45416
3 2 7 1.969 4 2.01966
3 3 10 1.963 6 1.98460
3 4 13 1.964 8 1.97463
3 5 16 1.964 10 1.97042
4 5 21 1.964 16 1.96624

Each triangle is defined by six nodes, including vertex nodes Fifth step constitute global diffusion matrix using element dif-
and three edge nodes. The elements have triangular shapes defined fusion matrix and connectivity.
by small group of geometrical element nodes. The collection of all
geometrical element nodes comprises a set of NGN unique geomet- e) Assemble the right – hand side of the linear system.
rical global nodes.
Result: At ndiv = 0, produces 4 triangles and 24 nodes, at ndiv = 1 Assembling the right - hand side of the linear system by using
produces 16 triangles and 96 nodes. At ndiv = 3 produces 256 tri- global diffusion matrix and global node flag.
angles, i.e1536 nodes. The spectral element solution for Laplace’s equation on disk like
domain is shown in Fig. 5 for Dirichilet boundary conditions with
4.4. Laplace’s equation the discritization level is 2 and the 6 noded triangular elements
are being used. To isolate from the domain to solution domain
The layout of the spectral element code for solving Laplace’s deform 0.6 being introduced over the global nodes. Different colour
equation indicates the variation in temperature on each and individual
elements.
r2 f ¼ 0 ð4:9Þ
Subject to the Dirichlet boundary condition applied all around
the boundary of the solution domain. 5. Conclusions

a) Data input The presented work started with understanding the basic the-
ory of finite element method, spectral element method, function
Input data consist of basic information which is must for a code interpolation and grid generation. It started without knowing
to perform desired operations and hence to give results. Here we how to develop software library in Scilab. With the little difficulties
are giving input data in a file (*.sce) which consists of discretization in the initial phase of the project, the software library could be
level ndiv and number of quadrature base points NQ. exceptionally utilized according to the project requirement.
A study has been carried out with successful implementation of
b) Grid generation spectral element method in Scilab, also developed software library
files.
Grid generation is done by using triangulation method. Which The tool kit has been developed for one dimension steady diffu-
generates the triangular elements, global nodes, connectivity sion, unsteady diffusion and two dimensions Laplace’s equation.
matrix and element-node and global –node flags. This toolkit didn’t require again and again compilation for same
problem with different initial and boundary condition.
c) Specify the Dirichlet boundary condition. This work demonstrates the spectral element method requires
fewer degrees of freedom than lower – order method. That is spec-
The specification of the Dirichilet boundary condition at bound- tral element method provides accuracy and convergence at very
ary node is done via connectivity matrix. Apply to all unique global less number of element compared to the finite element method.
nodes NG. This work is compared with existing Matlab packages the
agreement is seen to be good.
d) Assembly the global diffusion matrix.

To generate the element diffusion matrix over each triangular 6. Future work
element first step is to generate mapping coefficients alpha, beta
and gamma. The present work developed software library for one and two
dimensions CFD problem, the basis formulation is same for three
1 1 1
a¼ 

; b ¼
x6 x3  ; c ¼
    ð4:10Þ dimensions also, hence easily extended to three dimension case.
2 x5 x2 
1 þ xx44 x
x1  1 þ  x6 x1  1 þ x5 x3 
In this work we used successive subdivision techniques for grid
generation for two dimensions case, employing Delaunay triangu-
In second step the mapping is done with area of the triangle in lation technique one can use for various shapes of one and two
physical xy plane over the area of the triangle in the parametric ng dimensions problems can be easily solved.
plane. The spectral element basic implementation done in Scilab, need
In third step introducing Abscissas and weight for Gaussian to employ on practical application oriented one and two dimen-
integration over a flat triangle in, the xi-eta plane the integration sions problems.
is performed. This software library can be used for the further developing
Fourth step the generation of the element diffusion matrix, the incompressible Navier - Stokes equation for the fluid flow problem.
corresponding element mass matrix using isoparametric interpola- The software library developed here can be used directly for
tion and corresponding abscissas and weights. developing software packages.
5
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx

CRediT authorship contribution statement [3] F.N. van de Vosse, P.D. Minev, Spectral element methods: theory and
applications, Vol. 96-W-001, Eindhoven University of Technology, 1996.
[4] K. Raghavendra Pai, Ajit M. Hebbale, J.S. Vishwanatha, B. Sachin, Study of
J.S. Vishwanatha: Conceptualization, Writing – original draft. R. tribological properties on aluminium based hybrid composite developed
H.M. Somanath Swamy: Validation, Supervision. G. Mahesh: through microwave energy, Materials Today: Proceedings,Vol. 44, 2021, pp.
4245-4250.
Investigation. H. Virupaksha Gouda: Software.
[5] Russell G. DeAnna, Incompressible Spectral-Element Method - Derivation of
Equations, NASA Technical Memorandum, 1993.
Data availability [6] D. John, A. Jr, Computational Fluid Dynamics The Basics with Applications,
Department of Aerospace Engineering, University of Maryland, 1995.
[7] Charles Hirsch, Numerical Computation of Internal and External Flows,
Data will be made available on request. Fundamentals of Computational Fluid Dynamics, Volume 1, Second edition
Butterworth-Heinemann is an imprint of Elsevier, 2007.
[8] Satish Annigeri, Scilab- A Hands on Introduction, 2004.
Declaration of Competing Interest [9] S.L. Campbell, Jean-Philippe Chancelier, RamineNikoukhah, Modelling and
Simulation in Scilab/Scicos, Springer, New York, NY, 2009.
The authors declare that they have no known competing finan- [10] R.H.M. Somanath Swamy, G. Hiregoudar Yerrennagoudar, JS.V. Mahesh,
Performance of CI Engine Using Swirl Type Retrofit, Journal of Physics:
cial interests or personal relationships that could have appeared Conference Series (2021).
to influence the work reported in this paper. [11] Gilberto E Urroz, Introduction to Scilab, 2001.
[12] T.J. Chung, Computational Fluid Dynamics, University of Alabama, Huntsville,
2002.
References
[13] J. Balazek, Computational Fluid Dynamics: Principles and Applications,
ELSEVIER publication, 2001.
[1] G.E.M. Karniadakis, S.J. Sherwin, Spectral / hp Element Methods for CFD, [14] AnilW. Date, Introduction to Computational Fluid Dynamics, Cambridge
Oxford University Press, New York Oxford, 1999. University Press, 2005.
[2] Anthony T. Petera, A spectral element method for fluid dynamics laminar flow
in channel expansion, Journal of computational Physics 54 (3) (1984) 468–488.

You might also like