how to model two spark plugs


Fluent only allows for single spark plug in F6.2. How to model two spark plugs in F6.2?


P.S. F6.3 will implement 2 spark plugs.
/*********************************************************************************************
UDF to model two spark plugs

Fluent6.2 can model only one spark plug but not two. This UDF allows the user to
include a second spark plug. The method used is very similar to what Fluent code
does. The UDF should behave identical to Fluent code by default.
The UDF asks only for the spark center as input. Spark energy, start time, and
duration will be taken from the panel inputs.

This udf basically does two things just like Fluent code. It releases the spark
energy to the spark region and keeps the c variable a constant value of 1 for the
spark duration.

How to use the udf:
- Set up your premixed combustion case
- Set up your spark model inside Fluent
- Provide the spark center and combustion chamber fluid zone ID in the user input
part of the udf
- Build the library
- Add two more user defined memory (memory 1 and 2 will be used for the spark)
- Hook up the energy and progress variable (or c variable) source term to fluid
chamber cell zone where the spark is located. This is normally called the
fluid_chamber for IC cases.
- Hook up DEFINE_ADJUST udf

Note:
- UDF works for both 2d and 3d. And it works in both serial and parallel
- This UDF is intended for ONLY premixed combustion. It should be easily extended
to partially premixed
- Only uses sphere (3d) and circle (2d) as the spark kernal

Written by : Xiao HU (Fluent Inc)
Last updated : 04/08/2005
***********************************************************************************************/

# include "udf.h"
# include "surf.h"

/********************************* User input starts *****************************************/

static real spark_center[ND_ND]={20e-3, 1e-3}; /* Spark center */
static int fluid_chamber_ID = 2;

/********************************* User input starts *****************************************/

void my_adjust_T_u(Domain * domain);
void my_adjust_vol(Domain * domain);

DEFINE_ADJUST(adjust, domain)
{
my_adjust_T_u(domain);
my_adjust_vol(domain);
}

void my_adjust_vol(Domain * domain)
{
real vol, xc[ND_ND], dis[ND_ND], radius, vol_s=0, unused[3];
cell_t c;
Thread * tc;
CX_Cell_Id cx_cell;
CX_Cell_Id *cptr = &cx_cell;

tc = Lookup_Thread(domain, fluid_chamber_ID);

STORE_CX_CELL(cptr,0,tc);

radius = RP_Get_Real("spark/radius");

vol = 0;
begin_c_loop_int (c, tc)
{
C_CENTROID(xc, c, tc);
NV_VV(dis, =, xc, -, spark_center);
C_UDMI(c, tc, 2) = 0;

if (NV_MAG(dis) < radius)
{
vol += C_VOLUME(c, tc);
C_UDMI(c, tc, 2) = 1;
}
}
end_c_loop_int (c, tc)
vol = PRF_GRSUM1(vol);

if(SV_locate_point_in_thread (spark_center,unused, tc, cptr))
{
vol_s = C_VOLUME(RP_CELL(cptr), tc);
C_UDMI(RP_CELL(cptr), tc, 2) = 1;
}

vol_s = PRF_GRHIGH1(vol_s);

if(vol<vol_s)
vol = vol_s;

begin_c_loop_int (c, tc)
{
C_UDMI(c, tc, 1) = vol;
}
end_c_loop_int (c, tc)

return;
}

DEFINE_SOURCE(energy_source, c, t, dS, eqn)
{
#if !RP_HOST

real source, vol, CA, rpm, start_CA;

rpm = RP_Get_Real("dynamesh/in-cyn/crank-rpm");
start_CA = RP_Get_Real("spark/start-ca");

CA = rpm*CURRENT_TIME*6+RP_Get_Real("dynamesh/in-cyn/crank-start-angle");

if(CA>=start_CA&&CA<(start_CA+RP_Get_Real("spark/duration")*rpm*6))
{
if (C_UDMI(c, t, 2) == 1)
{
vol = C_UDMI(c, t, 1);
source = RP_Get_Real("spark/energy")/RP_Get_Real("spark/duration")/vol;
return source;
}
else
{
return 0;
}
}
else
{
return 0;
}
#endif
}

DEFINE_SOURCE(premixc_source, c, t, dS, eqn)
{
#if !RP_HOST
real source, CA, con=-1e10, rpm, start_CA;

rpm = RP_Get_Real("dynamesh/in-cyn/crank-rpm");
start_CA = RP_Get_Real("spark/start-ca");

CA = rpm*CURRENT_TIME*6+RP_Get_Real("dynamesh/in-cyn/crank-start-angle");

if(CA>=start_CA&&CA<(start_CA+RP_Get_Real("spark/duration")*rpm*6))
{
if (C_UDMI(c, t, 2) == 1)
{
source = con*(C_PREMIXC(c,t)-1.0);
dS[eqn] = con;
return source;
}
else
{
return 0;
}
}
else
{
return 0;
}
#endif
}





Show Form
No comments yet. Be the first to add a comment!