Skip to content

Commit ed00efe

Browse files
committed
[Test] Remove unused cases from surfSolver tests
1 parent 68eaf4a commit ed00efe

File tree

3 files changed

+11
-286
lines changed

3 files changed

+11
-286
lines changed

test_problems/SConscript

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,10 @@ CompileAndTest('silane_equil')
206206
CompileAndTest('stoichSolidKinetics')
207207
CompileAndTest('surfkin', slow=True)
208208
CompileAndTest('surfSolver', 'surfSolverTest', 'surfaceSolver', None,
209-
arguments='haca2.yaml',
210209
comparisons=[('results_blessed.txt', 'results.txt')],
211210
artifacts=['results.txt'],
212211
extensions=['^surfaceSolver.cpp'])
213212
CompileAndTest('surfSolver2', 'surfSolverTest', 'surfaceSolver2', None,
214-
arguments='haca2.yaml',
215213
comparisons=[('results2_blessed.txt', 'results2.txt')],
216214
artifacts=['results2.txt'],
217215
extensions=['^surfaceSolver2.cpp'])

test_problems/surfSolverTest/surfaceSolver.cpp

Lines changed: 6 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
// This file is part of Cantera. See License.txt in the top-level directory or
77
// at https://cantera.org/license.txt for license and copyright information.
88

9-
// Example
10-
//
11-
// Read a surface growth mechanism and calculate the solution
12-
// using Placid.
13-
//
14-
159
#include "cantera/thermo/ThermoFactory.h"
1610
#include "cantera/kinetics.h"
1711
#include "cantera/kinetics/ImplicitSurfChem.h"
@@ -26,13 +20,6 @@ using namespace Cantera;
2620

2721
#define MSSIZE 200
2822

