Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix System tests with 2D GRM #10

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions test/SystemTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>() / static_cast<double>(nRad);
double* flowRate = new double[nRad];
const double pi = 3.1415926535897932384626433;

for (int r = 0; r < nRad; r++)
flowRate[r] = grm2D["VELOCITY"].get<double>() * grm2D["COL_POROSITY"].get<double>() * 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<mpfr::mpreal> secTimes{0.0, 1.0, 10.0};

Expand Down Expand Up @@ -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<double>() / static_cast<double>(nRad);
double* flowRate = new double[nRad];
const double pi = 3.1415926535897932384626433;
for (int r = 0; r < nRad; r++)
flowRate[r] = grm2D["VELOCITY"].get<double>() * grm2D["COL_POROSITY"].get<double>() * 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<mpfr::mpreal> secTimes{0.0, 1.0, 10.0};

Expand Down
Loading