You are on page 1of 38

Tutorial: Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Introduction
This tutorial describes the simulation process of non-premixed combustion in a direct injection natural gas engine. Direct injection natural gas engines are used in many heavy duty vehicles. Similar to diesel engines, high thermal eciency and power density is maintained in such direct injection natural gas engines. In such engines, natural gas is injected directly into the combustion chamber. Then the gas mixes with the high pressure air in the combustion chamber and combustion occurs. Due to the non-premixed nature of the combustion occurring in such engines, non-premixed combustion model of ANSYS FLUENT can be used to simulate the combustion process. The tutorial demonstrates how to do the following: Set up an in-cylinder (IC) case involving only a part of compression and power stroke with only a sector of mesh. Set up IC non-premixed combustion in ANSYS FLUENT. Use user-dened functions (UDF) to specify initial swirl and injection ow rate.

Prerequisites
This tutorial is written with the assumption that you have completed Tutorial 1 from ANSYS FLUENT 13.0 Tutorial Guide, and that you are familiar with the ANSYS FLUENT navigation pane and menu structure. Some steps in the setup and solution procedure will not be shown explicitly. In this tutorial, you will use the non-premixed combustion model and UDFs. For more information about this model, see Chapter 16, Modeling Non-Premixed Combustion in the ANSYS FLUENT 13.0 Users Guide. If you have not used UDFs before, see ANSYS FLUENT 13.0 UDF Manual.

Problem Description
The problem to be solved in this tutorial is shown in Figure 1. A 30 degree sector of a 4-stroke engine which corresponds to one fuel injector hole is modeled. Since combustion simulation is to be studied, the simulation starts at 20 degree crank angle (CA) before the

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

start of injection (SOI) and ends at 50 degree CA after top dead center (TDC). A simplied model of the engine with no valves is modeled since during the entire combustion process, both the valves remain closed.

Figure 1: Sector Geometry of a Direct Injection Natural Gas Engine

Setup and Solution Preparation


1. Copy the mesh le (natural gas-comb-CA0360.msh.gz) and the UDF source les (initialize.c, injection ch4.c) to your working folder. 2. Use FLUENT Launcher to start the 3D version of ANSYS FLUENT. For more information about FLUENT Launcher see Section 1.1.2, Starting ANSYS FLUENT Using FLUENT Launcher in the ANSYS FLUENT 13.0 Users Guide. 3. Enable Double-Precision in the Options list. 4. Click the UDF Compiler tab and ensure that the Setup Compilation Environment for UDF is enabled. The path to the .bat le which is required to compile the UDF will be displayed as soon as you enable Setup Compilation Environment for UDF. If the UDF Compiler tab does not appear in the FLUENT Launcher dialog box by default, click the Show Additional Options >> button to view the additional settings. The Display Options are enabled by default. Therefore, after you read in the mesh, it will be displayed in the embedded graphics window.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Step 1: Mesh 1. Read the mesh le (natural gas-comb-CA0360.msh). File Read Mesh... As the mesh le is read, ANSYS FLUENT will report the progress in the console. Step 2: General Settings 1. Dene the solver settings. General Transient

2. Check the mesh (see Figure 2). General Check Warnings will be displayed regarding unassigned interface zones, resulting in the failure of the mesh check. You do not need to take any action at this point, as this issue will be rectied when you dene the mesh interfaces in a later step.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Figure 2: Mesh Display

3. Scale the mesh. General Scale...

(a) Select mm from the View Length Unit In drop-down list. (b) Close the Scale Mesh dialog box.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Step 3: Dynamic Mesh 1. Set up IC parameters. Dynamic Mesh

(a) Enable the Dynamic Mesh option. (b) Disable Smoothing in the Mesh Methods group box. (c) Enable Layering in the Mesh Methods group box. (d) Click Settings... to open Mesh Method Settings dialog box.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

