Sei sulla pagina 1di 35

Tutorial: Simulate In-Cylinder Premixed Combustion Using ECFM Model

Introduction
For spark-ignited (SI) engines and some natural gas combustion engines, fuel and air are mixed before entering into the combustion chamber. At the spark event, the mixture can be assumed to be homogeneous and the combustion process to be premixed. This tutorial demonstrates how to do the following: Set up in-cylinder (IC) premixed combustion. Set up the spark model. Use the user-dened functions (UDFs) to modify laminar ame speed. Use UDF for some IC postprocessing.

Prerequisites
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. It is also assumed that you are familiar with ANSYS FLUENT moving deforming mesh (MDM) layering approach. For more information see Section 11.6, Using Dynamic Meshes in ANSYS FLUENT 13.0 Users Guide.

Problem Description
This tutorial considers a 2D axi-symmetric geometry of the IC engine cylinder conguration. Simulation starts at IVC and ends at EVO, hence there are no valves involved. The schematic is as shown in Figure 1. The initial conguration of the system has piston at TDC, hence rst mesh motion is performed to bring the piston to IVC position.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Figure 1: Schematic

Setup and Solution Preparation


1. Copy the mesh le (IC premixed com.msh.gz) and the UDF source les (initialize.c, laminar flame speed.c, and work.c) to your working folder. 2. Use FLUENT Launcher to start the 2D 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 Environment 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 Environment tab does not appear in the FLUENT Launcher dialog box by default, click the Show More 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 Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Step 1: Mesh 1. Read the mesh le (IC premixed com.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

(a) Select Transient in the Time list. (b) Select Axisymmetric Swirl in the 2D Space list. 2. Check the mesh (see Figure 2). General Check ANSYS FLUENT will perform various checks on the mesh and will report the progress in the console. Ensure that the minimum volume reported is a positive number.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Figure 2: Mesh Display

3. Scale the mesh. General Scale...

(a) Select mm from the Mesh Was Created In drop-down list. (b) Select mm from the View Length Unit In drop-down list. (c) Click Scale and close the Scale Mesh dialog box.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Step 3: Dynamic Mesh 1. Set up IC parameters. Dynamic Mesh (a) Enable the Dynamic Mesh option.

i. Disable Smoothing in the Mesh Methods group box. ii. Enable Layering in the Mesh Methods group box. iii. Click Settings... to open Mesh Method Settings dialog box. A. Retain the default settings under Layering tab. B. Click OK to close the Mesh Method Settings dialog box. iv. Enable In-Cylinder in the Options group box. v. Click Settings... to open Options dialog box. A. Enter the values as shown in the following table.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

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) B. Click OK to close Options dialog box. 2. Set up dynamic zones.

Value 3000 360 720 0.25 80 140 0 0

Dynamic Mesh (Dynamic Mesh Zones) Create/Edit... (a) Dene dynamic mesh zone for uid. i. Select uid from the Zone Names drop-down list. ii. Ensure 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. Ensure that the values of X and Y in Valve Piston Axis group box are 1 and 0 respectively. v. Click Create. (b) Dene dynamic mesh zone for piston.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

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

i. Select top from the Zone Names drop-down list. ii. Select Stationary in the Type group box. iii. Enter 1 mm for Cell Height under Meshing Options tab. iv. Click Create and close Dynamic Mesh Zones dialog box. 3. Perform a mesh motion preview. Dynamic Mesh Preview Mesh Motion...

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(a) Enter 840 for Number of Time Steps. (b) Ensure Display Mesh is enabled in the Options group box. (c) Click Preview. (d) Close the Mesh Motion dialog box after the preview is done. At Crank Angle Step Size of 0.25 degree, a mesh motion of 840 steps will bring the mesh to CA=570, the starting point of our combustion simulation. 4. Save the case le (IC premixed com CA570.cas.gz). File Write Case... 5. Examine the UDF inputs for initialize.c as shown in Appendix A. 6. Examine the UDF inputs for work.c as shown in Appendix B. 7. Examine the UDF inputs for laminar flame speed.c as shown in Appendix C. Open the les, initialize.c, work.c, and laminar flame speed.c using a text editor. For this tutorial, the swirl ratio is 3, swirl axis is x coordinate, and the swirl origin is (0, 0). For this tutorial, there is no need to modify the UDF input. Step 4: Models 1. Set up the combustion model. (a) Compile and load the UDF library. Dene User-Dened Functions Compiled... (b) Click Add... and select the les, initialize.c, laminar flame speed.c, and work.c.

