-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththickenedFlame.loci
executable file
·360 lines (304 loc) · 13 KB
/
thickenedFlame.loci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
// Copyright (C) 2019, ATA Engineering, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <Loci.h>
// chem.lh must come before chemio.h
$include "chem.lh"
#include "chemio.h"
#include "eos.h"
#include "reaction.h"
#include "qvi.h"
#include <string>
#include <iostream>
$include "thickenedFlame.lh"
using std::cout;
using std::cerr;
using std::endl;
namespace chem {
// -------------------------------------------------------------------------
// Determine progress variable type for standard flame sensor
$type progressTemperature Constraint;
$rule constraint(progressTemperature <- progressVariableName) {
$progressTemperature = ($progressVariableName == "T") ? ~EMPTY : EMPTY;
}
$type progressVariable store<real>;
$rule pointwise(progressVariable <- temperature),
constraint(progressTemperature, temperature) {
$progressVariable = $temperature;
}
// -------------------------------------------------------------------------
// Determine burned / unburned progress variables
// This is only done for progress variable based sensor
$rule pointwise(progressVariableBurned <- thickenedFlame),
constraint(pvBurnedValue, progressVariable) {
$thickenedFlame.getOptionUnits("pvBurnedValue", "K",
$progressVariableBurned);
}
$rule pointwise(progressVariableBurned),
constraint(pvBurnedEquilibrium, progressVariable) {
cerr << "progress variable burned equilibrium option not yet supported"
<< endl;
Loci::Abort();
$progressVariableBurned = 0.0;
}
$rule pointwise(progressVariableUnburned <- thickenedFlame),
constraint(pvUnburnedValue, progressVariable) {
$thickenedFlame.getOptionUnits("pvUnburnedValue", "K",
$progressVariableUnburned);
}
$rule pointwise(progressVariableUnburned),
constraint(pvUnburnedMaxInletFuelTemp) {
cerr << "progress variable unburned max inlet temperature option not yet "
"supported"
<< endl;
Loci::Abort();
$progressVariableUnburned = 0.0;
}
$rule pointwise(progressVariableUnburned),
constraint(pvUnburnedAvgInletFuelTemp) {
cerr << "progress variable unburned avg inlet temperature option not yet "
"supported"
<< endl;
Loci::Abort();
$progressVariableUnburned = 0.0;
}
// -------------------------------------------------------------------------
// Calculate reaction progress - only for progress variable sensor
$type reactionProgress store<real>;
$type reactionProgress_f store<real>;
$rule pointwise(reactionProgress <- progressVariable, progressVariableUnburned,
progressVariableBurned) {
$reactionProgress = ($progressVariable - $progressVariableUnburned) /
($progressVariableBurned - $progressVariableUnburned);
// enforce [0-1] limits
$reactionProgress = max(min($reactionProgress, 1.0), 0.0);
}
$rule pointwise(reactionProgress_f <- (cr, cl)->(vol, reactionProgress)) {
$reactionProgress_f = ($cr->$reactionProgress * $cl->$vol +
$cl->$reactionProgress * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(reactionProgress_f <- ci -> reactionProgress) {
$reactionProgress_f = $ci -> $reactionProgress;
}
//OUTPUT_SCALAR means that variable will only be output if requested
OUTPUT_SCALAR("cell2node(reactionProgress)",progress);
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Compute the grid scale assuming using the projected area and volume
$type projectedArea store<real>;
$rule unit(projectedArea), constraint(vol) {
$projectedArea = 0.0;
}
$rule apply(cl->projectedArea <- area, u_f)[Loci::Summation] {
const real weight = max(dot($u_f, $area.n),1e-12)/max(norm($u_f),1e-12);
join($cl->$projectedArea, weight*$area.sada);
}
$rule apply(cr->projectedArea <- area, u_f)[Loci::Summation] {
const real weight = max(-dot($u_f, $area.n),1e-12)/max(norm($u_f),1e-12);
join($cr->$projectedArea, weight*$area.sada);
}
$type gridScale store<real>;
$rule pointwise(gridScale <- projectedArea, vol){
$gridScale = $vol/$projectedArea;
}
$type gridScale_f store<real>;
$rule pointwise(gridScale_f <- ci->gridScale) {
$gridScale_f = $ci -> $gridScale;
}
OUTPUT_SCALAR("cell2node(gridScale)",gridScale);
OUTPUT_SCALAR("cell2node(projectedArea)",projectedArea);
// -------------------------------------------------------------------------
// Calculate dynamic flame sensor
$rule pointwise(flameSensor <- reactionProgress, sensorMaxAtProgressVal),
constraint(vol) {
real p = $sensorMaxAtProgressVal / (1.0 - $sensorMaxAtProgressVal);
real coeff = 1.0 / pow(pow($sensorMaxAtProgressVal, p) *
(1.0 - $sensorMaxAtProgressVal),
2.0);
$flameSensor =
coeff * pow(pow($reactionProgress, p) * (1.0 - $reactionProgress), 2.0);
}
$rule pointwise(flameSensor_f <- (cr, cl)->(vol, flameSensor)) {
$flameSensor_f =
($cr->$flameSensor * $cl->$vol + $cl->$flameSensor * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(flameSensor_f <- ci -> flameSensor) {
$flameSensor_f = $ci -> $flameSensor;
}
//OUTPUT_SCALAR means that variable will only be output if requested
OUTPUT_SCALAR("cell2node(flameSensor)",flameSensor);
// -------------------------------------------------------------------------
// Calculate flame thickening factor
$rule pointwise(thickeningFactor <- Fmax, flameSensor),
constraint(useDynamicThickening, flameSensor) {
$thickeningFactor = 1.0 + ($Fmax - 1.0) * $flameSensor;
}
$rule pointwise(thickeningFactor <- Fmax),
constraint(useStaticThickening, Fmax) {
$thickeningFactor = $Fmax;
}
$rule pointwise(thickeningFactor_f <- (cr, cl)->(vol, thickeningFactor)) {
$thickeningFactor_f = ($cr->$thickeningFactor * $cl->$vol +
$cl->$thickeningFactor * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(thickeningFactor_f <- ci -> thickeningFactor) {
$thickeningFactor_f = $ci -> $thickeningFactor;
}
//OUTPUT_SCALAR means that variable will only be output if requested
OUTPUT_SCALAR("cell2node(thickeningFactor)",F);
// -------------------------------------------------------------------------
// Calculate inputs to wrinkling factor
// Calculate grid length scale
$type Cs param<real>;
$rule default(Cs) { $Cs = 0.1; }
$rule pointwise(lengthScale <- Cs, vol, gridScale){
$lengthScale = $Cs * $gridScale;
}
$type lengthScale_f store<real>;
$rule pointwise(lengthScale_f <- (cr, cl)->(vol, lengthScale)) {
$lengthScale_f =
($cr->$lengthScale * $cl->$vol + $cl->$lengthScale * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(lengthScale_f <- ci->lengthScale) {
$lengthScale_f = $ci->$lengthScale;
}
OUTPUT_SCALAR("cell2node(lengthScale)",turbLengthScale);
$type uSGS store<real>;
$rule pointwise(uSGS <- tmuu, lengthScale, rho) {
real tke = pow($tmuu / ($rho * $lengthScale), 2.0);
$uSGS = sqrt(tke);
}
$type ReTurb store<real>;
$rule pointwise(ReTurb <- lengthScale, uSGS, muu, rho) {
$ReTurb = $rho * $uSGS * $lengthScale / $muu;
}
$type ReTurb_f store<real>;
$rule pointwise(ReTurb_f <- (cr, cl)->(vol, ReTurb)) {
$ReTurb_f = ($cr->$ReTurb * $cl->$vol + $cl->$ReTurb * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(ReTurb_f <- ci->ReTurb) {
$ReTurb_f = $ci->$ReTurb;
}
OUTPUT_SCALAR("cell2node(ReTurb)",ReTurb);
$type betaWrinkling store<real>;
$rule pointwise(betaWrinkling <- ReTurb) {
const real cms = 0.28;
$betaWrinkling =
max(2.0 * log(2.0) / (3.0 * cms * (sqrt($ReTurb) - 1.0)), 0.0);
}
double WrinklingFactorXi(const double &beta, const double &filterSize,
const double &velFluc,
const double &laminarFlameSpeed,
const double &flameThickness) {
const double eps = 1.0e-10;
double gamma = 0.75 *
exp(-1.2 * pow(velFluc / (laminarFlameSpeed + eps), -0.3)) *
pow(filterSize / (flameThickness + eps), 2.0 / 3.0);
return 1.0 + beta * velFluc / (laminarFlameSpeed + eps) * gamma;
}
// -------------------------------------------------------------------------
// Calculate laplacian of vorticity -- used for velocity fluctuation at
// thickened flame length scale
$type laplace_vort_vol store<vect3d>;
$rule unit(laplace_vort_vol), constraint(vol) {
$laplace_vort_vol = vect3d(0., 0., 0.);
}
$rule apply(cl->laplace_vort_vol <- gradv3d_f(vort), area)[Loci::Summation] {
join($cl->$laplace_vort_vol,
$area.sada * dot($gradv3d_f(vort), $area.n));
}
$rule apply(cr->laplace_vort_vol <- gradv3d_f(vort), area)[Loci::Summation] {
join($cr->$laplace_vort_vol,
-$area.sada * dot($gradv3d_f(vort), $area.n));
}
$type laplace_vort_raw store<vect3d>;
$rule pointwise(laplace_vort_raw <- laplace_vort_vol, vol) {
$laplace_vort_raw = $laplace_vort_vol / $vol;
}
$type laplace_vort store<vect3d>;
$rule pointwise(laplace_vort <- v3dSmooth(laplace_vort_raw)) {
$laplace_vort = $v3dSmooth(laplace_vort_raw);
}
$type laplace_vort_f store<vect3d>;
$rule pointwise(laplace_vort_f <- (cr, cl)->(vol, laplace_vort)) {
$laplace_vort_f =
($cr->$laplace_vort * $cl->$vol + $cl->$laplace_vort * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(laplace_vort_f <- ci->laplace_vort) {
$laplace_vort_f = $ci->$laplace_vort;
}
OUTPUT_VECTOR("cell2node_v3d(laplace_vort)",laplace_vort);
$type tfVelFluc store<real>;
$rule pointwise(tfVelFluc <- laplace_vort, lengthScale, thickeningFactor,
laminarFlameThickness) {
const real tfLengthScale = $thickeningFactor * $laminarFlameThickness;
const real c2 = 2.0;
const real nx = 10.0;
const real coeff = c2 * pow($lengthScale, 3.0);
const real wangCorrection =
pow(tfLengthScale / (nx * $lengthScale), 1.0 / 3.0);
$tfVelFluc = coeff * norm($laplace_vort) * wangCorrection;
}
$type tfVelFluc_f store<real>;
$rule pointwise(tfVelFluc_f <- (cr, cl)->(vol, tfVelFluc)) {
$tfVelFluc_f = ($cr->$tfVelFluc * $cl->$vol + $cl->$tfVelFluc * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(tfVelFluc_f <- ci->tfVelFluc) {
$tfVelFluc_f = $ci->$tfVelFluc;
}
// OUTPUT_SCALAR means that variable will only be output if requested
OUTPUT_SCALAR("cell2node(tfVelFluc)",tfVelFluc);
// -------------------------------------------------------------------------
// Adjust the efficiency factor formulation to ensure that it is not activated
// in non-flame regions
// Calculate efficiency factor
$rule pointwise(efficiencyFactor <- betaWrinkling, lengthScale, tfVelFluc,
laminarFlameSpeed, laminarFlameThickness, thickeningFactor),
constraint(useWangEfficiency, tfVelFluc) {
real filterSize = $lengthScale * $thickeningFactor;
real xiLaminar =
WrinklingFactorXi($betaWrinkling, filterSize, $tfVelFluc,
$laminarFlameSpeed, $laminarFlameThickness);
real xiThickened = WrinklingFactorXi(
$betaWrinkling, filterSize, $tfVelFluc, $laminarFlameSpeed,
$laminarFlameThickness * $thickeningFactor);
$efficiencyFactor = max(
min(xiLaminar / xiThickened, pow($thickeningFactor, 2.0 / 3.0)), 1.0);
}
$rule pointwise(efficiencyFactor<-thickeningFactor),
constraint(useMaxEfficiency,thickeningFactor) {
$efficiencyFactor = pow($thickeningFactor,2.0/3.0);
}
$rule pointwise(efficiencyFactor), constraint(useNoEfficiency) {
$efficiencyFactor = 1.0;
}
$rule pointwise(efficiencyFactor_f <- (cr, cl)->(vol, efficiencyFactor)) {
$efficiencyFactor_f = ($cr->$efficiencyFactor * $cl->$vol +
$cl->$efficiencyFactor * $cr->$vol) /
($cr->$vol + $cl->$vol);
}
$rule pointwise(efficiencyFactor_f <- ci -> efficiencyFactor) {
$efficiencyFactor_f = $ci -> $efficiencyFactor;
}
//OUTPUT_SCALAR means that variable will only be output if requested
OUTPUT_SCALAR("cell2node(efficiencyFactor)",E);
}