i. Enter 0.1 for Collapse Factor under Layering tab. ii. Click OK to close the Mesh Method Settings dialog box. (e) Enable In-Cylinder in the Options group box. (f) Click Settings... to open In-Cylinder Settings dialog box. i. Enter the values as shown in the Table 1. Parameter Crank Shaft Speed (rpm) Starting Crank Angle (deg) Crank Period (deg) Crank Angle Step Size (deg) Piston Stroke (mm) Connecting Rod Length (mm) Piston Stroke Cuto (mm) Minimum Valve Lift (mm) Value 2000 360 720 0.25 120 220 0 0

Table 1: Values for IC Parameters ii. Click OK to close In-Cylinder Settings dialog box.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

2. Set up dynamic zones. Dynamic Mesh (Dynamic Mesh Zones) Create/Edit... (a) Dene dynamic mesh zone for uid-outer.

i. Select uid-outer from the Zone Names drop-down list. ii. Ensure that Rigid Body is selected in the Type group box. iii. Ensure the selection of **piston-full** from the Motion UDF/Prole dropdown list under Motion Attributes tab. iv. Enter the values of X, Y, and Z as 0, 0, and 1 respectively. v. Click Create. (b) Dene dynamic mesh zone for bowl.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

i. Select bowl from the Zone Names drop-down list. ii. Retain the default settings for Motion Attributes tab. iii. Enter 0.8 mm for Cell Height under Meshing Options tab. iv. Click Create. (c) Dene dynamic mesh zone for bowl:019.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

i. Select bowl:017 from the Zone Names drop-down list. ii. Retain the default settings for Motion Attributes tab. iii. Retain 0.8 mm for Cell Height under Meshing Options tab. iv. Click Create. (d) Dene dynamic mesh zone for wall top outer.

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

i. Select wall top outer from the Zone Names drop-down list. ii. Select Stationary in the Type group box. iii. Retain 0.8 mm for Cell Height under Meshing Options tab. iv. Click Create. (e) Close the Dynamic Mesh Zones dialog box. 3. Create mesh interfaces. Mesh Interfaces Create/Edit...

10

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(a) Enter intf for Mesh Interface. (b) Select intf-inner from Interface Zone 1 list. (c) Select intf-outer from Interface Zone 2 list. (d) Click Create and close the Create/Edit Mesh Interfaces dialog box. 4. Create periodic boundary. (a) Create periodic boundary out of face zone period inner1 and period inner2 using the text command /grid/mz/make-periodic.
Periodic zone [()] period inner1 Shadow zone [()] period inner2 Rotational periodic? (if no, translational) [yes] Create periodic zones? [yes]

all 1296 faces matched for zones 12 and 11.

zone 11 deleted created periodic zones.

c ANSYS, Inc. October 11, 2010

11

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(b) Create periodic boundary out of face zone period outer1 and period outer2 using the text command /grid/mz/make-periodic.
Periodic zone [()] period outer1 Shadow zone [()] period outer2 Rotational periodic? (if no, translational) [yes] Create periodic zones? [yes]

all 779 faces matched for zones 14 and 13.

zone 13 deleted created periodic zones.

5. Check the mesh. General Check This ensures that the periodic boundary is correctly created. ANSYS FLUENT shows the progress in the console (as shown below). Ensure that the stored rotation angle is equal to the average rotation angle.
Checking periodic boundaries. Periodic Zone 12: average rotation angle (deg) = -30.000 (-30.000 to -30.000) stored zone rotation angle (deg) stored axis = -30.000

, (0.000000e+00, 0.000000e+00, 1.000000e+00)

stored origin, (0.000000e+00, 0.000000e+00, 0.000000e+00) Periodic Zone 14: average rotation angle (deg) = -30.000 (-30.000 to -30.000) stored zone rotation angle (deg) stored axis = -30.000

, (0.000000e+00, 0.000000e+00, 1.000000e+00)

stored origin, (0.000000e+00, 0.000000e+00, 0.000000e+00)

6. Perform a mesh motion preview. (a) Display the mesh. Graphics and Animations 12 Mesh Set Up...

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

i. Click Display and close the Mesh Display dialog box. (b) Preview the mesh motion. Dynamic Mesh Preview Mesh Motion...

