Convergence Study using the Meta Job Manager

Initialization

In order to execute the individual solver runs, we are going to employ the mini batch processor, for running the calculations on the local machine. We also have to initialize the workflow management system and create a database.

Note:

  1. This tutorial can be found in the source code repository as as convStudy.ipynb. One can directly load this into Jupyter to interactively work with the following code examples.
  2. In the following line, the reference to BoSSSpad.dll is required. You must either set #r "BoSSSpad.dll" to something which is appropirate for your computer (e.g. C:\Program Files (x86)\FDY\BoSSS\bin\Release\net5.0\BoSSSpad.dll if you installed the binary distribution), or, if you are working with the source code, you must compile BoSSSpad and put it side-by-side to this worksheet file (from the original location in the repository, you can use the scripts getbossspad.sh, resp. getbossspad.bat).

The following (deactivated) line would delete all Sessions (i.e. solver runs) which correspond to this project from the database. Hence, on every execution of the worksheet, all simulations would be re-done.

Normally, without the following line, existing simulations from the database will be used; therefore, it is save to close and open the worksheet.

This is handy e.g. when simulations are running on a cluster for a long time, and we usually don't want to re-submit the calculation every time we execute the worksheet.

BoSSSshell.WorkflowMgm.Sessions.ForEach(si => si.Delete(true));

For sake of simplicity, we employ the Poisson solver ipPoisson which is just a benchmarking application, but sufficient for the purpose of this tutorial.

Mesh Creation

We create multiple grids using resolutions of $2 \times 2$, $4 \times 4$ to $32 \times 32$ cells:

Setup and execution of solver runs

First, we implement the exact expressions for the right-hand-side $$ f(x,y)= -2\cos(x)\cos(y)$$ and the exact solution. $$ u_{sol} (x,y)=\cos(x) \cos(y) $$

The exact solution will be used to compute the error of the simulation. Normally, the exact solution is not known; in those cases, we need to compute the experimental convergence against the solution on the finest grid.

We compute 4 different polynomial orders:

Setup of all runs...

...and activate them:

The following line ensures that all jobs are complete before post-processing analysis is started, although, there is a one-hour (3600-seconds ) time-out.

Note that, in a larger production run study, where jobs may run days or weeks, blocking the worksheet is not really usefull. Instead, one might split process into two workseets (eactly at this line here), one for set-up and job sumbission and another one for the analysis.

We can take a closer inspection of anything that failed (should not be, anyway).

Convergence against exact solution

As already noted, the computation of the $L^2$ error against the exact solution is handled specially in the ipPoisson solver. However, the following tutorial can serve as a general template of how to extract data from the session table and visualize it.

We aquire a copy of the session table, and from all the columns in there...

...we extract those which sound interesting:

Note: the session table can also be exported, e.g. to Excel or Libre/Open Office Calc, by using the ToCSVFile function.

The columns of the session table can be easily converted to a plot: the $x$-axis is determined by the cell width, the $y$-axis is determined by the $L^2$ error. Furthermore, we want to group our plots according to the DG degree, i.e. have one line for each polynomial degree;

We set logarithmic axes:

Of course, we can adjust the plot styles:

And we can compute the convergence order:

Note: these plots can also be exported to LaTeX, in a quality that is suitable for print publication: ```csharp ErrorPlot.ToGnuplot().PlotCairolatex().SaveTo("C:\tmp\errplt.tex");

experimental convergence plot

If the exact solution is not known, one can only estimate the convergence behavior experimentally. BoSSS provides some utility for this, the DGFieldComparison class, which has a versatile, yet complex interface.

However, there is a simple interface in the workflow management toolbox.

We can augment the current session table with experimental errors:

We observe, that columns have been added to the session table, starting with a prefix L2Error_

We observe that the \emph{experimental} $L^2$ error is approximately equal to the $L^2$ error against the exact solution, except for the highest resolutions. There, the error of the numerical solution is computed against itself, and thus the error is zero up to round-off errors.

If we would like to extract convergence plots from this table, we need to exclude the rows with the finest solution using e.g. the TableExtensions.ExtractRows method.

Rows could be extracted form a table using a selector function: this is an expression, which is true for all rows that we want to extract;

Working without the session table

As an alternative to working with the session table, which is sometimes not versatile enough, we demonstrate a way to extract data from the sessions in the current project directly.

Create a list in which we store a separate plot for each polynomial degree:

We adjust some plot style settings:

and we can merge all four plot objects into a singe one:

and we can also verify the slope of the error curves. Note that convergence order by using the $H^1$ norm is one degree lower compared to the $L^2$ norm..

Multiplot demonstration

If we have more than one plot object, we can arrange them in an array to realize multi-plots:

Now, we can draw an array of plots:

this already looks neat, but a few formatting tweaks to make the multi-plot look nicer:

Summary

This tutorial showed how to set-up a parameter study, by looping over a set of parameters (in this case, different grids and polynomial degrees), see sections about MeshCreation and about Setup-And-Execution. Finally, it only requires a simple loop to send all jobs to a compute resource.

Afterwards, c.f. section about ExactConvergence, the session table was used to combine measurements taken in each session (here, the $L^2$ error against the exact solution) into a single table. This table can either be exported to spreadsheet analysis software or visualized internally.