FLUENT 6.1 Magnetohydrodynamics (MHD) Module Manual

Size: px
Start display at page:

Download "FLUENT 6.1 Magnetohydrodynamics (MHD) Module Manual"

Transcription

1 FLUENT 6.1 Magnetohydrodynamics (MHD) Module Manual February 2003

2 Licensee acknowledges that use of Fluent Inc. s products can only provide an imprecise estimation of possible future performance and that additional testing and analysis, independent of the Licensor s products, must be conducted before any product can be finally developed or commercially introduced. As a result, Licensee agrees that it will not rely upon the results of any usage of Fluent Inc. s products in determining the final design, composition or structure of any product. Copyright c 2003 by Fluent Inc. All rights reserved. No part of this document may be reproduced or otherwise used in any form without express written permission from Fluent Inc. Airpak, FIDAP, FLUENT, GAMBIT, Icepak, MixSim, and POLYFLOW are registered trademarks of Fluent Inc. All other products or name brands are trademarks of their respective holders. Fluent Inc. Centerra Resource Park 10 Cavendish Court Lebanon, NH 03766

3 Contents 1 Introduction Technical Background Introduction Magnetic Induction Method Case 1: B0 generated in non-conducting media Case 2: B0 generated in conducting media Electric Potential Method Implementation Solving Induction Equations Solving Electric Potential Equation Calculation of MHD Variables MHD Interaction with Fluid Flows MHD Interaction with Discrete Phase Model General UDFs Using the FLUENT MHD Model MHD Module Installation Installing the MHD Model on Unix/Linux Platforms Installing the MHD Model on NT/Windows Platforms Getting Started With the MHD Model MHD Modeling External Applied Field User-Defined Scalar Allocation Solving User-Defined Scalars c Fluent Inc. January 24, 2003 i

4 CONTENTS Allocating User-Defined Memory Source Terms Boundary Conditions MHD/DPM Interaction General UDF Set-up Solving and Post-processing MHD Model Initialization Iteration Post-processing Limitations A Guidelines For Using the FLUENT MHD Model A-1 A.1 Installing the MHD Module A-1 A.2 An Overview of Using the MHD Module A-2 B Definitions of the Magnetic Field B-1 B.1 Magnetic Field Definitions B-1 C External Magnetic Field Data Format C-1 C.1 Magnetic Field Data Format C-1 ii c Fluent Inc. January 24, 2003

5 Chapter 1. Introduction Magnetohydrodynamics (MHD) refers to the interaction between an applied electromagnetic field and a flowing, electrically-conductive fluid. The FLUENT MHD model allows you to analyze the behavior of electrically conducting fluid flow under the influence of constant (DC) or oscillating (AC) electromagnetic fields. The externally-imposed magnetic field may be generated either by selecting simple built-in functions or by importing a user-supplied data file. For multiphase flows, the MHD model is compatible with both the discrete phase model (DPM) and the volume-of-fluid (VOF) approach in FLUENT, including the effects of a discrete phase on the electrical conductivity of the mixture. This document describes the FLUENT MHD model. Chapter 2 provides theoretical background information. Chapter 3 summarizes the UDF-based software implementation. Instructions for getting started with the model are provided in Chapter 4. Appendix A provides an condensed overview on how to use the MHD model, while Appendix B contains defintions for the magnetic field, and Appendix C describes the external magnetic field data format. c Fluent Inc. January 24,

6 Introduction 1-2 c Fluent Inc. January 24, 2003

7 Chapter 2. Technical Background 2.1 Introduction The coupling between the fluid flow field and the magnetic field can be understood on the basis of two fundamental effects: the induction of electric current due to the movement of conducting material in a magnetic field, and the effect of Lorentz force as the result of electric current and magnetic field interaction. In general, the induced electric current and the Lorentz force tend to oppose the mechanisms that create them. Movements that lead to electromagnetic induction are therefore systematically braked by the resulting Lorentz force. Electric induction can also occur in the presence of a time-varying magnetic field. The effect is the stirring of fluid movement by the Lorentz force. Electromagnetic fields are described by Maxwell s equations: B = 0 (2.1-1) E = B t (2.1-2) D = q (2.1-3) H = j + D t (2.1-4) where B (Tesla) and E (V/m) are the magnetic and electric fields, respectively, and H and D are the induction fields for the magnetic and electric fields, respectively. q (C/m 3 ) is the electric charge density, and j (A/m 2 ) is the electric current density vector. The induction fields H and D are defined as: H = 1 µ B (2.1-5) D = ε E (2.1-6) c Fluent Inc. January 24,

8 Technical Background where µ and ε are the magnetic permeability and the electric permittivity, respectively. For sufficiently conducting media such as liquid metals, the electric charge density q and the displacement current D t are customarily neglected [1]. In studying the interaction between flow field and electromagnetic field, it is critical to know the current density j due to induction. Generally, two approaches may be used to evaluate the current density. One is through the solution of a magnetic induction equation; the other is through solving an electric potential equation. 2.2 Magnetic Induction Method In the first approach, the magnetic induction equation is derived from Ohm s law and Maxwell s equation. The equation provides the coupling between the flow field and the magnetic field. In general, Ohm s law that defines the current density is given by: j = σ E (2.2-1) where σ is the electrical conductivity of the media. For fluid velocity field U in a magnetic field B, Ohm s law takes the form: j = σ( E + U B) (2.2-2) From Ohm s law and Maxwell s equation, the induction equation can be derived as: B t + ( U ) B = 1 µσ 2 B + ( B ) U (2.2-3) From the solved magnetic field B, the current density j can be calculated using Ampere s relation as: j = 1 µ B (2.2-4) Generally, the magnetic field B in a MHD problem can be decomposed into the externally imposed field B 0 and the induced field b due to fluid motion. Only the induced field b needs to be solved. From Maxwell s equations, the imposed field B 0 satisfies the following equation: 2 B0 µσ B 0 t = 0 (2.2-5) 2-2 c Fluent Inc. January 24, 2003