i. Enter 1360 for Number of Time Steps . ii. Click Apply and then click Preview. (c) Save the case le (natural gas-comb-CA0700.cas.gz). File Write Case... (d) Examine the UDF inputs as shown in Appendix A. (e) Examine the UDF inputs for injection ch4.c as shown in Appendix B. Open initialize.c, injection ch4.c in text editor. For this tutorial, the swirl ratio is 2, swirl axis is z coordinate, and the swirl origin is (0, 0, 0). Step 4: Models: Combustion Model Setup 1. Set up the combustion model. (a) Read the case le (natural gas-comb-CA0700.cas.gz). File Read Case... (b) Compile and load the UDF library. Dene User-Dened Functions Compiled...

c ANSYS, Inc. October 11, 2010

13

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(c) Click Add... to open Select File dialog box. i. Select initialize.c and injection ch4.c from the Source Files list. ii. Click OK to close the Select File dialog box. (d) Click Build to build the library. Ensure that the UDF source les are in same directory that contains your case and data les. (e) Click Load to close the Compiled UDFs dialog box. 2. Hook your model to the UDF library. Dene User-Dened Function Hooks... (a) Click Edit... for Initialization to open Initialization Functions dialog box.

i. Select my init function::libudf from the Available Initialization Functions list. ii. Click Add to add it in the Selected Initialization Functions list. iii. Click OK to close Initialization Functions dialog box. (b) Close User-Dened Function Hooks dialog box. 3. Enable the standard k-epsilon turbulence model. Models Viscous Edit...

(a) Select k-epsilon in the Model group box. (b) Retain the default settings and click OK to close Viscous Model dialog box.

14

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

4. Dene the species model. Models Species Edit...

(a) Select Non-Premixed Combustion in the Model group box. (b) Click the Chemistry tab.

i. Ensure Equilibrium is selected in the State Relation group box. ii. Select Non-Adiabatic in the Energy Treatment group box. iii. Enter 3000000 pascal for Equilibrium Operating Pressure. iv. Retain 0.1 for Fuel Stream Rich Flammability Limit. v. Enable Inlet Diusion and Compressibility Eects in the PDF Options group box.

c ANSYS, Inc. October 11, 2010

15

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(c) Click the Boundary tab.

i. Select Mole Fraction in the Specify Species in group box. ii. Enter the values as shown in the Table 2. Species ch4 n2 o2 Fuel 1 0 0 Oxid 0 0.78992 0.21008

Table 2: Fuel and Oxid Values for Species iii. Retain 300 K for Fuel and Oxid in the Temperature group box.

16

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(d) Click the Table tab.

i. Retain the default settings. ii. Click Calculate PDF Table. iii. Click Display PDF Table... to open PDF Table dialog box.

A. Click Display (see Figure 3).

c ANSYS, Inc. October 11, 2010

17

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Figure 3: PDF Table B. Close the PDF Table dialog box. (e) Click OK to close the Species Model dialog box. 5. Save the PDF le. File Write PDF... (a) Enter natural gas-comb-CA0700.pdf.gz for the lename. (b) Click OK to close Select File dialog box. Step 7: Boundary Conditions Boundary Conditions inlet

18

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

1. Select mass-ow-inlet from the Type drop-down list. The question dialog box appears to conrm the change of type from axis to mass-owinlet. Click Yes to open the Mass-Flow Inlet dialog box.

c ANSYS, Inc. October 11, 2010

19

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(a) Ensure that Absolute is selected from the Reference Frame drop-down list. (b) Select Mass Flux from the Mass Flow Specication Method drop-down list. (c) Select udf fuel ux::libudf from the Mass Flux drop-down list. (d) Select Normal to Boundary from the Direction Specication Method drop-down list. (e) Select Intensity and Length Scale from the Specication Method drop-down list. (f) Enter 2 mm for Turbulent Length Scale. (g) Click the Species tab. i. Enter 1 for Mean Mixture Fraction. ii. Retain 0 for Mixture Fraction Variance. (h) Click OK to close Mass-Flow Inlet dialog box. Step 8: Solution 1. Set the solution parameters. Solution Methods

20

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(a) Select PISO from the Scheme drop-down list. (b) Set Skewness Correction to 0. (c) Retain Standard for Pressure drop-down list. (d) Select Second Order Upwind from the Momentum drop-down list. (e) Retain First Order Upwind for all other equations. 2. Set the under-relaxation factors. Solution Controls

