#r "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");
string ProjectName = "PrintingNip_Part1";
BoSSSshell.WorkflowMgm.Init(ProjectName);
Project name is set to 'PrintingNip_Part1'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\PrintingNip_Part1'.
static var myDb = BoSSSshell.WorkflowMgm.DefaultDatabase;
var sessions = myDb.Sessions.Where(s => s.ProjectName == ProjectName).ToArray(); // theoretically this database contains only projects with the correct project name
sessions.Count()
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Clear();
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("PressureRange", Postprocessing.PressureRange);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("VelocityXMax", Postprocessing.VelocityXMax);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("Massflux", Postprocessing.Massflux);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("NipShearRate", Postprocessing.NipShearRate);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("NipShearRateCylinder", Postprocessing.NipShearRateCylinder);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("ShearStressCylinder", Postprocessing.ShearStressCylinder);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("NipShearRateSubstrate", Postprocessing.NipShearRateSubstrate);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("ShearStressSubstrate", Postprocessing.ShearStressSubstrate);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("ViscousDissipation", Postprocessing.ViscousDissipation);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("PositionOfSynchronousFlow", Postprocessing.PositionOfSynchronousFlow);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("PositionOfStagnatingFlow", Postprocessing.PositionOfStagnatingFlow);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("dPdXatSynchronousPoint", Postprocessing.dPdXatSynchronousPoint);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("dPdXatStagnationPoint", Postprocessing.dPdXatStagnationPoint);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("dPdXatNip", Postprocessing.dPdXatNip);
BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Add("dPdXatConstantX", Postprocessing.dPdXatConstantX);
DataTable tab;
if(GenerateOutput){
if(!File.Exists("./PrintingNip/Files/PrintingNip-Part1Export.csv")){
tab = sessions.GetSessionTable(BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Select(kv => new Tuple<string, Func<ISessionInfo, object>>(kv.Key, kv.Value)).ToArray());
tab.ToCSVFile("./PrintingNip/Files/PrintingNip-Part1Export.csv", ColSep: '%');
} else{
tab = TableExtensions.FromCSVFile("./PrintingNip/Files/PrintingNip-Part1Export.csv", ColSep: '%');
}
} else {
// in this case always recreate the datatable
tab = sessions.GetSessionTable(BoSSSshell.WorkflowMgm.AdditionalSessionTableColums.Select(kv => new Tuple<string, Func<ISessionInfo, object>>(kv.Key, kv.Value)).ToArray());
tab.ToCSVFile("./PrintingNip-Part1Export.csv", ColSep: '%');
}
Loaded Fields for J2000_delta1E-06_V10_P100 Loaded Fields for J2000_delta1E-06_V10_P10000000000 Loaded Fields for J2000_delta1E-06_V10_P1000000 Loaded Fields for J2000_delta1E-06_V10_P0 Loaded Fields for J2000_delta1E-06_V1_P10000000000 Loaded Fields for J2000_delta1E-06_V1_P1000000 Loaded Fields for J2000_delta1E-06_V1_P0 Loaded Fields for J2000_delta1E-06_V1_P100 Loaded Fields for J2000_delta1E-06_V0.1_P10000000000 Loaded Fields for J2000_delta1E-06_V0.1_P1000000 Loaded Fields for J2000_delta1E-06_V0.1_P100 Loaded Fields for J2000_delta1E-06_V0.1_P0 Loaded Fields for J2000_delta1E-06_V0_P10000000000 Loaded Fields for J2000_delta1E-06_V0_P1000000 Loaded Fields for J2000_delta1E-06_V0_P100 Loaded Fields for J2000_delta1E-06_V0_P0 Loaded Fields for J2000_delta1E-05_V10_P10000000000 Loaded Fields for J2000_delta1E-05_V10_P1000000 Loaded Fields for J2000_delta1E-05_V10_P100 Loaded Fields for J2000_delta1E-05_V10_P0 Loaded Fields for J2000_delta1E-05_V1_P1000000 Loaded Fields for J2000_delta1E-05_V1_P100 Loaded Fields for J2000_delta1E-05_V1_P10000000000 Loaded Fields for J2000_delta1E-05_V1_P0 Loaded Fields for J2000_delta1E-05_V0.1_P10000000000 Loaded Fields for J2000_delta1E-05_V0.1_P1000000 Loaded Fields for J2000_delta1E-05_V0.1_P100 Loaded Fields for J2000_delta1E-05_V0.1_P0 Loaded Fields for J2000_delta1E-05_V0_P10000000000 Loaded Fields for J2000_delta1E-05_V0_P1000000 Loaded Fields for J2000_delta1E-05_V0_P100 Loaded Fields for J2000_delta1E-05_V0_P0 Loaded Fields for J2000_delta0.0001_V10_P10000000000 Loaded Fields for J2000_delta0.0001_V10_P1000000 Loaded Fields for J2000_delta0.0001_V10_P100 Loaded Fields for J2000_delta0.0001_V10_P0 Loaded Fields for J2000_delta0.0001_V1_P10000000000 Loaded Fields for J2000_delta0.0001_V1_P1000000 Loaded Fields for J2000_delta0.0001_V1_P100 Loaded Fields for J2000_delta0.0001_V1_P0 Loaded Fields for J2000_delta0.0001_V0.1_P10000000000 Loaded Fields for J2000_delta0.0001_V0.1_P1000000 Loaded Fields for J2000_delta0.0001_V0.1_P0 Loaded Fields for J2000_delta0.0001_V0.1_P100 Loaded Fields for J2000_delta0.0001_V0_P1000000 Loaded Fields for J2000_delta0.0001_V0_P10000000000 Loaded Fields for J2000_delta0.0001_V0_P100 Loaded Fields for J2000_delta0.001_V10_P1000000 Loaded Fields for J2000_delta0.0001_V0_P0 Loaded Fields for J2000_delta0.001_V10_P10000000000 Loaded Fields for J2000_delta0.001_V10_P100 Loaded Fields for J2000_delta0.001_V10_P0 Loaded Fields for J2000_delta0.001_V1_P10000000000 Loaded Fields for J2000_delta0.001_V1_P1000000 Loaded Fields for J2000_delta0.001_V1_P100 Loaded Fields for J2000_delta0.001_V1_P0 Loaded Fields for J2000_delta0.001_V0.1_P10000000000 Loaded Fields for J2000_delta0.001_V0.1_P1000000 Loaded Fields for J2000_delta0.001_V0.1_P100 Loaded Fields for J2000_delta0.001_V0.1_P0 Loaded Fields for J2000_delta0.001_V0_P10000000000 Loaded Fields for J2000_delta0.001_V0_P1000000 Loaded Fields for J2000_delta0.001_V0_P0 Loaded Fields for J2000_delta0.001_V0_P100
string[] Columns = new string[] {"PressureRange", "VelocityXMax", "Massflux", "NipShearRate", "NipShearRateCylinder", "ShearStressCylinder", "NipShearRateSubstrate", "ShearStressSubstrate", "ViscousDissipation", "PositionOfSynchronousFlow", "PositionOfStagnatingFlow", "dPdXatSynchronousPoint", "dPdXatStagnationPoint", "dPdXatNip", "dPdXatConstantX"};
string[] Labels = new string[] {"Pressure", "Velocity", "Massflux", "Shearrate (Nip)", "Shearrate (Cylinder)", "Shearforce (Cylinder)", "Shearrate (Substrate)", "Shearforce (Substrate)", "Dissipation", "$x_{sync}$", "$x_{stag}$", @"$\\\frac{\\\partial p}{\\\partial x}_{sync}$", @"$\\\frac{\\\partial p}{\\\partial x}_{stag}$", @"$\\\frac{\\\partial p}{\\\partial x}_{nip}$", @"$\\\frac{\\\partial p}{\\\partial x}$"};
string[] Units = new string[] {@"$\\\left[\\\frac{N}{m^2}\\right]$", @"$\\\left[\\\frac{m}{s}\\right]$", @"$\\\left[\\\frac{kg}{s}\\right]$", @"$\\\left[\\\frac{1}{s}\\right]$", @"$\\\left[\\\frac{1}{s}\\right]$", @"$\\\left[N\\right]$", @"$\\\left[\\\frac{1}{s}\\right]$", @"$\\\left[N\\right]$", @"$\\\left[W\\right]$", @"$\\\left[m\\right]$", @"$\\\left[m\\right]$", @"$\\\left[\\\frac{N}{m^3}\\right]$", @"$\\\left[\\\frac{N}{m^3}\\right]$", @"$\\\left[\\\frac{N}{m^3}\\right]$", @"$\\\left[\\\frac{N}{m^3}\\right]$"}; // some escape character nonsense
var tab2export = tab.ExtractColumns(Columns.ToList().Prepend("id:V_Wall").Prepend("id:P_Diff").Prepend("id:Radius").Prepend("id:delta").Prepend("SessionName").ToArray());
if(GenerateOutput){
tab2export.ToHTMLFile("PrintingNip-Part1.html", Path.GetFullPath("./PrintingNip/Files"));
tab2export.ToCSVFile("./PrintingNip/Files/PrintingNip-Part1.csv", ColSep: ';');
} else {
tab2export.ToHTMLFile("PrintingNip-Part1.html", Path.GetFullPath("./"));
tab2export.ToCSVFile("./PrintingNip-Part1.csv", ColSep: ';');
}
var tab2plt = tab.ExtractRows((i,row) => Convert.ToDouble(row["id:P_Diff"]).ApproxEqual(0.0) && Convert.ToDouble(row["id:V_Wall"])>0.0);
List<Plot2Ddata> plts = new List<Plot2Ddata>();
foreach(string col in Columns){
int k = Columns.IndexOf(col);
var plt = tab2plt.ToPlot("id:delta", col, ColName_GroupSelection: new string[] { "id:V_Wall" });
plt.LogX = true;
plt.LogY = true;
plt.Xlabel = @"Nip Width $\\\left[m\\right]$";
plt.Ylabel = Labels[k] + " " + Units[k];
plt.LabelTitleFont = 32;
plt.LabelFont = 24;
plt.LegendFont = 18;
plt.lmargin = 12;
plt.bmargin = 4;
plt.ShowLegend = true;
plt.LegendBox = true;
if(plt.Regression().Average(kv => kv.Value) > 0){
plt.LegendAlignment = new string[]{"i", "l", "t"};
plt.LegendSwap = true;
} else{
plt.LegendAlignment = new string[]{"i", "r", "t"};
plt.LegendSwap = false;
}
for(int n= 0; n < plt.dataGroups.Count(); n++){
plt.dataGroups[n].Format.LineWidth = 2;
plt.dataGroups[n].Format.PointSize = 1;
plt.dataGroups[n].Name = "$V_W = " + Convert.ToDouble(plt.dataGroups[n].Name.Split("id:V_Wall").Last()).ToString("N1") + @" \\\frac{m}{s}$";
}
plt.ModFormat();
plts.Add(plt);
}
int k = 0;
foreach(var plt in plts){
var gp = new Gnuplot();
gp.PlotLogSlope(plt, format: new PlotFormat(lineColor: (LineColors)7));
gp.Cmd("set key box width -5");
plt.ToGnuplot(gp);
if(GenerateOutput){
gp.PlotCairolatex().SaveTo("./PrintingNip/Figures/Part1/P0_V_"+Columns[k]+".tex");
} else {
gp.PlotNow().Display();
}
k++;
}
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!