9 2.2 Magnetic Induction Method where σ is the electrical conductivity of the media in which field B 0 is generated. Two cases need to be considered Case 1: B0 generated in non-conducting media. In this case the imposed field B 0 satisfies the following conditions: B 0 = 0 (2.2-6) 2 B0 = 0 (2.2-7) With B = B 0 + b, the induction equation (Equation 2.2-3) can be written as: b t + ( U ) b = 1 µσ 2 b + (( B0 + b) ) U ( U ) B 0 B 0 t (2.2-8) The current density is given by: j = 1 µ b (2.2-9) Case 2: B0 generated in conducting media. In this case the conditions given in Equations and are not true. Assuming that the electrical conductivity of the media in which field B 0 is generated is the same as that of the flow, i.e. σ = σ, from Equations and the induction equation can be written as: b t + ( U ) b = 1 µσ 2 b + (( B0 + b) ) U ( U ) B 0 (2.2-10) and the current density is given by: j = 1 µ ( B 0 + b) (2.2-11) For the induction equation Equations or , the boundary conditions for the induced field are given by: b = {bn b t1 b t2 } T = b (2.2-12) c Fluent Inc. January 24,

10 Technical Background where the subscripts denote the normal and tangential components of the field and b is specified by the user. For an electrically insulating boundary, as j n = 0 at the boundary, from Ampere s relation one has b t1 = b t2 = 0 at the boundary. 2.3 Electric Potential Method The second approach for the current density is to solve the electric potential equation and calculate the current density using Ohm s law. In general, the electric field E can be expressed as: E = ϕ A t (2.3-1) where ϕ and A are the scalar potential and the vector potential, respectively. For a static field and assuming b << B 0, Ohm s law given in Equation can be written as: j = σ( ϕ + ( U B 0 )) (2.3-2) For sufficiently conducting media, the principle of conservation of electric charge gives: The electric potential equation is thus given by: j = 0 (2.3-3) 2 ϕ = ( U B 0 ) (2.3-4) The boundary condition for the electric potential ϕ is given by: ϕ n = ( U B 0 ) boundary n (2.3-5) for an insulating boundary, where n is the unit vector normal to the boundary, and ϕ = ϕ 0 (2.3-6) for a conducting boundary, where ϕ 0 is the specified potential at the boundary. The current density can then be calculated from Equation c Fluent Inc. January 24, 2003

11 2.3 Electric Potential Method With the knowledge of the induced electric current, the MHD coupling is achieved by introducing additional source terms to the fluid momentum equation and energy equation. For the fluid momentum equation, the additional source term is the Lorentz force given by: F = j B (2.3-7) which has units of N/m 3 in the SI system. For the energy equation, the additional source term is the Joule heating rate given by: which has units of W/m 3. Q = 1 j j (2.3-8) σ For charged particles in an electromagnetic field, the Lorentz force acting on the particle is given by: F p = q( E + ν p B) (2.3-9) where q is the particle charge density (Coulomb/m 3 ) and ν p is the particle velocity. The force F p has units of N/m 3. For multiphase flows, assuming that the electric surface current at the interface between phases can be ignored, the electric conductivity for the mixture is given by: σ m = i σ i ν i (2.3-10) where σ i and ν i are respectively the electric conductivity and volume fraction of phase i. σ m is used in solving the induction equations. c Fluent Inc. January 24,

12 Technical Background 2-6 c Fluent Inc. January 24, 2003

13 Chapter 3. Implementation Implementation of the MHD model is achieved through the user-defined function (UDF) facility of FLUENT. The UDF module is linked to the FLUENT code as a run-time library. The model is accessed through a number of UDF schemes. The magnetic induction equation given by Equations or and the electric potential equation given by Equation are solved through user-defined scalar (UDS) transport equations. Other model-related variables such as the external magnetic field data, current density, Lorentz force and Joule heat are stored through user-defined memory locations. The MHD-related parameters are input through a combination of new, modified, and standard FLUENT graphical user interface (GUI) panels, as described in Chapter Solving Induction Equations The magnetic induction equation is solved as a set of user-defined scalar transport equations. The magnetic field vector is represented by its Cartesian components, each solved as a user-defined scalar. The convection and the diffusion terms of the scalar equations are defined through user functions DEFINE UDS FLUX(mhd flux,..., ns) and DEFINE DIFFUSIVITY (mhd magnetic diffusitivity,..., ns) respectively. The user-defined scalar equation is identified by the scalar index ns. The source terms to the induction equations are implemented through user function DEFINE SOURCE(mhd magnetic source,..., eqn), where eqn identifies the scalar equations. For unsteady cases, the additional unsteady source term is introduced through user function DEFINE UDS UNSTEADY(mhd magnetic tsource,..., ns), where ns identifies the scalar being solved. The wall boundary conditions are implemented through user profile functions (DEFINE PROFILE()). Two types of boundary condition, i.e. insulating and conducting, exist and each can be applied to the Cartesian components of the induced magnetic field vector. c Fluent Inc. January 24,

