Set up and run a simulationΒΆ
Let’s first show how to set up a single simulation. The basic work-flow consists of several steps. First we have to prepare the simulation, then we run the main simulation program. This gives us a data file with the simulation results. Then we can apply various post processing steps, for example the computation of energies, plotting of norms and many more.
The first step is to create a configuration file and set the simulation parameters.
We use the file examples/harmonic_oscillators/harmonic_1D_p.py
from the examples
collection. The full content of this file is printed below:
algorithm = "hagedorn"
propagator = "semiclassical"
splitting_method = "Y4"
T = 12
dt = 0.01
dimension = 1
ncomponents = 1
eps = 0.1
potential = "quadratic"
# The parameter set of the initial wavepacket
Q = [[1.0]]
P = [[1.0j]]
q = [[1.0]]
p = [[0.0]]
S = [[0.0]]
# What it takes to specify a wavepacket!
wp0 = {
"type": "HagedornWavepacket",
"dimension": 1,
"ncomponents": 1,
"eps": eps,
"Pi": [q, p, Q, P, S],
"basis_shapes": [{
"type": "HyperbolicCutShape",
"K": 10,
"dimension": 1
}],
"coefficients": [[((0,), 1.0)]],
"innerproduct": {
"type": "HomogeneousInnerProduct",
"delegate": {
"type": "DirectHomogeneousQuadrature",
'qr': {
'type': 'TensorProductQR',
'dimension': 1,
'qr_rules': [{'dimension': 1, 'order': 14, 'type': 'GaussHermiteQR'}]
}
}
}
}
# Which wavepackets are initial values
initvals = [wp0]
leading_component = 0
# How often do we write data to disk
write_nth = 5
matrix_exponential = "pade"
Now we have to run the main simulation program. This is done by the following command:
Main.py harmonic_1D_p.py
where we have to provide the configuration file as command line option of the Main.py
program. The Main.py
command (like all other commands) supports an online help listing
the available options and switches:
Main.py --help
usage: Main.py [-h] [-o OUTPUTFILE] [-r [RESULTSPATH]] parametersfile
positional arguments:
parametersfile The simulation configuration parameters file.
optional arguments:
-h, --help show this help message and exit
-o OUTPUTFILE, --outputfile OUTPUTFILE
The data file to write the transformed data.
-r [RESULTSPATH], --resultspath [RESULTSPATH]
Path where to put the results.
When the program terminates, it leaves a file called simulation_results.hdf5
which
contains all the simulation data. This hdf
results file is stored in the local
directory where the script was called (unless specified otherwise by the -o
or -r
switches) and not in the directory where the configuration file was loaded from.
The script refuses to run if it would overwrite an existing hdf
file.
This measure is in place to prevent you from data loss.
We can use the program hdfview
for example to gain some insight of the contents
of the file. More tools for manipulating hdf files can be found on the web-page
of the [hdfgroup]. Two very useful command line tools are h5ls
and h5dump
.
[hdfgroup] | http://www.hdfgroup.org/products/hdf5_tools/ |