(c) Click OK to close the Select File dialog box. (d) Click Build to build the library. Note: Make sure that the UDF source les are in same directory that contain the case and data les. (e) Click Load to close the Compiled UDFs dialog box.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

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. (b) Click Edit... for Adjust to open Adjust Functions dialog box. i. Select my T u::libudf from the Available Initialization Functions list. ii. Click Add to add it in the Selected Initialization Functions list. iii. Click OK. (c) Click Edit... for Execture At End to open Execture At End Functions dialog box. i. Select output results::libudf from the Available Initialization Functions list. ii. Click Add to add it in the Selected Initialization Functions list. iii. Click OK. (d) Click Edit... for Read Data to open Read Data Functions dialog box. i. Select read data::libudf from the Available Initialization Functions list. ii. Click Add to add it in the Selected Initialization Functions list. iii. Click OK. (e) Click Edit... for Write Data to open Write Data Functions dialog box. i. Select write data::libudf from the Available Initialization Functions list. ii. Click Add to add it in the Selected Initialization Functions list. iii. Click OK.

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(f) Click OK to close the User-Dened Function Hooks dialog box. 3. Set the user-dened memory location. Dene User-Dened Memory...

(a) Increase Number of User-Dened Memory Locations from 0 to 1. (b) Click OK to close the User-Dened Memory dialog box. 4. Enable the standard k-epsilon turbulence model. Models Viscous Edit...

(a) Select k-epsilon (2 eqn) in the Model group box to open Viscous Model dialog box. (b) Retain the default settings and click OK to close Viscous Model dialog box. 5. Dene the species model. Models Species Edit...

10

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(a) Select Premixed Combustion in the Model group box. (b) Select Non-Adiabatic in the Premixed Combustion Model Options group box. (c) Select Extended Coherent Flame Model from the Premixed Model group box. (d) Select meneveau from the ITNFS Treatment drop-down list. (e) Click OK. The information dialog box will appear informing that available material properties or methods have changed, asking you to conrm the property values. Click OK to close the Information dialog box.

6. Set up the spark ignition model. Models Spark Ignition Edit...

(a) Set Number of Sparks to 1. (b) Click Dene... to open the Set Spark Ignition dialog box.

c Fluent Inc. February 28, 2011

11

Simulate In-Cylinder Premixed Combustion Using ECFM Model

i. Select Fixed Spark Size in the Model group box. ii. Retain selection of Circle in the Shape group box. iii. Enter 715 (deg) for Start Time. iv. Enter 0.01 (s) for Diusion Time. v. Click OK to close the Set Spark Ignition dialog box. (c) Close the Spark Ignition dialog box. Step 5: Materials Dene the material properties. Materials Fluid Create/Edit...

12

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

1. Select ideal-gas from the Density drop-down list. 2. Select piecewise-polynomial from the Cp (Specic Heat) drop-down list. The PiecewisePolynomial Prole dialog box opens. (a) Set Range to 2.

(b) Retain the default settings. (c) Click OK to close Piecewise-Polynomial Prole dialog box. 3. Select user-dened from the Laminar Flame Speed drop-down list.

c Fluent Inc. February 28, 2011

13

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(a) Select laminar ame speed from the User-Dened Functions dialog box. This will hook Metghalchi and Keck model to calculate laminar ame speed. In ANSYS FLUENT this model is now available internally. To use it, you have to select metghalchi-keck-law from the drop-down list and then methane-air from the combustion mixture dialog box. (b) Click OK to close the User-Dened Functions dialog box.. 4. Enter 5e+07 (j/kg) for Heat of Combustion. 5. Enter 0.0363 for Unburnt Fuel Mass Fraction. 6. Click Change/Create and close the Create/Edit Materials dialog box. Step 6: Boundary Conditions Boundary Conditions axis

1. Select axis from the Type drop-down list. The question dialog box will appear to conrm the change of type of axis from wall to axis. Click Yes to open the Axis dialog box. 14

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(a) Click OK to close the Axis dialog box. Step 7: Solution 1. Set the solution parameters. Solution Methods

(a) Select PISO from the Scheme drop-down list. (b) Set Skewness Correction to 0. (c) Select PRESTO! from the Pressure drop-down list.

c Fluent Inc. February 28, 2011

15

Simulate In-Cylinder Premixed Combustion Using ECFM Model

2. Set the Under-Relaxation Factors for Pressure to 0.5. Solution Controls

