Numerical study of a heat exchanger
Abstract
Investigating the possibilities of VMS techniques in the simulation of a heat exchanger
Full text
Universitat Politècnica de Catalunya BarcelonaTech Master Thesis Numerical Study of a Heat Exchanger Author: Christian ROSSI Adviser: Riccardo ROSSI September 22, 2017
Numerical Study of a Heat Exchanger Christian Rossi September 22, 2017
Contents 1 Introduction 11 1.1 Starting Point of the Thesis . . . . . . . . . . . . . . . . . . . . . . . 11 1.2 Thermo-Fluid Dynamic Problem . . . . . . . . . . . . . . . . . . . . 11 1.3 Objectives................................. 12 2 State Of Art 15 2.1 Fluid Mechanics and Heat Transfer Equations . . . . . . . . . . . . . 15 2.1.1 Continuity Equation . . . . . . . . . . . . . . . . . . . . . . . 15 2.1.2 Momentum Equation . . . . . . . . . . . . . . . . . . . . . . . 16 2.1.3 Energy Equation . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.1.4 Constitutive Equations . . . . . . . . . . . . . . . . . . . . . . 17 2.1.5 Boussinesq Approximation (Buoyancy) . . . . . . . . . . . . . 18 2.1.6 HeatEquation .......................... 19 2.2 Stabilization Techniques . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.3 Variational Multiscale Methods . . . . . . . . . . . . . . . . . . . . . 20 2.3.1 ASGS stabilization . . . . . . . . . . . . . . . . . . . . . . . . 22 2.4 Thermodynamics and Heat Transfer . . . . . . . . . . . . . . . . . . . 24 2.4.1 Conduction ............................ 25 2.4.2 Convection ............................ 26 2.4.3 NusseltNumber.......................... 28 2.5 FluidDynamics.............................. 31 2.5.1 Fluid Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.2 Flow Across Staggered Tube Banks . . . . . . . . . . . . . . . 33 2.5.3 PecletNumber .......................... 35 2.5.4 Velocity Boundary Layer . . . . . . . . . . . . . . . . . . . . . 35 2.5.5 Thermal Boundary Layer . . . . . . . . . . . . . . . . . . . . . 37 2.5.6 PrandtlNumber ......................... 37 2.5.7 Navier-Stokes Equations . . . . . . . . . . . . . . . . . . . . . 38 2.5.8 Turbulence ............................ 39 2.5.9 Heat and Momentum Transfer in Turbulent Flow . . . . . . . 41 2.6 Finite Element Method . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.6.1 Weighted Residual Method . . . . . . . . . . . . . . . . . . . . 43 2
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger 2.6.2 Weak and Algebraic Formulation of the Heat Equation . . . . 44 2.6.3 Weak and Algebraic Formulation of the Navier-Stokes Equations 48 2.6.4 LBBcondition .......................... 51 2.7 TimeDiscretization............................ 52 2.7.1 Explicit vs. Implicit Schemes . . . . . . . . . . . . . . . . . . 52 2.7.2 θScheme Time Integration . . . . . . . . . . . . . . . . . . . 52 2.7.3 Backward Differentiation in Time . . . . . . . . . . . . . . . . 53 2.7.4 AdamsMethod .......................... 53 3 Methodology 55 3.1 Kratos Muliphysics Software . . . . . . . . . . . . . . . . . . . . . . . 55 3.1.1 Problem Description and Main Kratos’s Tools . . . . . . . . . 56 3.1.2 Creating an Element . . . . . . . . . . . . . . . . . . . . . . . 57 3.1.3 Application Solvers . . . . . . . . . . . . . . . . . . . . . . . 58 3.1.4 Application Conditions . . . . . . . . . . . . . . . . . . . . . . 59 3.1.5 Creating a Problem to Be Solved . . . . . . . . . . . . . . . . 60 3.2 Strategy.................................. 62 3.2.1 Transmission Conditions . . . . . . . . . . . . . . . . . . . . . 62 3.2.2 Approach Analysis . . . . . . . . . . . . . . . . . . . . . . . . 63 3.2.3 Dirichlet-Neumann Method . . . . . . . . . . . . . . . . . . . 64 3.3 3D Heat Exchanger Modeling . . . . . . . . . . . . . . . . . . . . . . 64 3.3.1 Problem Description and Properties . . . . . . . . . . . . . . . 64 3.3.2 Geometry ............................. 65 3.3.3 Boundaries Conditions and Initial Conditions . . . . . . . . . 66 3.3.4 MeshGeneration ......................... 67 3.4 Solution at the Interface . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.5 Boussinesq Approximation . . . . . . . . . . . . . . . . . . . . . . . . 69 3.6 HeaterExchangers ............................ 69 3.6.1 Types of Heat Exchangers . . . . . . . . . . . . . . . . . . . . 69 3.6.2 Cross-Flow Heat Exchanger . . . . . . . . . . . . . . . . . . . 71 4 Tests and Results 75 4.1 Heat Equation Application Testing . . . . . . . . . . . . . . . . . . . 75 4.1.1 PureDiffusion........................... 75 4.1.2 Diffusion Dominant . . . . . . . . . . . . . . . . . . . . . . . . 77 4.1.3 Convection Dominant . . . . . . . . . . . . . . . . . . . . . . . 78 4.1.4 ASGS implementation . . . . . . . . . . . . . . . . . . . . . . 79 4.2 Neumann Flux Condition Testing 2D . . . . . . . . . . . . . . . . . . 80 4.3 CFD-Heat Transfer Application Testing 2D . . . . . . . . . . . . . . . 82 4.3.1 Laminar Flow Around a Cylinder . . . . . . . . . . . . . . . . 82 4.3.2 Laminar Flow Around a Heated Cylinder . . . . . . . . . . . . 85 4.4 Heat Exchanger’s Numerical Simulation in 2D . . . . . . . . . . . . . 88 3
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 4.4.1 Description of the Problem . . . . . . . . . . . . . . . . . . . . 88 4.4.2 Velocity Definition . . . . . . . . . . . . . . . . . . . . . . . . 91 4.4.3 Mesh Size Definition . . . . . . . . . . . . . . . . . . . . . . . 91 4.4.4 Fluid Dynamic Results . . . . . . . . . . . . . . . . . . . . . . 93 4.4.5 Heat Transfer Results . . . . . . . . . . . . . . . . . . . . . . . 94 4.5 Flow Around a Heated Cylinder 3D . . . . . . . . . . . . . . . . . . . 95 4.5.1 Description of the Problem . . . . . . . . . . . . . . . . . . . . 96 4.5.2 Mesh Size Definition . . . . . . . . . . . . . . . . . . . . . . . 97 4.5.3 Results............................... 97 4.6 Heat Exchanger Numerical Simulation in 3D . . . . . . . . . . . . . . 100 4.6.1 Description of the Problem . . . . . . . . . . . . . . . . . . . . 100 4.6.2 Mesh Size Definition . . . . . . . . . . . . . . . . . . . . . . . 101 4.6.3 Results...............................101 5 Conclusion 105 Appendices ...................................107 A GenerateHeatEquationElement.py . . . . . . . . . . . . . . . . . . . . 107 B HeatEquationTemplate.cpp . . . . . . . . . . . . . . . . . . . . . . . 110 C HeatEquationSolver.py . . . . . . . . . . . . . . . . . . . . . . . . . . 115 D CFD-HeatTransferSolver.py . . . . . . . . . . . . . . . . . . . . . . . 120 E HeatEquationNeumannCondition.cpp . . . . . . . . . . . . . . . . . . 125 F HeatEquation.cpp.............................130 G HeatEquation.h..............................139 4
List of Figures 2.1 Convection and conduction between a solid and a fluid (Bahrami). . . 27 2.2 Velocity profile depending on the adverse pressure gradient and separationpoint.(Baker) .......................... 29 2.3 Separation flow over a cylinder(MPGC). . . . . . . . . . . . . . . . . 30 2.4 Nu vs θ(Cengel) ............................. 30 2.5 Correlation for different Nu number for a flow over a cylinder for different Re numbers (Cengel). . . . . . . . . . . . . . . . . . . . . . . 31 2.6 Tubebanks(NPTEL). .......................... 34 2.7 Velocity boundary layer generation for a different fluid regime (Atreya). 36 2.8 Boundary layer for a fluid temperature greater than the solid surface temperature(NPTEL)........................... 37 2.9 Thermal boundary layer and velocity boundary layer comparison for different Prandtl numbers (Bahrami). . . . . . . . . . . . . . . . . . . 38 2.10 Velocity filed turbulent regime (Ferziger). . . . . . . . . . . . . . . . . 41 2.11 Velocity and temperature gradients at the wall for laminar and turbulentregime[11]. ............................ 42 2.12 2D domain discretization using three-node triangular elements (Oñate). 46 2.13 Linear shape function for the triangular element (Oñate). . . . . . . . 47 3.1 Square domain 18 triangular elements. . . . . . . . . . . . . . . . . . 60 3.2 Physical domain decomposed into two subdomains (Ω1,Ω2) separated by the interface Γint (Chessa)....................... 62 3.3 Geometry domains in GiD. . . . . . . . . . . . . . . . . . . . . . . . . 66 3.4 Inlet boundary condition definitions in GiD. . . . . . . . . . . . . . . 67 3.5 Cylindermeshed. ............................. 68 3.6 Double pipe heat exchanger design. Parallel flow (left) and counter flow(right)(Cengel)............................ 70 3.7 Cross-flow unmixed and mixed configuration (Cengel). . . . . . . . . 71 3.8 Cross-flow heat exchanger EUETIB FM Laboratory (Riera M, 2016). 72 3.9 Methacrylate cylinders heat exchanger test area (Riera M, 2016). . . 72 3.10 Fluid flow control valve (Riera M, 2016). . . . . . . . . . . . . . . . . 73 5
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 4.1 Results of a pure diffusion case at dimensionless time t = 1. . . . . . 76 4.2 Results of a diffusion dominant case for Pe = 7.5 at dimensionless timet=10................................. 78 4.3 Results of a convection dominant case for Pe = 10 for different time steps..................................... 79 4.4 Results of a convection dominant case for Pe = 10 at dimensionless timet=10................................. 80 4.5 Heat conduction through a large plane wall (Cengel). . . . . . . . . . 80 4.6 Results of a pure diffusion case imposing flux condition through a largeplanewall............................... 81 4.7 Geometry of 2D test cases with boundary conditions (Schäfer). . . . . 82 4.8 Temperature field results at different time steps of a laminar flow aroundacylinder.............................. 84 4.9 Temperature evolution of a point located on the cylinder. . . . . . . . 85 4.10 Transient velocity behaviour at the inlet . . . . . . . . . . . . . . . . 86 4.11 Matching nodes between the solid and the fluid domain at the interface(greencircle).............................. 87 4.12 Temperature evolution for a node localized at the interior of the solid . 87 4.13 Heat flux results at time = 0.3 s. . . . . . . . . . . . . . . . . . . . . 88 4.14 Geometry and dimensions of the heat exchanger. . . . . . . . . . . . . 90 4.15 Geometry and dimensions of the heat exchanger’s test area. . . . . . 90 4.16 Triangular unstructured mesh of the whole domain. . . . . . . . . . . 92 4.17 Very dense mesh in the tube banks area. . . . . . . . . . . . . . . . . 92 4.18 Two domains interface matching nodes (green circle). . . . . . . . . . 93 4.19 Velocity distribution at 1 seconds. . . . . . . . . . . . . . . . . . . . . 93 4.20 Velocity profile before the tube banks. . . . . . . . . . . . . . . . . . 94 4.21 Velocity profile after the tube banks. . . . . . . . . . . . . . . . . . . 94 4.22 Temperature distribution after 1 seconds. . . . . . . . . . . . . . . . . 95 4.23 Cylinder temperature evolution after 1 second. . . . . . . . . . . . . 95 4.24 Configuration for flow around a cylinder with circular cross–section (Schafer). ................................. 96 4.25 Fluid’s temperature field after 6 seconds. . . . . . . . . . . . . . . . . 98 4.26 Solid’s temperature field after 6 seconds. . . . . . . . . . . . . . . . . 98 4.27 Cylinder temperature decreasing evolution during 6 seconds. . . . . 99 4.28 Temperature evolution of the fluid domain at the heat exchanger in 3D......................................102 4.29 Velocity evolution of the heat exchanger in 3D. . . . . . . . . . . . . 103 4.30Heatfluxatt=1s. ...........................104 4.31 Solid temperature field at t = 1.35 s. . . . . . . . . . . . . . . . . . . 104 6
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger Abstract Thermo-fluid dynamic is the science that deals with mass movement and energy transfer. More specifically it involves fluid mechanics and heat transfer and, due to different fields interact between them, the thermo-fluid dynamic problem is defined as coupled problem. In this this case there is a dependence between velocity and temperature fields. From the engineering point of view, the thermo-fluid dynamic problem is very important and very present in standard design and practical analysis. On top of that, the continuing increasing computing power has allowed to solve realistic complex problems in a reliable way and make it really interesting. In the current work, an application in order to computationally study the thermofluid dynamic problem has been developed using the Kratos Multiphysics Software . Objective of this work has been the creation and simulation of an heat exchanger model working in a turbulent regime using the variational multiscale method formulation. First, in order to computationally study the problem, a solver able to study the heat exchange through convection and diffusion has been developed; successively the previous solver has been coupled with the fluid dynamic solver, obtaining a tool in order solve thermally coupled flows, where both physical problems take place in the same domain. Finally different cases have been analyzed in order to test the reliability of the application and also the information transfer between different subdomains following the Dirichlet-Neumann scheme. An extra transversal objective has been the competence to getting familiar with Kratos and also to progress with my coding ability using Python and C++. 7
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Resumen La termo-fluidodinamica es la ciencia que estudia el movimiento de masa y el intercambio de energía. Más específicamente esta rama de la física incorpora la mecánica de fluidos e la la transferencia de calor. Debido a la física del problema, el termo-fluido dinámico se define como problema acoplado porqué diferentes campos iteracionan entre ellos. En el caso in cuestión hay una dependencia entre velocidad y temperatura. Desde el punto de vista ingenieril, el problema termo-fluido dinamico es muy importante y muy presente en el diseño y en el analisis practico. Además, el continuo avance de potencia de calculo de los ordenadores permite solucionar complejos problemas reales de forma fiable y lo rende interesante. En este trabajo se ha tratado de desarrollar una aplicación de manera que el problema termo-fluido dinámico fuera accesible bajo el enfoque computacional utilizando el software Kratos Multiphysics. Objetivo has sido simular un modelo de intercambiador de calor en régimen turbulento utilizando la formulación variational multiscale method y comparar datos experimentales. En primer lugar, para poder hacer factible una herramienta de estudio, se ha desarrollado un solver para poder estudiar el intercambio de calor a través de conducción e y difusión; sucesivamente el mismo se ha acoplado con el solver de la aplicación fluido dinámica, obtenido una herramienta en grado de resolver flujos acoplados termicamente, donde los dos campos interaccionan entre ellos en el mismo dominio. Finalmente se han examinado diferentes casos a fin de evaluar la fiabilidad de la aplicación creada y también la transferencia de informaciones entre sub-dominios siguiendo el esquema Dirichlet-Neumann. Como objetivo transversal también se ha incluido a la familiarización con el software Kratos y la mejora de las habilidades de programación en Python y C++. 8
Chapter 2 State Of Art This chapter provides the most important fluid mechanics and heat transfer equations. Also the stabilization techniques and the variational multiscale method are introduced and finally an overview of basic concepts of thermodynamics and fluid mechanics are proposed. 2.1 Fluid Mechanics and Heat Transfer Equations Conservation laws state that a particular measurable property of an isolated physical system does not change as the system evolves over time. Exact conservation laws include continuity equation, momentum equation and energy equation. 2.1.1 Continuity Equation Continuity equation is a conservative law and it is based on the conservation principles where the total mass of a continuum does not change, then: ∂ρ ∂t +∇ · (ρv)=0 (2.1) Where ρis the density and vis the velocity. The divergence of the mass-density flux ρvis also called transport term because it transfers quantity from one region to another without making a net contribution over the entire field [5]. For incompressible flows the continuity equations implies: ∇ · v= 0 (2.2) 15
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 2.1.2 Momentum Equation Momentum Equation is a conservative law based on Newton’s second law and it is based on the conservation principles where no momentum can be created or destroyed, but merely moves from one place to another. The momentum equation states that the rate of change of the linear momentum of an arbitrary part of a continuous medium is equal to the resultant force acting on the part in question, then: ∂ ∂t(ρv) + ∇ · (ρv⊗v) = ∇ · σ+ρg(2.3) where σis the stress tensor , gis the body accelerations (per unit of mass) acting on the continuum and ⊗is the outer product. And for an incompressible fluid, the momentum equation is: ∂v ∂t + (v· ∇)v−ν∇2v=−1 ρ∇p+g(2.4) where νis the cinematic viscosity and pis the pressure. The term (v· ∇)vis known as the convective term, which makes the Navier-Stokes equation nonlinear, and ν∇2vis know as the viscous term. 2.1.3 Energy Equation Energy Equation, as the continuity and the momentum equation, is a conservative law and it is based on the conservation principles where no energy can be created or destroyed, but merely moves from one place to another. For an incompressible fluid continuity and momentum equation can determine the flow motion meanwhile, if the fluid is compressible, the energy equation is required. The energy equation is: ρ∂h ∂t +∇ · (hv)=−Dp Dt +∇ · (k∇T)+(τ· ∇)v(2.5) where his the enthalpy, Tis the absolute temperature, kis the heat conductivity and (τ· ∇)vis the dissipation function representing the work done against viscous forces and the conduction heat transfer is governed by Fourier’s law with being the thermal conductivity. For compressible flows the equation of state is used in order to give the relation between density , pressure and temperature: 16
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger p=ρRT (2.6) where R is the gas constant ( R = 287.1 J/KgK for air). For an incompressible fluid the density is considered constant and using the relation dh =cpdT, equation 2.5 takes the next form: ρcp∂T ∂t + (v· ∇)T=∇ · (k∇T)+(τ· ∇)v(2.7) where cpis the heat capacity at constant pressure. For incompressible flows the equation of states doesn’t exist and the energy equation is not coupled with the continuity and the momentum equations. Due to this condition first it is possible to solve the continuity and the momentum equations in order to obtain the velocity and the pressure distribution without knowing the temperature (the assumption where the fluid properties are not function of the temperature is taken into account). If the density changes due to the temperature variations it is considered in the body force term of the momentum equation. Once the velocity and pressure are obtained, energy equation is solved in order to find the temperature distribution. 2.1.4 Constitutive Equations Considering a thermo-fluid dynamic problem where it is described as Dρ Dt +ρ∇ · v= 0 ρ∂v ∂t +ρ(v· ∇)v=∇ · σ+ρg ρ∂e ∂t +ρv· ∇e=σ:∇v−∇·q and the two equations of state p=p(ρ, T)and e=e(ρ, T). The heat flux can be written in terms of the temperature using Fourier’s law (Eq.2.36). In order to solve the problem some constitutive equations must be added. Constitutive equations give a relation between the stress tensor (σ), the pressure (p) and the velocity (v). For a fluid in motion the stress tensor σ=σ(p, τ)is decomposed into: σ=−p1+τ(2.8) 17
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis where pis the thermodynamic pressure, which is a variable in terms of the density and the temperature, and τis the shear stress tensor. According to the type of fluid the constitutive equations are: •Ideals fluids: σ=−pI •Newtonian fluids: σ=−pI+C:∇sv •Non-Newtonian fluids: σ=−pI+f(∇sv) For the Non-Newtonian fluids fis a non-linear function. In the case of the Newtonian fluids there is a linear relation between the shear stress and the strain rate tensor ∇sv. For the isotropic case, the shear stress tensor becomes: τ=λtr(∇sv)I+ 2µ∇sv(2.9) Using this expression, the mean pressure is: p−¯p=K∇ · v(2.10) with K = λ+ 2/3µ, which is the bulk viscosity. In the case of the incompressible fluid or when λ=−2/3µ(Stokes assumption), the thermodynamic pressure and the mean pressure are equal. 2.1.5 Boussinesq Approximation (Buoyancy) Due to the fluid is influenced by change in temperature, the Boussinesq approximation must be taken into account. In Boussinesq approximation the density variations are considered and a linear dependence on temperature is registered as: ρ=ρ0−ρ0β∆T(2.11) where βis the thermal expansion and ∆Tis the difference between the computed temperature and the room temperature. In stead of modify the value of the density, changes in gravity gare taken into account using the next approximation: gy=gy0−gy0β∆T(2.12) 18
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger where gy0is the initial value of the gravity in the ydirection. The value of the gravity will be update at each time step as g∗= (0,1,0)gy Applying the Boussinesq approximation the momentum equation (Eq.2.4) is: ∂T ∂t +v· ∇v=−1 ρ∇p+∇ · (ν∇v)−g∗(2.13) 2.1.6 Heat Equation The heat equation equation describes the transport inside a physical system of a scalar quantity by convection and diffusion and the equation reads: ρcp ∂T ∂t +ρcpa· ∇T−∇·(k∇T) = q(2.14) where the scalar quantity Tis the temperature, ais the convection velocity and q is the source term. It can be applied also for solids setting a= 0 and the transport of the quantity be possible just by diffusion. 2.2 Stabilization Techniques It is well known that for the heat equation (Eq. 2.14), for a convective dominant problem, strongly oscillatory values are produced . In order to avoid this behaviour a sufficiently small element size can be chosen, but the computational cost would be extremely expensive. Several technique have been proposed which add an extra term over the element interiors to the Galerkin weak form. This extra term involves the residual of the differential equation which is: R(T) = q−(ρcp ∂T ∂t +ρcpa· ∇T−∇·(k∇T)) | {z } L(T) (2.15) where L(T)is the differential operator associated with the differential equation. The standard Galerkin finite element method applied to the heat equation and adding the stabilization term gives back the next equation in weak form: 19
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ZΩ ρcpw∂T ∂t +ZΩ ρcpwa· ∇T−ZΩ ∇w·k∇T +X eZΩe P(w)τR(T)dΩ = ZΩ wq +ZΓ w(n· ∇T)dΓ (2.16) where the stabilization term is: P(w)τR(T)(2.17) and P(w)is an operator which depends of the stabilization technique used and τis called the stabilization parameter. Several technique (see [7]) are available as Streamline-Upwind Petrov—Galerkin (SUPG ),Galerkin/Least-squares (GLS) and Algebraic Subgrid Scale Method (ASGS), which is a model of the variational multiscale method (VMS) techniques. 2.3 Variational Multiscale Methods The VMS method provides the explanation of the origins of the stabilization parameters in residual based methods [14]. The VMS method basic idea is that the solution, u, can be decomposed into a coarse scale component,uh, which can be solved by finite element method, and a fine scale solution, ˜u, solved in a sub-grid scale. It is important to remark that the fine scale solution ˜urepresents the error u - uhof the coarse scale component [7]. VMS method exposition can be illustrated considering the heat equation (Eq. 2.14), with Dirichlet boundary conditions. The variational form of this boundary value problem, where Lis a differential operator on the domain Ω( with boundary Γ), is: Lu=f in Ω(2.18a) u=g in Γ(2.18b) The variational form is: a(w, u)=(w, Lu) = (w, f)(2.19) 20
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger where the inner product is (∗,∗),wis the weight function and a(w, u)is a bilinear form. In this case Lrepresents the heat equation. In the VMS method the solution is assumed to be u=uh+ ˜uand the weight function w=wh+ ˜w. The coarse and the sub grid quantities have the follow properties: uh=g in Ω(2.20a) ˜u= 0 in Γ(2.20b) Substituting uand win the variational formulation: a(wh+ ˜w, uh+ ˜u) = (wh+ ˜w, L(uh+ ˜u)) = (wh+ ˜w, f)(2.21) the problem can be reformulated for the coarse scale (Eq. 2.22.a) and the fine scale (Eq. 2.22.b), where the first problem governs the resolved scales and the second one governs the unresolvable scales: (wh,Luh)+(wh,L(˜u)) = (wh, f)(2.22a) ( ˜w, L˜u) + ( ˜w, L(uh)) = (˜u, f)(2.22b) Also the coarse scale and the fine scale can be rewritten using the adjoint operator L∗and the residual of the coarse scale Ruhas: (wh,Luh)+(L∗wh,˜u) = (wh, f)(2.23a) ( ˜w, L˜u) = (˜u, f)−( ˜w, L(uh) = ( ˜w, Ruh)(2.23b) 21
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis The VMS method key point is to derive an analytic solution for the fine scale in terms of the coarse scale. Solving 2.23.b and substituting into 2.23.a single coarse scale equation with a proper accounting for the fine scale phenomena is provided [14]. Using Green’s function the fine scale can be rewritten as: ˜u=−Zg0(Luh−f)dΩ = −M0Ruh=−M0(Luh−f)(2.24) In this case g0i s the Green’s function associated with the fine scale adjoint and finally the coarse scale becomes: (wh,Luh)−(L∗wh,−M0(Luh−f)) = (wh, f)(2.25) where than the equation have to be solved for the coarse scale. 2.3.1 ASGS stabilization In the current work the ASGS stabilization technique has been used and the derivation is obtained next. ASGS stabilization technique has been introduced by Hughes and it is an efficient technique able to stabilize the convective term in a consistent manner. The idea in order to control the instability, is considering the unknown T=th+˜ Tusing VMS method. An important assumption of the ASGS method is that the unresolvable scale ˜ Tare forced to vanish on the element boundaries [1]. The simplest way to approximate the fine scale component ˜ Tis to assume: ˜ T=τR(T)(2.26) where τis the stabilization parameter and R(T) is the residual. Considering the convective term following the assumption T=th+˜ Tas: ZΩ ρcpwa· ∇TdΩ = ZΩ ρcpwa· ∇ThdΩ + ZΩ ρcpwa· ∇ ˜ TdΩ(2.27) Expressing the fine scale convective term in the form: 22
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger a· ∇ ˜ T=∇ · (˜ Ta)−˜ T∇ · a(2.28) and after using the divergence theorem, it can be rewritten as: ZΩ ρcpwa· ∇ ˜ TdΩ = : 0 ZΓ ρcpw˜ Ta·ndΓ−ZΩ ρcpa· ∇w˜ TdΩ(2.29) where the term evaluated at the boundary vanishes because we imposed ˜ T= 0 on Γ. Considering: P(w) = −ρcpa· ∇w(2.30) the stabilization term element by element is: ASGS :−XZΩ ρcpa· ∇wτR(T)dΩ(2.31) The stabilization parameter τhas been taken following Codina’s (2000) definition: τ=ρcp 4t+c1ρcpkak 4h+c2k 4h2−1 (2.32) where 4tis the time increment, 4his the element size, kakis the convective velocity norm, c1and c2are two constant parameters which typically in fluid mechanic take the value of c1= 2 and c2= 4. The discrete form of the PDE with ASGS stabilization for linear elements will be: ZΩ ρcpw∂T ∂t +ZΩ ρcpwa· ∇T−ZΩ ∇w·k∇T +XZΩ ρcpa· ∇wτ ρcp ∂T ∂t +ρcpa· ∇T−q=ZΩ wq +ZΓ w(n· ∇T)dΓ (2.33) Applying Tapprox =PNjTjand w = Niwe get: 23
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ZΩ ρcpNiNj ∂Tj ∂t +ZΩ ρcpNi(a· ∇)NjTj−ZΩ ∇Ni·(k∇NjTj) +XZΩ ρcpa· ∇Niτρcp ∂NjTj ∂t +ρcp(a· ∇)NjTj−q =ZΩ Niq+ZΓ Ni(n· ∇Nj)TjdΓ (2.34) Algebraic Problem Converting the discrete heat equation problem with ASGS stabilization technique in algebraic form, Eq. 2.34 will be: [M+N]∂tT+ [C−K+S+Bout]T=q(2.35) where, M=RΩρcpNiNjdΩ: Mass matrix N=RΩ(ρcpa· ∇Ni)τ(ρcpNj)dΩ: Mass matrix fine scale C=RΩρcpNi(a· ∇)NjdΩ: Convective matrix K=RΩ∇Ni·(k∇Nj)dΩ: Diffusion matrix S=RΩ(ρcpa· ∇Ni)τ(ρcpa· ∇Nj)dΩ: Stabilization term matrix Bout =RΓNjNi(a·n)dΓ: Outflow boundary matrix q=RΩNiq+τ(ρcpa· ∇Ni)qdΩ: Load vector 2.4 Thermodynamics and Heat Transfer The heat is the form of energy which can be transferred from a system to another due to a temperature difference and the rate of this energy transfer is called heat transfer. The heat transfer can be expressed as the science which deals with the transfer of the thermal energy from a point to another within a medium or from one medium to another due to the occurrence of the a temperature difference [14]. 24
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger Figure 2.5: Correlation for different Nu number for a flow over a cylinder for different Re numbers (Cengel). 2.5 Fluid Dynamics The fluid dynamic is the discipline which describes the fluid flow and the effects at the boundary, where it can be a solid surface or another fluid. Due to the wide variety of fluid flows, fluids can be classified into different categories and also some fundamental fluid properties have been introduced. In this chapter also the fluid dynamic problem described by the Navier-Stokes Equations will be discussed. 2.5.1 Fluid Properties Viscous versus Inviscid Flow In order to understand the difference between viscid and inviscid flow, an important property called viscosity has to be introduced. Viscosity is an internal resistance to flow. This property is the product of the internal friction between the different fluid layers, where in liquids it is generated by the cohesion forces between molecules meanwhile for gases it is generated due to molecular collision. Such common fluids follow a linear relation between shear and resulting strain rate. Also for the common linear fluids it can be demonstrated that the shear stresses are proportional velocity gradient and the proportional coefficient is called viscosity: τ=µ∂u ∂y N m2(2.43) Newtonian fluids are the linear fluids which follow Eq.2.43, meanwhile fluids which do not follow this relation are defined as nonewtonians. A fluid which has no resistance to shear stresses (µ= 0) is called inviscid or ideal. Viscosity can be expressed also divided by ρ, where the mass unit is canceled, and it is called kinematic viscosity 31
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ν=µ ρm2 s(2.44) For practical calculation and under certain conditions, fluids like water and air can be assumed as Newtonian fluids. It is important to underline that temperature has strong effects on viscosity. For liquids viscosity decreases with temperature increasing and on the other end, for gases viscosity increases with temperature. Compressible versus Incompressible Flow The density variation of the fluid characterizes the flow classification as compressible or incompressible. Generally flows in which the density is constant in an infinitesimal volume that moves with the flow velocity are considered incompressible. For the flows where the density variations can not be neglected, are considered compressible. An important indicator of the compressibility is the Mach number, which is defined as: M∞=V∞ a∞ (2.45) where V∞is the free stream flow and a∞is the speed of sound (in dry air, at 20oC, a = 1230 km/h). Theory and observations in wind tunnels suggest that most flows may be treated as incompressible (constant density) until the Mach number is sufficiently high. For M < 0.3 a flow can be considered incompressible. Reynolds Number Reynold number is an important dimensionless number which determine the behaviour of a fluid flow. It is defines as: Re =ρuD µ(2.46) Where uis the velocity, D is characteristic linear dimension of the problem, and µ is the dynamic viscosity. The three different flow regimes can be quantified according to Re as 32
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger •Re < 2300 laminar flow •2300 ≤Re ≤10.000 transitional flow •Re > 10.000 turbulent flow For a circular pipeline, the characteristic linear dimension corresponds with the diameter of the pipe, meanwhile for a sections such as squares, rectangular or annular ducts where the height and width are comparable, characteristic linear dimension is defined as: Dh= 4Ac pr (2.47) where Acis the section of the pipe and pr is the wet perimeter. The Reynolds number can be also defined as: Re =Fi Fv (2.48) where Firepresents the inertial forces and Fvthe viscous forces. Inertial forces are defined due to the momentum of the fluid. This is usually expressed in the momentum equation by the term (ρu)u. So the momentum (inertia) is higher with the increasing of the velocity and it also depends to the density. As in classical mechanics, a force that can counteract or counterbalance this inertial force is the force of friction or viscous forces. In fact Reynolds number is an important viscous effect indicator: due to it is inversely proportional to the viscosity, for a large Reynolds number, the viscous effects do not play an important role about the flow behaviour. On the other end, for a dominant viscous effect, Reynolds number is small and it indicates loss of energy due to the viscous forces. 2.5.2 Flow Across Staggered Tube Banks Flow across bank of tubes is a really common case of study in thermo-fluid dynamic. The two most common geometric arrangements of a tube bank are shown in Figure 2.6. 33
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ((a)) Aligned configuration. ((b)) Staggered configuration. Figure 2.6: Tube banks (NPTEL). For each configuration, D is the diameter of tube, SLis the longitudinal spacing, and STis the transverse tube spacing. For the staggered configuration SD corresponds to the diagonal spacing. In order to determine the maximum velocity the continuity equation for steady incompressible flow is required. For the aligned configuration the maximum velocity occurs at the minimum flow area and the continuity equation can expressed as ρv∞ST=ρvmax(ST−D). The maximum velocity becomes: vmax =ST ST−Dv∞(2.49) In the case of the staggered configuration the maximum velocity occurs at the diagonal cross section and the maximum velocity is: vmax =ST 2(ST−D)v∞(2.50) It has been proved experimentally that the flow behaviour in the first row of tubes is really similar to a flow around a single tube. When the flow reaches a tube in the second and subsequent rows the behaviour is very different because of the wakes and the turbulence formed after the upstream tubes. The consequence is an increasing of the heat transfer coefficient and the level of the turbulence with the rows number. It also be proved the the level of turbulence and the heat transfer coefficient remain constant after the few first rows [11]. 34
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger 2.5.3 Peclet Number Another dimensionless number really important in transport phenomena is the Peclet number (Pe). Peclet number characterizes the relative importance of convective and diffusive effects in a given flow and it expresses the ratio of convective to diffusive transport. For 1D case, Peclet number is: Pe =uL k(2.51) where Lis the characteristic length, uthe local flow velocity and kis the thermal conductivity. It has been proved that when the convection is dominant corresponds to Peclet values greater than one and, due to the effects of the convection, instabilities in the numerical solution are generated. Laminar versus Turbulent Flow In Laminar flow the motion of the particles of fluid is characterized by smooth streamlines and highly-ordered motion. As the flow experiments sudden fluctuations of the velocity field, pressure filed and temperature filed and the particle paths become completely irregular, the flow is defined turbulent. Steady versus Unsteady (Transient) Flow The steady state flow implies that the fluid does not experiment any properties change in a point domain with time. Basically the fluid properties can be different from point to point in the domain, but at any fix point they must be constant with time. Energy, volume and mass do not vary for a steady state case. Unsteady flow is characterized by the conditions at one point vary with time. 2.5.4 Velocity Boundary Layer The velocity boundary layer is a concept introduced by Ludwig Prandtl and its main assumption is that the viscous forces are negligible everywhere, except near the solid boundaries because the no-slip condition. The most important assumption is that the thickness layer is extremely thin compared to the other length scale due to the no-slip condition and the fluid layer velocity adjacent to the surface body becomes zero. The consequence results is a slow down of the fluid neighboring layers due the particles friction because of the adjoining layers different velocity. The result is the boundary layer development 35
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis where, from the solid surface until a certain distance δthe velocity in the normal direction describes a parabolic profile. In the boundary layer the fluid velocity tangential to the solid surface goes from zero at y=0 to nearly u∞at y=δ. The boundary layer thickness, δ, can be considered as the distance y=0 from the solid surface at which u= 0.99u∞[11]. With the velocity boundary layer generation the flow can be divided into two regions: the velocity boundary region and the inviscid flow region, where in the last one the velocity remains constant and the viscous effects are neglected. Figure 2.7: Velocity boundary layer generation for a different fluid regime (Atreya). In the turbulent regime boundary layer three different sub layers can be recognized (Figure 2.7). Close to the wall, a really thin layer called laminar sublayer is generated and it is characterized to have viscous dominant effects. Next to the laminar layer appears the buffer sublayer, where, even if the turbulent effects are important, the flow is dominated by the viscous effects. Finally above the buffer sublayer, where the turbulent effects are dominant, a large layer called turbulent region is developed. No-Slip Condition No-slip condition states that due to the viscous forces the fluid flow velocity is equal to zero at the contact surface with a solid. This condition ensures that, excluding rarefied gases, then all fluids at a point of contact with a solid take on the velocity of the surface: vfluid =vsolid = 0 (2.52) 36
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger 2.5.5 Thermal Boundary Layer The thermal boundary layer develops when a fluid with a certain temperature T∞ flows is in contact with a solid surface at a different temperate Ts. As a consequence a thermal equilibrium will be achieved through the contact between the fluid particles temperature with the solid particles. As a result due to the energy absorption between solid-fluid particles, a temperature profile is generated with the normal direction to the surface (Figure 2.8). The region where the temperature variation is important is called thermal boundary layer. The thickness δcan be defined as the distance from the solid surface where the difference temperature (T−Ts)is equal to 0.99(T−Ts). Figure 2.8: Boundary layer for a fluid temperature greater than the solid surface temperature (NPTEL). 2.5.6 Prandtl Number The dimensionless Prandtl number is a ratio of two molecular transport properties and it describes the relative thickness between the velocity boundary layer and the thermal boundary layer. The Prandtl number is defined as: Pr =µcp k(2.53) The physical meaning from a molecular point of view of the Prandtl number can be explained as the relation between the momentum molecular diffusivity and the heat molecular diffusivity. For a Prandtl number nearly close to 1, common for gases, both the momentum and the heat dissipate through the fluid at about the same rate [11]. For the case where Pr < 1, the thermal boundary layer δtis thicker than the velocity boundary layer δdue to the heat diffuse quickly. It is typically of 37
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis liquid metals behaviour where the conductivity value is very high and the thermal diffusivity dominates. From the other hand heat diffuses very slow compared with the momentum for Pr > 1, where in this case the thermal boundary layer is thinner (Figure 2.9). It is associated for oils behaviour, where the momentum diffusivity dominates. Figure 2.9: Thermal boundary layer and velocity boundary layer comparison for different Prandtl numbers (Bahrami). 2.5.7 Navier-Stokes Equations The fluid dynamic problem for a Newtonian fluid is governed by the Navier- Stokes Equations, where the dynamic effect due to the external and internal forces over a fluid are stated. For a transient flow of an incompressible viscous flow, the problem is governed by the Navier Stokes equations, which are the mass conservation equation (Eq. 2.1) plus the incompressibility condition (Eq. 2.2) and the momentum equation (Eq. 2.4): ρ∂v ∂t + (v· ∇)v=∇ · σ+ρb ∇ · v= 0 Under the incompressibility condition , which states that the density remains constant during the motion, the momentum equation can be rewritten as ∂v ∂t + (v· ∇)v−ν∇2v+∇p=b 38
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger The Navier-Stokes Equations carry some issues which makes the incompressible flow problems difficult. The first difficulty is related with the presence of the convective term in the momentum equation. This difficulty arises with instabilities for the convective dominant case for the standard Galerkin formulation. Such difficulties can be overcome using the stabilization technique discussed in chapter 2.2. The second difficulty is associated with the constrain on the velocity field, which must be divergence free [7]. Due to that pressure is treated as another degree of freedom (DoF) needed to satisfy the incompressibility constrain and originating a coupling between pressure and velocity unknowns. For an incompressible flow an appropriate combination of element interpolation function for the velocity and pressure is needed and the solvability depend on the Ladyzenskaja-Babuska-Brezzi (LBB) condition. 2.5.8 Turbulence Turbulence is a highly complex physical phenomenon that is pervasive in flow problems of scientific and engineering concern [14]. Due to its complexity it is one of the unsolved problems in science and it entails theoretical difficulties and high numerical computation demand. A definition of turbulence can be expressed as an irregular flow condition showing random variations with respect to both time and space coordinates with discernible statistical properties [14]. Even if it is difficult to define a standard definition of this phenomenon, several general characteristics are recognizable. For a turbulent flow the most important are: •highly nonlinear •fluctuations •vorticity •dissipation •highly diffusive •random process in time •fully three-dimensional and fully time-dependent A fluid becomes turbulent when the Reynold number Re exceeds a critical value and small perturbations can grow spontaneously and may equilibrating as finite amplitude disturbances. The non-linearity of turbulence is evident since it is the final state of a nonlinear transition process. The disturbances can increase and get more complicated, reaching an unrepeatable unpredictable state (turbulence) [5]. Turbulence involves irregular and chaotic fluctuations of the dependent-filed quantities 39
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis (pressure, temperature, velocity,...). Typically turbulence involves identifiable structures called eddies. These structures are recognizable as regions in the fluid where the flow rotates, deforms and divides. Eddies’s size increase with the Reynolds number and the characteristic size of the largest eddies is the width of the turbulent region. In turbulence the chaotic vorticity is characterized to be three-dimensional where vortexes stretch and turn by themselves, so without a three dimensional vorticity the turbulence is not real. From a engineering point of view turbulence can be simplified without taking into account the detailed resolution and considering the average flow description. In order to obtain an accurate study of a turbulent flow, it is extremely important to generate a mesh resolution respecting the same order of the smallest length scale. The smallest eddy in turbulent flow are ≈ O(0.001L)where L is the characteristic flow dimension, and for a three dimension mesh the number of nodes are ≈109 [Eddy]. It is important to underline that the computational cost for a relevant industrial problem with complex geometries is extremely expensive. Classification of Turbulent Models Even if in the present work any turbulent model has been used it is important to introduce them due to their importance in CFD. Different turbulence models have been formulated and especially the next three are distinguished due to their importance. •Direct Numerical Simulation (DNS) •Large Eddy Simulation (LES) •Reynolds Avaraged Navier-Stokes (RANS) The DNS simulation is used for high Reynolds numbers in order to solve all the turbulence’s structures. In order to capture all the turbulence behaviour, the time step and the mesh element size have to be really small and consequently the simulation is extremely expensive. The DNS computation required ≈Re9/4number of elements and the total computational time is proportional to ≈Re3. The LES simulation solves the very wide range of time and length scales ignoring the smallest length scales, which are solved computing a time and spatial averaging. Finally, the RANS models compute the avarage flux and they approximate the turbulence effects over the avarage flux. The formulation consists in the decomposition of the velocity field (u) into the avarage flux (U) and the small oscillations (u0) at each time step, adding new unknowns at the system, of equation and approximations are introduced near the walls. u=U+u0 40
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger X eZ ZΩ(e)"ρcpN(e) i ax n X j=1 ∂N(e) j ∂x T(e) j!+ay n X j=1 ∂N(e) j ∂y T(e) j!!#dΩ +X eZ ZΩ(e)"∂N(e) i ∂x kx n X j=1 ∂N(e) j ∂x T(e) j!+∂N(e) i ∂y ky n X j=1 ∂N(e) j ∂y T(e) j!#dΩ =X eZ ZΩ(e) N(e) iqdΩ + ZΓ N(e) ikx ∂T ∂x nx+ky ∂T ∂y nydΓ (2.67) where the sum applied is over all the elements of the domain. Considering the triangular elements used for the discretization and taking into account that due to the type of problem we have one DoF per node, the unknown solution is expressed by the following polynomial: T= 3 X i=3 N(e) iT(e) i=N(e) 1T(e) 1+N(e) 2T(e) 2+N(e) 3T(e) 3(2.68) The shape functions are identified as: N(e) i(x, y) = 1 2A(e)(a(e) i+b(e) ix+c(e) iy)i= 1,2,3(2.69) where A(e)is the element area and a(e) i,b(e) iand c(e) ivalues are obtained operating with the element nodes coordinates (see [17]). Figure 2.13 shows that linear shape functions take the unit value at the node and zero at the others nodes. Figure 2.13: Linear shape function for the triangular element (Oñate). The problem in algebraic form can be rewritten as: [C+K−Bout]T=q(2.70) 47
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis where Cis the convective matrix, Kis the diffusive matrix, Bout is the external flux matrix, qis the load vector and they are defined as: C(e) ij =Z ZΩ(e) ρcpN(e) i ax ∂N(e) j ∂x +ay ∂N(e) j ∂y !dΩ(2.71a) K(e) ij =Z ZΩ(e)"∂N(e) i ∂x kx ∂N(e) j ∂x +∂N(e) i ∂y ky ∂N(e) j ∂y #dΩ(2.71b) B(out)(e) ij =Z ZΓ(e) N(e) ikx ∂T ∂x nx+ky ∂T ∂y nydΓ(2.71c) q(e) i=Z ZΩ(e) N(e) iqdΩ(2.71d) For the derivation of other 2D elements such quadratic triangular, linear and quadratic quadrilateral and 3D elements see Oñate. 2.6.3 Weak and Algebraic Formulation of the Navier-Stokes Equations Applying the same concept in order to obtain the algebraic form of the Navier- Stokes Equations first of all the weak formulation of the problem must be obtained. Multiplying the linear momentum equation by the test function w, where it can be described as: w∈V0,V0={w|w∈H1 0(Ω)}(2.72) we obtain: ZΩ w∂v ∂t dΩ + ZΩ (v· ∇)v·wdΩ−ZΩ wν∇2vdΩ +ZΩ w∇pdΩ = ZΩ w·bdΩ∀w∈V0 (2.73) 48
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger After integrating by parts the diffusive term and the pressure term as: −ZΩ wν∇2vdΩ = ZΩ ∇wν∇vdΩ−ZΓ νw·(n∇v)dΓ(2.74a) ZΩ w∇pdΩ = −ZΩ p∇ · wdΩ + ZΓ w·(pn)dΓ(2.74b) the weak form of the Navier-Stokes Equations is: ZΩ w∂v ∂t dΩ + ZΩ (v· ∇)v·wdΩ + ZΩ ∇wν∇vdΩ−ZΩ p∇ · wdΩ =ZΩ w·bdΩ + ZΓ νw·(n∇v)dΓ−ZΓ w·(pn)dΓ∀w∈V0 (2.75) In the same manner the weak form of the continuity equation of an incompressible flow (Eq. 2.2) can be obtained first of all defining a test function q: q∈Q0,Q0={q|q∈L2(Ω)}(2.76) where the L2(Ω) space contains the square integrable functions. The weak form of the continuity equation can be expressed as: ZΩ q∇ · vdΩ=0 ∀q∈Q(2.77) The space element discretization of the Navier-Stokes Equations taking the finite element solution as an approximation of the exact solution of a property ( γ≡˜γ), Galerkin method states that the velocity interpolation reads as: ˜ v(x, t) = n X j=0 Nj(x)vj(t)(2.78) where Nj(x)are the shape function in Eulerian coordinates. The test function is discretized as: 49
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ˜ w(x, t) = n X j=0 Nj(x)wj(2.79) and finally the acceleration is approximated as : ∂˜ v ∂t (x, t) = n X j=0 Nj(x)˙ vj(t)(2.80) On the other end the pressure is approximated as: p(x, t) = n X j=0 Nj(x)pj(t)(2.81) and its test function approximation reads: q(x, t) = n X j=0 Nj(x)qj(2.82) After the space discretization is obtained, the momentum equation can be written in algebraic form as: M ˙v + (K+C)v−Gp =fext (2.83) where Mis the mass matrix,Kis the viscous matrix,Cis the convective matrix,G is the pressure matrix and fext is the volumetric external force vector. For a 2D case the coefficient are computed as: M(e) ij =Z ZΩ(e) N(e) iN(e) jdΩ(2.84a) K(e) ij =νZ ZΩ(e) ∂N(e) i ∂x ∂N(e) j ∂x +∂N(e) i ∂y ∂N(e) j ∂y !dΩ(2.84b) 50
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger C(e) ij =Z ZΩ(e) N(e) i u∂N(e) j ∂x +v∂N(e) j ∂y !dΩ(2.84c) G(e) ij =Z ZΩ(e) ∂N(e) i ∂x +∂N(e) i ∂y !N(e) jdΩ(2.84d) fext i(e) = Z ZΩ(e) N(e) i(bx+by)dΩ(2.84e) The algebraic form of the continuity equation reads: GTv= 0 (2.85) Where the Gis the divergence matrix which is equal to the transpose of the pressure matrix, where its coefficients are obtained as: GT(e) ij =Z ZΩ(e) N(e) i ∂N(e) j ∂x +∂N(e) j ∂y !dΩ(2.86) 2.6.4 LBB condition The LBB condition, as well known as inf-sup condition, states that a link between pressure and velocity spaces must be defined. A necessary but not sufficient condition in order to determinate an unique solution for vand pwhich states a necessary relation between finite element pressure and velocity dimension spaces is dimQh≤dimVh So the existence of a stable approximation of the numerical solution (vh, ph) depends on the discretized spaces Vhand Qh, such as follow: infqh∈Qhsupwh∈Vh qh,∇ · wh kqk0kwhk0 ≥α > 0(2.87) where αis independent of the mesh size. The uniqueness existence of vh∈Vhand ph∈Qhis ensured if the LBB condition is satisfied. 51
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 2.7 Time Discretization 2.7.1 Explicit vs. Implicit Schemes Explicit schemes are easy to code/parallelize but the time step may not exceed a certain threshold that depends on the Peclet number and on the smallest mesh size. The inconvenient of the explicit schemes are lack of stability and, for extremely small time steps, a high computational cost. Implicit schemes implies a large cost per time step because a system of equations at every time step has to be solved. On the other hand, most implicit schemes are unconditionally stable, and the use of large time steps makes it possible to reach the final time faster than with an explicit scheme subject to a restrictive stability limit. Due to the unsteady behaviour of the problem which involves a time dependency term, a time discretization method has been used. Several methods are available and next the θscheme time integration, Backward differentiation in time and Adams method (Linear multistep method) will be discussed. In the current work the BDF2 second order method has been used in order to approximate the time derivative operator. 2.7.2 θScheme Time Integration The θmethods are based on the formula Tn+1−Tn ∆t=θTn+1 t+ (1 −θ)Tn t+O((1/2−θ)∆t, ∆t2) The formula can be rewritten after truncation error as ∆T ∆t−θ∆Tt=Tn t where ∆T=Tn+1 −Tnand ∆Tt=Tn+1 t−Tn t For the heat equation the time discrete scheme is: ρcpw∆T ∆t+θ[ρcpwa·∇−∇·(k∇)]∆T=θqn+1 + (1 −θ)qn−[ρcpwa·∇−∇·(k∇)]Tn (2.88) 52
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger Taking θ= 0 the Forward Euler method, which is the explicit method of the family, is recovered. In order to use an implicit scheme, the Crank-Nicolson method is obtained taking θ= 1/2 and the Backward Euler method taking θ= 1. Among the implicit methods, Crank Nicolson is the only second order accurate. The matrix form of the problem is: Mδt(Tn+1 −Tn) + θ(C−K)∆T=θqn+1 + (1 −θ)qn−(C−K)Tn(2.89) Where Mis the mass matrix, Cis the convective matrix and Kis the diffusive matrix. 2.7.3 Backward Differentiation in Time The method adopted is called Backward differentiation in time and several previous steps in time are used to approximate the time derivative at tn+1. Using this method different schemes can be used and all of them are implicit because the operator at tn+1 is evaluated and the method results unconditionally stable for any size of the time step. Considering the heat equation without stabilization, the problem in algebraic form is: Mδt(Tn+1 −Tn)+(C−K)Tn+1 =q(2.90) The approximation for ∂tTn+1 can take different order: –BDF1 : δtTn+1 = (Tn+1 −Tn)/δt –BDF2 : δtTn+1 = (3 2Tn+1 −2Tn+1 2Tn−1)/δt –BDF3 : δtTn+1 = (11 6Tn+1 −3Tn+3 2Tn−1−1 3Tn−2)/δt BDF1 method is unconditionally stable of order 1 (O(δt)) and BDF2 method is also unconditionally stable but with higher order up to 2 (O(δt2)). BDF3 method has an higher order, up to 3 (O(δt3)), but is conditionally stable. 2.7.4 Adams Method The Adam method is a second order accurate derived from polynomial fitting and it can be either explicit or implicit. For the explicit scheme the Adam method follow: 53
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis –ADB1 : M/δt(Tn+1 −Tn)+(C−K)Tn=qn –ADB1 : M/δt(Tn+1 −Tn)+ 3 2(C−K)Tn−1 2(C−K)Tn−1=3 2qn−1 2qn−1 And for the implicit scheme the method follow: –ADB1 : M/δt(Tn+1 −Tn)+(C−K)Tn+1 =qn+1 –ADB1 : M/δt(Tn+1 −Tn)+ 1 2(C−K)Tn+1 +1 2(C−K)Tn=1 2qn+1 −1 2qn 54
Chapter 3 Methodology In this chapter are collected all the main aspects which compose the current work. The first section introduces Kratos software and also all the steps in order to implement the application needed in order to solve a thermo-fluid dynamic problem. Than the strategy used concerning the type of the problem where different fields are coupled together is described and also the Dirichlet-Neumann method, which has been used in order to iterate between subdomains, is introduced. Next the 3D heat exchanger problem and modelling are introduced and finally a brief introduction and description related with heat exchanger is presented. 3.1 Kratos Muliphysics Software Kratos is a framework for building multi-disciplinary finite element program composed by a wide variety of applications involved in different engineering areas. The flexibility of the framework is improved adopting Python scripting language in order to define the main procedure of Kratos. Kratos can be used from a developer or user point of view. Finite element developers can take the advantages of all the Kratos’s requirements even without having a deep C++ programming knowledge and also, at the same time, Kratos may be used by application developers in order to optimize programs or design tools without having a strong interest in finite element programming. Users of Kratos are more interested in model and solve engineering problems without getting involved in programming. In this case Kratos offers a flexible external interface without implementing any programming code. The main features of Kratos are: •MULTI-PHYSIC: Multi-Physic problems are one of the most important topic nowadays. A multi-physics simulation involves multiple physical models or multiple simultaneous physical phenomena. 55
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis •FINITE ELEMENT METHOD (FEM): FEM is a powerful method extremely popular in order to solve Partial Differential Equations (PDE) using the numerical analysis. •OBJECT ORIENTED PROGRAMMING (OOP): OOP is a programming paradigm based on the concept of objects, which may contains attributes and procedures. Due to the flexibility, the modular design, abstraction and hierarchy, this methodology is needed in order to maximum exploit the numerical methods techniques. •OPEN SOURCE: An open source software is developed and share for free. It is focused in the main code free access. •FREE: It is free with the purpose to share knowledge and built a robust numerical methods and also everyone is able to modify and distribute the software. 3.1.1 Problem Description and Main Kratos’s Tools As explained before, Kratos uses finite element model formulation in order to solve multi-physics problems where routines such as assembling matrices, solving systems, printing results, and others tasks are involved in the framework. An application has been generated using all the tools provided by Kratos after implementing an element, a condition and a solver in order to solve a physical problem. The application created solves a transient heat equation problem for a 2D/3D case (one degree of freedom (DoF) per node) and the mathematical formulation respects equation 2.14. The problem consists of different components, as the stiffness matrix K, the Dirichlet boundary conditions, the Neumann boundary conditions and the thermal loads. Due to the rigidity matrix will be calculated element by element, an element must be implied in the application. The Dirichlet conditions has to be multiplied by the K matrix and it will be done element-wise. Finally, the thermal loads will add them node by node to the right hand side vector of the system of equation (RHS). Also a condition, in order to take into account the contributions of the Neumann boundary conditions, has been created. In order to execute Kratos and execute a problem type, python’s scripts are used and the following tasks are done: 1. Load Kratos and import applications 2. Read the problem data and create the model part in Kratos 56
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger The first transmission condition states that the jump of the solution at the interface must be zero and mathematically can be expressed as: JTKΓ= 0 on Γint (3.3) The second transmission conditions defines that the normal component of the fluxes are weakly continuous at the interface and the jump of the flux is equal to zero on: Γint JkdT dn KΓ= 0 on Γint (3.4) At the interface the first transmission condition is usually enforced in a strong manner, meanwhile the second transmission condition is imposed in a weak sense. 3.2.2 Approach Analysis There are two many approaches in order to solve the thermo-fluid dynamic problems: •Monolithic approach: the Navier-Stokes Equations and the heat equations are solved simultaneously using one solver. •Partitioned approach: the Navier-Stokes Equations and the heat equation are solved separately using different solvers. Monolithic approaches presents several advantages as the coupled problems are solved in single step and no convergence or iterative issues are needed. Unfortunately the global system of equations to be solved can be very large and also it can be illconditioned due to the fact that different physical parameters, constitutive laws and psychical problems are involved. Modularity and customization are ones of the advantages of partitioned schemes. Each problem and all the implementations can be packed in a software module and each field can be performed with the better suitable algorithm. Also partitioned scheme make easy problems where non-matching grids are involved. Due to the fact that both the fluid dynamic problem and the thermal problem occur in the same domain (fluid domain), and also because of the non-linearity of the temperature term in the heat equation, it is not possible to solve the global system in a single step. The best strategy is first solve the velocity and pressure for fluid dynamic problem, and than plug the velocity into the heat equation in order to solve the temperature. Once the temperature is resolved, it is used to compute the Boussinesq body forces on the fluid. 63
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 3.2.3 Dirichlet-Neumann Method The strategy to solve the problem involving two different continuums, i.e. the Laminar Flow Around a Solid (Sect.4.3.2), where heat is transferred from a cylinder to a fluid flowing around it, the problem can split it in two subdomains (Ωsand Ωf) by assigning the transmission conditions (Eq. 3.1 and Eq. 3.2) at the interface Γ. The iterative algorithm can be set up following the Dirichlet-Neumann problem (DN): considering Fas the fluid mathematical operator, Sas the solid mathematical operator and given u(0) 2on Γ, for k ≥1 solve the problems: Fu(k) 1=f on ∂Ωf u(k) 1=u(k−1) 2on Γ u(k) 1= 0 on ∂Ωf\Γ Su(k) 2=f on ∂Ωs u(k) 2 ∂n =u(l) 1 ∂n on Γ u(k) 2= 0 on ∂Ωs\Γ where depending on lthe scheme can be: •l=k−1(parallel scheme) •l=k(sequential scheme) Condition 3.1 is used as a Dirichlet boundary condition on the interface Γfor the sub-problem Ωsmeanwhile condition 3.2 is used as a Neumann boundary condition at the interface Γfor the sub-problem Ωfwhere it has to be prescribed weakly. 3.3 3D Heat Exchanger Modeling 3.3.1 Problem Description and Properties The problem involves an incompressible fluid entering from the heat exchanger’s nozzle (inlet) describing a paraboloid profile depending on the fluid mean velocity. In order to have a fully developed turbulent regime , the mean velocity flow Umstarts from 0 m/s and reaches 5 m/s (Re = 81551) using a sinusoidal velocity function (Eq.4.10g) in the time interval 0≤t≤1s. After 1 seconds the fluid velocity is kept constant (Eq.4.10h). The fluid initial temperature is T= 298.15 K and the solid initial temperature is T= 353.15 K. Also at the inlet the fluid temperature has been fixed to 298.15 K during all the simulation. The fluid in question is an incompressible Newtonian fluid where the kinematic viscosity ν= 1.47760E−5m2/s, the fluid density is ρ= 1.205 kg/m3, the thermal 64
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger conductivity k= 0.0257 W/(mK)and the specific heat cp= 1.005 kJ/(kgK). For the solid the density is ρ= 8940 kg/m3, the thermal conductivity k= 401 W/(mK) and the specific heat cp= 0.39 kJ/(kgK). 3.3.2 Geometry The 3D heat exchanger geometry has been created using Grasshopper and than, in order to create the model, it has been imported in GiD . The model consists in two different geometries: the body of the heat exchanger and the heated cylinder. Both have been set separately treated as two different domains. It has not been taking into account the presence of all the cylinders but only one of them heated. The heated cylinder is located at the first cylinder’s row and the no heated cylinders are considered as an empty space with no material properties. 65
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ((a)) Heat exchanger body. ((b)) Cylinder. Figure 3.3: Geometry domains in GiD. 3.3.3 Boundaries Conditions and Initial Conditions Due to the problem involves two different physics, the conditions can be divided into two groups: the fluid mechanics conditions and the thermal conditions. The first group includes all the conditions at the boundaries related with pressure and velocities: the inlet (inflow condition), the outlet (outflow condition), the walls and the cylinder interface conditions. At the outlet, in order to do not have any inflow situation due to the vortex generated, all the velocity’s components have been set equal to zero but the x component, which has been imposed to be great than zero. Also at the outlet, due to the flow experiments buoyancy effects, the hydrostatic pressure is set as the boundary conditions. 66
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger The walls and cylinder interface conditions are characterized by the no-slip condition, where the velocity is imposed equal to zero. The second group includes the boundary conditions and initial conditions, where the fluid and the cylinder temperature are set at t=0 and the inlet fluid temperature is fixed at the inlet. Once the models have been imported in GiD, all the boundary conditions have been assigned according to the type of the problem. All the boundary conditions and the mathematically description of the problem are described in Sec. 4.6. The boundary conditions must be selected for each surface, i.e. the inlet of exchanger’s body (Fig.3.4). Figure 3.4: Inlet boundary condition definitions in GiD. 3.3.4 Mesh Generation Once all the boundary condition have been set, the next step has been the mesh generation. Gid offers the possibility to generate different type of meshes: structured,unstructured and semi-structured. The structured mesh differentiates from the unstructured due to the internal node is connected with a constant number of elements. In the current model an unstructured mesh has been generated taking into account that near the walls and at the interface between the cylinder and the heat exchanger’s body, the mesh has to be very dense in order to have an accurate solution (Fig.3.5) 67
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 3.5: Cylinder meshed. 3.4 Solution at the Interface In order to transfer all the information between the solid and the fluid, a function called NonConformantOneSideMap has been used (see [21]). Specifically the function couples the fluid and solid nodes at the interface and the problem is solved using the Dirichlet-Neumann scheme. Once the mapper has been set, the next to functions StructureToFluidScalarMap and StructureToF luidScalarMap pass the variables informations from one filed to the other. The solution for each time steps has been obtained using a Dirichlet-Neumann routine where first the fluid has been solved and than, according to a certain tolerance, the solid and the fluid have been iterating. During the iteration, once the temperature solution at the solid boundaries has been computed, it has been used has a Dirichlet condition for the fluid at the interface. Next step has been to solve the fluid and computing the thermal fluxes at the interface. Those thermal fluxes has been used as a Neumann condition for the solid and the same routine has been used for each time step (see Algo. 1). Algorithm 1 Dirichlet-Neumann scheme 1: for t< tend do 2: Solve the Fluid →compute the fluxes FΓ,f 3: while TΓ,s −TΓ,f <tolerance do 4: FΓ,s =FΓ,f .assign Neumann BC for the solid 5: Solve the Solid →compute the temperature TΓ,s 6: TΓ,f =TΓ,s .assign Dirichlet BC for the fluid 7: Solve the Fluid →compute the fluxes FΓ,f 68
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger 3.5 Boussinesq Approximation According to the Boussinesq approximation (Sec.2.1.5), due to the change in temperature of the fluid, at each time step the gravity has been compute following the next algorithm (see Algo. 2): Algorithm 2 Boussinesq Approximation 1: for t< tend do 2: get temperature solution Tf 3: gy=g0∗(1 −1/Tf,0∗(Tf−Tf,0)) .compute the new gravity value gy 4: g=gy.set gyas new gravity value 3.6 Heater Exchangers Heat exchangers are devices able to exchange energy due to a temperature difference between two different mediums. Convection and diffusion are the process involved in order to transfer the The rate of heat transfer between the two fluids at a location in a heat exchanger depends on the magnitude of the temperature difference at that location, which varies along the heat exchanger [11]. 3.6.1 Types of Heat Exchangers According to the application, heat exchangers can be classified depending the types of hardware and configuration as a double-pipe or compact. The double pipe heat exchanger has the simplest design (Figure 3.6) and it consists of two concentric pipes of different diameter, where one fluid flows in the inner pipe mean while the other fluid flows in the annular space between the two pipes. According to the flow direction, the double pipe heat exchanger can have a parallel flow arrangement, where both fluids flow in the same direction, or in counter flow, which is the case where both fluids have the opposite direction. 69
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 3.6: Double pipe heat exchanger design. Parallel flow (left) and counter flow (right) (Cengel). The compact heat exchanger design leads to realize a large heat transfer surface per unit of volume. It is a more complex design compared with the double pipe and it fits for the case where the weight and the volume of the heat exchangers restrict the application possibility. The ability to obtain a large surface area is obtained by attaching closely spaced thin plate to the walls separating the two fluids. When the two fluids flows are perpendicular the compact heat exchanger is called crossflow. Depending on the flow configuration, the flow configuration can be classified as mixed and unmixed. In the first case (Figure 3.7.a) the fluid is free to move in the transversal direction meanwhile for the unmixed case (Figure 3.7.b) the fluid is prevented to move in the transversal direction. 70
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger Figure 3.7: Cross-flow unmixed and mixed configuration (Cengel). 3.6.2 Cross-Flow Heat Exchanger The EUETIB fluid mechanic laboratory heat exchanger (Figure 3.8) is a compact cross flow mixed arrangement type and its utility has been to analyze the convection phenomena between a air at room temperature and a cylinder made of cooper at 80. The device consists of the next elements: 1. Support bench 2. Nozzle (square-section) 3. Suction tube (square-section) 4. Acrylic test area 5. Diffuser 6. Volute chamber 7. Pipe output 8. Valve regime control 9. Pitot tube 10. Manometer 11. Electrical resistance 12. Thermocouple 13. Thermocouple 14. On/Off 71
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 3.8: Cross-flow heat exchanger EUETIB FM Laboratory (Riera M, 2016). Heat Exchanger Under Operation When the device is operating, the air is moved by suction because of the work done by the volute chamber. The fluid enters from the nozzle, which is a device designed in order to increase the velocity and to have a better control of the direction of the fluid. As the nozzle section decreases, the fluid experiment a kinetic energy increasing and therefor a pressure decreasing. As the fluid circulates through all the suction tube, the air profile velocity develops until it arrives at the test area (Figure 3.9), where it finds a group of tubes perpendicular to the flow direction. Figure 3.9: Methacrylate cylinders heat exchanger test area (Riera M, 2016). 72
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger ((a)) Solution at dimensionless time t = 0.3. ((b)) Solution at dimensionless time t = 10. Figure 4.3: Results of a convection dominant case for Pe = 10 for different time steps. 4.1.4 ASGS implementation In order to avoid the instabilities observed in the convective dominant problem, the ASGS stabilization technique has been added to the finite element formulation considering the same problem of the previous section 4.1.3. After the ASGS technique has been implemented in Kratos as stated in section 2.3.1, the result clearly shows how the stability has been reached with perfect matching between the analytical and the numerical solution for a Peclet number equal to 10 (Figure 4.4). 79
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ((a)) Temperature distribution. ((b)) Analytical solution vs numerical solution. Figure 4.4: Results of a convection dominant case for Pe = 10 at dimensionless time t = 10. 4.2 Neumann Flux Condition Testing 2D In this section, in order to test the flux condition, the Poisson equation is solved using Neumann and Dirichlet boundary conditions and the numerical results are compared with a typical case of study Heat conduction through a large plane wall (see [11]). Figure 4.5: Heat conduction through a large plane wall (Cengel). 80
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger For the next case a rectangular domain, Ω = [0,1]x[0,4] has been tested. The problem reads: −∆T=f in Ω(4.4a) ∇T·n=˙ Q on ∂Ωleft (4.4b) ∇T·n=−˙ Q on ∂Ωright (4.4c) T1=h on ∂ΩL(4.4d) where ˙ Q= 4010[W/m2]and h= 303[K]. The results show the temperature T2achieved on ∂Ωright when the system reached stability corresponds to 293 K, which is exactly as the analytical solution provided by the bibliography. Figure 4.6: Results of a pure diffusion case imposing flux condition through a large plane wall. 81
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 4.3 CFD-Heat Transfer Application Testing 2D 4.3.1 Laminar Flow Around a Cylinder For the CFD-Heat Transfer Application the 2D classical test case simulating the fluid flow (Ω1) around a cylinder with a circular cross section (Ω2) has been considered. In the current problem the cylinder domain is considered empty and only the fluid domain is taken into account. The fluid in question is an incompressible Newtonian fluid where the kinematic viscosity ν= 10−3m2/s, the fluid density is ρ= 1 kg/m3, the thermal conductivity k= 0.0257 W/(mK)and the specific heat is cp= 1.005 kJ/(kgK). The entire domain (Ω = Ω1∪Ω2) is described in Figure 4.7, where H is the height of the channel and D is the cylinder diameter. Figure 4.7: Geometry of 2D test cases with boundary conditions (Schäfer). The problem is governed by the following set of differential equations and initial and boundary conditions (Eq. 4.5). The mechanical part of the problem is governed by the Navier-Stokes equations (Eq. 4.5a and Eq. 4.5b) and the thermal part of the problem is governed by the heat equation (Eq. 4.5c): ∇ · a= 0 in Ω1 (4.5a) ∂a ∂t + (a· ∇)a−ν∇2a=−1 ρ∇p+gin Ω1 (4.5b) ρcp ∂T ∂t +ρcpa·(∇T)−∇·(∇T) = 0 in Ω(4.5c) 82
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger T(x, y, 0) = 298.15 in Ω1 (4.5d) T(0, y, t) = 298.15 at ∂Ω1INLET (4.5e) T(x, y, 0) = 355.15 at ∂Ω2 (4.5f) U(0, y, t) = 4Umy(H−y)/H2, V = 0 at ∂Ω1INLET (4.5g) V(L, y, t) = 0 at ∂Ω1OUT LET (4.5h) The inlet velocity condition (Eq. 4.5g) describe a parabolic profile which depends on the mean velocity Um(t)=2U(0, H/2, t)/3 with Um= 1.5 m/s, yielding the Reynold number Re = 100. At the wall and around the cylinder the no-slip condition have been assigned. For the outlet condition (Eq. 4.5h) the vertical velocity component at the end of the domain (L = 2.2 m) has been set to zero. The temperature initial condition define for all the fluid a temperature equal to 298.15 K (Eq. 4.5d) and the cylinder temperature equal to 355.15 K (Eq. 4.5f). A fixed temperature condition , T = 298.15 K, has been set also for the fluid the at the inlet (Eq.4.5). The time step simulation has been set to 0.05 for a total of 100 steps. Results for different time steps show how the heat transfer between the fluid and the heated circumference has been achieved through convection. Figure 4.8(a) shows the initial temperature condition for the circumference and the fluid. Here, the difference of temperature between the two domains is clearly visible , where the cylinder is heated up to 355.15 K and the fluid, still static, has a temperature of 298.15 K. At the second time step (4.8(b)) how the temperature decreases in the whole domain can be seen . After 0.05 sthe maximum temperature registered decreased 83
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis down to 305.59 K. It is also visible how the fluid has been warmed up near the cylinder and how the heat is transported by the flow. This behaviour can be better appreciated on Figure 4.8(d) and Figure 4.8(b) where clearly the circumference cools down and almost all the heat has been transferred to the fluid and transported to the outlet. After 0.4 s, the maximum temperature decreased down to 299.37 K. ((a)) Time step = 1. ((b)) Time step = 2. ((c)) Time step = 3. ((d)) Time step = 8. Figure 4.8: Temperature field results at different time steps of a laminar flow around a cylinder. The temperature evolution of a point on the circumference (Figure 4.9) shows how the temperature drops down during the first 2 time steps and then becomes constant approximately reaching 298 Kafter 5 time steps. 84
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger ((a)) Point under study localized around the cylinder. ((b)) Plot time steps vs temperature. Figure 4.9: Temperature evolution of a point located on the cylinder. 4.3.2 Laminar Flow Around a Heated Cylinder After testing the CFD-heat transfer application the next step has been to test a problem where two different domain are involved. In order to compute the evolution of the temperature in the domain Ω2, a solid material has been assigned. The fluid’s data for the domain Ω1 is the same as in the previous section 4.3.1. The material assigned to the cylinder has a thermal conductivity k= 1000 W/(mK), the specific heat is cp= 0.1 kJ/(kgK)and the density is ρ= 8940 kg/m3. The problem is governed by the following set of differential equations and initial and boundary conditions (Eq.4.6): ∇ · a= 0 in Ω1 (4.6a) ∂a ∂t + (a· ∇)a−ν∇2a=−1 ρ∇p+gin Ω1 (4.6b) ρcp ∂T ∂t +ρcpa·(∇T)−∇·(∇T) = 0 in Ω(4.6c) T(x, y, 0) = 298.15 in Ω1 (4.6d) 85
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis T(0, y, t) = 298.15 at ∂Ω1INLET (4.6e) T(x, y, 0) = 355.15 at Ω2 (4.6f) U(0, y, t < 5) = 4yUmsin(0.1πt)(H−y)/H2, V = 0 at ∂Ω1INLET (4.6g) U(0, y, t ≥5) = 4yUm(H−y)/H2, V = 0 at ∂Ω1INLET (4.6h) V(L, y, t) = 0 at ∂Ω1OUT LET (4.6i) In order to have a more effective heat transfer the value of the velocity at the inlet has been increased from zero to an avarage velocity of 5 m/s in the time interval 0≤t < 5s (Eq. 4.6g). This gives a time varying Reynolds number between 0≤Re(t)<4000. After 5 s the velocity remains constant until the end of the simulation (Eq. 4.6h). The time step simulation has been set to 0.1 for a total of 80 steps. Figure 4.10(b) shows how the flow velocity starts from zero and after 5 seconds (50 time steps) it gets a stable velocity almost of 9.5 m/s. ((a)) Point under study localized at the inlet . ((b)) Plot time steps vs velocity. Figure 4.10: Transient velocity behaviour at the inlet . 86
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger In this case the two domains have matching nodes at the interface (Figure 4.11). Figure 4.11: Matching nodes between the solid and the fluid domain at the interface (green circle). Temperature results for the solid domain (Figure 4.12 ) shows that the temperature has decreased in time so the communication between domains has been effective. Specifically, for a point inside the solid domain, the temperature has decreased from 355.18 K down to 352.6 K in 100 time steps. ((a)) Point under study. ((b)) Plot time steps vs temperature. Figure 4.12: Temperature evolution for a node localized at the interior of the solid . 87
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 4.13 shows the value of the fluxes at time t = 0.3 sfor both domains. As can be appreciated the fluxes at the interface are the same due to the imposition of the fluid’s reactions as Neumann boundary conditions to the solid domain. It is also visible how the value of the flux is greater at the cylinder’s side facing the inlet. This result can be explained due to the temperature difference between the flow and the heated solid is greater and that generates bigger fluxes compared with the cylinder side facing the outlet. ((a)) Solid domain. ((b)) Fluid domain. Figure 4.13: Heat flux results at time = 0.3 s. 4.4 Heat Exchanger’s Numerical Simulation in 2D In this chapter the 2D heat exchanger model has been simulated for a turbulent case. During the simulation it has not been taking into account the presence of all the cylinders but only one of them heated. The heated cylinder is located at the first cylinder’s row and the no heated cylinders are considered as an empty space with no material properties (Figure 4.15)). 4.4.1 Description of the Problem The governing equations of the problem reads: ∇ · a= 0 in Ω1 (4.7a) 88
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger Figure 4.22: Temperature distribution after 1 seconds. ((a)) Point over the cylinder under study. ((b)) Temperature evolution. Figure 4.23: Cylinder temperature evolution after 1 second. It is important to point out that due to the fact that turbulence is a phenomenon involving three-dimensional vorticity fluctuations, the results obtained are not reliable unless a turbulent model is used. In order to obtain more consistent results, the 3D model has been studied and it is presented in the next chapter. 4.5 Flow Around a Heated Cylinder 3D In order to test the CFD-Heat Transfer Application in 3D the typical case flow around a cylinder, has been tested. 95
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 4.5.1 Description of the Problem Also for this case the fluid in question is an incompressible Newtonian fluid where the kinematic viscosity ν= 10−3m2/s, the fluid density is ρ= 1 kg/m3, the thermal conductivity k= 0.0257 W/(mK)and the specific heat is cp= 1.005 kJ/(kgK). The entire domain (Ω = Ω1 ∪Ω2) is described in Figure 4.24, where H is the height of the channel and D is the cylinder diameter. The material assigned to the cylinder has a thermal conductivity k= 1000 W/(mK), the specific heat is cp= 0.1 kJ/(kgK)and the density is ρ= 8940 kg/m3. Figure 4.24: Configuration for flow around a cylinder with circular cross–section (Schafer). The problem is governed by the following set of differential equations and initial and boundary conditions (Eq.4.9): ∇ · a= 0 in Ω1 (4.9a) ∂a ∂t + (a· ∇)a−ν∇2a=−1 ρ∇p+gin Ω1 (4.9b) ρcp ∂T ∂t +ρcpa·(∇T)−∇·(∇T) = 0 in Ω(4.9c) T(x, y, z, 0) = 298.15 in Ω1 (4.9d) 96
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger T(0, y, z, t) = 298.15 at ∂Ω1INLET (4.9e) T(x, y, z, t > 5) = 355.15 at Ω2 (4.9f) U(0, y, z, t < 5) = 16Umyz(H−y)(H/2−z)sin(Cπ 2t)/(H4/4), V = 0, Z = 0 at ∂Ω1INLET (4.9g) U(0, y, z, t ≥5) = 16Umyz(H−y)(H/2−z)/(H4/4), V = 0, Z = 0 at ∂Ω1INLET (4.9h) V(L, y, z, t)=0 at ∂Ω1OUTLET (4.9i) P(L, y, z, t) = 0 at ∂Ω1OUT LET (4.9j) where Ω1 is the body of the heat exchanger domain, Ω2 is the heated cylinder domain and Cis a constant depending on the time step. 4.5.2 Mesh Size Definition The reference element size chosen has been hmax = 0.01 and near the walls and the cylinders the element size has been taken respectively as hmin = 0.001. Once the mesh has been generated, the cylinder’s mesh was composed by 1.232 triangular elements and 3.783 tetrahedral elements and the fluid’s mesh by 15.460 triangular elements and 199.595 tetrahedral elements. Also for the 3D case at the interface between the cylinder and the fluid, the two domains have matching nodes. 4.5.3 Results Figure 4.25 and Figure 4.26 show how the heat transfer has been effective also for he 3D case. Results show the temperature fields for both the fluid and solid domains. After 6 seconds the solid temperature has decreased from 353.15 K down to 352.09 K (Figure 4.27). 97
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 4.25: Fluid’s temperature field after 6 seconds. Figure 4.26: Solid’s temperature field after 6 seconds. 98
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger ((a)) Point over the cylinder under study. ((b)) Temperature evolution. Figure 4.27: Cylinder temperature decreasing evolution during 6 seconds. The next step has been to test the 3D heat exchanger model and compare the numerical results with the experimental data. 99
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis 4.6 Heat Exchanger Numerical Simulation in 3D Once the problem in 2D has been solved the next step has been creating a 3D heat exchanger model using the same 2D model’s conditions. 4.6.1 Description of the Problem The governing equations of the problem reads: ∇ · a= 0 in Ω1 (4.10a) ∂a ∂t + (a· ∇)a−ν∇2a=−1 ρ∇p+gin Ω1 (4.10b) ρcp ∂T ∂t +ρcpa·(∇T)−∇·(∇T) = 0 in Ω(4.10c) T(x, y, z, 0) = 298.15 in Ω1 (4.10d) T(0, y, z, t) = 298.15 at ∂Ω1INLET (4.10e) T(x, y, z, t > 5) = 355.15 at Ω2 (4.10f) U(0, y, z, t < 1) = 16Umyz(H−y)(H−z)sin(Cπ 2t)/(H4), V = 0, Z = 0 at ∂Ω1INLET (4.10g) U(0, y, z, t ≥1) = 16Umyz(H−y)(H−z)/(H4), V = 0, Z = 0 at ∂Ω1INLET (4.10h) V(L, y, z, t) = 0, Z(L, y, z, t)=0 at ∂Ω1OUTLET (4.10i) P(L, y, z, t) = Y ρg0at ∂Ω1OUTLET (4.10j) where Ω1 is the body of the heat exchanger domain, Ω2 is the heated cylinder domain and Cis a constant depending on the time step. 100
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger 4.6.2 Mesh Size Definition The reference element size chosen has been hmax = 0.008. Near the walls and the cylinders the element size has been taken respectively as hmin = 0.001. Once the mesh has been generated, the cylinder’s mesh was composed by 2.842 triangular elements and 16.782 tetrahedral elements and the heat exchanger’s mesh by 396.296 triangular elements and 1.944.246 tetrahedral elements. Also for the 3D case, at the interface between the cylinder and the heat exchanger, the two domains have matching nodes. 4.6.3 Results Different snapshots of the temperature evolution of the fluid are collected in Figure 4.28. Energy transfer from the solid to the fluid is also visible for the 3D heat exchanger case. Figure 4.29 shows the the velocity field at different stages. It can be appreciated how vortexes are generated as the velocity increases and also how the velocity increases at the tube banks reaching a maximum velocity of 23.76 km/h. 101
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ((a)) t = 0.005 s. ((b)) t = 1 s. ((c)) t = 1.135 s. Figure 4.28: Temperature evolution of the fluid domain at the heat exchanger in 3D. 102
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger ((a)) t = 1 s. ((b)) t = 1.35 s. Figure 4.29: Velocity evolution of the heat exchanger in 3D. For the solid domain, the heat flux is represented in Figure 4.30. In this case the flux is computed by element, where the value at the nodes is multiplied y the element area. 103
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Figure 4.30: Heat flux at t = 1 s. A temperature decreasing for the solid domain has been registered after 1.35 seconds (Fig. 4.31), where the temperature has decreased by 0.01 K. Figure 4.31: Solid temperature field at t = 1.35 s. 104
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger unsigned int Dim = 2; unsigned int NumNodes = 3; unsigned int DofSize = NumNodes ; i f ( rResult . s i z e () != DofSize ) rResult . r e s i z e ( DofSize , false ) ; for(unsigned int i =0; i<NumNodes ; i++) { rResult [ i ] = this−>GetGeometry ( ) [ i ] . GetDof (TEMPERATURE) . EquationId ( ) ; } KRATOS_CATCH( "" ) } template<> void HeatEquation <3>:: GetDofList ( DofsVectorType& ElementalDofList , ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY unsigned int Dim = 3; unsigned int NumNodes = 4; unsigned int DofSize = NumNodes ; i f ( ElementalDofList . s i z e ( ) != DofSize ) ElementalDofList . r e s i z e ( DofSize ) ; for(unsigned int i =0; i<NumNodes ; i++) { ElementalDofList [ i ] = this−>GetGeometry ( ) [ i ] . pGetDof (TEMPERATURE) ; } KRATOS_CATCH( "" ) ; } template<> void HeatEquation <2>:: GetDofList ( DofsVectorType& ElementalDofList , ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY unsigned int Dim = 2; unsigned int NumNodes = 3; unsigned int DofSize = NumNodes ; 111
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis i f ( ElementalDofList . s i z e ( ) != DofSize ) ElementalDofList . r e s i z e ( DofSize ) ; for(unsigned int i =0; i<NumNodes ; i++) { ElementalDofList [ i ] = this−>GetGeometry ( ) [ i ] . pGetDof (TEMPERATURE) ; } KRATOS_CATCH( "" ) ; } template<> void HeatEquation <3>::ComputeGaussPointLHSContribution (bounded_matrix<double,4,4>& lhs , const ElementDataStruct& data) { const int nnodes = 4; const int dim = 3; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; const double h = data . h ; const double& delta_t = data . delta_t ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = 1 . 0/( dyn_tau_coeff∗rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; 112
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger } template<> void HeatEquation <2>::ComputeGaussPointLHSContribution (bounded_matrix<double,3,3>& lhs , const ElementDataStruct& data) { const int nnodes = 3; const int dim = 2; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double h = data . h ; const double& delta_t = data . delta_t ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; // S t a b i l i z a t i o n parameters const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = 1 . 0/( dyn_tau_coeff∗rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; } template<> void HeatEquation <3>::ComputeGaussPointRHSContribution ( array_1d<double,4>& rhs , const ElementDataStruct& data) { const int nnodes = 4; 113
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis const int dim = 3; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double h = data . h ; const double& delta_t = data . delta_t ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; // Au xi lia ry v a r i a b l e s used in the c a l c u l a t i o n of the RHS const double q_gauss = inner_prod ( data .Q, data .N) ; // S t a b i l i z a t i o n parameters const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = 1 . 0/( dyn_tau_coeff∗rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; } template<> void HeatEquation <2>::ComputeGaussPointRHSContribution ( array_1d<double,3>& rhs , const ElementDataStruct& data) { const int nnodes = 3; const int dim = 2; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double h = data . h ; const double& delta_t = data . delta_t ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; 114
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; // Au xi lia ry v a r i a b l e s used in the c a l c u l a t i o n of the RHS const double q_gauss = inner_prod ( data .Q, data .N) ; // S t a b i l i z a t i o n parameters const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = 1 . 0/( dyn_tau_coeff∗rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; } } C HeatEquationSolver.py from __future__ import print_function , absolute_import , d i v i s i o n #importing the Kratos Library import KratosMultiphysics import KratosMultiphysics . HeatEquationApplication #import KratosMultiphysics . MeshingApplication as KratosMeshing #Check that KratosMultiphysics was imported in the main s c r i p t KratosMultiphysics . CheckForPreviousImport () def C reate Sol ve r ( main_model_part , custom_settings ) : return HeatEquationSolver ( main_model_part , custom_settings ) class HeatEquationSolver(object ): def __init__( s e l f , main_model_part , custom_settings ) : object i s implemented se l f . main_model_part = main_model_part 115
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ##s e t t i n g s s t r i n g in jso n format base_s et ti ngs = KratosMultiphysics . Parameters ( """ ␣␣␣␣␣␣␣␣{ ␣␣␣␣␣␣␣␣␣␣␣␣" solver_type "␣ : ␣" heat_equation_solver " , ␣␣␣␣␣␣␣␣␣␣␣␣"problem_data"␣ :{ ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣"domain_size"␣:␣2 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣}, ␣␣␣␣␣␣␣␣␣␣␣␣" model_import_settings " : ␣{ ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣"input_type" : ␣"mdpa" , ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣" input_filename " : ␣"unknown_name" ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣}, ␣␣␣␣␣␣␣␣␣␣␣␣" r e l a ti ve _ t o le ra nc e "␣␣␣␣␣␣␣␣ : ␣1e−5, ␣␣␣␣␣␣␣␣␣␣␣␣" absolute_tolerance "␣␣␣␣␣␣␣␣ : ␣1e −7, ␣␣␣␣␣␣␣␣␣␣␣␣"time_order"␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣:␣2, ␣␣␣␣␣␣␣␣␣␣␣␣"echo_level"␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣:␣0, ␣␣␣␣␣␣␣␣␣␣␣␣"maximum_iterations"␣␣␣␣␣␣␣␣ : ␣ 20 , ␣␣␣␣␣␣␣␣␣␣␣␣"compute_reactions"␣␣␣␣␣␣␣␣␣:␣false , ␣␣␣␣␣␣␣␣␣␣␣␣" reform_dofs_at_each_step "␣␣ : ␣ f a l s e , ␣␣␣␣␣␣␣␣␣␣␣␣"move_mesh_flag"␣␣␣␣␣␣␣␣␣␣␣␣ : ␣ f a l s e , ␣␣␣␣␣␣␣␣␣␣␣␣"domain_model_part"␣␣␣␣␣␣␣␣␣ : ␣"your_computational_domain" , ␣␣␣␣␣␣␣␣␣␣␣␣"dynamic_tau"␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣:␣1 ␣␣␣␣␣␣␣␣}""") ## Overwrite the default s e t t i n g s with user−provided parameters s e l f . s e t t i n g s = custom_settings s e l f . s e t t i n g s . ValidateAndAssignDefaults ( base_settings ) ## Construct the l i n e a r s o l v e r #import linear_ s o lve r _ f a ct o r y #s e l f . li ne ar_ so lv er = l i n e ar_s o l ver _ f a c to r y . ConstructSolver ( s e l f . s e t t i n g s ["linear_solver_settings"]) from KratosMultiphysics . ExternalSolversApplication import SuperLUIterativeSolver s e l f . lin ea r_s ol ve r = SuperLUIterativeSolver ( ) pri nt ( " Construction ␣ of ␣ HeatEquationSolver ␣ f i n i s h e d " ) def AddVariables ( s e l f ) : ## Add base class variables s e l f . main_model_part . AddNodalSolutionStepVariable (KratosMultiphysics .DENSITY); s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .CONDUCTIVITY) ; s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .SPECIFIC_HEAT) ; 116
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .HEAT_FLUX) ; s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .TEMPERATURE) ; s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .VELOCITY) ; s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .NODAL_AREA) s e l f . main_model_part . AddNodalSolutionStepVariable ( KratosMultiphysics .FACE_HEAT_FLUX ) pri nt ( "Base␣ c l a s s ␣Heat␣ Equation␣ s o lv e r ␣ v a ri a bl e ␣added␣ c o r r e c t l y " ) def ImportModelPart( self ): ## Read model part s e l f . _ModelPartReading () ## Replace elements and conditions self . _ExecuteAfterReading() ## Set b uf fe r s i z e self . _SetBufferSize () # pr i nt ( s e l f . main_model_part . GetSubModelPart ( " Wall_solid " ) ) pri nt ( "Base␣ c l a s s ␣model␣ reading ␣ f i n i s h e d . " ) def ExportModelPart ( s e l f ) : name_out_file = s e l f . s e t t i n g s [ " model_import_settings " ] [ " input_filename " ] . GetString ()+" . out " f i l e = open ( name_out_file + " .mdpa" , "w") f i l e . c l o s e ( ) ## Model part writing KratosMultiphysics . ModelPartIO ( name_out_file , KratosMultiphysics . IO .WRITE) . WriteModelPart ( s e l f . main_model_part ) def AddDofs ( s e l f ) : ## Adding dofs for node in s e l f . main_model_part . Nodes : node . AddDof( KratosMultiphysics .TEMPERATURE, KratosMultiphysics .FACE_HEAT_FLUX) pri nt ( "Base␣ c l a s s ␣Heat␣ Equation␣ s o lv e r ␣DOFs␣added␣ c o r r e c t l y . " ) def AdaptMesh( s e l f ) : pass def GetMinimumBufferSize( self ): return 3 def GetComputingModelPart ( s e l f ) : 117
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis return s e l f . main_model_part #.GetSubModelPart ( s e l f . s e t t i n g s [ "domain_model_part" ] . GetString ( ) ) def GetOutputVariables ( s e l f ) : pass def I n i t i a l i z e ( s e l f ) : s e l f . computing_model_part = s e l f . GetComputingModelPart ( ) # Creating the s o lu t io n s trat e gy s e l f . conv_criteria = KratosMultiphysics . R es idu al Cr i te ri a ( s e l f . s e t t i n g s [ " r el at iv e_ to le ra n ce " ] . GetDouble ( ) , s e l f . s e t t i n g s [ " absolute _t olerance " ] . GetDouble ( ) ) s e l f . bdf_process = KratosMultiphysics . ComputeBDFCoefficientsProcess ( s e l f . computing_model_part , s e l f . s e t t i n g s [ "time_order" ] . GetInt ( ) ) time_scheme = KratosMultiphysics . ResidualBasedIncrementalUpdateStaticScheme() builder_and_solver = KratosMultiphysics . ResidualBasedBlockBuilderAndSolver ( s e l f . li ne ar _so lv er ) self . solver=KratosMultiphysics . ResidualBasedNewtonRaphsonStrategy ( s e l f . computing_model_part , time_scheme , self . linear_solver , self . conv_criteria , builder_and_solver , s e l f . s e t t i n g s [ "maximum_iterations " ] . GetInt ( ) , s e l f . s e t t i n g s [ " compute_reactions " ] . GetBool ( ) s e l f . s e t t i n g s [ "reform_dofs_at_each_step" ] . GetBool ( ) , s e l f . s e t t i n g s [ "move_mesh_flag" ] . GetBool ( ) ) ( s e l f . s o l v e r ) . SetEchoLevel ( s e l f . s e t t i n g s [ " echo_level " ] . GetInt ( ) ) KratosMultiphysics . CalculateNodalAreaProcess ( self . computing_model_part , s e l f . s e t t i n g s [ "problem_data" ] [ "domain_size" ] . GetInt ( ) ) . Execute () ( s e l f . s o l v e r ) . I n i t i a l i z e ( ) ( s e l f . s o l v e r ) . Check ( ) def SaveRestart ( s e l f ) : pass #one should write the r e s t a r t f i l e here 118
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger def Clear ( s e l f ) : ( s e l f . s o l v e r ) . Clear ( ) def Check ( s e l f ) : ( s e l f . s o l v e r ) . Check ( ) def SetEchoLevel ( s e l f , l e v e l ) : ( s e l f . s o l v e r ) . SetEchoLevel ( l e v e l ) def S o l v e r I n i t i a l i z e ( s e l f ) : ( s e l f . s o l v e r ) . I n i t i a l i z e ( ) def S o l v e r I n i t i a l i z e S o l u t i o n S t e p ( s e l f ) : ( s e l f . bdf_process ) . Execute () ( s e l f . s ol ve r ) . I n i t i a l i z e S o l u t i o n S t e p ( ) def So lv e rP r e di ct ( s e l f ) : ( s e l f . s o l v e r ) . Pre di ct ( ) def SolverSolveSolutionStep( self ): ( s e l f . s o l v e r ) . So lve Sol uti onSt ep ( ) def SolverFinalizeSolutionStep( self ): ( s e l f . s o l v e r ) . F i na l i ze S o lu ti o n St ep ( ) def Solve ( s e l f ) : s e l f . S o l v e r I n i t i a l i z e S o l u t i o n S t e p ( ) self . SolverPredict () self . SolverSolveSolutionStep () self . SolverFinalizeSolutionStep() def _ModelPartReading ( s e l f ) : ## Model part reading i f ( s e l f . s e t t i n g s [ " model_import_settings " ] [ "input_type " ] . GetString () == "mdpa" ) : KratosMultiphysics .ModelPartIO ( s e l f . s e t t i n g s [ " model_import_settings" ] [ " input_filename " ] . GetString ( ) ) . ReadModelPart ( s e l f . main_model_part ) else : r a i s e Exception ( "Other␣ input ␣ o pt io ns ␣ are ␣ not␣ yet ␣implemented . " ) def _ExecuteAfterReading( self ): for e l in s e l f . main_model_part . Elements : 119
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis rho = e l . P ro pe rt ie s . GetValue ( KratosMultiphysics .DENSITY) k = e l . Pro p erties . GetValue ( KratosMultiphysics .CONDUCTIVITY) cp = e l . P ro pe rt ie s . GetValue ( KratosMultiphysics .SPECIFIC_HEAT) break prin t ( s e l f . s e t t i n g s [ "dynamic_tau" ] . GetDouble ( ) ) s e l f . GetComputingModelPart ( ) . ProcessInfo [ KratosMultiphysics .TAU] = s e l f . s e t t i n g s [ "dynamic_tau" ] . GetDouble () KratosMultiphysics . V ari abl eU t il s () . SetScalarVar ( KratosMultiphysics .DENSITY, rho , s e l f . main_model_part . Nodes ) KratosMultiphysics . V ari abl eU t il s () . SetScalarVar ( KratosMultiphysics .CONDUCTIVITY, k , s e l f . main_model_part . Nodes ) KratosMultiphysics . V ari abl eU t il s () . SetScalarVar ( KratosMultiphysics .SPECIFIC_HEAT, cp , s e l f . main_model_part . Nodes ) def _SetBufferSize ( s e l f ) : ## Set the buf fe r s i z e current_buffer_size = s e l f . main_model_part . GetBufferSize ( ) i f ( s e l f . GetMinimumBufferSize ( ) > current_buffer_size ) : s e l f . main_model_part . Se tBuf ferS ize ( self . GetMinimumBufferSize ()) D CFD-HeatTransferSolver.py #importing the Kratos Library import KratosMultiphysics import KratosMultiphysics . FluidDynamicsApplication as KratosCFD import KratosMultiphysics . HeatEquationApplication as KratosHEq KratosMultiphysics . CheckForPreviousImport () import navier_stokes_base_solver def CreateSolver ( fluid_main_model_part , heat_equation_main_model_part , project_parameters ): return CFDThermalSolver ( fluid_main_model_part , heat_equation_main_model_part , project_parameters ) class CFDThermalSolver : """␣␣␣␣␣␣␣␣␣␣""" def __init__( s e l f , fluid_main_model_part , 120
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger for (unsigned int iNode = 0 ; iNode < NumNodes ; ++iNode ) { rResult [ LocalIndex++] = this−>GetGeometry ( ) [ iNode ] . GetDof (TEMPERATURE) . EquationId ( ) ; } } /∗∗ ∗@see HeatEquationNeumannCondition : : GetDofList ∗/ template <> void HeatEquationNeumannCondition <2 ,2 >:: GetDofList ( DofsVectorType& rElementalDofList , ProcessInfo& rCurrentProcessInfo ) { const SizeType NumNodes = 2 ; const SizeType LocalSize = 2; i f ( rElementalDofList . s i z e ( ) != LocalSize ) rElementalDofList . r e s i z e ( LocalSize ) ; unsigned int LocalIndex = 0; for (unsigned int iNode = 0 ; iNode < NumNodes ; ++iNode ) { rElementalDofList [ LocalIndex++] = this−>GetGeometry () [ iNode ] . pGetDof (TEMPERATURE) ; } } /∗∗ ∗@see HeatEquationNeumannCondition : : GetDofList ∗/ template <> void HeatEquationNeumannCondition <3 ,3 >:: GetDofList ( DofsVectorType& rElementalDofList , ProcessInfo& rCurrentProcessInfo ) { const SizeType NumNodes = 3 ; const SizeType LocalSize = 3; i f ( rElementalDofList . s i z e ( ) != LocalSize ) rElementalDofList . r e s i z e ( LocalSize ) ; unsigned int LocalIndex = 0; for (unsigned int iNode = 0 ; iNode < NumNodes ; ++iNode ) 127
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis { rElementalDofList [ LocalIndex++] = this−>GetGeometry ( ) [ iNode ] . pGetDof (TEMPERATURE) ; } } /// Computes the Gauss pt . LHS co nt ri b ut io n /∗∗ ∗@param lhs_gauss refe r ence to the l o c a l LHS matrix ∗@param data Gauss pt . data s t ru ct u r e ∗/ template<unsigned int Tdim , unsigned int TNumNodes> void HeatEquationNeumannCondition<Tdim , TNumNodes>::7 ComputeGaussPointLHSContribution (bounded_matrix<double , TNumNodes , TNumNodes>& lhs_gauss , const ConditionDataStruct& data ) { no a li as ( lhs_gauss ) = ZeroMatrix (TNumNodes, TNumNodes ) ; }/// Computes the Gauss pt . RHS c on tr i bu ti on /∗∗ ∗@param rhs_gauss re fere nce to the l o c a l RHS v e ctor ∗@param data Gauss pt . data s t ru ct u r e ∗/ template<unsigned int TDim, unsigned int TNumNodes> void HeatEquationNeumannCondition<TDim, TNumNodes>:: ComputeGaussPointRHSContribution ( array_1d<double , TNumNodes>& rhs_gauss , const ConditionDataStruct& data ) { // I n i t i a l i z e the l o c a l RHS no a li as ( rhs_gauss ) = ZeroVector (TNumNodes ) ; // Gauss pt . Neumann BC c on t ri bu ti on this−>ComputeRHSNeumannContribution ( rhs_gauss , data ) ; } /// Computes the condition RHS Neumann BC c on tr ib ut io n /∗∗ ∗@param rhs_gauss re fere nce to the l o c a l RHS v e ctor ∗@param data Gauss pt . data s t ru ct u r e ∗/ template<unsigned int Tdim , unsigned int TNumNodes> void HeatEquationNeumannCondition<Tdim , TNumNodes>:: ComputeRHSNeumannContribution(array_1d<double , TNumNodes>& rhs_gauss , const ConditionDataStruct& data ) { const GeometryType& rGeom = this−>GetGeometry ( ) ; 128
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger // Add Neumann BC c o nt ri bu ti on for (unsigned int i =0; i<TNumNodes ; ++i ) { const double flux_ext = rGeom [ i ] . FastGetSolutionStepValue (FACE_HEAT_FLUX) ; const double k = 401; //rGeom [ i ] . FastGetSolutionStepValue (CONDUCTIVITY) ; rhs_gauss [ i ] −= k∗data . wGauss∗data .N[ i ]∗flux_ext ; // std : : cout << "Neumann c on tr ib ut ion OK\n"; } } /// Computes the 2D condition normal /∗∗ ∗@param An refe re nce to condition normal vector ∗/ template <> void HeatEquationNeumannCondition <2 ,2 >:: CalculateNormal ( array_1d<double,3>& An) { Geometry<Node<3> >& pGeometry = this−>GetGeometry ( ) ; An [ 0 ] = pGeometry [ 1 ] .Y( ) −pGeometry [ 0 ] .Y( ) ; An [ 1 ] = −( pGeometry [ 1 ] .X( ) −pGeometry [ 0 ] .X( ) ) ; An [ 2 ] = 0 . 0 0 ; } /// Computes the 3D condition normal /∗∗ ∗@param An refe re nce to condition normal vector ∗/ template <> void HeatEquationNeumannCondition <3 ,3 >:: CalculateNormal ( array_1d<double,3>& An ) { Geometry<Node<3> >& pGeometry = this−>GetGeometry ( ) ; array_1d<double,3> v1 , v2 ; v1 [ 0 ] = pGeometry [ 1 ] .X() −pGeometry [ 0 ] . X( ) ; v1 [ 1 ] = pGeometry [ 1 ] .Y() −pGeometry [ 0 ] . Y( ) ; v1 [ 2 ] = pGeometry [ 1 ] . Z( ) −pGeometry [ 0 ] . Z ( ) ; v2 [ 0 ] = pGeometry [ 2 ] .X() −pGeometry [ 0 ] . X( ) ; v2 [ 1 ] = pGeometry [ 2 ] .Y() −pGeometry [ 0 ] . Y( ) ; v2 [ 2 ] = pGeometry [ 2 ] . Z( ) −pGeometry [ 0 ] . Z ( ) ; MathUtils<double>:: CrossProduct (An, v1 , v2 ) ; An ∗= 0 . 5 ; 129
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis } template class HeatEquationNeumannCondition <2,2>; template class HeatEquationNeumannCondition <3,3>; }// namespace Kratos F HeatEquation.cpp // | / | // ’ / __| _‘ | __| _ \ __| // . \ | ( | | ( |\__ ‘ // _|\_\_| \__,_|\__|\___/ ____/ // Multi−Physics // // License : BSD License // Kratos d e f a u l t l i c e n s e : kr at os / l i c e n s e . t x t // // Main authors : Christian Rossi // #include "custom_elements/ heat_equation . h" namespace Kratos { template<> void HeatEquation <3>:: EquationIdVector ( EquationIdVectorType& rResult , Pr o c e s s I n f o& rCurrentProcessInfo ) { KRATOS_TRY unsigned int Dim = 3; unsigned int NumNodes = 4; unsigned int DofSize = NumNodes ; i f ( rResult . s i z e () != DofSize ) rResult . r e s i z e ( DofSize , false ) ; for(unsigned int i =0; i<NumNodes ; i++) { rResult [ i ] = this−>GetGeometry ( ) [ i ] . GetDof (TEMPERATURE) . EquationId ( ) ; } KRATOS_CATCH( "" ) } 130
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger template<> void HeatEquation <2>:: EquationIdVector ( EquationIdVectorType& rResult , Pr o c e s s I n f o& rCurrentProcessInfo ) { KRATOS_TRY unsigned int Dim = 2; unsigned int NumNodes = 3; unsigned int DofSize = NumNodes ; i f ( rResult . s i z e () != DofSize ) rResult . r e s i z e ( DofSize , false ) ; for(unsigned int i =0; i<NumNodes ; i++) { rResult [ i ] = this−>GetGeometry ( ) [ i ] . GetDof (TEMPERATURE) . EquationId ( ) ; } KRATOS_CATCH( "" ) } template<> void HeatEquation <3>:: GetDofList ( DofsVectorType& ElementalDofList , ProcessInfo& rCurrentProcessInfo ) { KRATOS_TRY unsigned int Dim = 3; unsigned int NumNodes = 4; unsigned int DofSize = NumNodes ; i f ( ElementalDofList . s i z e ( ) != DofSize ) ElementalDofList . r e s i z e ( DofSize ) ; for(unsigned int i =0; i<NumNodes ; i++) { ElementalDofList [ i ] = this−>GetGeometry ( ) [ i ] . pGetDof (TEMPERATURE) ; } KRATOS_CATCH( "" ) ; } template<> void HeatEquation <2>:: GetDofList ( DofsVectorType& ElementalDofList , ProcessInfo& rCurrentProcessInfo ) 131
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis { KRATOS_TRY unsigned int Dim = 2; unsigned int NumNodes = 3; unsigned int DofSize = NumNodes ; i f ( ElementalDofList . s i z e ( ) != DofSize ) ElementalDofList . r e s i z e ( DofSize ) ; for(unsigned int i =0; i<NumNodes ; i++) { ElementalDofList [ i ] = this−>GetGeometry ( ) [ i ] . pGetDof (TEMPERATURE) ; } KRATOS_CATCH( "" ) ; } template<> void HeatEquation <3>::ComputeGaussPointLHSContribution (bounded_matrix<double,4,4>& lhs , const ElementDataStruct& data ) { const int nnodes = 4; const int dim = 3; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; const double h = data . h ; const double& delta_t = data . delta_t ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; 132
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = dyn_tau_coeff∗1.0/( rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; const double clhs 0 = bdf0∗cp∗rho ; const double clhs 1 = N[ 0 ] ∗cp∗rho ; const double clhs 2 = N[ 0 ] ∗v (0 ,0) + N[ 1 ] ∗v (1 ,0) + N[ 2 ] ∗v (2 ,0) + N[ 3 ] ∗v ( 3 , 0 ) ; const double clhs 3 = N[ 0 ] ∗v (0 ,1) + N[ 1 ] ∗v (1 ,1) + N[ 2 ] ∗v (2 ,1) + N[ 3 ] ∗v ( 3 , 1 ) ; const double clhs 4 = N[ 0 ] ∗v (0 ,2) + N[ 1 ] ∗v (1 ,2) + N[ 2 ] ∗v (2 ,2) + N[ 3 ] ∗v ( 3 , 2 ) ; const double clhs 5 = DN(0 ,0)∗clhs2 + DN(0 ,1)∗clhs3 +DN(0 ,2)∗clhs4 ; const double clhs 6 = N[ 0 ] ∗bdf0 + clhs5 ; const double c lh s7 = pow( cp , 2 ) ; const double c lh s8 = pow( rho , 2 ) ; const double clhs9 = clhs5∗clhs7∗clhs8∗tau ; const double clhs10 = DN(0 ,0)∗k ; const double clhs11 = DN(0 ,1)∗k ; const double clhs12 = DN(0 ,2)∗k ; const double clhs13 = N[ 0 ] ∗bdf0∗cp∗rho ; const double clhs14 = DN(1 ,0)∗clhs10 + DN(1 ,1)∗clhs11 + DN(1 ,2)∗clhs12 + N[ 1 ] ∗clhs13 ; const double clhs15 = DN(1 ,0)∗clhs2 + DN(1 ,1)∗clhs3 + DN(1 ,2)∗clhs4 ; const double clhs16 = N[ 1 ] ∗bdf0 + clhs15 ; const double clhs17 = DN(2 ,0)∗clhs10 + DN(2 ,1)∗clhs11 + DN(2 ,2)∗clhs12 + N[ 2 ] ∗clhs13 ; const double clhs18 = DN(2 ,0)∗clhs2 + DN(2 ,1)∗clhs3 + DN(2 ,2)∗clhs4 ; const double clhs19 = N[ 2 ] ∗bdf0 ; const double clhs20 = clhs18 + clhs19 ; const double clhs21 = DN(3 ,0)∗clhs10 + DN(3 ,1)∗clhs11 + DN(3 ,2)∗clhs12 + N[ 3 ] ∗clhs13 ; const double clhs22 = DN(3 ,0)∗clhs2 + DN(3 ,1)∗clhs3 + DN(3 ,2)∗clhs4 ; const double clhs23 = N[ 3 ] ∗bdf0 + clhs22 ; const double clhs24 = N[ 1 ] ∗cp∗rho ; const double clhs25 = clhs15 ∗clhs7∗clhs8∗tau ; const double clhs26 = DN(1 ,0)∗k ; const double clhs27 = DN(1 ,1)∗k ; const double clhs28 = DN(1 ,2)∗k ; const double clhs29 = N[ 1 ] ∗bdf0∗cp∗rho ; const double clhs30 = DN(2 ,0)∗clhs26 + DN(2 ,1)∗clhs27 + DN(2 ,2)∗clhs28 + N[ 2 ] ∗clhs29 ; 133
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis const double clhs31 = DN(3 ,0)∗clhs26 + DN(3 ,1)∗clhs27 + DN(3 ,2)∗clhs28 + N[ 3 ] ∗clhs29 ; const double clhs32 = N[ 2 ] ∗cp∗rho ; const double clhs33 = clhs18 ∗clhs7∗clhs8∗tau ; const double clhs34 = N[ 3 ] ∗cp∗rho ; const double clhs35 = DN(2 ,0)∗DN(3 ,0)∗k + DN(2 ,1)∗DN(3 ,1)∗k + DN(2 ,2)∗DN(3 ,2)∗k + clhs19 ∗clhs34 ; const double clhs36 = clhs22 ∗clhs7∗clhs8∗tau ; lhs (0 ,0)=pow(DN( 0 , 0) , 2)∗k + pow(DN(0 , 1) , 2)∗k + pow(DN( 0 , 2) , 2)∗k + pow(N[ 0 ] , 2)∗clhs0 + clhs1∗clhs5 + clhs6∗clhs9 ; lhs (0 ,1)= clhs1 ∗clhs15 + clhs14 + clhs16 ∗clhs9 ; lhs (0 ,2)= clhs1 ∗clhs18 + clhs17 + clhs20 ∗clhs9 ; lhs (0 ,3)= clhs1 ∗clhs22 + clhs21 + clhs23 ∗clhs9 ; lhs (1 ,0)= clhs14 + clhs24 ∗clhs5 + clhs25 ∗clhs6 ; lhs (1 ,1)=pow(DN( 1 , 0) , 2)∗k + pow(DN(1 , 1) , 2)∗k + pow(DN( 1 , 2) , 2)∗k + pow(N[ 1 ] , 2)∗clhs0 + clhs15 ∗clhs24 + clhs16 ∗clhs25 ; lhs (1 ,2)= clhs18 ∗clhs24 + clhs20 ∗clhs25 + clhs30 ; lhs (1 ,3)= clhs22 ∗clhs24 + clhs23 ∗clhs25 + clhs31 ; lhs (2 ,0)= clhs17 + clhs32 ∗clhs5 + clhs33 ∗clhs6 ; lhs (2 ,1)= clhs15 ∗clhs32 + clhs16 ∗clhs33 + clhs30 ; lhs (2 ,2)=pow(DN( 2 , 0) , 2)∗k + pow(DN(2 , 1) , 2)∗k + pow(DN( 2 , 2) , 2)∗k + pow(N[ 2 ] , 2)∗clhs0 + clhs18 ∗clhs32 + clhs20 ∗clhs33 ; lhs (2 ,3)= clhs22 ∗clhs32 + clhs23 ∗clhs33 + clhs35 ; lhs (3 ,0)= clhs21 + clhs34 ∗clhs5 + clhs36 ∗clhs6 ; lhs (3 ,1)= clhs15 ∗clhs34 + clhs16 ∗clhs36 + clhs31 ; lhs (3 ,2)= clhs18 ∗clhs34 + clhs20 ∗clhs36 + clhs35 ; lhs (3 ,3)=pow(DN( 3 , 0) , 2)∗k + pow(DN(3 , 1) , 2)∗k + pow(DN( 3 , 2) , 2)∗k + pow(N[ 3 ] , 2)∗clhs0 + clhs22 ∗clhs34 + clhs23 ∗clhs36 ; } template<> void HeatEquation <2>::ComputeGaussPointLHSContribution (bounded_matrix<double,3,3>& lhs , const ElementDataStruct& data) { const int nnodes = 3; const int dim = 2; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double h = data . h ; const double& delta_t = data . delta_t ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; 134
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger const double& bdf2 = data . bdf2 ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; // S t a b i l i z a t i o n parameters const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; const double c2 = 4 . 0 ; const double tau = dyn_tau_coeff∗1.0/( rho∗cp/ delta_t + c1∗rho∗cp∗v_norm/h + c2∗k /(h∗h ) ) ; const double clhs 0 = bdf0∗cp∗rho ; const double clhs 1 = N[ 0 ] ∗cp∗rho ; const double clhs 2 = N[ 0 ] ∗v (0 ,0) + N[ 1 ] ∗v (1 ,0) + N[ 2 ] ∗v ( 2 , 0 ) ; const double clhs 3 = N[ 0 ] ∗v (0 ,1) + N[ 1 ] ∗v (1 ,1) + N[ 2 ] ∗v ( 2 , 1 ) ; const double clhs 4 = DN(0 ,0)∗clhs2 + DN(0 ,1)∗clhs3 ; const double clhs 5 = N[ 0 ] ∗bdf0 + clhs4 ; const double c lh s6 = pow( cp , 2 ) ; const double c lh s7 = pow( rho , 2 ) ; const double clhs8 = clhs4∗clhs6∗clhs7∗tau ; const double clhs 9 = DN(0 ,0)∗k ; const double clhs10 = DN(0 ,1)∗k ; const double clhs11 = N[ 0 ] ∗bdf0∗cp∗rho ; const double clhs12 = DN(1 ,0)∗clhs9 + DN(1 ,1)∗clhs10 + N[ 1 ] ∗clhs11 ; const double clhs13 = DN(1 ,0)∗clhs2 + DN(1 ,1)∗clhs3 ; const double clhs14 = N[ 1 ] ∗bdf0 ; const double clhs15 = clhs13 + clhs14 ; const double clhs16 = DN(2 ,0)∗clhs9 + DN(2 ,1)∗clhs10 + N[ 2 ] ∗clhs11 ; const double clhs17 = DN(2 ,0)∗clhs2 + DN(2 ,1)∗clhs3 ; const double clhs18 = N[ 2 ] ∗bdf0 + clhs17 ; const double clhs19 = N[ 1 ] ∗cp∗rho ; const double clhs20 = clhs13 ∗clhs6∗clhs7∗tau ; const double clhs21 = N[ 2 ] ∗cp∗rho ; const double clhs22 = DN(1 ,0)∗DN(2 ,0)∗k + DN(1 ,1)∗DN(2 ,1)∗k + clhs14 ∗clhs21 ; const double clhs23 = clhs17 ∗clhs6∗clhs7∗tau ; 135
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis lhs (0 ,0)=pow(DN( 0 , 0) , 2)∗k + pow(DN(0 , 1) , 2)∗k + pow(N[ 0 ] , 2)∗clhs0 + clhs1∗clhs4 + clhs5∗clhs8 ; lhs (0 ,1)= clhs1 ∗clhs13 + clhs12 + clhs15 ∗clhs8 ; lhs (0 ,2)= clhs1 ∗clhs17 + clhs16 + clhs18 ∗clhs8 ; lhs (1 ,0)= clhs12 + clhs19 ∗clhs4 + clhs20 ∗clhs5 ; lhs (1 ,1)=pow(DN( 1 , 0) , 2)∗k + pow(DN(1 , 1) , 2)∗k + pow(N[ 1 ] , 2)∗clhs0 + clhs13 ∗clhs19 + clhs15 ∗clhs20 ; lhs (1 ,2)= clhs17 ∗clhs19 + clhs18 ∗clhs20 + clhs22 ; lhs (2 ,0)= clhs16 + clhs21 ∗clhs4 + clhs23 ∗clhs5 ; lhs (2 ,1)= clhs13 ∗clhs21 + clhs15 ∗clhs23 + clhs22 ; lhs (2 ,2)=pow(DN( 2 , 0) , 2)∗k + pow(DN(2 , 1) , 2)∗k + pow(N[ 2 ] , 2)∗clhs0 + clhs17 ∗clhs21 + clhs18 ∗clhs23 ; } template<> void HeatEquation <3>::ComputeGaussPointRHSContribution ( array_1d<double,4>& rhs , const ElementDataStruct& data) { const int nnodes = 4; const int dim = 3; const double rho = data . rho ; const double k = data . k ; const double cp = data . cp ; const double h = data . h ; const double& delta_t = data . delta_t ; const double& bdf0 = data . bdf0 ; const double& bdf1 = data . bdf1 ; const double& bdf2 = data . bdf2 ; const array_1d<double , nnodes>& Q = data .Q; const bounded_matrix<double , nnodes , dim>& v = data . v ; const array_1d<double , nnodes>& temp = data . temp ; const array_1d<double , nnodes>& tempn = data . tempn ; const array_1d<double , nnodes>& tempnn = data . tempnn ; const double& dyn_tau_coeff = data . dyn_tau_coeff ; // Get shape function val u es const array_1d<double , nnodes>& N = data .N; const bounded_matrix<double , nnodes , dim>& DN = data .DN_DX; // A ux ilia ry v a r i a b l e s used in the c a l c u l a t i o n of the RHS const double q_gauss = inner_prod ( data .Q, data .N) ; // S t a b i l i z a t i o n parameters const array_1d<double , dim> v_gauss = prod ( trans ( v ) , N) ; const double v_norm = norm_2( v_gauss ) ; // S t a b i l i z a t i o n parameters const double c1 = 2 . 0 ; 136
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger no a li as ( rRightHandSideVector ) += rhs_local ; } rLeftHandSideMatrix ∗= data . volume/ static_cast<double>(TNumNodes ) ; rRightHandSideVector ∗= data . volume/ static_cast<double>(TNumNodes ) ; KRATOS_CATCH( "" ) } void CalculateRightHandSide ( VectorType& rRightHandSideVector , ProcessInfo& rCurrentProcessInfo ) ov e rrid e { KRATOS_TRY constexpr unsigned int MatrixSize = TNumNodes ; i f ( rRightHandSideVector . s i z e () != MatrixSize ) rRightHandSideVector . r e s i z e ( MatrixSize , false ) ; // Struct to pass around the data ElementDataStruct data ; this−>FillElementData ( data , rCurrentProcessInfo ) ; // A l loc a te memory needed array_1d<double , MatrixSize> rhs_local ; // Gauss point p os i t i on bounded_matrix<double , TNumNodes , TNumNodes> Ncontainer ; GetShapeFunctionsOnGauss ( Ncontainer ) ; // Loop on gauss point no ali as ( rRightHandSideVector ) = ZeroVector ( MatrixSize ) ; for(unsigned int i ga us s = 0 ; igauss <Ncontainer . s i z e 2 ( ) ; igau s s++) { n o a l i a s ( data .N) = row ( Ncontainer , ig a us s ) ; ComputeGaussPointRHSContribution ( rhs_local , data ) ; no a li as ( rRightHandSideVector ) += rhs_local ; } 143
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis rRightHandSideVector ∗= data . volume/ static_cast<double>(TNumNodes ) ; KRATOS_CATCH( "" ) } virtual int Check(const ProcessInfo& rCurrentProcessInfo ) ove rr ide { KRATOS_TRY // Perform b asic element checks int ErrorCode = Kratos : : Element : : Check ( rCurrentProcessInfo ) ; i f ( ErrorCode != 0) return ErrorCode ; i f (TAU. Key ( ) == 0) KRATOS_THROW_ERROR( std : : invalid_argument , "TAU␣Key␣ i s ␣ 0 . ␣␣␣␣␣␣␣␣␣␣␣Check␣ i f ␣ the ␣ a p pl ic at io n ␣was␣ c o r r e c t l y ␣ r e g i s t e r e d . " , "" ) ; i f (DENSITY. Key ( ) == 0) KRATOS_THROW_ERROR( std : : invalid_argument , "DENSITY␣Key␣ i s ␣ 0. ␣␣␣␣␣␣␣␣␣␣␣Check␣ i f ␣ the ␣ a p pl ic at io n ␣was␣ c o r r e c t l y ␣ r e g i s t e r e d . " , "" ) ; i f (CONDUCTIVITY. Key ( ) == 0) KRATOS_THROW_ERROR( std : : invalid_argument , "CONDUCTIVITY␣Key␣ i s ␣ 0. ␣␣␣␣␣␣␣␣␣␣␣␣Check␣ i f ␣ the ␣ a p pl ic at i on ␣was␣ c o r r e c t l y ␣ r e g i s t e r e d . " , "" ) ; i f (SPECIFIC_HEAT. Key ( ) == 0) KRATOS_THROW_ERROR( std : : invalid_argument , "SPECIFIC_HEAT␣Key␣ i s ␣ 0. ␣␣␣␣␣␣␣␣␣␣␣␣Check␣ i f ␣ the ␣ a p pl ic at i on ␣was␣ c o r r e c t l y ␣ r e g i s t e r e d . " , "" ) ; for(unsigned int i =0; i<this−>GetGeometry ( ) . s i z e ( ) ; ++i ) { // i f ( this −>GetGeometry ( ) [ i ] . SolutionStepsDataHas (VELOCITY) == false ) // KRATOS_THROW_ERROR( std : : invalid_argument , " Missing ␣VELOCITY␣ va ri ab le ␣on␣ s ol u ti o n ␣ step ␣data␣ f o r ␣node ␣␣␣␣␣␣␣␣␣␣␣␣" ,this−>GetGeometry ( ) [ i ] . Id ( ) ) ; i f (this−>GetGeometry ( ) [ i ] . SolutionStepsDataHas (TEMPERATURE) == false ) KRATOS_THROW_ERROR( std : : invalid_argument , " Missing ␣TEMPERATURE␣ v a ri ab l e ␣on␣ s o lu ti o n ␣ step ␣ data ␣ f o r ␣node ␣␣␣␣␣␣␣␣␣␣␣␣" ,this−>GetGeometry ( ) [ i ] . Id ( ) ) ; 144
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger i f (this−>GetGeometry ( ) [ i ] . HasDofFor (TEMPERATURE) == false ) KRATOS_THROW_ERROR( std : : invalid_argument , " Missing ␣TEMPERATURE␣component␣ degree ␣ of ␣ freedom ␣on␣node ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣" ,this−>GetGeometry ( ) [ i ] . Id ( ) ) ; } KRATOS_CATCH( "" ) ; } virtual std : : s t r i n g I nfo ( ) const override { return "HeatEquation␣#"; } /// Print information about t h i s o b j e c t . virtual void P rin tInf o ( std : : ostream& rOStream ) const override { rOStream << Info () << Id ( ) ; } /// Print o b j e c t ’ s data . // v i r t u a l void PrintData ( s td : : ostream& rOStream ) const ov er ride ///@} ///@name Friends ///@{ ///@} protected : ///@name Protected s t a t i c member v a r i a b l e s ///@{ ///@} ///@name Protected member Variables ///@{ // C on st i t u ti ve law pointer // ConstitutiveLaw : : Pointer mpConstitutiveLaw = n u l l p t r ; // Symbolic fun c tion implementing the element GetDofList<TDim, TNumNodes> void GetDofList ( DofsVectorType& ElementalDofList , ProcessInfo& rCurrentProcessInfo ) ov e rrid e ; void EquationIdVector ( EquationIdVectorType& rResult , ProcessInfo& rCurrentProcessInfo ) ov e rrid e ; 145
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis void ComputeGaussPointLHSContribution (bounded_matrix<double , TNumNodes , TNumNodes>& lhs , const ElementDataStruct& data ) ; void ComputeGaussPointRHSContribution ( array_1d<double , TNumNodes>& rhs , const ElementDataStruct& data ) ; // double SubscaleErrorEstimate ( const ElementDataStruct& data ) ; ///@} ///@name Protected Operators ///@{ HeatEquation () : Element () { } // Au x iliar function to f i l l the element data st ru ct u r e void FillElementData ( ElementDataStruct& rData , const ProcessInfo& rCurrentProcessInfo ) { GeometryUtils : : CalculateGeometryData ( this−>GetGeometry ( ) , rData .DN_DX, rData .N, rData . volume ) ; // Compute element s i z e rData . h = ComputeH( rData .DN_DX) ; // Database access to a l l of the v a r i a b l e s needed const Vector& BDFVector = rCurrentProcessInfo [BDF_COEFFICIENTS ] ; rData . delta_t = rCurrentProcessInfo [DELTA_TIME] ; rData . bdf0 = BDFVector [ 0 ] ; rData . bdf1 = BDFVector [ 1 ] ; rData . bdf2 = BDFVector [ 2 ] ; rData . dyn_tau_coeff = rCurrentProcessInfo [TAU] ; rData . cp = this−>GetProperties ( ) [ SPECIFIC_HEAT ] ; rData . rho = this−>GetProperties ( ) [ DENSITY ] ; rData . k = this−>GetProperties ( ) [CONDUCTIVITY] ; for (unsigned int i = 0 ; i < TNumNodes ; i++) { 146
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger const array_1d<double,3>& vel = this−>GetGeometry ( ) [ i ] . FastGetSolutionStepValue (VELOCITY) ; for(unsigned int k=0; k<TDim; k++) { rData . v ( i , k ) = ve l [ k ] ; } rData .Q[ i ] = this−>GetGeometry ( ) [ i ] . FastGetSolutionStepValue (HEAT_FLUX) ; rData . temp [ i ] = this−>GetGeometry ( ) [ i ] . FastGetSolutionStepValue (TEMPERATURE) ; rData . tempn [ i ] = this−>GetGeometry ( ) [ i ] . FastGetSolutionStepValue (TEMPERATURE, 1 ) ; rData . tempnn [ i ] = this−>GetGeometry ( ) [ i ] . FastGetSolutionStepValue (TEMPERATURE, 2 ) ; } } //~ template< unsigned in t TDim, unsigned in t TNumNodes=TDim+1> double ComputeH( boost : : numeric : : ublas : : bounded_matrix<double ,TNumNodes, TDim>& DN_DX) { double h=0.0; for(unsigned int i =0; i<TNumNodes ; i++) { double h_inv = 0 . 0 ; for(unsigned int k=0; k<TDim; k++) { h_inv += DN_DX( i , k)∗DN_DX( i , k ) ; } h += 1.0/ h_inv ; } h = s q rt (h)/ static_cast<double>(TNumNodes ) ; return h ; } // 3D tet r ah edra shape fu ncti ons va l ue s at Gauss poin t s void GetShapeFunctionsOnGauss ( boost : : numeric : : ublas : : bounded_matrix<double,4,4>& Ncontainer ) { Ncontainer (0 ,0) = 0.58541020; Ncontainer (0 ,1) = 0.13819660; Ncontainer (0 ,2) = 0.13819660; Ncontainer (0 ,3) = 0.13819660; Ncontainer (1 ,0) = 0.13819660; Ncontainer (1 ,1) = 0.58541020; Ncontainer (1 ,2) = 0.13819660; 147
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis Ncontainer (1 ,3) = 0.13819660; Ncontainer (2 ,0) = 0.13819660; Ncontainer (2 ,1) = 0.13819660; Ncontainer (2 ,2) = 0.58541020; Ncontainer (2 ,3) = 0.13819660; Ncontainer (3 ,0) = 0.13819660; Ncontainer (3 ,1) = 0.13819660; Ncontainer (3 ,2) = 0.13819660; Ncontainer (3 ,3) = 0.58541020; } // 2D t r i a n g l e shape fun ct ion s va lues at Gauss poi nts void GetShapeFunctionsOnGauss ( boost : : numeric : : ublas : : bounded_matrix<double,3,3>& Ncontainer ) { const double one_sixt = 1 . 0 / 6 . 0 ; const double two_third = 2 . 0 / 3 . 0 ; Ncontainer (0 ,0) = one_sixt ; Ncontainer (0 ,1) = one_sixt ; Ncontainer (0 ,2) = two_third ; Ncontainer (1 ,0) = one_sixt ; Ncontainer (1 ,1) = two_third ; Ncontainer (1 ,2) = one_sixt ; Ncontainer (2 ,0) = two_third ; Ncontainer (2 ,1) = one_sixt ; Ncontainer (2 ,2) = one_sixt ; } // 3D tet r ah edra shape fu ncti ons va l ue s at centered Gauss point void GetShapeFunctionsOnUniqueGauss ( boost : : numeric : : ublas : : bounded_matrix<double,1,4>& Ncontainer ) { Ncontainer (0 ,0) = 0 . 2 5 ; Ncontainer (0 ,1) = 0 . 2 5 ; Ncontainer (0 ,2) = 0 . 2 5 ; Ncontainer (0 ,3) = 0 . 2 5 ; } // 2D t r i a n g l e shape fun ct ion s va lues at centered Gauss point void GetShapeFunctionsOnUniqueGauss ( boost : : numeric : : ublas : : bounded_matrix<double,1,3>& Ncontainer ) { Ncontainer (0 ,0) = 1 . 0 / 3 . 0 ; Ncontainer (0 ,1) = 1 . 0 / 3 . 0 ; Ncontainer (0 ,2) = 1 . 0 / 3 . 0 ; } ///@} ///@name Protected Access ///@{ 148
Master Thesis Numerical Study of a Cross-Flow Heat Exchanger ///@} ///@name Protected Inquiry ///@{ ///@} ///@name Protected LifeCycle ///@{ ///@} private : ///@name S t a t i c Member Va riabl es ///@{ ///@} ///@name Member Variables ///@{ ///@} ///@name S e r i a l i z a t i o n ///@{ friend class Serializer ; virtual void save ( S e r i a l i z e r& r S e r i a l i z e r ) const override { KRATOS_SERIALIZE_SAVE_BASE_CLASS( r S e r i a l i z e r , Element ) ; } virtual void load ( S e r i a l i z e r& r S e r i a l i z e r ) o v erri de { KRATOS_SERIALIZE_LOAD_BASE_CLASS( r S e r i a l i z e r , Element ) ; } ///@} ///@name Private Operations ///@{ ///@} ///@name Private Access ///@{ ///@} ///@name Private Inquiry ///@{ 149
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis ///@} ///@name Un a c c e s s i b l e methods ///@{ ///@} }; ///@} ///@name Type D ef in it i o n s ///@{ ///@} ///@name Input and output ///@{ /// input stream function /∗i n l i n e st d : : istream& operator >> ( std : : istream& rIStream , Fluid2DASGS& rThis ) ; ∗/ /// output stream function /∗i n l i n e st d : : ostream& operator << ( st d : : ostream& rOStream , const Fluid2DASGS& rThis ) { rThis . P ri nt In fo ( rOStream ) ; rOStream << std : : endl ; rThis . PrintData ( rOStream ) ; return rOStream ; }∗/ ///@} }// namespace Kratos . #endif // 150
Bibliography [1] Manzán, M; Oñate, E. Stabilization Techniques for Finite Element Analysis of Convection-Diffusion Problems of convection-diffusion problems, 2000. [2] Moran, M; Shapiro H N.Engineering Thermodynamics, 2006. [3] Schafer, M; Turek, S.Benchmark Computations of Laminar Flow Around a Cylinder, 1996. [4] Cotela, J.Applications of Turbulence Modeling in Civil Engineering, 2016. [5] Kundu, P K. Fluid Mechanics, 2012. [6] Callister, W ;Rethwisch, D. Material Science and Engineering, 2012. [7] Donea, J; Huerta, A. Finite Element Methods for Flow Problems, 2003. [8] John, V; Tambulea, A. on Finite Element Variational Multiscale Methods for Incompressible Turbulent Flows, 2006. [9] Layton, W; Nathaniel N; Monika, T. Numerical Analysis of Modular Regularization Methods for the Navier Stokes Equations, 2013. [10] John, V; Kindl, A. A Variational Multiscale Method for Turbulent Flow Simulation with Adaptive Large Scale Space, 2010. [11] Cengel, YA. Heat and Mass Transfer. A Practical Approach, 2006. [12] Fay, J. Introduction to Fluid Mechanics Copyrighted Material Introduction to Fluid Mechanics, 2004. [13] Ambrosio, J. Multibody Dynamics: Bridging for Multidisciplinary Applications, 2004. [14] Reddy, J. The Finite Element Method in Heat Transfer and Fluid Dynamics, 2017. 151
Numerical Study of a Cross-Flow Heat Exchanger Master Thesis [15] Riera Santacreu, M. Estudi Experimental i Numeric d’un Bescanviador de Calor, 2017. [16] Skare, B.Numerical Methods for Solving Complex Heat Exchanger Models in Transient Operation, 2014. [17] Oñate, E. Introduction to the Finite Element Method, 2008. [18] Murthy, J. Numerical Methods in Heat , Mass and Momentum Transfer, 2002. [19] Suhas, V. Numerical Heat Transfer and Fluid Flow, 1990. [20] Hughes, T ;Calo, V ; Scovazzi, G. Variational and Multiscale Methods in Turbulence, 2005. [21] Israel, U. Implementation of an Algorithm for Data Transfer on the Fluid- Structure Interface between Non-Matching Meshes in Kratos and an Algorithm for the Generation of an Interface between GiD and Kratos, 2006. [22] Kuzmin, D. A Guide to Numerical Methods for Transport Equations, 2010. [23] Holman, J; Lloyd, J ; Fluid Mechanics, 2010. [24] Ursula, R, Computational Multiscale Methods for Turbulent Single and Two- Phase Flows, 2013. [25] Hughes, T ;Franca, L; Scovazzi, G, Multiscale and Stabilized Methods, 2004. 152