Skip to content

Commit d88d4ab

Browse files
committed
Fix System tests with 2D GRM
1 parent a75580c commit d88d4ab

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

test/SystemTests.cpp

+27-8
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,20 @@ TEST_CASE("Joint system solution multiple ports", "[System]")
305305
jsonModel["unit_002"] = grm2D;
306306
jsonModel["unit_003"] = createOutlet();
307307
jsonModel["unit_004"] = createOutlet();
308-
jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, 1.0,
309-
1.0, 2.0, 0.0, 1.0, -1.0, -1.0, 1.0,
310-
2.0, 3.0, 0.0, 0.0, -1.0, -1.0, 1.0,
311-
2.0, 4.0, 1.0, 0.0, -1.0, -1.0, 1.0
308+
309+
// calculate flow rates to maintain constant velocity
310+
const int nRad = grm2D["discretization"]["NRAD"];
311+
double deltaR = grm2D["COL_RADIUS"].get<double>() / static_cast<double>(nRad);
312+
double* flowRate = new double[nRad];
313+
const double pi = 3.1415926535897932384626433;
314+
315+
for (int r = 0; r < nRad; r++)
316+
flowRate[r] = grm2D["VELOCITY"].get<double>() * grm2D["COL_POROSITY"].get<double>() * pi * (std::pow(deltaR * (r + 1), 2) - std::pow(deltaR * r, 2));
317+
318+
jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, flowRate[0], // unit from, to, port from, to, component from, to, flow rate
319+
1.0, 2.0, 0.0, 1.0, -1.0, -1.0, flowRate[1],
320+
2.0, 3.0, 0.0, 0.0, -1.0, -1.0, flowRate[0],
321+
2.0, 4.0, 1.0, 0.0, -1.0, -1.0, flowRate[1]
312322
});
313323
const std::vector<mpfr::mpreal> secTimes{0.0, 1.0, 10.0};
314324

@@ -358,10 +368,19 @@ TEST_CASE("Joint system solution multiple ports single out", "[System]")
358368

359369
jsonModel["unit_002"] = grm2D;
360370
jsonModel["unit_003"] = createOutlet();
361-
jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, 3.0,
362-
1.0, 2.0, 0.0, 1.0, -1.0, -1.0, 1.0,
363-
2.0, 3.0, 0.0, 0.0, -1.0, -1.0, 3.0,
364-
2.0, 3.0, 1.0, 0.0, -1.0, -1.0, 1.0
371+
372+
// calculate flow rates to maintain constant velocity
373+
const int nRad = grm2D["discretization"]["NRAD"];
374+
double deltaR = grm2D["COL_RADIUS"].get<double>() / static_cast<double>(nRad);
375+
double* flowRate = new double[nRad];
376+
const double pi = 3.1415926535897932384626433;
377+
for (int r = 0; r < nRad; r++)
378+
flowRate[r] = grm2D["VELOCITY"].get<double>() * grm2D["COL_POROSITY"].get<double>() * pi * (std::pow(deltaR * (r + 1), 2) - std::pow(deltaR * r, 2));
379+
380+
jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, flowRate[0], // unit from, to, port from, to, component from, to, flow rate
381+
1.0, 2.0, 0.0, 1.0, -1.0, -1.0, flowRate[1],
382+
2.0, 3.0, 0.0, 0.0, -1.0, -1.0, flowRate[0],
383+
2.0, 3.0, 1.0, 0.0, -1.0, -1.0, flowRate[1]
365384
});
366385
const std::vector<mpfr::mpreal> secTimes{0.0, 1.0, 10.0};
367386

0 commit comments

Comments
 (0)