7. Getting started

The purpose of this chapter is to guide new users during their first steps with PI-DSMC.

First of all, the simulation must be set up in PIDSMCconfig with the goal to obtain a configuration file that can be used with PIDS2geo or PIDS3geo. The following text illustrates the steps to perform a 2D simulation.

After starting PIDSMCconfig, select 2D in order to generate a new 2D data set.

I suggest defining the gas first. To do that, select "Gas" from the menu "Setup". Click on "molecular species" and add a predefined gas species to the gas mixture. Let's assume there is only one gas species for now.
Go back to "Reference gas" and select an initial state. Set the density to the highest density in the flow. If the highest density is not known at the beginning, the value must be determined from a first simulation. Set the fraction of species to 1 for gas species 1 and the setup of the gas is done.

The next step is to define the size of the domain and the boundary conditions at the edges of the domain. Select "Domain and general" from the menu "Setup". Enter the minimum and maximum coordinates for the x and y axis.
Select the boundary condition for each domain edge. Select "Interface with the reference gas" if gas should enter at that edge. The properties of the entering gas are that of the reference gas defined earlier. Select "Interface with a vacuum" if molecules exit the domain when crossing that edge. No molecules are created at the edge when this boundary condition is selected. Choose "Not in the flow" when the edge is completely inside a solid body.

Set the number of domains so that the available CPUs are utilized efficiently. Each domain will use 4 threads. If the demo version is used, the number of domains must be 1. The shape for domain decomposition does not matter much in 2D. Leave the resource factor at 500 for the first simulation.

Now that the gas and the domain is set up, the geometry, i.e. the surfaces interacting with the gas, must be set up.
In this example a simple triangle that is surrounded by gas will be generated. To do that, click on "Add surface" to create a new surface primitive. Click inside the domain to define the starting point and click again at a different location to define the ending point. A line will be drawn. If you move the mouse over the line a circle will be moving along the line. The gas will be on the right of the path that the moving circle marks.
Click on "Add intersection" and click on the line. Now click somewhere to the right of the path marked by the moving circle to create another line segment. You should now see two line segments connected at one point.
Click on "Edit" and click on one of the line segments. Check the box "The surface is closed when checked or open otherwise" in order to turn the line segments into a closed surface and click "OK". Note that a third line segment was created and the triangle is complete.
Click on the newly generated line segment and enter 1 for the "number of sampling intervals". In the same window a surface group must be created to define the boundary conditions at the surface. Click on "add", then select the newly generated entry and click "edit". Enter 3 for the "Number of sampling intervals" and click "OK". The surface of the triangle is now configured as a solid surface.

Before saving the configuration, select "Consistency Check" from the menu "Setup" to check the configuration for errors. If no errors were reported, save the data set and exit PIDSMCconfig.

Now that the configuration was created, the data set can be generated. To do that run PIDS2geo:
PIDS2geo -d directory -g configuratio_file.ds2

After PIDS2geo completed, the calculation can be started. To run PIDSMC enter:
"mpiexec -n x PIDSMC -d directory -v" where x is the number of domains.

Depending on the configuration of your system mpiexec places the MPI ranks on different computers. Please consult your system administrator for instructions on how to start a mpi program on your system.
If you are using a batch system certain machines might be assigned to your job. In order to run PIDSC on a specific machine type;
"mpiexec -n x -hosts computer1:y,computer2:y,computer3:y... PIDSMC -d directory -v" where x is the number of domains and y is the number of domains per computer. y times 4 should be the number of CPU cores on that computer.

The simulation should be left running until the number of particles remains constant, assuming the simulation has an inlet and and outlet. The number of particles over time is written to a file called "Convergence.dat" in the directory of the data set. The information in that file can be easily visualized using gnuplot.

After then number of molecules converged, run "PIDSMCfrontend -se_on -q" to stop the simulation and store the data set.

Now generate a vtk file by executing "PIDSMCoutput -d directory". After PIDSMCoutput started, simply chose option 1 to generate a file in vtk format, and after that select option 1 again to output all quantities.
Open the file in paraview and check that the quantity "mcs/mfp" is less than 1/3 throughout the domain. If the value is significantly higher, the number of molecules has to be increased. If mcs/mfp is too high, the collisions in the flow are not represented correctly and the resulting flow field will be incorrect. Please note that this is an empirical criterion. Higher values of mcs/mfp than 1/3 might produce correct results in some applications.

In order to increase the number of molecules, I suggest the following strategy:
First of all, the resource factor should be increased. An increase in the resource factor will lead to a finer cell structure and more simulated molecules. The additional molecules and the finer cell structure will consume more memory.
Depending on the size of the system memory, there comes a point when the resource factor can not be increased further but there is still room for additional molecules. In that case, start setting "Factor to multiply the number of molecules" to values larger than 1.