@@ -305,10 +305,20 @@ TEST_CASE("Joint system solution multiple ports", "[System]")
305
305
jsonModel[" unit_002" ] = grm2D;
306
306
jsonModel[" unit_003" ] = createOutlet ();
307
307
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 ]
312
322
});
313
323
const std::vector<mpfr::mpreal> secTimes{0.0 , 1.0 , 10.0 };
314
324
@@ -358,10 +368,19 @@ TEST_CASE("Joint system solution multiple ports single out", "[System]")
358
368
359
369
jsonModel[" unit_002" ] = grm2D;
360
370
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 ]
365
384
});
366
385
const std::vector<mpfr::mpreal> secTimes{0.0 , 1.0 , 10.0 };
367
386
0 commit comments