Preparing Mechanical Engineering Design Students ...

7 downloads 22543 Views 357KB Size Report
must be taught to add computer coding to what usually is a well protected, though .... An anonymous online survey (Table 1), in the form of a questionnaire was ...
Preparing Mechanical Engineering Design Students for Computational Fluid Dynamics Code Development D. Adair1 and Martin Jaeger2 1

2

University of Tasmania, Hobart, Australia, [email protected]

University of Tasmania, Hobart, Australia, [email protected]

Abstract CFD is now a useful tool for mechanical design engineers. CFD has also gained a broad acceptance in engineering education, and has been adopted at undergraduate and postgraduate level course in many universities. The teaching of CFD at the undergraduate level however usually focuses on giving students an understanding of the numerical methods and details involved, supported by what are little more than code fragments, followed by learning an abstract form of CFD skills and processes, without any real interaction with the complex core computer coding behind what is often just “easy-to-use” or “push button” commercial interfaces. Quite often, as the student progresses in his/her use of CFD, especially in the research area, it becomes clear that an “off-the-shelf” commercial CFD package is not able to satisfy all requirements to simulate a given problem fully, nor to obtain accurate results. Code development has to be undertaken to enhance the commercial code’s capabilities with the insertion of say additional FORTRAN coding or through MATLAB. The purpose of this paper is to outline what must be taught to add computer coding to what usually is a well protected, though capable of being compiled and linked, core computer code so that the complexity of interacting is lessened and better understood.

Keywords: Computational fluid dynamics, Code development, Mechanical engineering 1. Introduction Computational Fluid Dynamics (CFD) can provide detailed characteristics of the pressure, velocity and temperature fields as well as information concerning the distribution of species for a wide variety of geometry and applications. With the rapid growth of powerful computer resources and the development of well optimized and reliable commercial packages, CFD is now a useful tool for mechanical design engineers [1]. Projects involving design, especially in the thermo-fluids area, now routinely involve the use of CFD, CAD, Rapid Prototyping and testing in aerodynamic or hydraulic facilities [2]. CFD has also gained a broad acceptance in engineering education, and has been adopted at undergraduate and postgraduate level course in many universities [3]-[5]. However, the teaching of CFD at the undergraduate level usually focuses on giving students an understanding of the numerical methods and details involved, supported by what are little more than code fragments, followed by learning an abstract form of CFD skills and processes, without any real interaction with the complex core computer coding behind what is often just “easy-to-use” or “push button” commercial interfaces. Quite often, as the student progresses in his/her use of CFD, especially in the research area, it becomes clear that an “off-the-shelf” commercial CFD package is not able to satisfy all requirements to simulate a given problem fully, nor to obtain satisfactory accurate results. Code development has to be undertaken to enhance the commercial code’s capabilities with the insertion of say additional FORTRAN coding or through MATLAB. This is usually not an easy procedure, as commercial codes are not usually open source but do allow ‘add-ons’ as substitutes to the protected core computer coding. Care must be taken to ensure that the student has all the necessary knowledge and skills to proceed.

The purpose of this paper is to outline what must be taught to add computer coding to what usually is a well protected, though capable of being compiled and linked, core computer code so that the complexity of interacting is lessened and better understood, the added coding is in fact correct, and, efficient and reliable results are obtained from the enhanced commercial package. The results of a survey of participants specific to this part of a CFD course undertaken by mechanical engineering design students are also presented.

2. Method of Interfacing Generally, current developments are the integration of two computer packages, which allows a scripting programming package to combine with a computational fluid dynamics package to enhance pre-processing, model manipulation and post-processing, as indicated on Figure 1. This is a two-way process where, for example, functions within the script programming package can be imported into the CFD package for use, or, models from the CFD package can be exported to the scripting programming package for further use say in the control area. An example of the integration can be found in Ramadesigan et al. [6].

Figure 1. Two-way integration of CFD and scripting programming packages. The work here however, is not intended to give full integration of two packages, but rather to enhance the capability, and importantly the accuracy of a commercial computational fluid dynamics package and to devise a learning curve to achieve this in an efficient and rewarding way. There are many areas of a commercial CFD code which could be changed with the view to improvement, for example, by adding a faster, more efficient new numerical solving technique, or, by improving the method of closure of the momentum equations. It is the latter which is chosen here to give a framework to build on. Closure of the momentum equations is necessary as the equations used in current CFD packages are averaged, which introduces extra unknowns into the equations. These extra unknowns are accounted for by ReynoldsAveraged Navier-Stokes (RANS) turbulence models [7] [8], a good variety of which come as standard with a commercial code. Closure using the more recent and increasingly preferred Large Eddy Simulation (LES) [9] [10] is however, not found in all commercial codes, and this together with the fact that LES is currently a strong research topic, makes it a good candidate to teach students how to introduce computer coding into a commercial CFD package. The method of enhancement of the commercial code used here is summarized on Figure 2.