3. Enable the plotting of residuals during calculation. Monitors Residuals Edit...

(a) Set the Convergence Absolute Criteria for continuity to 0.1. (b) Click OK to close the Residual Monitors dialog box.

16

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

4. Initialize the solution. Solution Initialization

(a) Enter 0 for Progress Variable and Flame Area Density. (b) Retain other default initial values. (c) Click Initialize. 5. Set auto save option. Calculation Activities (a) Enter 90 for Autosave Every (Time Steps).

c Fluent Inc. February 28, 2011

17

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(b) Click Edit... to open Autosave dialog box.

i. Enter an appropriate le name (IC premixed com CA570.gz). ii. Click OK to close the Autosave dialog box. If required, you can set the volume monitors for volume-averaged pressure/temperature. Monitors (Volume Monitors) Create... Step 9: Animation Setup 1. Mirror the view across the axis. Graphics and Animations Views...

(a) Select axis from the Mirror Planes list. (b) Click Apply.

18

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

2. Display the mesh (see Figure 3). Graphics and Animations Mesh Set Up...

Figure 3: View Setup

3. 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.

c Fluent Inc. February 28, 2011

19

Simulate In-Cylinder Premixed Combustion Using ECFM Model

4. Display the contours of progress variables. Graphics and Animations Contours Set Up...

(a) Enable Filled in the Options group box. (b) Select Premixed Combustion... and Progress Variable from the Contours of dropdown list. (c) Click Display and close the Contours dialog box. 5. Execute commands for the animation setup. Calculation Activities (Execute Commands) Create/Edit...

20

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

(a) Set the Dened Commands to 2. (b) Enable Active for command-1. i. Set Every to 4. ii. Select Time Step from the When drop-down list. iii. Enter /dis/sw 1 /dis/view/rv plot-view /dis/cont premixc 0 1 for Command. (c) Enable Active for command-2. i. Set Every to 4. ii. Select Time Step from the When drop-down list. iii. Enter /dis/save-picture ./flame %t.tif for Command. (d) Click OK to close the Execute Commands dialog box. 6. Save the hardcopy of display. File Save Picture...