14 Implementation 3.2 Solving Electric Potential Equation The electric potential is also solved through a user-defined scalar equation. The convection and the diffusion terms for the equation are introduced through user functions DEFINE UDS FLUX(mhd flux,..., ns) and DEFINE DIFFUSIVITY (mhd magnetic diffusitivity,..., ns), respectively. The equation is identified by the scalar index ns. The source term for the equation is implemented through user function DEFINE SOURCE (mhd phi source,..., eqn). A user profile function DEFINE PROFILE(mhd phi bc ins,...) is used for defining the insulating wall boundary condition for the equation. 3.3 Calculation of MHD Variables Apart from the Cartesian components of the magnetic field vectors and the electric potential function, which are stored as user-defined scalars, other MHD-related variables include the induced electric current density vector, induced electric field vector, the Lorentz force vector and Joule heat. These variables are stored in user-defined memory locations. Updating of MHD variables is accessed through the user function DEFINE ADJUST(mhd adjust,...). The variables are updated at the start of each iteration using the solved induced magnetic field from the previous iteration. 3.4 MHD Interaction with Fluid Flows Additional source terms due to the magnetic induction are added to the flow momentum and energy equations as user defined source terms. For the momentum equation, user function DEFINE SOURCE(mhd momentum source,..., eqn) is used to introduce the Lorentz force to the equation, where eqn identifies the Cartesian component of the fluid momentum. For the energy equation, the additional source due to Joule heating is added through user function DEFINE SOURCE(mhd energy source,..., eqn), where eqn is the energy equation index. 3.5 MHD Interaction with Discrete Phase Model In discrete phase modelling, the Lorentz force acting on charged particles is introduced through the user function DEFINE DPM BODY FORCE(mhd dpm force,...). User function DEFINE DPM SOURCE(mhd dpm source,...) is used to update the volume fraction of the discrete phase inside a fluid cell and the volume-weighted electric conductivity of the discrete phase. 3-2 c Fluent Inc. January 24, 2003

15 3.6 General UDFs 3.6 General UDFs Several general UDFs are used as part of the MHD model implementation. DEFINE INIT(mhd init,...) is an initialization function called during the general case initialization to set up the external magnetic field and initialize MHD model parameters and variables. DEFINE ADJUST(mhd adjust,...) is called at the start of each iteration. It is used to adjust the magnetic boundary conditions and update MHD related variables and properties. DEFINE ON DEMAND(mhd initialise,...) is used to initialise the MHD model on a solved or partially solved case. DEFINE ON DEMAND(mhd update B0,...) is used to re-initialise the external magnetic field. DEFINE ON DEMAND(mhd init dpm,...) is used to initialise MHD variables that are used in FLUENT s discrete phase model. c Fluent Inc. January 24,

16 Implementation 3-4 c Fluent Inc. January 24, 2003

17 Chapter 4. Using the FLUENT MHD Model This chapter provides basic instructions to install the magnetohydrodynamics (MHD) module and solve MHD problems in FLUENT. It assumes that you are already familiar with standard FLUENT features, including the user-defined function procedures described in the FLUENT UDF Manual. Appendix A also outlines the general procedure for using the MHD model. 4.1 MHD Module Installation The MHD model consists of a number of user-defined functions (UDFs) and scheme routines which need to be loaded and activated before calculations can be performed. These files are provided with your standard installation of FLUENT. They can be found in your installation area in a directory called addons/mhd1.0. In order to load these files, you will need to either provide the complete path to your installation area when loading, or create a local copy of the files (or a link for UNIX platforms) Installing the MHD Model on Unix/Linux Platforms To install the MHD model on Unix and Linux platforms, it is recommended that you create links in your local working directory to the files you will need. This can be done with the commands: ln -s <path>/addons/mhd1.0/lib/mhd-parameter.scm mhd-parameter.scm ln -s <path>/addons/mhd1.0 libudf where <path> represents the location in the file system where FLUENT is installed. c Fluent Inc. January 24,

18 Using the FLUENT MHD Model Installing the MHD Model on NT/Windows Platforms To install the MHD model on Windows platforms, you will need to create copies of the MHD model folder and the files you will need in your local working folder. From your installation area, you will have to copy the folder <path>\addons\mhd1.0 locally and rename it to libudf. Inside this folder are three different ports of the MHD module, one for each type of parallel message passing supported (net, smpi and vmpi). You will need to select one of the folders; ntx86 net, ntx86 smpi, or ntx86 vmpi you wish to use and rename it as ntx86. If you are only running in serial mode, you can rename any of the folders. Also you will need to copy the file <path>\addons\mhd1.0\lib\mhd-parameter.scm locally. Note that <path> represents the location in the file system where FLUENT is installed. 4.2 Getting Started With the MHD Model The graphical user interface for the MHD module is designed in the form of a Scheme program. You load this program into FLUENT by using the File Read Scheme... menu and selecting the file mhd-parameter.scm from the Select File panel. MHD parameters you subsequently input are stored in the FLUENT case file. When restarting a MHD calculation, it is important that the Scheme program for the user interface is loaded before the case/data files are read into FLUENT. The MHD model library should be pre-compiled using the standard procedure for compiling FLUENT UDFs. You install this library into FLUENT using the Define User-Defined Functions Compiled... menu. Enter libudf in the Compiled UDFs panel to open the library. The name of the UDF library will be saved with the FLUENT case file. The library is opened automatically when the case file is subsequently read into FLUENT. 4-2 c Fluent Inc. January 24, 2003