29-
/*****************************************************************/
30-
/*****************************************************************/
31-
/*****************************************************************/
32-
static void printUsage()
33-
{
34-
}
35-
3623
void printGas(ostream& oooo, ThermoPhase* gasTP, InterfaceKinetics* iKin_ptr, double* src)
3724
{
3825
double x[MSSIZE];
@@ -147,67 +134,15 @@ int main(int argc, char** argv)
147134
#if defined(_MSC_VER) && _MSC_VER < 1900
148135
_set_output_format(_TWO_DIGIT_EXPONENT);
149136
#endif
150-
string infile;
137+
string infile = "haca2.yaml";
138+
string gasPhaseName = "gas";
139+
string bulkParticlePhaseName = "soot";
140+
string surfParticlePhaseName = "soot_interface";
151141
int ioflag = 1;
152-
int i, k;
153-
// look for command-line options
154-
if (argc > 1) {
155-
string tok;
156-
for (int j = 1; j < argc; j++) {
157-
tok = string(argv[j]);
158-
if (tok[0] == '-') {
159-
int nopt = static_cast<int>(tok.size());
160-
for (int n = 1; n < nopt; n++) {
161-
if (tok[n] == 'h') {
162-
printUsage();
163-
exit(0);
164-
} else if (tok[n] == 'd') {
165-
int lvl = 0;
166-
if (j < (argc - 1)) {
167-
string tokla = string(argv[j+1]);
168-
if (strlen(tokla.c_str()) > 0) {
169-
lvl = atoi(tokla.c_str());
170-
n = nopt - 1;
171-
j += 1;
172-
ioflag = lvl;
173-
}
174-
}
175-
} else {
176-
printUsage();
177-
exit(1);
178-
}
179-
}
180-
} else if (infile == "") {
181-
infile = tok;
182-
} else {
183-
printUsage();
184-
exit(1);
185-
}
186-
}
187-
}
188-
if (infile == "") {
189-
infile = "diamond.cti";
190-
}
191142

192143
try {
193144
/*************************************************************/
194145

195-
/*
196-
* FILL IN THESE NAMES FOR EACH PROBLEM
197-
*/
198-
/*
199-
* ProblemNumber = 0 : diamond.cti
200-
* = 1 : haca.cti
201-
*/
202-
int ProblemNumber = 1;
203-
string gasPhaseName = "gas";
204-
string bulkParticlePhaseName = "diamond";
205-
string surfParticlePhaseName = "diamond_100";
206-
if (ProblemNumber == 1) {
207-
gasPhaseName = "gas";
208-
bulkParticlePhaseName = "soot";
209-
surfParticlePhaseName = "soot_interface";
210-
}
211146

212147
/************************************************************/
213148
ThermoPhase* gasTP = newPhase(infile, gasPhaseName);
@@ -231,55 +166,10 @@ int main(int argc, char** argv)
231166
size_t nr = iKin_ptr->nReactions();
232167
cout << "Number of reactions = " << nr << endl;
233168

234-
double x[MSSIZE], p = OneAtm;
169+
double x[MSSIZE];
235170

236171
ofstream ofile("results.txt");
237172

238-
/*
239-
* Set the Gas State:
240-
* -> note that the states are set in the XML files too
241-
*/
242-
for (i = 0; i < MSSIZE; i++) {
243-
x[i] = 0.0;
244-
}
245-
if (ProblemNumber == 0) {
246-
x[0] = 0.0010;
247-
x[1] = 0.9888;
248-
x[2] = 0.0002;
249-
x[3] = 0.0100;
250-
p = 20.0*OneAtm/760.0;
251-
gasTP->setState_TPX(1200., p, x);
252-
}
253-
254-
/*
255-
* Set the surface initial state
256-
*/
257-
for (i = 0; i < MSSIZE; i++) {
258-
x[i] = 0.0;
259-
}
260-
if (ProblemNumber == 0) {
261-
size_t i0 = surfPhaseTP->speciesIndex("c6H*");
262-
if (i0 != npos) {
263-
x[i0] = 0.1;
264-
}
265-
size_t i1 = surfPhaseTP->speciesIndex("c6HH");
266-
if (i1 != npos) {
267-
x[i1] = 0.9;
268-
}
269-
surfPhaseTP->setState_TX(1200., x);
270-
}
271-
272-
/*
273-
* Set the bulk Phase State
274-
*/
275-
for (i = 0; i < MSSIZE; i++) {
276-
x[i] = 0.0;
277-
}
278-
if (ProblemNumber == 0) {
279-
x[0] = 1.0;
280-
bulkPhaseTP->setState_TPX(1200., p, x);
281-
}
282-
283173
iKin_ptr->setIOFlag(ioflag);
284174
/*
285175
* Solve the Equation system
@@ -292,30 +182,6 @@ int main(int argc, char** argv)
292182
double src[MSSIZE];
293183
iKin_ptr->getNetProductionRates(src);
294184

295-
double sum = 0.0;
296-
if (ProblemNumber == 0) {
297-
double naH;
298-
for (k = 0; k < 13; k++) {
299-
if (k < 4) {
300-
naH = gasTP->nAtoms(k, 0);
301-
} else if (k == 4) {
302-
naH = 0;
303-
} else if (k > 4) {
304-
int itp = k - 5;
305-
naH = surfPhaseTP->nAtoms(itp, 0);
306-
}
307-
cout << k << " " << naH << " " ;
308-
if (fabs(src[k]) < 2.0E-17) {
309-
cout << " nil" << endl;
310-
} else {
311-
cout << src[k] << endl;
312-
}
313-
sum += naH * src[k];
314-
}
315-
cout << "sum = " << sum << endl;
316-
}
317-
318-
319185
printGas(cout, gasTP, iKin_ptr, src);
320186
printBulk(cout, bulkPhaseTP, iKin_ptr, src);
321187
printSurf(cout, surfPhaseTP, iKin_ptr, src) ;
@@ -329,7 +195,7 @@ int main(int argc, char** argv)
329195

330196
/*
331197
* Set the Gas State:
332-
* -> note that the states are set in the XML files too
198+
* -> note that the states are set in the input file too
333199
*/
334200
double pres = gasTP->pressure();
335201
gasTP->getMoleFractions(x);

test_problems/surfSolverTest/surfaceSolver2.cpp

Lines changed: 5 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,8 @@
66
// This file is part of Cantera. See License.txt in the top-level directory or
77
// at https://cantera.org/license.txt for license and copyright information.
88

9-
// Example
10-
//
11-
// Read a surface growth mechanism and calculate the solution
12-
// using Placid.
13-
//
14-
159
#define MSSIZE 200
1610

17-
/*****************************************************************/
18-
/*****************************************************************/
19-
/*****************************************************************/
20-
static void printUsage()
21-
{
22-
}
23-
2411
#include "cantera/thermo/ThermoFactory.h"
2512
#include "cantera/kinetics.h"
2613
#include "cantera/kinetics/ImplicitSurfChem.h"
@@ -142,69 +129,13 @@ void printSurf(ostream& oooo, ThermoPhase* surfPhaseTP,
142129

143130
int main(int argc, char** argv)
144131
{
145-
string infile;
146-
int i, k;
132+
string infile = "haca2.yaml";
133+
string gasPhaseName = "gas";
134+
string bulkParticlePhaseName = "soot";
135+
string surfParticlePhaseName = "soot_interface";
147136
int ioflag = 1;
148-
// look for command-line options
149-
if (argc > 1) {
150-
string tok;
151-
for (int j = 1; j < argc; j++) {
152-
tok = string(argv[j]);
153-
if (tok[0] == '-') {
154-
int nopt = static_cast<int>(tok.size());
155-
for (int n = 1; n < nopt; n++) {
156-
if (tok[n] == 'h') {
157-
printUsage();
158-
exit(0);
159-
} else if (tok[n] == 'd') {
160-
int lvl = 0;
161-
if (j < (argc - 1)) {
162-
string tokla = string(argv[j+1]);
163-
if (strlen(tokla.c_str()) > 0) {
164-
lvl = atoi(tokla.c_str());
165-
n = nopt - 1;
166-
j += 1;
167-
ioflag = lvl;
168-
}
169-
}
170-
} else {
171-
printUsage();
172-
exit(1);
173-
}
174-
}
175-
} else if (infile == "") {
176-
infile = tok;
177-
} else {
178-
printUsage();
179-
exit(1);
180-
}
181-
}
182-
}
183-
if (infile == "") {
184-
infile = "diamond.cti";
185-
}
186137

187138
try {
188-
/*************************************************************/
189-
190-
/*
191-
* FILL IN THESE NAMES FOR EACH PROBLEM
192-
*/
193-
/*
194-
* ProblemNumber = 0 : diamond.cti
195-
* = 1 : haca.cti
196-
*/
197-
int ProblemNumber = 1;
198-
string gasPhaseName = "gas";
199-
string bulkParticlePhaseName = "diamond";
200-
string surfParticlePhaseName = "diamond_100";
201-
if (ProblemNumber == 1) {
202-
gasPhaseName = "gas";
203-
bulkParticlePhaseName = "soot";
204-
surfParticlePhaseName = "soot_interface";
205-
}
206-
207-
/************************************************************/
208139
ThermoPhase* gasTP = newPhase(infile, gasPhaseName);
209140
size_t nspGas = gasTP->nSpecies();
210141
cout << "Number of species = " << nspGas << endl;
@@ -246,52 +177,6 @@ int main(int argc, char** argv)
246177

247178
double x[MSSIZE], p = OneAtm;
248179

249-
/*
250-
* Set the Gas State:
251-
* -> note that the states are set in the XML files too
252-
*/
253-
for (i = 0; i < MSSIZE; i++) {
254-
x[i] = 0.0;
255-
}
256-
if (ProblemNumber == 0) {
257-
x[0] = 0.0010;
258-
x[1] = 0.9888;
259-
x[2] = 0.0002;
260-
x[3] = 0.0100;
261-
p = 20.0*OneAtm/760.0;
262-
gasTP->setState_TPX(1200., p, x);
263-
}
264-
265-
/*
266-
* Set the surface initial state
267-
* other problem numbers take their initial state from the XML files.
268-
*/
269-
for (i = 0; i < MSSIZE; i++) {
270-
x[i] = 0.0;
271-
}
272-
if (ProblemNumber == 0) {
273-
size_t i0 = surfPhaseTP->speciesIndex("c6H*");
274-
if (i0 != npos) {
275-
x[i0] = 0.1;
276-
}
277-
size_t i1 = surfPhaseTP->speciesIndex("c6HH");
278-
if (i1 != npos) {
279-
x[i1] = 0.9;
280-
}
281-
surfPhaseTP->setState_TX(1200., x);
282-
}
283-
284-
/*
285-
* Set the bulk Phase State
286-
*/
287-
for (i = 0; i < MSSIZE; i++) {
288-
x[i] = 0.0;
289-
}
290-
if (ProblemNumber == 0) {
291-
x[0] = 1.0;
292-
bulkPhaseTP->setState_TPX(1200., p, x);
293-
}
294-
295180
/*
296181
* Set-up the Surface Problem
297182
* This problem will consist of 2 identical InterfaceKinetics objects
@@ -313,30 +198,6 @@ int main(int argc, char** argv)
313198
iKin_ptr->getNetProductionRates(src);
314199
iKin2_ptr->getNetProductionRates(src2);
315200

316-
double sum = 0.0;
317-
if (ProblemNumber == 0) {
318-
double naH;
319-
for (k = 0; k < 13; k++) {
320-
if (k < 4) {
321-
naH = gasTP->nAtoms(k, 0);
322-
} else if (k == 4) {
323-
naH = 0;
324-
} else if (k > 4) {
325-
int itp = k - 5;
326-
naH = surfPhaseTP->nAtoms(itp, 0);
327-
}
328-
cout << k << " " << naH << " " ;
329-
if (fabs(src[k]) < 2.0E-17) {
330-
cout << " nil" << endl;
331-
} else {
332-
cout << src[k] << endl;
333-
}
334-
sum += naH * src[k];
335-
}
336-
cout << "sum = " << sum << endl;
337-
}
338-
339-
340201
printGas(cout, gasTP, iKin_ptr, src);
341202
printBulk(cout, bulkPhaseTP, iKin_ptr, src);
342203
printSurf(cout, surfPhaseTP, iKin_ptr, src) ;
@@ -354,7 +215,7 @@ int main(int argc, char** argv)
354215

355216
/*
356217
* Set the Gas State:
357-
* -> note that the states are set in the XML files too
218+
* -> note that the states are set in the input file too
358219
*/
359220
double pres = gasTP->pressure();
360221
gasTP->getMoleFractions(x);

0 commit comments

Comments
 (0)