(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. 7. Save the case and data les (IC premixed com CA570 0000.cas/dat.gz). File Write Case & Data 8. Run the calculation. Run calculation (a) Enter 1120 for Number of Time Steps. (b) Click Calculate.

c Fluent Inc. February 28, 2011

21

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Step 10: Postprocessing At the end of the simulation, you have TIFF les for the contours of progress variable at dierent crank angles. Figures 45 show some of the TIFF les. You can use these ti les for animation.

Figure 4: Combustion Sequence 1

Figure 4: Combustion Sequence 2

Figure 4: Combustion Sequence 3

Figure 4: Combustion Sequence 4

22

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Figure 5: Combustion Sequence 5

Figure 5: Combustion Sequence 6

Figure 5: Combustion Sequence 7

Figure 5: Combustion Sequence 8

Figure 5: Combustion Sequence 9


c Fluent Inc. February 28, 2011

Figure 5: Combustion Sequence 10 23

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Appendix A: UDF for initialize.c


This shows the UDF for IC initialization with swirl (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" # define RPM RP_Get_Real("dynamesh/in-cyn/crank-rpm") /********************************* User input starts *****************************************/

/* Initial swirl ratio and swirl axis*/ static real init_swirl_ratio=3.0; static real swirl_axis[ND_ND]={1, 0}; static real swirl_origin[ND_ND]={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 = whole_domain; /* 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[]={2, -1}; /********************************** User input ends ******************************************/ static void initialize_cell_zone(Thread * t, real * omega) { cell_t c; real xc[ND_ND], x[ND_ND]; static int counter=0; /* loop over all cells */ begin_c_loop(c,t) { C_CENTROID(xc,c,t); NV_VV(x,=,xc,-,swirl_origin);

24

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM 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); } % \end{minipage}

% \pagebreak else { if(counter == 0) { Message0("No initialization for pure 2D. counter++; } }

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

#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; /* 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++; } }

*/

c Fluent Inc. February 28, 2011

25

Simulate In-Cylinder Premixed Combustion Using ECFM Model

{ else { Message0("Wrong method for initialization calculation--aborting!!"); exit(0); } Init_Face_Flux(domain); } else { Message0("IC not turned on. } } % \end{minipage} No initialization is performed.");

26

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Appendix B: UDF for work.c.


This shows the UDF for IC indicated work (work.c).

/********************************************************************************************* UDF for IC indicated work This UDF does the following - Calculate indicated work - Output volume as a function of CA - Output pressure as a function of CA - Output burnt fuel mass fraction as a function of CA How to use the udf: - Set up your case - Build the library - Hook the DEFINE_EXECUTE_AT_END udf - Hook the two DEFINE_RW_FILE udfs Note: - The indicated work will be saved with the data file. So, you CAN restart from a previously saved cas/dat and continue the run to obtain the indicated work. - UDF works in 2d, 2d axisymmetry, and 3d. And it works in both serial and parallel ***********************************************************************************************/ # include "udf.h" # define RPM RP_Get_Real("dynamesh/in-cyn/crank-rpm") /********************************* User input starts *****************************************/ /* Cell zone ID list for pressure output (cell zone ID for combustion chamber). so please keep it. */ static int Zone_ID[]={2, -1}; /* Face zone ID list for work output (face zone ID for the piston) */ static int Piston_ID[]={6, -1}; -1 is a flag

/********************************** User input ends ******************************************/ static real work=0, start_CA=0, end_CA=0; static int counter=0; /* Function to calculate cell volume. It takes care of 2d and 2d axisymmetric case as well. */ static real C_MYVOLUME(cell_t c, Thread *tc) { real factor=1.0; #if RP_2D if (rp_axi) factor=2*M_PI; #endif return C_VOLUME(c,tc)*factor; } /* Function to calculate face area. It takes care of 2d and 2d axisymmetric case as well. */ static void F_MYAREA(real * x, face_t f, Thread *tf) { real factor=1.0; F_AREA(x, f, tf);

c Fluent Inc. February 28, 2011

27

Simulate In-Cylinder Premixed Combustion Using ECFM Model

#if RP_2D if (rp_axi) factor=2*M_PI; #endif NV_S(x, *=, factor); } DEFINE_ON_DEMAND(Indicated_work) { if(counter==0) { Message0("\n\n********************** IC Indicated Work Results *****************************\n"); Message0("\nIndicated work calculation has not started. Please do at least one time step.\n"); Message0("\nStart CA :%5.2f (deg) End CA :%5.2f (deg) Work : %9.3e (J)", start_CA, end_CA, work); Message0("\n\n******************************************************************************\n"); } else { Message0("\n\n********************** IC Indicated Work Results *****************************\n"); Message0("\nIndicated work calculation started at :%7.2f (deg)", start_CA); Message0("\nIndicated work calculation finished at :%7.2f (deg)", end_CA); Message0("\nFor the above duration, the indicated work is :%12.4e (J)", work); Message0("\n\n******************************************************************************\n"); } } DEFINE_ON_DEMAND(reset) { counter=0; work=0; start_CA=0; end_CA=0; Message0("\n\n******************************** WARNING *************************************\n"); Message0("\nNote that this resets indicated work and the calculation start CA to zero."); Message0("\nPlease save the data file to save the new values."); Message0("\n\n******************************************************************************\n"); } DEFINE_EXECUTE_AT_END(output_results) { #if !RP_HOST int i; real pressure, volume, fmf, mass, work_one_dt, x[ND_ND]; Thread *tc, *tf; cell_t c; face_t f; FILE *fp_results; Domain* domain; domain=Get_Domain(1); #if PARALLEL if(I_AM_NODE_ZERO_P) #endif { if(!(fp_results=fopen("work.txt","a"))) { Message0("\nCan not open file-aborting!!"); exit(0); } } if(counter==0) { start_CA = (CURRENT_TIME-CURRENT_TIMESTEP)*RPM*6.0+RP_Get_Real("dynamesh/in-cyn/crank-start-angle");

28

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

#if PARALLEL if(I_AM_NODE_ZERO_P) #endif { fprintf(fp_results, " CA Volume Pressure Yfb Work\n"); } counter ++; } end_CA=CURRENT_TIME*RPM*6.0+RP_Get_Real("dynamesh/in-cyn/crank-start-angle"); #endif node_to_host_int_1(counter); node_to_host_real_2(start_CA, end_CA); #if !RP_HOST /* Calculate volume weighted pressure and burnt fuel mass fraction */ pressure=0; volume=0; fmf=0; mass=0; i=0; while(Zone_ID[i]>=0) { tc=Lookup_Thread(domain, Zone_ID[i]); begin_c_loop_int(c, tc) { pressure += C_P(c,tc) * C_MYVOLUME(c,tc); volume += C_MYVOLUME(c,tc); if(sg_premixed) { fmf += C_PREMIXC(c,tc) * C_R(c,tc) * C_MYVOLUME(c,tc); } mass += C_R(c,tc) * C_MYVOLUME(c,tc); } end_c_loop_int(c, tc) i++; } pressure = PRF_GRSUM1(pressure); volume = PRF_GRSUM1(volume); fmf = PRF_GRSUM1(fmf); mass = PRF_GRSUM1(mass); pressure /= volume; fmf /= mass; /* Calcualte work by piston. Only pressure force is accounted for and viscous force is neglected. */

work_one_dt=0; i=0; while(Piston_ID[i]>=0) { tf=Lookup_Thread(domain, Piston_ID[i]); begin_f_loop(f, tf) { F_MYAREA(x, f, tf); work_one_dt += CURRENT_TIMESTEP * F_P(f,tf) * NVD_DOT(x, WALL_F_GRID_VV(f, tf)[0], WALL_F_GRID_VV(f, tf)[1], WALL_F_GRID_VV(f, tf)[2]); } end_f_loop(f, tf) i++; }

c Fluent Inc. February 28, 2011

29

Simulate In-Cylinder Premixed Combustion Using ECFM Model

work_one_dt = PRF_GRSUM1(work_one_dt); work += work_one_dt; #endif node_to_host_real_1(work); #if !RP_HOST /* Output volume, pressure, burnt fuel mass fraction */ #if PARALLEL if(I_AM_NODE_ZERO_P) #endif { fprintf(fp_results, "%8.2f %12.4e %12.4e %12.4e %12.4e\n", end_CA, volume, pressure, fmf, work); fclose(fp_results); } #endif } DEFINE_RW_FILE(write_data, fp) { Message0("\nWriting user defined data to the data file...\n"); #if PARALLEL #if RP_HOST fprintf(fp, fprintf(fp, fprintf(fp, fprintf(fp, #endif #else fprintf(fp, fprintf(fp, fprintf(fp, fprintf(fp, #endif }

"\n%d", "\n%e", "\n%e", "\n%e",

counter); work); start_CA); end_CA);

"\n%d", "\n%e", "\n%e", "\n%e",

counter); work); start_CA); end_CA);

