This notebook was added later, used for validating the results.
Basically this notebook loads the postprocessed data from Part1 - Part4
and verifies some scaling relations.
#r "BoSSSpad.dll"
// #r "..\..\src\L4-application\BoSSSpad\bin\Release\net5.0\BoSSSpad.dll"
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Data;
using System.Globalization;
using System.Threading;
using ilPSP;
using ilPSP.Utils;
using BoSSS.Platform;
using BoSSS.Foundation;
using BoSSS.Foundation.Grid;
using BoSSS.Foundation.Grid.Classic;
using BoSSS.Foundation.IO;
using BoSSS.Solution;
using BoSSS.Solution.Control;
using BoSSS.Solution.GridImport;
using BoSSS.Solution.Statistic;
using BoSSS.Solution.Utils;
using BoSSS.Solution.Gnuplot;
using BoSSS.Application.BoSSSpad;
using BoSSS.Application.XNSE_Solver;
using static BoSSS.Application.BoSSSpad.BoSSSshell;
using BoSSS.Foundation.Grid.RefElements;
using BoSSS.Platform.LinAlg;
using BoSSS.Application.XNSE_Solver.PhysicalBasedTestcases.PrintingNip;
Init();
Only if the output directories were previously created via Part0_PrintingNip_Setup
output is stored to the subdirectories.
Otherwise, datatables are stored directly to the working directory and plots displayed in the notebook.
The plots are not adjusted to look "nice" in the notebook.
This is not part of the ValidationTestRunner
.
static bool GenerateOutput = Directory.Exists(@"./PrintingNip") && Directory.Exists(@"./PrintingNip/Figures") && Directory.Exists(@"./PrintingNip/Files") && Directory.Exists(@"./PrintingNip/Output");
DataTable tab1, tab2, tab3, tab4;
if(GenerateOutput){
tab1 = TableExtensions.FromCSVFile("./PrintingNip/Files/PrintingNip-Part1.csv", ColSep: ';');
tab2 = TableExtensions.FromCSVFile("./PrintingNip/Files/PrintingNip-Part2.csv", ColSep: ';');
tab3 = TableExtensions.FromCSVFile("./PrintingNip/Files/PrintingNip-Part3.csv", ColSep: ';');
tab4 = TableExtensions.FromCSVFile("./PrintingNip/Files/PrintingNip-Part4.csv", ColSep: ';');
} else {
tab1 = TableExtensions.FromCSVFile("./PrintingNip-Part1.csv", ColSep: ';');
tab2 = TableExtensions.FromCSVFile("./PrintingNip-Part2.csv", ColSep: ';');
tab3 = TableExtensions.FromCSVFile("./PrintingNip-Part3.csv", ColSep: ';');
tab4 = TableExtensions.FromCSVFile("./PrintingNip-Part4.csv", ColSep: ';');
}
Number of Rows in DataTables
and number of sessions should be equal and not empty:
The Values set here to check the number of sessions depends on the settings in Part1_*_Run
-Part4_*_Run
.
The following is expected:
Part1
: 64 simulationsPart2
: 20 simulationsPart3
: 72 simulationsPart4
: 42 simulationsBoSSSshell.wmg.Init("PrintingNip_Part1");
int cnt1 = BoSSSshell.wmg.Sessions.Count();
if(cnt1 != 64 || cnt1 != tab1.Rows.Count){
throw new ApplicationException("Part1: Missing DataRows");
}
Project name is set to 'PrintingNip_Part1'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\PrintingNip_Part1'.
BoSSSshell.wmg.Init("PrintingNip_Part2");
int cnt2 = BoSSSshell.wmg.Sessions.Count();
if(cnt2 != 20 || cnt2 != tab2.Rows.Count){
throw new ApplicationException("Part2: Missing DataRows");
}
Project name is set to 'PrintingNip_Part2'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\PrintingNip_Part2'.
BoSSSshell.wmg.Init("PrintingNip_Part3");
int cnt3 = BoSSSshell.wmg.Sessions.Count();
if(cnt3 != 72 || cnt3 != tab3.Rows.Count){
throw new ApplicationException("Part3: Missing DataRows");
}
Project name is set to 'PrintingNip_Part3'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\PrintingNip_Part3'.
BoSSSshell.wmg.Init("PrintingNip_Part4");
int cnt4 = BoSSSshell.wmg.Sessions.Count();
if(cnt4 != 42 || cnt4 != tab4.Rows.Count){
throw new ApplicationException("Part4: Missing DataRows");
}
Project name is set to 'PrintingNip_Part4'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\PrintingNip_Part4'.
First compute the proportionality of some physical values $z \propto \varepsilon^\alpha$ for the simulations in Part1
.
Namely the rounded values in Table 1 of https://doi.org/10.1063/5.0139000
to the first digit i.e. $\pm 0.05$
double thrsh = 0.05;
Case A - dp = 0, V = const, h variable
double[] ExpectedSlopesA = new double[] {-1.5, 0.0, 1.0, -2.0, -1.0, -0.5, 0.5, 0.5, -0.5};
string[] ColumnsA = new string[] {"PressureRange", "VelocityXMax", "Massflux", "dPdXatNip", "NipShearRateCylinder", "ShearStressCylinder", "PositionOfSynchronousFlow", "PositionOfStagnatingFlow", "ViscousDissipation"};
var tab1A = tab1.ExtractRows((i,row) => Convert.ToDouble(row["id:P_Diff"]).ApproxEqual(0.0) && Convert.ToDouble(row["id:V_Wall"])>0.0);
if(tab1A.Rows.Count != 12){ // should be 12
throw new ApplicationException("Error extracting rows!");
}
foreach(string col in ColumnsA){
int k = ColumnsA.IndexOf(col);
var plt = tab1A.ToPlot("id:delta", col, ColName_GroupSelection: new string[] { "id:V_Wall" });
plt.LogX = true;
plt.LogY = true;
var reg = plt.Regression();
int j = 0;
foreach(var kvp in reg){
j++;
if(kvp.Value < ExpectedSlopesA[k] - thrsh || kvp.Value > ExpectedSlopesA[k] + thrsh){
Console.WriteLine("Expected: {0}, but is {1}", ExpectedSlopesA[k], kvp.Value);
throw new ApplicationException("Wrong slope computed for " + col);
} else {
Console.WriteLine("Expected: {0}, and is {1} - success!", ExpectedSlopesA[k], kvp.Value);
}
}
if(j <= 0){
throw new ApplicationException("No slopes computed!");
}
}
Expected: -1.5, and is -1.4982794147884522 - success! Expected: -1.5, and is -1.4982794148239313 - success! Expected: -1.5, and is -1.498279414776739 - success! Expected: 0, and is -0.0007329369457784729 - success! Expected: 0, and is -0.0007329369496034494 - success! Expected: 0, and is -0.0007329369492028559 - success! Expected: 1, and is 0.9994838920398195 - success! Expected: 1, and is 0.999483892039715 - success! Expected: 1, and is 0.9994838920397889 - success! Expected: -2, and is -2.001531970391172 - success! Expected: -2, and is -2.001531981514793 - success! Expected: -2, and is -2.0015319799879308 - success! Expected: -1, and is -1.0022177832163544 - success! Expected: -1, and is -1.0022177661113347 - success! Expected: -1, and is -1.0022177663322425 - success! Expected: -0.5, and is -0.527154160017129 - success! Expected: -0.5, and is -0.5271541596785052 - success! Expected: -0.5, and is -0.5271541596928676 - success! Expected: 0.5, and is 0.4991730958923382 - success! Expected: 0.5, and is 0.4991730958927583 - success! Expected: 0.5, and is 0.4991730958934129 - success! Expected: 0.5, and is 0.5001352180764558 - success! Expected: 0.5, and is 0.5001352180684392 - success! Expected: 0.5, and is 0.5001352180676092 - success! Expected: -0.5, and is -0.5260315965052587 - success! Expected: -0.5, and is -0.5260315965122822 - success! Expected: -0.5, and is -0.5260315965120027 - success!
Case B - dp = const, V = 0, h variable
double[] ExpectedSlopesB = new double[] {0.0, 1.5, 2.5, -0.5, 0.5, 1.0, 2.5};
string[] ColumnsB = new string[] {"PressureRange", "VelocityXMax", "Massflux", "dPdXatNip", "NipShearRateCylinder", "ShearStressCylinder", "ViscousDissipation"};
var tab1B = tab1.ExtractRows((i,row) => Convert.ToDouble(row["id:V_Wall"]).ApproxEqual(0.0) && Convert.ToDouble(row["id:P_Diff"])>0.0);
if(tab1B.Rows.Count != 12){ // should be 12
throw new ApplicationException("Error extracting rows!");
}
foreach(string col in ColumnsB){
int k = ColumnsB.IndexOf(col);
var plt = tab1B.ToPlot("id:delta", col, ColName_GroupSelection: new string[] { "id:P_Diff" });
plt.LogX = true;
plt.LogY = true;
var reg = plt.Regression();
int j = 0;
foreach(var kvp in reg){
j++;
if(kvp.Value < ExpectedSlopesB[k] - thrsh || kvp.Value > ExpectedSlopesB[k] + thrsh){
Console.WriteLine("Expected: {0}, but is {1}", ExpectedSlopesB[k], kvp.Value);
throw new ApplicationException("Wrong slope computed for " + col);
} else {
Console.WriteLine("Expected: {0}, and is {1} - success!", ExpectedSlopesB[k], kvp.Value);
}
}
if(j <= 0){
throw new ApplicationException("No slopes computed!");
}
}
Expected: 0, and is -0.0001196074702333405 - success! Expected: 0, and is -0.00011960747079839962 - success! Expected: 0, and is -0.0001196074713737172 - success! Expected: 1.5, and is 1.4995668196748966 - success! Expected: 1.5, and is 1.4995668196749419 - success! Expected: 1.5, and is 1.4995668196749525 - success! Expected: 2.5, and is 2.4996336598394655 - success! Expected: 2.5, and is 2.4996336598395446 - success! Expected: 2.5, and is 2.4996336598395756 - success! Expected: -0.5, and is -0.5004330225095242 - success! Expected: -0.5, and is -0.5004330224354463 - success! Expected: -0.5, and is -0.5004330224795406 - success! Expected: 0.5, and is 0.4999012528843805 - success! Expected: 0.5, and is 0.49990125288428083 - success! Expected: 0.5, and is 0.49990125288385734 - success! Expected: 1, and is 0.9994838553278509 - success! Expected: 1, and is 0.9994838511991848 - success! Expected: 1, and is 0.9994838591413803 - success! Expected: 2.5, and is 2.4996334105665183 - success! Expected: 2.5, and is 2.4996334105631104 - success! Expected: 2.5, and is 2.4996334105674696 - success!
stagnation point is set to $x_s \approx 0.01 m$
double ExpectedSlope = 0.0;
double ExpectedValue = 0.01;
double AllowedDeviation = 0.0001;
string Column = "PositionOfStagnatingFlow";
{
var plt = tab2.ToPlot("id:delta", Column, ColName_GroupSelection: new string[] { "id:V_Wall" });
plt.LogX = true;
plt.LogY = true;
var reg = plt.Regression();
int j = 0;
foreach(var kvp in reg){
j++;
if(kvp.Value < ExpectedSlope - thrsh || kvp.Value > ExpectedSlope + thrsh){
Console.WriteLine("Expected: {0}, but is {1}", ExpectedSlope, kvp.Value);
throw new ApplicationException("Wrong slope computed for " + Column);
} else {
Console.WriteLine("Expected: {0}, and is {1} - success!", ExpectedSlope, kvp.Value);
}
}
foreach(var group in plt.dataGroups){
double IsValue = group.Values.Average();
if(IsValue < ExpectedValue - AllowedDeviation || IsValue > ExpectedValue + AllowedDeviation){
Console.WriteLine("Expected: {0}, but is {1}", ExpectedValue, IsValue);
throw new ApplicationException("Wrong value for " + Column);
} else {
Console.WriteLine("Expected: {0}, and is {1} - success!", ExpectedValue, IsValue);
}
}
if(j <= 0){
throw new ApplicationException("No slopes computed!");
}
}
Expected: 0, and is 0.00031423952892761786 - success! Expected: 0, and is 0.00031423980656615226 - success! Expected: 0, and is 0.0003139984528765849 - success! Expected: 0, and is 0.0003139282564199819 - success! Expected: 0, and is 0.00031392748948473327 - success! Expected: 0.01, and is 0.00998444566150291 - success! Expected: 0.01, and is 0.009984445656170876 - success! Expected: 0.01, and is 0.009984450265179157 - success! Expected: 0.01, and is 0.009984451608224306 - success! Expected: 0.01, and is 0.00998445162284436 - success!