(a) Set the Under-Relaxation Factors for Pressure to 0.5. 3. Enable the plotting of residuals during calculation. Monitors Residuals Edit...

c ANSYS, Inc. October 11, 2010

21

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(a) Enter 100 for Iterations to Plot. (b) Click OK to close the Residual Monitors dialog box. 4. Set up surface monitor for mass ow rate. Monitors (Surface Monitors) Create...

(a) Enable Plot and Write in the Options group box. (b) Enter mass flow rate inlet.out for the File Name. (c) Select Flow Time from X Axis drop-down list. 22

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(d) Select Time Step from the Every drop-down list. (e) Select Mass Flow Rate from Report Type drop-down list. (f) Select inlet from Surfaces list. (g) Click OK to close the Surface Monitor dialog box. 5. Set up volume monitor for mass-averaged temperature. Monitors (Volume Monitors) Create...

(a) Enable Plot and Write in the Options group box. (b) Enter vol temp.out for the File Name. (c) Select Flow Time from X Axis drop-down list. (d) Select Time Step from the Every drop-down list. (e) Select Mass-Average from the Report Type drop-down list. (f) Select Temperature... and Static Temperature from the Field Variable drop-down list. (g) Select uid-inj, uid-outer, and uid-inner from the Cell Zones list. (h) Click OK to close the Volume Monitor dialog box. 6. Set up volume monitor for mass-averaged pressure. Monitors (Volume Monitors) Create... (a) Enable Plot and Write in the Options group box. (b) Enter vol press.out for the File Name. (c) Select Flow Time from X Axis drop-down list.

c ANSYS, Inc. October 11, 2010

23

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(d) Select Time Step from the Every drop-down list. (e) Select Mass-Average from the Report Type drop-down list. (f) Select Pressure... and Static Pressure from the Field Variable drop-down list. (g) Select uid-inj, uid-outer, and uid-inner from the Cell Zones list. (h) Click OK to close the Volume Monitor dialog box. Solution Initialization Initialize the variables carefully because the simulation will start at CA = 700 degrees, which is almost the end of the compression stroke. Assuming adiabatic compression and atmospheric conditions (i.e. atmospheric pressure = 1 and temperature = 300 k) at the start of compression stroke (i.e. at BDC or 360 CA), calculate the pressure and the temperature at 700 CA. For this engine, the Gause Pressure and Temperature at 700 CA can be assumed as 1898675 pascal and 690 K respectively. 7. Initialize the solution.

(a) Enter 1898675 pascal for Gauge Pressure. 24

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(b) Retain 1 m2 /s2 for Turbulent Kinetic Energy and Turbulent Dissipation Rate. (c) Enter 690 K for Temperature. (d) Click Initialize. 8. Set auto save option. Calculation Activities (a) Enter 20 for Autosave Every (Time Steps). (b) Click Edit... to open Autosave dialog box.

i. Retain the default settings. ii. Click OK to close Autosave dialog box. Step 9: Postprocessing 1. Create a new surface for animation. Surface Iso-Surface...

c ANSYS, Inc. October 11, 2010

25

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(a) Select Mesh... and Abs. Angular Coordinate from the Surface of Constant drop-down list. (b) Enter 90 for Iso-Values. (c) Enter theta=90 for New Surface Name. (d) Click Create and close the Iso-Surface dialog box. 2. Dene the plot for animation view (plot-view). Graphics and Animations Views...

(a) Enter plot-view under Save Name and click Save. (b) Close the Views dialog box. 3. Execute commands for the animation setup. Calculation Activities (Execute Commands) Create/Edit...

26

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