DEFINE_RW_FILE(read_data, fp) { Message0("\nReading user defined data from the data file...\n"); #if PARALLEL #if RP_HOST fscanf(fp, "%d", fscanf(fp, "%e", fscanf(fp, "%e", fscanf(fp, "%e", #endif #else fscanf(fp, fscanf(fp, fscanf(fp, fscanf(fp, #endif

&counter); &work); &start_CA); &end_CA);

"%d", "%e", "%e", "%e",

&counter); &work); &start_CA); &end_CA);

host_to_node_int_1(counter); host_to_node_real_3(work,start_CA,end_CA); }

30

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Appendix C: UDF for laminar flame speed.c


This shows the UDF to modify laminar ame speed for premixed combustion (laminar flame speed.c).

/********************************************************************************************* UDF to modify laminar flame speed for premixed combustion In Fluent Zimont model, the laminar flame speed by default is a constant. Laminar flame speed is a strong function of temperature, equivalence ratio. A udf is used to modify that to be a more realistic value. The correlation is from Metghalchi and Keck. How to use the udf: - Set up your premixed combustion case - Define one user defined memory - Modify the user input part of the udf - Build the library - Hook up the DEFINE_ADJUST function - Use the laminar_flame_speed udf in the material panel to replace the default constant value Note: - UDF works in 2d, 2d axisymmetry, and 3d. And it works in both serial and parallel ***********************************************************************************************/ # include "udf.h" /********************************* User input starts *****************************************/ /* Ydil is the mass fraction of diluent, included to account for any EGR product. */ static real Ydil = 0; /* Fuel type. Supported ones are methane, methanol, isooctane, RMFD_303_indolene. RMFD_303_indolene is a reserch fuel (also called indolene), which has a controlled composition simulating typical gasolines.*/ enum { methane, methanol, propane, isooctane, RMFD_303_indolene, FLAG }fuel = methane; /* Fuel mass fraction (required for partially premixed model) */ real Fuel_Mass_Fraction = 0.05; /********************************** User input ends ******************************************/ /* Fuel molecular weight for each fuel. Assuming RMFD_303_indolene has the same molecuar weight as isooctance */ static real molecular_weight[]={16.043, 32.040, 44.096, 114.23, 114.23}; /* For one mole of fuel, how many moles of air needed for stoic combustion */ static real stoic_air_moles[]={2.0, 1.5, 5.0, 12.5, 12.5};