19 4.3 MHD Modeling 4.3 MHD Modeling External Applied Field Following installation, you can access the MHD Model Setup panel using the Define User-Defined MHD Model... menu. This panel is designed for setting up the external magnetic field conditions. Two options are available for setting up the external magnetic field. One is to patch the computational domain with a constant or varying magnetic field in the form of sinusoidal or square wave. Figure shows the set-up panel for patching the external magnetic field. Definitions for the sinusoidal and square forms of patched magnetic field are provided in Appendix B. The second option for setting the external magnetic field is to read it from a magnetic data file that you provide. Figure shows the sub-panel that appears if you select Import for the B0 Input Option in Figure The magnetic data can be generated using a third-party program such as MAGNA. The required format of the magnetic field data file is given in Appendix C. When using the Import option, set the B0 Data Media flag in Figure to Non- Conducting or Conducting, depending on the assumptions used in generating this data. (These choices correspond to Case 1 and Case 2, respectively, as discussed in Section 2.2.) User-Defined Scalar Allocation You need to specify the number of user-defined scalars using the Define User-Defined Scalars... menu. The number of user-defined scalars is five for a 2-D case and seven for a 3-D case. Table lists the names of the scalars and the variables they represent in the MHD model. In the User-Defined Scalars panel (Figure 4.3.3), set the Number of User-Defined Scalars to 5 or 7 depending on whether the case is 2-D or 3-D. For the user-defined scalar transport equation, a user flux function and, for unsteady cases, a user unsteady function should also be set. In the User-Defined Scalars panel, select mhd flux as Flux Function and mhd magnetic tsource as Unsteady Function. To set the diffusion term for the user-defined scalar equations, you use the Define Materials... menu. In the Materials panel, select the user-defined option for UDS Diffusivity and select mhd magnetic diffusivity from the User-Defined Functions list. Figure shows the Materials panel. c Fluent Inc. January 24,

20 Using the FLUENT MHD Model Figure 4.3.1: The MHD Model Setup Panel for Patching an External Magnetic Field Table 4.3.1: Identification of User-Defined Scalars Scalar Description 2-D Scalar-0 X component of induced magnetic field (b x ) Scalar-1 Y component of induced magnetic field (b y ) Scalar-2 X component of imposed magnetic field (B 0x ) Scalar-3 Y component of imposed magnetic field (B 0y ) Scalar-4 Electric potential (ϕ) 3-D Scalar-0 X component of induced magnetic field (b x ) Scalar-1 Y component of induced magnetic field (b y ) Scalar-2 Z component of induced magnetic field (b z ) Scalar-3 X component of imposed magnetic field (B 0x ) Scalar-4 Y component of imposed magnetic field (B 0y ) Scalar-5 Z component of imposed magnetic field (B 0z ) Scalar-6 Electric potential (ϕ) 4-4 c Fluent Inc. January 24, 2003

21 4.3 MHD Modeling Figure 4.3.2: The MHD Model Setup Panel for Importing an External Magnetic Field Figure 4.3.3: The User-Defined Scalars Panel c Fluent Inc. January 24,

22 Using the FLUENT MHD Model Figure 4.3.4: Setting Up UDS Diffusivity in the Materials Panel 4-6 c Fluent Inc. January 24, 2003

23 4.3 MHD Modeling Solving User-Defined Scalars Not all the scalars you define in the User-Defined Scalars panel need to be solved in a MHD calculation. The selection of which user scalars to solve will depend on the approach used in solving a MHD problem and the type of problem. As mentioned in Chapter 2, a MHD problem may be approached by solving the magnetic induction equation or the electric potential equation. For steady cases where the induced magnetic field ( b) is much smaller than the imposed field ( B 0 ), the electric potential approach can be used. In this case only the electric potential scalar needs to be solved. In the magnetic induction approach, the scalars representing the induced magnetic field ( b) must be solved. Scalars representing the imposed magnetic field ( B 0 ) are not solved. The user-defined scalars that do not need to be solved can be de-selected from the Equations list in the Solution Controls panel, shown in Figure 4.3.5, accessed from the Solve Controls Solution... menu. Figure 4.3.5: The Solution Controls Panel c Fluent Inc. January 24,

24 Using the FLUENT MHD Model Allocating User-Defined Memory The number of user-defined memory locations used by the MHD module is 27. You must allocate this memory using the Define User-Defined Memory... menu. In the User-Defined Memory panel set the Number of User-Defined Memory Locations to 27 or more, as shown in Figure Table gives the names of the user memory locations and the variables they represent in the MHD model. Figure 4.3.6: The User-Defined Memory Panel Source Terms MHD source terms should be defined for the momentum equation, energy equation, magnetic induction equations, and electric potential equation. You set these terms using the Define Boundary Conditions... menu. Select a fluid zone in the Boundary Conditions panel and set appropriate userdefined functions in the Fluid panel (Figure 4.3.7). Repeat this process for each fluid zone in the model that represents an electrically conductive fluid. UDFs for all MHD source terms are listed in Table Boundary Conditions You set electromagnetic boundary conditions with user-defined functions at the relevant boundaries using the Define Boundary Conditions... menu. Figure shows the panel for a Wall boundary condition set-up. For all scalars except the electric potential, set the User Defined Scalar Boundary Condition to Specified Value and set the corresponding User Defined Scalar Boundary Value to the appropriate user function listed in Table 4.3.4, according to the type of boundary condition required. For the electric potential equation, a user-defined function is required only for electrically insulating boundaries. In this case, the User Defined Scalar Boundary Condition for the 4-8 c Fluent Inc. January 24, 2003