(a) Set the Dened Commands to 4. (b) Enable Active for command-1. i. Set Every to 5. ii. Select Time Step from the When drop-down list. iii. Enter /dis/sw 3 /dis/view/rv plot-view /dis/set/cont/fc y /dis/set/cont/surf (theta=90) /dis/cont ch4 0 1 for Command. (c) Enable Active for command-2. i. Set Every to 5. ii. Select Time Step from the When drop-down list. iii. Enter /display/hard-copy "ch4-%t.tif" for Command. (d) Enable Active for command-3. i. Set Every to 5. ii. Select Time Step from the When drop-down list. iii. Enter /display/cont temp 600 2500 for Command. (e) Enable Active for command-4. i. Set Every to 5. ii. Select Time Step from the When drop-down list. iii. Enter /display/hard-copy "temp-%t.tif" for Command. (f) Click OK to close the Execute Commands dialog box. 4. Save the hardcopy of display. File Save Picture...

c ANSYS, Inc. October 11, 2010

27

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(a) Select TIFF in the Format group box. (b) Select Color in the Coloring group box. (c) Click Apply and close the Save Picture dialog box. 5. Display the contours of mass fraction of ch4. Graphics and Animations Contours Set Up...

(a) Enable Filled in the Options group box. (b) Select Species... and Mass fraction of ch4 from the Contours of drop-down list. (c) Select theta=90 from the Surfaces list. (d) Click Display (see Figure 4).

28

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Figure 4: Contours of Mass Fraction at 700 CA 6. Run the calculation. Run calculation

(a) Enter 200 for Number of Time Steps. (b) Retain 20 for Max Iterations/Time Step. 29

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

(c) Click Calculate. The plots are as shown in Figures 5 and Figures 6.

Figure 5: Pressure as a Function of Time

Figure 6: Temperature as a Function of Time

30

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

7. Save the case and data les (natural gas-comb-CA0700-final.cas/dat.gz). At the end of the simulation you have: (a) Ti les for ch4 mass fraction and temperature at dierent crank angles. (b) Auto-saved case and data les. Contours of Mass Fraction of CH4 and Temperature at Dierent Crank Angles

Figure 7: CA = 721.25 (deg)

Figure 8: CA = 723.75 (deg)

Figure 9: CA = 725 (deg)

Figure 10: CA = 727.5 (deg)

c ANSYS, Inc. October 11, 2010

31

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Figure 11: CA = 730 (deg)

Figure 12: CA = 732.5 (deg)

Figure 13: CA = 735 (deg)

Figure 14: CA = 737.5 (deg)

Figure 15: CA = 740 (deg)

Figure 16: CA = 742.5 (deg)

32

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Figure 17: CA = 721.25 (deg)

Figure 18: CA = 723.75 (deg)

Figure 19: CA = 726.25 (deg)

Figure 20: CA = 728.75 (deg)

Figure 21: CA = 732.5 (deg)

Figure 22: CA = 735 (deg)

c ANSYS, Inc. October 11, 2010

33

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Figure 23: CA = 737.5 (deg)

Figure 24: CA = 738.75 (deg)

Figure 25: CA = 741.25 (deg)

Figure 26: CA = 743.75 (deg)

Figure 27: CA = 746.25 (deg)

Figure 28: CA = 750 (deg)