Figure 2. The overall structure of the computational fluid dynamics package capable of being re-compiled. The above computer fluid dynamics package can be run without having to be compiled, i.e. no new FORTRAN coding has been added (or overlaid) to the CFD package central program and the ‘public’ executable file is used to obtain results for post-processing. When FORTRAN coding is added to any of the FORTRAN subroutines shown by the user then the central program does have to be compiled and linked. To protect the original CFD package from being changed, and perhaps corrupted, a ‘private’ executable file is produced and used.

3. Instruction Delivery It was thought convenient to introduce the method of code development by way of a computational fluid dynamics project, dealing with the simulation of turbulent vortex shedding from a cylinder investigated using Large Eddy Simulation (LES) as the closure method instead of the more conventional Reynolds-Averaged Navier-Stokes (RANS) turbulence models. However, before embarking on this fairly ambitious project, students needed a thorough grounding on the topics summarized on Figure 3. Of the topics shown on Figure 3, those not already covered in the existing mechanical engineering design students undergraduate course were, Introduction to Large Eddy Simulation, FORTRAN Language Course and Interface Method.

Figure 3. Topics necessary for students to know before enhancing a CFD package.

In the Introduction to Large Eddy Simulation module, which had a length of six hours, the idea of using filtered continuity and momentum equations so as to explicitly simulate the large scales of a turbulent flow while modelling the small scales was introduced [11]. A filtered kernel, which is a localized function can have several shapes , e.g. a Gaussian filter, a box filter or a cut-off filter [12], was discussed. It was shown that on applying filtering to the Navier-Stokes equations a set of equations similar to the RANS equations was obtained, and a non-linear analog term to the Reynolds stresses of RANS was shown to be produced. This term, the sub-grid (SGS) Reynolds stress must be modelled, and it should be remembered that this is not a physical stress but rather the large scale momentum flux caused by the action of the small or unresolved scales. The approximation of the SGS is the main topic of LES and it originates the different types of LES models. In this work, the Smagorinsky closure model [13] was used. This is one of the most commonly LES models employed nowadays. Making an analogy with the effects of stress in laminar flows, the SGS can be written in terms of the strain rate in the resolved velocity field and by dimensional analysis, it can be proven that this is a reasonable form of the eddy viscosity to effect closure of the momentum equations. This form however is known to vary with Reynolds number and so additional treatment is required. One approach, and the one used here is to include van Driest damping to reduce eddy viscosity when required. In the FORTRAN Language Course, which also lasted six hours, the basics of the procedural computer programming language was first introduced and these were built on with hand-on programming exercises. Students actually found this course reasonably easy, as they had already competed computer programming modules of object orientated programming and scripting programming. The later exercises concentrated on writing code suitable for solving discretized equations, an important part of CFD coding. Four additional hours were spent introducing the students to the Interface Method based on the scheme set out on Figure 2. This was very practical module where students learned, for example, to overlay existing formula for the ideal gas and set non-standard sources by the use of an Input Language script which is part of the commercial CFD package.

4. The Project - Flow Over and Downstream of a Square Cylinder The computation carried out was in a domain corresponding to that for the Workshop on LES organized by Rodi and Ferziger [14] as shown on Figure 4.

Figure 4. The geometry of the square cylinder flow. Both 2D and 3D simulations were performed. Three-dimensionality of turbulence cannot be questioned and it has been stated [15] that 2D LES calculations are clearly inferior to the 3D ones since certain important features of turbulence are not resolved, for example the vortex formation in the spanwise direction. However, some authors [16] have concluded that by means of a denser 2D grid the quasi-two-dimensional mechanism can be accurately evaluated, mainly in the regions closest to the solid walls. Due to lack of computer power and keeping in mind that the goal here is to teach and learn rather than simulate real engineering projects, it was concluded to evaluate the vortex shedding due to the square cylinder using 2D simulations only, as these are much more economical. There were several levels of mesh size used in the calculations, so reinforcing the good CFD practice of obtaining

solutions with mesh size independence. The maximum number of grid nodes used was 1.5 x 104. A typical grid is shown on Figure 5.