25 4.3 MHD Modeling Table 4.3.2: Identification of User-Defined Memory Locations User Memory Description UDM-0 Magnitude of the induced magnetic field ( b ) UDM-1 Magnitude of the imposed magnetic field ( B 0 ) UDM-2 X component of the induced electric current density (j x ) UDM-3 Y component of the induced electric current density (j y ) UDM-4 Z component of the induced electric current density (j z ) UDM-5 Magnitude of the induced electric current density ( j ) UDM-6 X component of the induced electric field (E x ) UDM-7 Y component of the induced electric field (E y ) UDM-8 Z component of the induced electric field (E z ) UDM-9 Magnitude of the induced electric field ( E ) UDM-10 X component of Lorentz force (F x ) UDM-11 Y component of Lorentz force (F y ) UDM-12 Z component of Lorentz force (F z ) UDM-13 Magnitude of Lorentz force ( F ) UDM-14 Joule heating rate (Q) UDM-15 x component of the real part of the external AC magnetic field UDM-16 y component of the real part of the external AC magnetic field UDM-17 z component of the real part of the external AC magnetic field UDM-18 x component of the imaginary part of the external AC magnetic field UDM-19 y component of the imaginary part of the external AC magnetic field UDM-20 z component of the imaginary part of the external AC magnetic field UDM-21 Electrical conductivity of the overall fluid mixture (σ m ) UDM-22 Volume-weighted discrete phase electrical conductivity UDM-23 Volume concentration of the discrete phase UDM-24 x component of the external DC magnetic field UDM-25 y component of the external DC magnetic field UDM-26 z component of the external DC magnetic field c Fluent Inc. January 24,

26 Using the FLUENT MHD Model Figure 4.3.7: The Fluid Panel Showing Source Term Selection Table 4.3.3: MHD Source Term UDFs Equation X Momentum Y Momentum Z Momentum Energy User-defined scalar-0 User-defined scalar-1 User-defined scalar-2 User-defined scalar-3 User-defined scalar-4 User-defined scalar-5 User-defined scalar-6 User-Defined Function mhd momentum source mhd momentum source mhd momentum source mhd energy source mhd magnetic source mhd magnetic source mhd magnetic source (3-D) or mhd B0 source (2-D) mhd B0 source mhd B0 source (3-D) or mhd phi source (2-D) mhd B0 source (3-D) mhd phi source (3-D) 4-10 c Fluent Inc. January 24, 2003

27 4.3 MHD Modeling electric potential scalar should be set to Specified Flux, and User Defined Scalar Boundary Value set to user function mhd phi bc. For conducting boundaries, set the User Defined Scalar Boundary Condition to Specified Value and set User Defined Scalar Boundary Value to the desired numerical value of the potential function without referencing a UDF. Figure 4.3.8: Setting Up the MHD Model in the Wall Panel MHD/DPM Interaction You can simulate MHD for a two-phase mixture using the discrete phase model (DPM) described in the FLUENT User s Guide. To include Lorentz force and/or Joule heating effects on the discrete second phase, you access the Discrete Phase Model panel (Figure 4.3.9), through the Defined Models Discrete Phase... menu. In the User-Defined Functions box, select mhd dpm force as the UDF for Body Force and mhd dpm source as the UDF for Source. c Fluent Inc. January 24,

28 Using the FLUENT MHD Model Figure 4.3.9: Setting Up the MHD Model in the Discrete Phase Model Panel 4-12 c Fluent Inc. January 24, 2003

29 4.3 MHD Modeling Table 4.3.4: MHD Boundary Condition UDFs Scalar Insulating Wall Conducting Wall 2-D Scalar-0 mhd BX bc ins mhd BX bc con Scalar-1 mhd BY bc ins mhd BY bc con Scalar-2 mhd B0X bc mhd B0X bc Scalar-3 mhd B0Y bc mhd B0Y bc Scalar-4 mhd phi bc* (none - set value directly) 3-D Scalar-0 mhd BX bc ins mhd BX bc con Scalar-1 mhd BY bc ins mhd BY bc con Scalar-2 mhd BZ bc ins mhd BZ bc con Scalar-3 mhd B0X bc mhd B0X bc Scalar-4 mhd B0Y bc mhd B0Y bc Scalar-5 mhd B0Z bc mhd B0Z bc Scalar-6 mhd phi bc* (none - set value directly) *(BC Type = Specified Flux) c Fluent Inc. January 24,

30 Using the FLUENT MHD Model General UDF Set-up To complete MHD problem set-up, you need to invoke two utility UDFs in the User- Defined Function Hooks panel accessed from the Define User-Defined Function Hooks... menu. As shown in Figure , you should select mhd init and mhd adjust for Initialization Function and Adjust Function, respectively. Figure : Setting Up the UDFs in the User-Defined Function Hooks Panel 4.4 Solving and Post-processing MHD Model Initialization Initialization of the MHD model involves specifying the externally-imposed magnetic field and all MHD-related user-defined scalars and memory locations. Two approaches may be used for the model initialization. In the first approach, the MHD model is initialized along with the overall FLUENT case. The Hook Function mhd init is called during the initialization. This approach is used when the MHD model is to be activated at the start of the flow field calculation. In the second approach, the MHD model is initialized manually using the execute-ondemand UDF capability. This approach is used when MHD effects are added to a fully or partially solved flow field, or when the model parameters are changed during a MHD calculation. You can access the execute-on-demand user function using the Define User-Defined Execute On Demand c Fluent Inc. January 24, 2003

