Software/BDSIM: Difference between revisions

From PBTWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Work in progress (JChappell 17/10/17)
== BDSIM ==
== BDSIM ==


Line 9: Line 7:
** [http://www.pp.rhul.ac.uk/bdsim/manual/index.html BDSIM Documentation]
** [http://www.pp.rhul.ac.uk/bdsim/manual/index.html BDSIM Documentation]
** [https://bitbucket.org/jairhul/bdsim BDSIM Bitbucket Page]
** [https://bitbucket.org/jairhul/bdsim BDSIM Bitbucket Page]
** [http://www.pp.rhul.ac.uk/bdsim/manual/installation.html Official Installation Guide]


This is a tutorial about installing and using BDSIM. BDSIM is installed on the HEP Linux cluster at UCL. You will need an account on that cluster to be able to use this software, run example tutorials and create your own simulations.  
This is a tutorial about installing and using BDSIM. BDSIM is installed on the HEP Linux cluster at UCL. You will need an account on that cluster to be able to use this software, run example tutorials and create your own simulations.  
Line 17: Line 16:


In order to use the UCL HEP Linux cluster, you will need a HEP account: please contact Dr. Simon Jolly for more details.  
In order to use the UCL HEP Linux cluster, you will need a HEP account: please contact Dr. Simon Jolly for more details.  
=== Running on the UCL HEP Linux Cluster ===
In order to run <code>BDSIM</code> simulations on the UCL HEP Cluster, you must first source the development version of the PBT environment from a system within the cluster that is running Scientific Linux V6. This can be done using the following command:
<pre>
source /unix/pbt/software/scripts/pbt.sh -vd
</pre>
'''Note:''' the '-d' flag is essential as this sources the script that links the latest development software available on the PBT section of the cluster.
Following this, a second script must be sourced in order to create the environment required to run <code>BDSIM</code>:
<pre>
source /unix/pbt/software/scripts/bdsim_setup.sh
</pre>
Now your system is ready to use <code>BDSIM</code>. To check that it is working correctly, test the built-in help function:
<pre>
bdsim --help
</pre>
This should produce an output explaining all the possible options that can be used within <code>BDSIM</code>.


== Required Software ==
== Required Software ==
Line 32: Line 55:
These are all installed on the UCL HEP cluster.
These are all installed on the UCL HEP cluster.


== Details ==
; Website: https://twiki.ph.rhul.ac.uk/twiki/bin/view/PP/JAI/BdSim
; Latest Version: 0.9.9.2 (19th October 2017)
== Installation Instructions ==
The installation process follows the general process described on the [[Software/Geant4/UCL HEP Cluster|UCL HEP Linux Cluster]] page. 
The basic method used is as follows:
# Check that all the prerequisites for building <code>BDSIM</code> are installed (see above);
# Download the latest version of the source code;
# Create a build folder;
# Configure, build and install <code>BDSIM</code> from within the build folder.
=== Download BDSIM from its central repository ===
The BDSIM source code can be downloaded from its git repository using:
<pre> git clone --recursive <nowiki>https://bitbucket.org/jairhul/bdsim</nowiki> </pre>
This creates a <code>/bdsim</code> folder within your current folder. This folder contains all the code, examples, documentation and associated Python packages.
=== Configure, build and install <code>BDSIM</code> ===
'''Note:''' When installing <code>BDSIM</code>, all the <code>Geant4</code> environment variables must be available. This can be tested using the following command:
<pre> echo $G4 <tab> </pre>
If the <code>Geant4</code> environment variables are available, you should see an output similar to:
<pre>
$G4ABLADATA          $G4NEUTRONHPDATA      $G4REALSURFACEDATA
$G4ENSDFSTATEDATA    $G4NEUTRONXSDATA      $G4SAIDXSDATA
$G4LEDATA            $G4PIIDATA            $G4SHARE
$G4LEVELGAMMADATA    $G4RADIOACTIVEDATA    $G4VERSION
</pre>
This output corresponds to using the UCL PBT environment, but it will be dependent on the installed <code>Geant4</code> modules. If this does not return a list of environment variables, make sure you have correctly sourced the <code>Geant4</code> environment script and updated all relevant path variables.
Once the source code has been downloaded, a build directory should be created alongside the <code>src</code> to hold the compiled <code>BDSIM</code> files before they are moved to their final installation location.
On the UCL HEP Linux Cluster, the build directory should be created in <code>/unix/pbt/software/build</code>:
<pre>
cd /unix/pbt/software/build
mkdir bdsim
cd bdsim
mkdir bdsim-0.9.9.2-build
cd bdsim-0.9.9.2-build
</pre>
Unlike other software installed on the UCL HEP Linux Cluster, there are a number of ways to configure the software before building. Using the <code>ccmake</code> command, each configuration option can be set interactively:
<pre>
cmake ../../../src/bdsim/bdsim-bitbucket/
ccmake .
</pre>
CMake opens an interactive configuration program. Set the options as required for your system e.g. on the UCL HEP Cluster:
<pre>
CMAKE_INSTALL_PREFIX    /unix/pbt/software/dev/bdsim-0.9.9.2/
USE_AWAKE                ON
</pre>
Note that the <code>CMAKE_INSTALL_PREFIX=/unix/pbt/software/dev/bdsim-0.9.9.2</code> flag specifies that the resulting <code>BDSIM</code> should be installed in the directory <code>/unix/pbt/software/dev/bdsim-0.9.9.2</code> after compilation: this should be changed to suit the particular installation in question.
*''c'' to configure.
*''g'' to generate and exit.
<code>BDSIM</code> can then be compiled and installed by running:
<pre>
make
make install
</pre>
== Testing ==
Multiple examples are provided with the source code and can be found in the original build folder. A complete list of examples and tutorials for running them can be found at http://www.pp.rhul.ac.uk/bdsim/manual/examples/examples.html
Here, the simpleMachine example will be demonstrated.
First, navigate to the examples within build directory and find simpleMachine:
<pre>
cd /unix/pbt/software/build/bdsim/bdsim-0.92-dev/bdsim-build-updated/examples
cd simpleMachine
</pre>
To run the simulation via the GUI use the command:
<pre>
bdsim --file=sm.gmad
</pre>
An interface should load up and display the simpleMachine setup. It has a few drift beam pipes with a quadrupole, collimator and sector bend dipole magnet. To run the simulation once with any output exported to a file called <code>output.root</code>, use the following command:
<pre>
bdsim --file=sm.gmad --outfile=output
</pre>
From within the GUI command line, type:
<pre>
/run/beamOn 1
exit
</pre>
This will execute a single run of the simulation with the output data exported to <code>output.root</code>. This can then be analysed from within ROOT by following the tutorial at http://www.pp.rhul.ac.uk/bdsim/manual/output_analysis.html.
To run this simulation in Batch mode, the following command can be used:
<pre>
bdsim --file=sm.gmad --outfile=output --batch
</pre>
Batch mode has no interactive interface, but as a consequence is much faster and exits the program once it has finished. For simulations with large numbers of particles within the beam, this is the preferred method of use.





Revision as of 16:16, 19 October 2017

BDSIM

BDSIM (Beam Delivery Simulation) is a program that uses a suite of high energy physics software including Geant4, CLHEP & ROOT to build a 3D model of an accelerator and simulate the passage of particles through both the vacuum and the material of the accelerator itself seamlessly.

This is a tutorial about installing and using BDSIM. BDSIM is installed on the HEP Linux cluster at UCL. You will need an account on that cluster to be able to use this software, run example tutorials and create your own simulations.

Running BDSIM Simulations

In order to run BDSIM simulations, you will either need to download and install the software yourself or make use of the existing installation on the UCL HEP Linux cluster.

In order to use the UCL HEP Linux cluster, you will need a HEP account: please contact Dr. Simon Jolly for more details.

Running on the UCL HEP Linux Cluster

In order to run BDSIM simulations on the UCL HEP Cluster, you must first source the development version of the PBT environment from a system within the cluster that is running Scientific Linux V6. This can be done using the following command:

source /unix/pbt/software/scripts/pbt.sh -vd

Note: the '-d' flag is essential as this sources the script that links the latest development software available on the PBT section of the cluster.

Following this, a second script must be sourced in order to create the environment required to run BDSIM:

source /unix/pbt/software/scripts/bdsim_setup.sh

Now your system is ready to use BDSIM. To check that it is working correctly, test the built-in help function:

bdsim --help

This should produce an output explaining all the possible options that can be used within BDSIM.

Required Software

BDSIM requires the following software to be installed:

  • Recent compiler with full C++11 support - proven compiler versions are GCC v4.9 or higher, or Clang 6 or higher.
  • CMake v2.8.12 or higher
  • CLHEP v2.1.3.1 or higher
  • ROOT v6.x or higher
  • Geant4 v4.10 or higher
  • Flex v2.5.37 or higher
  • Bison v2.3 or higher

These are all installed on the UCL HEP cluster.

Details

Website
https://twiki.ph.rhul.ac.uk/twiki/bin/view/PP/JAI/BdSim
Latest Version
0.9.9.2 (19th October 2017)

Installation Instructions

The installation process follows the general process described on the UCL HEP Linux Cluster page. The basic method used is as follows:

  1. Check that all the prerequisites for building BDSIM are installed (see above);
  2. Download the latest version of the source code;
  3. Create a build folder;
  4. Configure, build and install BDSIM from within the build folder.

Download BDSIM from its central repository

The BDSIM source code can be downloaded from its git repository using:

 git clone --recursive https://bitbucket.org/jairhul/bdsim 

This creates a /bdsim folder within your current folder. This folder contains all the code, examples, documentation and associated Python packages.

Configure, build and install BDSIM

Note: When installing BDSIM, all the Geant4 environment variables must be available. This can be tested using the following command:

 echo $G4 <tab> 

If the Geant4 environment variables are available, you should see an output similar to:

 
$G4ABLADATA          $G4NEUTRONHPDATA      $G4REALSURFACEDATA 
$G4ENSDFSTATEDATA    $G4NEUTRONXSDATA      $G4SAIDXSDATA 
$G4LEDATA            $G4PIIDATA            $G4SHARE 
$G4LEVELGAMMADATA    $G4RADIOACTIVEDATA    $G4VERSION 

This output corresponds to using the UCL PBT environment, but it will be dependent on the installed Geant4 modules. If this does not return a list of environment variables, make sure you have correctly sourced the Geant4 environment script and updated all relevant path variables.

Once the source code has been downloaded, a build directory should be created alongside the src to hold the compiled BDSIM files before they are moved to their final installation location.

On the UCL HEP Linux Cluster, the build directory should be created in /unix/pbt/software/build:

cd /unix/pbt/software/build
mkdir bdsim
cd bdsim
mkdir bdsim-0.9.9.2-build
cd bdsim-0.9.9.2-build

Unlike other software installed on the UCL HEP Linux Cluster, there are a number of ways to configure the software before building. Using the ccmake command, each configuration option can be set interactively:

cmake ../../../src/bdsim/bdsim-bitbucket/

ccmake .

CMake opens an interactive configuration program. Set the options as required for your system e.g. on the UCL HEP Cluster:

CMAKE_INSTALL_PREFIX     /unix/pbt/software/dev/bdsim-0.9.9.2/
USE_AWAKE                ON

Note that the CMAKE_INSTALL_PREFIX=/unix/pbt/software/dev/bdsim-0.9.9.2 flag specifies that the resulting BDSIM should be installed in the directory /unix/pbt/software/dev/bdsim-0.9.9.2 after compilation: this should be changed to suit the particular installation in question.

  • c to configure.
  • g to generate and exit.

BDSIM can then be compiled and installed by running:

make
make install

Testing

Multiple examples are provided with the source code and can be found in the original build folder. A complete list of examples and tutorials for running them can be found at http://www.pp.rhul.ac.uk/bdsim/manual/examples/examples.html

Here, the simpleMachine example will be demonstrated.

First, navigate to the examples within build directory and find simpleMachine:

cd /unix/pbt/software/build/bdsim/bdsim-0.92-dev/bdsim-build-updated/examples
cd simpleMachine

To run the simulation via the GUI use the command:

bdsim --file=sm.gmad

An interface should load up and display the simpleMachine setup. It has a few drift beam pipes with a quadrupole, collimator and sector bend dipole magnet. To run the simulation once with any output exported to a file called output.root, use the following command:

bdsim --file=sm.gmad --outfile=output

From within the GUI command line, type:

/run/beamOn 1
exit

This will execute a single run of the simulation with the output data exported to output.root. This can then be analysed from within ROOT by following the tutorial at http://www.pp.rhul.ac.uk/bdsim/manual/output_analysis.html.

To run this simulation in Batch mode, the following command can be used:

bdsim --file=sm.gmad --outfile=output --batch

Batch mode has no interactive interface, but as a consequence is much faster and exits the program once it has finished. For simulations with large numbers of particles within the beam, this is the preferred method of use.