Figure 5. Cartesian computational grid used for the present project. For the convective and temporal discretization, a second-order Van Leer scheme was selected for simulating the convective transport in the momentum equations, and, a third-order Adam-Moulton scheme was implemented for time. The flow was simulated only over 50 time steps, again due to lack of computer power. The computational domain geometry, material properties, initialization and numeric were all set up for the current project using the normal CFD computer package User Interface mention on Figure 2. The FORTRAN computer code needed to be written by the students in this project was for the discretized Smagorinsky sub-grid model which would calculate the eddy viscosity needed for closure of the momentum equations. The code was first written using a FORTRAN Integrated Development Environment and checked for syntax errors. The students were given the relationship between the eddy viscosity and the rate of strain tensor, together with the fairly lengthy discretized form of the rate of strain tensor and asked to write the FORTRAN coding based on the standard finite volume grid cell notation which would return a value for the eddy viscosity. This LES sub-grid model would be the one which would overlay the standard RANS models found in the commercial code. The FORTRAN coding written by the students was then transferred to one of the Subroutine modules listed on Figure 2, and appropriate instructions were written for the inclusion of the sub-grid model and relayed to the CFD Package Central Program using the Input Language script. This was followed by compilation and linking the new CFD package so producing a private executable file ready for solving. Typical results found by the students for streamlines in the near-wake of the cylinder are shown on Figure 6. Students were then strongly encouraged to find experimental measurements in the literature for comparison to ensure that their simulation was of reasonable accuracy.

Figure 6. Streamlines calculated using LES simulation in the near-wake of the square cylinder.

5. Online Questionnaire An anonymous online survey (Table 1), in the form of a questionnaire was conducted for students (N = 43) concerning the preparation for CFD code development module. The questionnaire consisted of 10 statements with which students could, strongly agree, agree, neutral, disagree and strongly disagree plus a column for no opinion. Comments were encouraged to help understanding of why they responded as they did. Table 1. A list of questions/statements used in the survey for students' feedback No. 1 2 3 4 5 6 7 8 9 10

Question/Statement I found the standard CFD computer package easy to use. I found the FORTRAN computer programming easy. I found interfacing the FORTRAN coding with the CFD package easy. The skill of enhancing a commercial CFD package will be useful to my later studies. The theory of CFD is easy. The skills of CFD are easy. CFD gives me a much better understand of physical phenomena. I feel I can relate CFD to some physical situations. I feel I am in a position to do ‘real’ engineering projects using CFD. I would recommend this CFD course to others.

Generally, student feedback surveys have a very low response rate [17, 18]. However the response rate here was high (>70%) and overall, the results from the survey were positive. The responses to the survey are shown on Figure 7 and indicate that students felt that they benefited both from using CFD packages in general and from learning the particular skill of enhancing a commercial CFD package.

Figure 7. Chart showing survey results. From Figure 7 it is clear that this cohort now finds the use of the standard CFD package reasonably easy, but is fairly neutral in finding the FORTRAN computer programming easy. As may be expected, the students are still not confident about the extensive theory and knowledge underpinning CFD, but are very comfortable applying the skills. There is still a reluctance to think they are prepared for ‘real’ engineering projects. This would actually normally not happen immediately in a professional engineering office where the norm would be that newly graduated engineering would be teamed up with more experience staff. There was a reasonably positive view by the students to the course as a whole, based on the response to question 10. In additional comments, the students expressed the view that with some practice, it was reasonably easy to use the standard commercial CFD package but that the results obtained always needed validation. They did say that this latter part was not always easy to do, as a literature search could take a long time to find suitable experimental results on which to base the validation. Regarding the enhancement of the existing commercial CFD package, there

was general agreement that this was an involved and intricate process and needed special concentration and a detailed knowledge of both FORTRAN and how to implement the extra coding into the standard CFD package. Generally they felt the process needed to be repeated many times before they were fully confident. However almost everyone saw the use and value of knowing this process, especially if they were to make a novel contribution to future research.

6. Conclusions A process has been devised to allow students to enhance the capabilities of a commercial CFD package by the insertion of computer coding to allow some novel method of calculation not already built-in to the existing package. In this way students can use the capabilities of what is usually a highly optimized and reliable computer package, which has been built up over decades on occasions, with new and inventive ways of solving thermo-fluid problems. The project chosen here as a framework for the teaching and learning was fairly ambitious, in that the method of closure of the momentum equations was much different from those the students had already been shown, and although the students found the preliminary FORTRAN instruction and assignment work quite easy, the extra FORTRAN coding necessary for completion of the project was reasonably difficult and detailed for undergraduate students to complete. However as can be seen from the survey above, the students were reasonably comfortable with the process, which would indicate that they found the learning curve reasonably easy generally, but with occasional large challenges.

