From d88d4abdafa828f29944a67dd5785df936a68225 Mon Sep 17 00:00:00 2001 From: Jan Breuer Date: Thu, 21 Nov 2024 14:56:15 +0100 Subject: [PATCH] Fix System tests with 2D GRM --- test/SystemTests.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/test/SystemTests.cpp b/test/SystemTests.cpp index 73b3d26..d6c7c80 100644 --- a/test/SystemTests.cpp +++ b/test/SystemTests.cpp @@ -305,10 +305,20 @@ TEST_CASE("Joint system solution multiple ports", "[System]") jsonModel["unit_002"] = grm2D; jsonModel["unit_003"] = createOutlet(); jsonModel["unit_004"] = createOutlet(); - jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, 1.0, - 1.0, 2.0, 0.0, 1.0, -1.0, -1.0, 1.0, - 2.0, 3.0, 0.0, 0.0, -1.0, -1.0, 1.0, - 2.0, 4.0, 1.0, 0.0, -1.0, -1.0, 1.0 + + // calculate flow rates to maintain constant velocity + const int nRad = grm2D["discretization"]["NRAD"]; + double deltaR = grm2D["COL_RADIUS"].get() / static_cast(nRad); + double* flowRate = new double[nRad]; + const double pi = 3.1415926535897932384626433; + + for (int r = 0; r < nRad; r++) + flowRate[r] = grm2D["VELOCITY"].get() * grm2D["COL_POROSITY"].get() * pi * (std::pow(deltaR * (r + 1), 2) - std::pow(deltaR * r, 2)); + + 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 + 1.0, 2.0, 0.0, 1.0, -1.0, -1.0, flowRate[1], + 2.0, 3.0, 0.0, 0.0, -1.0, -1.0, flowRate[0], + 2.0, 4.0, 1.0, 0.0, -1.0, -1.0, flowRate[1] }); const std::vector secTimes{0.0, 1.0, 10.0}; @@ -358,10 +368,19 @@ TEST_CASE("Joint system solution multiple ports single out", "[System]") jsonModel["unit_002"] = grm2D; jsonModel["unit_003"] = createOutlet(); - jsonModel["connections"] = makeConnections({ 0.0, 2.0, 0.0, 0.0, -1.0, -1.0, 3.0, - 1.0, 2.0, 0.0, 1.0, -1.0, -1.0, 1.0, - 2.0, 3.0, 0.0, 0.0, -1.0, -1.0, 3.0, - 2.0, 3.0, 1.0, 0.0, -1.0, -1.0, 1.0 + + // calculate flow rates to maintain constant velocity + const int nRad = grm2D["discretization"]["NRAD"]; + double deltaR = grm2D["COL_RADIUS"].get() / static_cast(nRad); + double* flowRate = new double[nRad]; + const double pi = 3.1415926535897932384626433; + for (int r = 0; r < nRad; r++) + flowRate[r] = grm2D["VELOCITY"].get() * grm2D["COL_POROSITY"].get() * pi * (std::pow(deltaR * (r + 1), 2) - std::pow(deltaR * r, 2)); + + 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 + 1.0, 2.0, 0.0, 1.0, -1.0, -1.0, flowRate[1], + 2.0, 3.0, 0.0, 0.0, -1.0, -1.0, flowRate[0], + 2.0, 3.0, 1.0, 0.0, -1.0, -1.0, flowRate[1] }); const std::vector secTimes{0.0, 1.0, 10.0};