|
This tutorial shows how to do a parameter study by using the autonumber function in DPMBase. This tutorial treats the case in which only a 1D parameter study has to be performed, for example one wants to study the same setup but for different particle sizes. In the image below a schematic overview is given for a 1D parameter study, This tutorial explains only how to setup a parameter study, for (more) realistic geomtries or complicated setups one is referred to the other tutorials.
Definition of words:
Parameter study: The complete set of simulations that needs to be run in which parameters change value based on the dimension set. This is done by creating a exectuable of the complete parameter study that is capable of starting many simulations. Parameter study is sometimes abreviated to study.
Simulation: A single simulation that is part of the parameter study. The simulation is not a distinct executable, but run through the parameter study executable.
The following headers are included:
These are the headers needed for this tutorial.
The main class inherits from Mercury3D.
All steps needed in order to create this class are explained below.
Step 1: (Private) Member variables.
The private member variables are needed in order to keep track of which simulation has to be run next, these are stored in studyNum. The total amount of simulations that need to be performed are stored in dim1_. studyNum is build up as follows:
The first entry is storing an integer giving information on the completeness of the study. If the value is 0 the parameter study is incomplete, if the value is 1 (or larger) the study is complete.
The second entry is storing the current run in the first dimension of the parameter study.
Step 2: Set- and Get-functions for private member variables.
The set- and get-functions are needed to access the private member variables in the public member functions of ParameterStudy1DDemo.
Step 3: Create the particle species.
In this case it has been chosen to create a separate function for the particle species. In principle any contact model can be chosen here, but for the sake of simplicity a simple LinearViscoelasticFrictionSpecies is implemented.
Step 4: Setup the initial conditions.
The initial conditions are run inside the DPMBase::solve() routine. This means that before the actual simulation is started, this function is run first. This makes us able to do the following things. First we get the studyNum, as we need this information to setup the current simulation. Also the createSpecies function is called (see Step 3). Afterwards two particles are inserted. Note that in these lines the studyNum is used to change the particle radius of particle 1. the variable studyNum gets assigned integer values, starting from 1 and ranging to dim1_ (which will be set through main()).
Step 5: Seting up the parameter study.
This is probably the most difficult part of the tutorial, as the previous steps are similar to other tutorials that can be found. The desire is to create a smart algorithm to decide what simulation runs have to be performed. It might happen that one runs the executable twice in the same directory, or that you want to extend the previous dimension of your parameter study. In this case the previous simulations do not need to be rerun, as all the data is already known and stored. Hence in actionsBeforeTimeLoop this is checked by looking for data-files of a certain name as well as checking the studyNum. If the study is complete the parameter study is done, and hence the process is terminated by the exit code. If the data-file has been found, but the study is not yet complete the program is taking a short-cut by skipping the current simulation (without rerunning) and starting the next.
Please Note: Not all systems use the same syntax to start simulations. For this reason the entry in the functions "launchNewRun(..)" might be slightly different depending on the operating system you use.
If none ot the above options are triggered, in other words the simulation has to be performed, the code is simply run. At the end of the simulation it is once again checked if the parameter study is completed (the case if this simulation is the last one of the study) or if a new simulation has to be started.
Step 6: Creating the main() function The main function contains some core function calls that setup the parameter study, but also have some information that is the same for each simulation (e.g. the system dimensions). In principle one could place everything that is equal in all simulations here. Typically one wants to perform a parameter study in which particle properties or contact models are changed, hence these can be found in the ParameterStudy1DDemo class, it is less likely that the system dimensions need to be changed. If however this is the case for you, simply move the lines setXMax(), etc. to the setupInitialConditions(). The key line in main() is problem.autonumber(), this creates the file COUNTERDONOTDEL and stores the information needed for the parameter study. This file should only be deleted in the cases: The data is backed up in a different directory (as then the executable is no longer able to make changes).
One wants to rerun the parameter study completely.
The last thing we need to do is to set the dimension os the 1D parameter study, in this case it is set to 4. This means that in total we want 4 simulations.
If you would like to continue to the 2D or 3D parameter study demos:
ParameterStudy2DDemo
ParameterStudy3DDemo
Or return to Overview of advanced tutorials