References [1]

D. Adair, and M. Jaeger, “Integration of Computational Fluid Dynamics into a Fluid Mechanics Course”, Computer Applications in Engineering Education, Vol. 22, No. 1, pp.131-141, 2014.

[2]

D. Adair, and M. Jaeger, “An Integrated Centrifugal Pump Rotor Design Course”, 4th Interdisciplinary Engineering Design Education Conference (IEDEC), Santa Clara, CA, 3-5th March, 2014

[3]

D. Adair, Z. Bakenov and M. Jaeger, “Building on a Traditional Chemical Engineering Curriculum using Computational Fluid Dynamics”, Education for Chemical Engineers, Vol. 9, No. 3, pp. 30-38, 2014

[4]

R. LaRoche, B. Hutchings and R. Muralikrishnan, “FlowLab: Computational Fluid Dynamics (CFD) Framework for Undergraduate Education”, ASEE, AC 2002-1520, 2002

[5]

F.Stern, T. Xing, D. Yarborough, A. Rothmyer, G. Rajagopalan, S. Otta, D. Caughey, R. Bhaskaran, S. Smith, B. Hutching and S. Moevkens, “Development of Hands-On CFD Educational Interface for Undergraduate Engineering Courses and Laboratories”, ASEE, AC 2004-1526, 2004.

[6]

V. Ramadesigan, P. W. C. Northrop, S. De, S. Santhanagopalan, R. D. Braatz, and V. R. Subramamian, “Modeling and Simulation of Lithium-Ion Batteries from a Systems Engineering Perspective”, J. Electrochemical Soc., Vol. 159, No. 3, pp. R31-R45, 2012.

[7]

R. Franke, and W. Rodi, (1993), Calculation of Vortex Shedding Past a Square Cylinder with Various Turbulence Models, Turbulent Shear Flows 8, Springer, 1993. pp. 189-204

[8]

W. Rodi, Turbulence Models and their Application in Hydraulics, (3rd Ed.), CRC Press, 2000.

[9]

P. Sagaut, Large Eddy Simulation for Incompressible Flow - An Introduction, (3rd Ed.), Springer, 2006.

[10]

A. G. Hutton, “The Emerging Role of Large Eddy Simulation in Industrial Practice: Challenges and Opportunities, Phil. Trans. R. Soc.,A, Vol. 367, pp. 2819-2826, 2009.

[11]

A. Leonard, “Energy Cascade in Large Eddy Simulations of Turbulent Fluid Flow”, Adv. in Geophys., Vol. 18A, p. 237, 1974.

[12]

J. H. Peroc, and M. Ferziger, Computational Methods for Fluid Dynamics, SpringerVerlag, Berlin, 1996.

[13]

J. Smagorinsky, “General Circulation Experiments with the Primitive Equations. I. The Basic Experiment”, Monthly Weather Review, Vol. 91, pp. 99-165, 1963.

[14]

W. Rodi, J. H. Ferziger, M. Breuer and M. Pourquié, in: Proc. Workshop on Large- Eddy Simulation of Flows Past Bluff Bodies, Rottach-Egern, Germany, June, 1995.

[15]

A. Murakami, and A. Mochida, “On Turbulent Vortex Shedding Flow Past a Square Cylinder Predicted by CFD”, J. Wind Eng. Ind. Aerodyn., Vol. 54, pp. 191-211, 1995.

[16]

D. Bouris, and G. Bergeles, “2D LES of Vortex Shedding from a Square Cylinder”, J. Wind Eng. Ind. Aerodyn., Vol. 90, pp. 31-46, 1999.

[17]

E. Gamliel, and L. Davidovitz, “Online Versus Traditional Teaching Evaluation: Mode Can Matter”, Assessment & Evaluation in Higher Education, Vol. 30, No. 6, pp. 581592, 2005.

[18]

D. D. Nulty, “The Adequacy of Response Rates to Online and Paper Surveys: What Can be Done?”, Assessment & Evaluation in Higher Education, Vol. 33, No. 3, pp. 301314, 2008.

Authors Principal Author: Desmond Adair is a Professor of Mechanical Engineering. His recent research interests include investigations of air-bourne pollutions for both passive and reacting flows, and developing engineering mathematics. Co-author: Martin Jaeger is an Associate Professor of Civil Engineering and Head of Department. His recent research interests include construction management and total quality as well as developing strategies for engineering education.