Part of the simulations done for `https://doi.org/10.1063/5.0139000`

In [1]:

```
#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();
```

In [2]:

```
string ProjectName4Correlation = "PrintingNip_Part1";
string ProjectName = "PrintingNip_Part2";
```

In [3]:

```
BoSSSshell.WorkflowMgm.Init(ProjectName4Correlation);
static var myDb4Correlation = BoSSSshell.OpenDatabase(BoSSSshell.WorkflowMgm.DefaultDatabase.Path);
Console.WriteLine("Initializing : " + myDb4Correlation.Path); // we need to init the static var! otherwise we end up with a reference to the wrong database!
```

In [4]:

```
BoSSSshell.WorkflowMgm.Init(ProjectName);
static var myDb = BoSSSshell.OpenDatabase(BoSSSshell.WorkflowMgm.DefaultDatabase.Path);
Console.WriteLine("Initializing : " + myDb.Path);
```

In [5]:

```
static var myBatch = BoSSSshell.GetDefaultQueue();
```

In [6]:

```
BoSSSshell.WorkflowMgm.SetNameBasedSessionJobControlCorrelation();
```

In [7]:

```
double H0 = 1e-5;
double V0 = 1.0;
double P0 = 1e6;
```

In [8]:

```
var sessions = myDb4Correlation.Sessions.Where(s => s.ProjectName == "PrintingNip_Part1").ToArray();
var sV = sessions.Single(s => Convert.ToDouble(s.KeysAndQueries["id:delta"]).ApproxEqual(H0) & Convert.ToDouble(s.KeysAndQueries["id:P_Diff"]).ApproxEqual(0.0) & Convert.ToDouble(s.KeysAndQueries["id:V_Wall"]).ApproxEqual(V0));
var sP = sessions.Single(s => Convert.ToDouble(s.KeysAndQueries["id:delta"]).ApproxEqual(H0) & Convert.ToDouble(s.KeysAndQueries["id:P_Diff"]).ApproxEqual(P0) & Convert.ToDouble(s.KeysAndQueries["id:V_Wall"]).ApproxEqual(0.0));
```

Function to create the velocity profile along the symmetry axis

In [9]:

```
using MathNet.Numerics.Interpolation;
```

In [10]:

```
static public CubicSpline ConstructVelocitySpline(ISessionInfo si) {
DGField VelocityX = si.Timesteps.Last().Fields.Single(f => f.Identification == "VelocityX");
var grd = (GridData)VelocityX.GridDat;
EdgeMask em = new EdgeMask(grd, X => Math.Abs(X[1]) < 1e-12); // symmetry axis
var Spline = Postprocessing.SplineOnEdge(em, VelocityX, 0, out double lB, out double uB);
return Spline;
}
```

Evaluate the profile for both simulations and superpose

In [11]:

```
var SplineV = ConstructVelocitySpline(sV);
var SplineP = ConstructVelocitySpline(sP);
```

In [12]:

```
double[] X = GenericBlas.Linspace(-0.01, 0.01, 1000);
double[] VV = X.Select(x => SplineV.Interpolate(x)).ToArray();
double[] VP = X.Select(x => SplineP.Interpolate(x)).ToArray();
BoSSSshell.Plot(X, VV, "u_A", "k-", X, VP, "u_B", "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.!

Out[12]:

In [13]:

```
Func<double, double, double, double, double> VelocityFunc = (x, h, v, p) => v/V0 * SplineV.Interpolate(x * Math.Sqrt(H0) / Math.Sqrt(h)) + (p * Math.Pow(h,1.5))/(P0 * Math.Pow(H0,1.5)) * SplineP.Interpolate(x * Math.Sqrt(H0) / Math.Sqrt(h));
```

Set Velocity to be zero at a certain x_stag and calculate the necessary pressure difference

In [14]:

```
Func<double, double, double, double> PressureFunc = (x_stag, h, v) => -v/V0 * SplineV.Interpolate(x_stag * Math.Sqrt(H0) / Math.Sqrt(h)) * (P0 * Math.Pow(H0,1.5)) / (Math.Pow(h,1.5) * SplineP.Interpolate(x_stag * Math.Sqrt(H0) / Math.Sqrt(h)));
```

In [15]:

```
double[] deltaS = new double[] {
0.001, // millimeters
//0.0005,
0.0001,
//0.00005,
0.00001,
//0.000005,
0.000001 }; // micro-meter
double[] V = new double[] {
0.1,
0.5,
1.0,
5.0,
10.0}; // Wall velocities in m/s
// always same
int Res = 10;
int DGdegree = 5;
double R = 0.1;
double x_stag = 0.01; // always at 10 mm
// set grid to be saved in database
GridFactory.myDb = myDb;
```

In [16]:

```
var controls = new List<XNSE_Control>();
foreach(double delta in deltaS) {
foreach(double V_wall in V) {
double p = PressureFunc(x_stag, delta, V_wall);
var C = new XNSE_Control();
C.DbPath = myDb.Path;
C.SetDGdegree(DGdegree);
C.SetGrid(GridFactory.GenerateGrid(Res,delta, R));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("Res", Res));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("delta", delta));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("Radius", R));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("V_Wall", V_wall));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("P_Diff", p));
C.Paramstudy_CaseIdentification.Add(new Tuple<string, object>("X_Stag", x_stag));
C.AddBoundaryValue("wall_walze", "VelocityX", BoundaryValueFactory.Get_VelX(delta, V_wall, R));
C.AddBoundaryValue("wall_walze", "VelocityY", BoundaryValueFactory.Get_VelY(delta, V_wall, R));
C.AddBoundaryValue("wall_substrat", "VelocityX", BoundaryValueFactory.Get_VelX(delta, V_wall, R));
C.AddBoundaryValue("wall_substrat", "VelocityY", BoundaryValueFactory.Get_VelY(delta, V_wall, R));
C.AddBoundaryValue("pressure_outlet_in", "Pressure", $"X => {p}", false);
C.AddBoundaryValue("pressure_outlet_out", "Pressure", $"X => {-p}", false);
C.TimesteppingMode = AppControl._TimesteppingMode.Steady;
C.PhysicalParameters.rho_A = 1026.4;
C.PhysicalParameters.mu_A = 0.0395;
C.PhysicalParameters.IncludeConvection = false;
C.Timestepper_LevelSetHandling = BoSSS.Solution.XdgTimestepping.LevelSetHandling.None;
C.SessionName = "J" + (20*Res*Res) + "_delta" + delta + "_V" + Math.Round(V_wall, 5) + "_xm" + x_stag;
controls.Add(C);
}
}
```

In [17]:

```
Console.WriteLine(controls.Count);
```

20

Workaround so we need to deploy the rather large executables only once!

In [18]:

```
controls.RunBatch(myBatch, true);
```

In [19]:

```
BoSSSshell.WorkflowMgm.BlockUntilAllJobsTerminate(18000);
```

All jobs finished.

Assert that, all sessions are present and all finished successful

In [20]:

```
int count = BoSSSshell.wmg.Sessions.Count();
int success = BoSSSshell.wmg.Sessions.Where(s => s.SuccessfulTermination).Count();
if(count != controls.Count() || count != success){
throw new ApplicationException("Not all simulations calculated or finished successful!");
}
```