31 4.4 Solving and Post-processing menu. In the Execute On Demand panel (Figure 4.4.1), select mhd initialise from the function list and click Execute to run the function. If your problem involves MHD/DPM interactions, you should also execute the function mhd init dpm to initialize the DPMrelated user memory locations. Figure 4.4.1: The Execute On Demand Panel To change external magnetic field parameters such as the scale factor during a MHD calculation, you will need to update the imposed magnetic field. This can be performed by running the execute-on-demand UDF named mhd update B Iteration It is often an effective strategy to begin your MHD calculations using a previouslyconverged flow field solution. With this approach, the induction equations themselves are generally easy to converge. The under-relaxation factors for these equations can be set to , although for very strong magnetic fields smaller values may be needed. For the electric potential equation, the convergence is generally slow. However, the under-relaxation value for this equation should not be set to 1. As additional source terms are added to the momentum and energy equations, the under-relaxation factors for these equations should generally be reduced to improve the rate of convergence. In case of convergence difficulties, another helpful strategy is to use the B0 Scale Factor in the MHD Model Setup panel (Figure 4.3.1) to gradually increase the MHD effect to its actual magnitude through a series of restarts Post-processing You can use the standard post-processing facilities of FLUENT to display the results of a MHD calculation. Contours of MHD variables can be displayed using the Display Contours... menu. The MHD variables can be selected from the variable list. Vectors of MHD variables, such as the magnetic field vector and current density vector, can be displayed using the Display Vectors... menu as custom vectors. Custom vectors are defined through the Custom Vectors... button in the Vectors panel. In the Custom Vectors panel, the components of the vector c Fluent Inc. January 24,

32 Using the FLUENT MHD Model can be selected. The defined custom vector can be selected from the Vectors Of dropdown list in the Vectors panel. The color scheme used to display the vector can be selected from the Color By list. Figures and illustrate the settings for displaying the induced magnetic field vector, colored by its magnitude. For more information on the postprocessing variables available in the FLUENT MHD model, Table and lists the names of the user-defined scalars and user-defined memory locations and the variables they represent in the MHD model. Figure 4.4.2: The Vectors Panel 4-16 c Fluent Inc. January 24, 2003

33 4.4 Solving and Post-processing Figure 4.4.3: The Custom Vectors Panel c Fluent Inc. January 24,

34 Using the FLUENT MHD Model 4.5 Limitations Many MHD applications involve the simultaneous use of other advanced FLUENT capabilities such as solidification, free surface modeling with the volume of fluid (VOF) approach, DPM, Eulerian multiphase, etc. You should consult the latest FLUENT documentation for the limitations that apply to those features. In addition, you should be aware of the following limitations of the MHD capability. Currently the MHD equations can be solved only in Fluid zones. Solving in Solid zones is not possible. You must specify the MHD wall boundary conditions as either perfectly conducting or non-conducting, which implies that the conductivity of the wall material is either infinite or zero. It is not possible to model walls with a finite non-zero conductivity. As explained in Chapter 2, the MHD module assumes a sufficiently conductive fluid so that the charge density and displacement current terms in Maxwell s equations can be neglected. For marginally conductive fluids, this assumption may not be valid. Further information about this simplification is available in the bibliography. For the electromagnetic material properties including conductivity and permeability, only constant isotropic models are available. Although multiphase volume fractions affect the mixture conductivity, no dependence on temperature, species concentration, or field strength can be modeled. Sufficiently strong magnetic fields can cause the constant-permeability assumption to become invalid. You must specify the applied magnetic field directly. The alternative specification of an imposed electrical current is not supported. In the case of alternating-current (AC) magnetic fields, the capability has been designed for relatively low frequencies; explicit temporal resolution of each cycle is required. Although not a fundamental limitation, the computational expense of simulating high-frequency effects may become excessive due to small required time step size. Time-averaging methods to incorporate high-frequency MHD effects have not been implemented c Fluent Inc. January 24, 2003

35 Appendix A. Guidelines For Using the FLUENT MHD Model! This appendix provides a basic outline to installing the magnetohydrodynamics (MHD) module and solving MHD problems in FLUENT. While Chapter 4 covers much of the same material in greater detail, this appendix presents a set of guidelines for solving typical MHD problems with FLUENT, with occasional references to Chapter 4 where more information can be found. A.1 Installing the MHD Module Before using the MHD module, you first need to install the necessary files onto your computer. These files are provided with your standard installation of FLUENT. They can be found in your installation area in a directory called addons/mhd1.0. In order to load these files, you will need to either provide the complete path to your installation area when loading, or create a local copy of the files (or a link for UNIX platforms). For more information on installing the MHD model on UNIX and Windows, see Section 4.1. Once the MHD model is installed, beneath the mhd directory there are two subdirectories: a lib directory, and a directory corresponding to your specific architecture, ntx86 for example. The lib directory holds a Scheme file called mhd-parameter.scm that contains the MHD module graphical interface. The specific architecture directory, ntx86 for example, contains the following subdirectories that hold various FLUENT files: 2d 2ddp 3d 3ddp 2d_host 2ddp_host 3d_host 3ddp_host 2d_node 2ddp_node 3d_node 3ddp_node c Fluent Inc. January 24, 2003 A-1