34

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Appendix A
Examine the UDF input in initialize.c.
/************************************************************************************** UDF for IC initialization with swirl For IC flow, if only combustion and power stroke is of interest. The initial condition normally contains swirl flow. This udf provides a tool to initialize the flow field with user specified swirl ratio How to use the udf: - Set up your IC case - Modify the user inputs part of the udf. - Build the library - Hook the DEFINE_INIT udf - Initialize your flow field Note: - UDF works in 2d axisymmetry, and 3d. - Pure 2d case does not have swirl and thus not supported (a warning will be given). - UDF works in both serial and parallel. **************************************************************************** # include "udf.h" # include "sg.h" # define RPM RP_Get_Real("dynamesh/in-cyn/crank-rpm") /********************************* User input starts / /* Initial swirl ratio and swirl axis*/ static real init_swirl_ratio=2.0; static real swirl_axis[ND_ND]={0, 0, 1}; static real swirl_origin[ND_ND]={0, 0, 0}; /* This variable defines whether the inialization occurs to the whole domain or just some cell zones */ enum { whole_domain, defined_cell_zones }method = defined_cell_zones; /* If defined_cell_zones is used in the above, then specify cell zone ID list for initialization. -1 is a flag so please keep it. */ static int Zone_ID[]={3, 4, -1}; /********************************** User input ends / static void initialize_cell_zone(Thread * t, real * omega) { cell_t c; real xc[ND_ND], x[ND_ND]; #if RP_2D static int counter=0; #endif /* loop over all cells */ begin_c_loop(c,t) { C_CENTROID(xc,c,t); NV_VV(x,=,xc,-,swirl_origin);

c ANSYS, Inc. October 11, 2010

35

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

#if RP_2D if (rp_axi) { C_U(c,t)=NV_CROSS_X(omega, x); C_V(c,t)=NV_CROSS_Y(omega, x); C_W(c,t)=NV_CROSS_Z(omega, x); } else { if(counter == 0) { Message0("\nNo initialization for pure 2D. counter++; } } #else C_U(c,t)=NV_CROSS_X(omega, x); C_V(c,t)=NV_CROSS_Y(omega, x); C_W(c,t)=NV_CROSS_Z(omega, x); #endif } end_c_loop(c,t) } DEFINE_INIT(my_init_function, domain) { Thread *t; int i; real omega[ND_ND], mag;

Needs to turn on 2d axisymmetric with swirl!\n");

/* Normalize swirl axis */ mag=NV_MAG(swirl_axis); NV_S(swirl_axis, /=, mag); if (RP_Get_Boolean("dynamesh/models/in-cylinder?")==TRUE) { NV_VS(omega, =, swirl_axis, *, RPM/60.*2.*M_PI*init_swirl_ratio); if(method == whole_domain) { /* loop over all cell threads in the domain */ thread_loop_c (t,domain) { initialize_cell_zone(t, omega); } } else if (method == defined_cell_zones) { i=0; while(Zone_ID[i]>=0) { t=Lookup_Thread(domain, Zone_ID[i]); initialize_cell_zone(t, omega); i++; } } else { Message0("\n\nWrong method for initialization calculation--aborting!!\n"); exit(0); } Init_Face_Flux(domain); } else { Message0("\nIC not turned on. } } No initialization is performed.\n");

36

c ANSYS, Inc. October 11, 2010

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Mo

Appendix B
Examine the UDF input in injection ch4.c.
#include "udf.h" # define RPM RP_Get_Real("dynamesh/in-cyn/crank-rpm") real real real real real fuel_injected = 7.4e-6; CAD = 20; CAP = 2; injection_CA = 720; inlet_area = 4.969325e-7;

static real fuel_mass_flow(real theta) { real fuel_mass_flow_rate_max, mdot; fuel_mass_flow_rate_max = 6*RPM*fuel_injected/(CAD-CAP); if(theta<=CAP) { mdot = fuel_mass_flow_rate_max/CAP*theta; } else if(theta<=(CAD-CAP)) { mdot = fuel_mass_flow_rate_max; } else if(theta<CAD) { mdot = (fuel_mass_flow_rate_max - 0)/(-CAP)*(theta-CAD); } else { mdot = 0; } if(mdot<0) mdot = 0; return mdot; }

DEFINE_PROFILE(fuel_flux, thread, i) { real CA; face_t f; CA = CURRENT_TIME*RPM*6.0+RP_Get_Real("dynamesh/in-cyn/crank-start-angle"); begin_f_loop(f,thread) { F_PROFILE(f,thread,i) = fuel_mass_flow(CA - injection_CA)/inlet_area; } end_f_loop(f,thread) /* Message0("\n CA: %10.2f, in_CA: %10.2f, flow: %12.3e \n", CA, injection_CA, fuel_mass_flow (CA - injection_CA)); */ }

c ANSYS, Inc. October 11, 2010

37

Simulate Combustion in Direct Injection Natural Gas Engine Using Non-Premixed Combustion Model

Summary
In this tutorial, you used ANSYS FLUENT to model combustion process in a direct injection natural gas engine. The tutorial explained entire process from setting up the dynamic mesh model for an IC engine to setting up the non-premixed model for combustion in the engine. It also demonstrated the process of creating and using PDF tables.

38

c ANSYS, Inc. October 11, 2010

You might also like