/* Unburnt gas temperature */ static real f_T_u(Thread * t) { /* determine the unburnt temperature as the weighted average of the unburnt temperature in each cell ahead of the flame. If c>0.001 everywhere, then the unburnt temperature is the lowest temperature of the cell zone */

c Fluent Inc. February 28, 2011

31

Simulate In-Cylinder Premixed Combustion Using ECFM Model

real T_u, vol, T_u_min=1e10; cell_t c; T_u=0.; vol=0.; begin_c_loop_int (c,t) { if( C_PREMIXC(c,t) < 0.001 ) { T_u += C_T(c,t)*C_VOLUME(c,t); vol += C_VOLUME(c,t); }

else { if( C_T(c,t) < T_u_min ) { T_u_min = C_T(c,t); } } } end_c_loop_int (c,t) T_u_min=PRF_GRLOW1(T_u_min); PRF_GRSUM2(T_u, vol); if(T_u>0. && vol>0.) { return T_u/vol; } else { return T_u_min; } } /* Calculate unburnt gas temperature for laminar flame speed calculation */ DEFINE_ADJUST(my_T_u, domain) { #if !RP_HOST Thread *t; cell_t c; real T_u; thread_loop_c (t,domain) { T_u=f_T_u(t); begin_c_loop_int(c, t) { C_UDMI(c, t, 0)= T_u; } end_c_loop_int(c, t) } #endif }

32

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

/* Laminar flame speed calculation */ DEFINE_PROPERTY(laminar_flame_speed, c, t) { real SL, SL_ref, T_u, gama, beta, FIm[FLAG], Bm[FLAG], B2[FLAG], fi, fm; /* Correlation from Metghalchi and Keck. The author does not have the original paper as of the time of writing. So, three coefficients for methane is from a plot. More accurate numbers could be from the original paper. Coefficients for other fuels listed are from the paper. */ FIm[methane]=1.08; Bm[methane]=44e-2; B2[methane]=-152e-2; FIm[methanol]=1.11; Bm[methanol]=36.92e-2; B2[methanol]=-140.51e-2; FIm[propane]=1.08; Bm[propane]=34.22e-2; B2[propane]=-138.65e-2; FIm[isooctane]=1.13; Bm[isooctane]=26.32e-2; B2[isooctane]=-84.72e-2; FIm[RMFD_303_indolene]=1.13; Bm[RMFD_303_indolene]=27.58e-2; B2[RMFD_303_indolene]=-78.34e-2;

if(sg_premixed) { fm = THREAD_PROP(t,PROP_premix_unburnt_fuel_mf,0); } else { fm = Fuel_Mass_Fraction; /* C_FMEAN(c,t) */ } if(fm<1e-5) fm=1e-5; fi = (4.76*stoic_air_moles[fuel]*29/molecular_weight[fuel])/(1.0/fm-1); SL_ref = Bm[fuel]+B2[fuel]*pow(fi-FIm[fuel],2); gama = 2.18-0.8*(fi-1); beta = -0.16+0.22*(fi-1); T_u = C_UDMI(c,t,0); SL = SL_ref*pow(T_u/298, gama)*pow((C_P(c, t)+RP_Get_Real("operating-pressure"))/ 1.013e5, beta)*(1-2.1*Ydil); if (SL>0) return SL; else return 0; }

c Fluent Inc. February 28, 2011

33

Simulate In-Cylinder Premixed Combustion Using ECFM Model

Further Improvement
UDF will automatically create the le work.txt. This le has combustion chamber pressure and burnt fuel mass fraction as a function of Crank Angle (CA). These can be used to generate plots as shown (see Figures 6, and 7,

Figure 6: Pressure as a Function of CA

Figure 7: Burnt Fuel Mass Fraction as a Function of CA

34

c Fluent Inc. February 28, 2011

Simulate In-Cylinder Premixed Combustion Using ECFM Model

You can use Execute On Demand UDF to calculate the indicated work at any time by executing Indicated work::libudf. Dene Use-Dened Execute on Demand...

Summary
This tutorial demonstrated the use of premixed combustion using the Extended Coherent Flame Model of ANSYS FLUENT.

c Fluent Inc. February 28, 2011

35

Potrebbero piacerti anche