36 Guidelines For Using the FLUENT MHD Model A.2 An Overview of Using the MHD Module To use the MHD module in a FLUENT simulation, follow the general guidelines: 1. Start FLUENT. To begin modeling your MHD simulation, you need to start an appropriate FLUENT session. Choose from either the 2d, 3d, 2ddp, 3ddp, or the parallel version of FLUENT.! 2. Read in the Scheme graphical interface. The graphical user interface for the MHD module is designed in the form of a Scheme program. You load this program into FLUENT by using the following menu selection: File Read Scheme... and selecting the file mhd-parameter.scm from the Select File panel. MHD parameters you subsequently input are stored in the FLUENT case file. When restarting a MHD calculation, it is important that the Scheme program for the user interface is loaded before the mesh, case, or data files are read into FLUENT. Following installation, you can access the MHD Model Setup panel using the Define User-Defined MHD Model... menu. This panel is designed for setting up the external magnetic field conditions. For more information, see Section Read in a mesh file or a non-mhd case file. You can have FLUENT read in your mesh file or a previously saved (non-mhd) case file. Note that if you read in a new mesh file, you need to perform the appropriate grid check and grid scale procedures. 4. Read in the user-defined function library. The MHD model library should be pre-compiled using the standard procedure for compiling FLUENT user-defined functions (UDFs). You install this library into FLUENT using the Compiled UDFs panel. Define User-Defined Functions Compiled... Select the Load option and enter libudf in the Compiled UDFs panel to open the library. The name of the UDF library will be saved with the FLUENT case file. The library is opened automatically when the case file is subsequently read into FLUENT. A-2 c Fluent Inc. January 24, 2003

37 A.2 An Overview of Using the MHD Module!!! 5. Define user-defined scalars. You need to specify the number of user-defined scalars using the User-Defined Scalars panel. Define User-Defined Scalars... The number of user-defined scalars is five for a 2-D case and seven for a 3-D case. In the User-Defined Scalars panel, set the Number of User-Defined Scalars to 5 or 7 depending on whether the case is 2-D or 3-D. For the user-defined scalar transport equation, a user flux function should be set. For unsteady cases, a user unsteady function should also be set. In the User-Defined Scalars panel, select mhd flux as Flux Function and mhd magnetic tsource as Unsteady Function. To set the diffusion term for the user-defined scalar equations, you use the Materials panel. Define Materials... In the Materials panel, select the user-defined option for UDS Diffusivity and select mhd magnetic diffusvity from the User-Defined Functions list.. Note the spelling of the UDS-Diffusivity user-defined function. For more information, see Chapter 4. Also, refer to Table for a list of scalars and the variables they represent in the MHD model. 6. Define user-defined memories. The number of user-defined memory locations used by the MHD module is 27. You must allocate this memory using the User-Defined Memory panel. Define User-Defined Memory... In the User-Defined Memory panel set the Number of User-Defined Memory Locations to 27 or more. Table lists the names of the user memory locations and the variables they represent in the MHD model. 7. Define user-defined function hooks. As part of the MHD problem set-up, you need to invoke two utility UDFs through the User-Defined Function Hooks panel. Define User-Defined Function Hooks... Select mhd init and mhd adjust for Initialization Function and Adjust Function, respectively. c Fluent Inc. January 24, 2003 A-3

38 Guidelines For Using the FLUENT MHD Model 8. Define the FLUENT solver parameters. You define the FLUENT solver parameters using the Solver panel. Define Models Solver... (a) Under Solver, select the Segregated option. (b) Under Formulation, select the Implicit option. (c) Under Space, select either the 3D or 2D option. (d) For steady cases, under Time, select the Steady option. (e) For unsteady cases, under Time, select the Unsteady option. (f) For unsteady cases, under Unsteady Formulation, select the 1st-Order Implicit option. 9. Define the turbulence model. A FLUENT MHD analysis involves using a turbulence model in your simulation. It is recommended that you start with the standard k-ɛ turbulence model. Turbulence models are set using the Viscous Model panel. Define Models Viscous Activate the energy equation (optional). Depending on your particular model, you may need to enable the energy equation in your FLUENT simulation. The energy equation option can be found in the Energy panel. Define Models Energy Specify gravity (optional). Depending on your particular model, you may or may not want to enable gravity in your FLUENT simulation. The Operating Conditions panel contains the Gravity option that you can either select or deselect. Define Operating Conditions...! 12. Define source terms. MHD source terms should be defined for the momentum equation, energy equation, magnetic induction equations, and electric potential equation. You set these terms using the Fluid panel via the Boundary Conditions panel. Define Boundary Conditions... Select a fluid zone in the Boundary Conditions panel and set appropriate user-defined functions in the Fluid panel. Repeat this process for each fluid zone in the model that represents an electrically conductive fluid. You can use the Copy option in the the Boundary Conditions panel to repeatedly attach source UDFs to other fluid zones. UDFs for all MHD source terms are listed in Table A-4 c Fluent Inc. January 24, 2003

39 A.2 An Overview of Using the MHD Module! 13. Define boundary conditions. You set electromagnetic boundary conditions with user-defined functions at the relevant boundaries using the Boundary Conditions panel. Define Boundary Conditions... For all scalars except the electric potential, set the User Defined Scalar Boundary Condition to Specified Value and set the corresponding User Defined Scalar Boundary Value to the appropriate user function according to the type of boundary condition required. Boundary condition user-defined functions are listed in Table For the electric potential equation, a user-defined function is required only for electrically insulating boundaries. In this case, the User Defined Scalar Boundary Condition for the electric potential scalar should be set to Specified Flux, and User Defined Scalar Boundary Value set to the user function mhd phi bc. For conducting boundaries, set the User Defined Scalar Boundary Condition to Specified Value and set User Defined Scalar Boundary Value to the desired numerical value of the potential function without referencing a UDF. 14. Initialize the MHD Module. To initialize the MHD model, you must specify the externally-imposed magnetic field and all MHD-related user-defined scalars and memory locations. Two approaches may be used for the model initialization. In the first approach, the MHD model is initialized along with the overall FLUENT case. The hook function mhd init is called during the initialization. This approach is used when the MHD model is to be activated at the start of the flow field calculation. In the second approach, the MHD model is initialized manually using the executeon-demand UDF capability. This approach is used when MHD effects are added to a fully or partially solved flow field, or when the model parameters are changed during a MHD calculation. You can access the execute-on-demand user function using the Execute On Demand panel. Define User-Defined Execute On Demand... In the Execute On Demand panel, select mhd initialise from the function list and click Execute to run the function. If your MHD problem involves interactions with the discrete phase model (DPM), you should also execute the function mhd init dpm to initialize the DPM-related user memory locations. For more information on MHD/DPM interaction, see Section To change external magnetic field parameters, such as the scale factor, during a MHD calculation, you will need to update the imposed magnetic field. This can be performed by running the execute-on-demand UDF named mhd update B0. c Fluent Inc. January 24, 2003 A-5

40 Guidelines For Using the FLUENT MHD Model! Make sure the proper function is displayed in the Function drop-down list before clicking Execute. 15. Fine-tune the FLUENT solver parameters. Not all the scalars you define in the User-Defined Scalars panel need to be solved for in a MHD calculation. The selection of which user scalars to solve will depend on the approach used in solving a MHD problem and the type of problem. In the magnetic induction approach, the scalars representing the induced magnetic field ( b) must be solved. Scalars representing the imposed magnetic field ( B 0 ) are never solved for in FLUENT. You can choose which user-defined scalars do not need to be solved using the Solution Controls panel. Solve Controls Solution... The user-defined scalars that do not need to be solved can be de-selected from the Equations list in the Solution Controls panel. For the magnetic induction approach, use the following solution control settings: In the Solution Controls panel, deselect User defined scalar-3 to User defined scalar-6 from the Equations listings. Under Under-Relaxation Factors, enter 0.9 for the remaining user defined scalars (i.e., User defined scalar-0 to User defined scalar-2). Choose other under-relaxation factors as usually done in FLUENT(e.g., Momentum:0.7, Pressure:0.3, Energy:1.0). 16. Run the FLUENT MHD simulation. It is often an effective strategy to begin your MHD calculations using a previouslyconverged flow field solution. With this approach, the induction equations themselves are generally easy to converge. For more information, see Chapter Process the solution data. You can use the standard post-processing facilities of FLUENT to display the results of a MHD calculation. Contours of MHD variables can be displayed using the Display Contours... menu. The MHD variables can be selected from the variable list. Vectors of MHD variables, such as the magnetic field vector and current density vector, can be displayed using the Display Vectors... menu as custom vectors. For more information, see Chapter 4. For more information on the postprocessing variables available in the FLUENT MHD model, Table and lists the names of the user-defined scalars and user-defined memory locations and the variables they represent in the MHD model. A-6 c Fluent Inc. January 24, 2003

41 Appendix B. Field Definitions of the Magnetic B.1 Magnetic Field Definitions The sinusoidal form of the magnetic field is defined as: B 0 = B 0 + A 0 cos(2 πft K R + φ) K = 1 { 1 λ cos α i + 1 cos β j + 1 } cos γ k (B.1-1) where B 0 is the mean vector, A 0 is the amplitude vector, K is defined as the propagation vector, R is the position vector of an arbitrary point. cos α, cos β and cos γ are the x, y and z direction cosines respectively. The quantities f, λ, and φ are the frequency, wavelength, and phase offset, respectively. For a non-moving field the propagation vector is zero. For a static field only applies. The square form of the magnetic field is defined as: B 0 = B 0 + A 0 cos(2 πft K R + φ) cos(2 πft K R + φ) (B.1-2) The definition of the propagation vector is the same as for the sinusoidal form. c Fluent Inc. January 24, 2003 B-1

42 Definitions of the Magnetic Field B-2 c Fluent Inc. January 24, 2003

43 Appendix C. Format External Magnetic Field Data C.1 Magnetic Field Data Format The external magnetic field data file is in text format and of the following structure: MAG DAT A nx ny nz X1 Xn Y 1 Y n Z1 Zn nac F req BX re 1 BY re 1 BZ re 1 BX im 1 BY im 1 BZ im 1... BX re n BY re n BZ re n BX im n BY im n BZ im n The first line is an identification tag for the data file. The second line defines the number of data points in the x, y and z directions. The next three lines define the ranges in x, y and z directions. The data points are assumed to be evenly distributed along each direction. Line 6 defines the AC field flag and frequency. When nac = 0, the magnetic field is static. For AC field, nac = 1 and Freq is the frequency in Hz. The rest of the data file contains the magnetic field data points. Each line defines the components of the real and imaginary parts of the magnetic field vector on one data point. The data points are indexed as: l = i + nx ((j 1 ) + ny (k 1 )) i = 1,..., nx ; j = 1,..., ny ; k = 1,..., nz The data is listed in the ascending order from 1 to n, where n is the total number of data points given by n = nx ny nz. For magnetic fields comprised of both DC and AC fields, the entire file structure described above is repeated for the DC and AC parts. These two sections within the same file will be imported into FLUENT and stored separately. The order of the DC and AC sections of the file is not important. c Fluent Inc. January 24, 2003 C-1