This page contains the basic user guide.
STARucn relies on specific ascii files to configure the various parts of the software. These scripts use a specific language. A script consists in a series of single line instructions. Empty lines and line beginning with #
are ignored.
A script line can either:
include <script>
define <name> <value>
. The value can be any chain of characters, not@{<name>}
. Constants@{this}
and@{thispath}
which refers to the absolute filname and path of the script itself.<type> <name> <value>
. Each value is caracterized by a type, name andstring
, double
, int
or bool
. More complex types canscript/parameters.typ
file.<usertype>:
- <type 1> <key 1>
- <type 2> <key 2>
A user type consists of several keys of basic types. It is used in the script with the syntax :
<user type> <name> <value key 1> <value key 2> ...
Standard and user defined variables will be accessible from the code.
When entering an integer of double value, one can also include simple arithmetic (+
, -
, *
, /
) as well as standard functions with a specific syntax. Available functions are :
Function | Syntax | Function | Syntax | Function | Syntax | |
---|---|---|---|---|---|---|
sin(x) | S(x) |
cos(x) | C(x) |
tan(x) | T(x) |
|
arcsin(x) | AS(x) |
arccos(x) | AC(x) |
arctan(x) | AT(x) |
|
sinh(x) | HS(x) |
cosh(x) | HC(x) |
tanh(x) | HT(x) |
|
exp(x) | E(x) |
ln(x) | L(x) |
√x or xy | R(x) or P(x,y) |
To run the code, call:
starucn <script>
By default, <script>
is scripts/STARucn.par
. This script controls the main function of the simulation.
One simple, minimal exemple is given here:
string RunMode Generate string Geometry @{thispath}/geo/TestBox.geo string GeoMode Star int Verbose 0 int NbParticles 1000 int MaxBounce 10000 int GenerationSeed 21235521 int InteractionSeed 76756243 mcsetup Generator VolumeGenerator @{thispath}/generator.par mcsetup Propagator StepPropagator @{thispath}/propagator.par mcsetup Interaction NeutronInteraction @{thispath}/interaction.par mcsetup Output TextOutputInterface @{thispath}/output.par string DisplayGraphics ogl string DisplayGeometry Root int StarGeometryStat 100000
The first mandatory element is the run mode of the simulation:
string RunMode <runmode>
Three basics modes are available:
Display
: display the geometry. In this mode the only mandatory information is the geometryGenerate
: run the actual full simulation.Test
: instantiate geometries and plug-ins but do not run the particle loop.The second mandatory line defines the input files describing the geometry:
string Geometry <geometry file>
The third mandatory line defines the type of geometry to be used in the simulation. STARucn uses to different internal geometry description. The ROOT base geometry (Root
) uses the ROOT TGeoVolume classes to define the geometry and benefits of the ROOT display features. Nevertheless it might get wrong when used with complex copmposite volumes. It can only be used with step-by-step propagator. STARucn implements also its own geometry package (Star
) that is recommended for simulation with both step-by-step and analytical propagator. The STARucn geometry has only poorer and slower display (see below)
string Geometry <geometry file>
The next nine parameters are only mandatory when running a simulation. They consists in several numeric constants:
int Verbose <value>
: level of verbosity, from 0 (nothing) to 2.int NbParticles <value>
: number of neutrons to generate.int MaxBounce <value>
: maximal number of bounces for each neutron. This is numericalint GenerationSeed <value>
and int InteractionSeed <value> : the seeds of the randomas well as the setup of the four plug-ins : Generator
, Propagator
, Interaction
and Output
:
mcsetup <plugin type> <class name> <config>
<config>
is the name of the script file configuring the plug-in. One can choose to include all the plug-ins configurations in the main script and use the keyword @{this}
to design the current script as the plug-in configuration.
Finally the last three parameters specify display options for the Display
runmode:
string DisplayGraphics <value>
: display with native 3D ROOT viewer (Root
) or openGL (ogl
).string DisplayGeometry <value>
: geometry mode used for display (Root
or Star
).int StarGeometryStat <value>
: total number of points in the display. The STARucn geometry display is done by randomly drawing points on the surface of each volume in the geometry.A geometry is a set of volumes, included in larger world box. Each volume is defined from a shape, a
material and a placement matrix. Here is a simple example of an empty cubic box:
int Transparency 70 geometry Geo 200 200 200 Inside|Top|Bottom|Front|Back|Right|Left material Vacuum 0 0 0 880 2 material BeO 250 0.5 0.001 0 4 matrix M2 0 0 105 0 0 0 matrix M3 0 0 -105 0 0 0 matrix M4 0 105 0 0 0 0 matrix M5 0 -105 0 0 0 0 matrix M6 105 0 0 0 0 0 matrix M7 -105 0 0 0 0 0 matrix Id 0 0 0 0 0 0 volume Top BeO Box 100|100|5 M2 0 volume Bottom BeO Box 100|100|5 M3 0 volume Front BeO Box 100|5|110 M4 0 volume Back BeO Box 100|5|110 M5 0 volume Right BeO Box 5|120|110 M6 0 volume Left BeO Box 5|120|110 M7 0 volume Inside Vacuum Box 100|100|100 Id 0
The overall geometry is defined by:
geometry Geometry <WorldX> <WorldY> <WorldZ> <volumes>
with :
<WorldX> <WorldY> <WorldZ>
are half length in x, y, and z direction of the world box<volumes>
is the list of the volumes constituting the geometry. It consists of the name of theFor display purposes one can also specify a fraction of transparency of the volumes for OpenGL, with
int Transparency <value>
Materials are defined with the command:
material <name> <Vf> <d> <eta> <tau> <color>
where:
<name>
is the name under which the material will be referred to afterwards,<Vf>
is the Fermi potential, in neV,<d>
is the fraction of diffuse reflection,<eta>
is the absorption coefficient upon reflection, defined as the ration of the imaginary and real<tau>
is the effective lifetime, in seconds, of the neutron in the medium. If this value is zero or<color>
is the color used for displaying any volume build from this material. The color schemeExtra properties can be added, for use in user-defined plugins. For any material one can add a property
as :
materialpropery <materialname>.<propertyname> <value>
Volumes are build following the volume definition from the ROOT geometry package (see chapter 18 of
the ROOT user’s guide). Distances are given in millimetres and angles in degrees. Shapes are always
centred around the (0,0,0) point and along the vertical z-axis and therefore need a transformation matrix
to place them within the geometry:
volume <name> <material> <type> <def> <matrix> <flag>
where :
<type>
is the type of shape. The available shapes, corresponding to the ROOT shapes classesTGeo<type>
are : Arb8
, Box
, Cone
, Cons
, Ctub
, Eltu
, Gtra
, Hype
, Para
, Pcon
, Pgon
, Sphere
, Toru
, Trap
, Trd1
, Trd2
, Tube
and Tubs
.<def>
is the list of parameters defining the shape. They are given in the same order as in the ROOT<matrix>
is the placement matrix.<flag>
is an additional integer flag that can be used for various purposes.Alternatively, one can also define composite volumes:
composite <name> <material> <def> <matrix> <flag>
where <def>
follow the syntax of composite volumes in the ROOT geometry package. As an example
the external part of the empty box shown previously could have been defined as a single composite
volume instead of six parts :
volume ExternalBox vacuum Box 120|120|120 Id 0
composite Outside BeO ExternalBox:Id-Inside:Id Id 0
Volume placement is done through a combination of a rotation around the (0,0,0) center followed by a
translation of the center:
matrix <name> <Tx> <Ty> <Tz> <A1> <A2> <A3>
with:
<name>
is the name under which the matrix will be referred to,<Tx> <Ty> <Tz>
are the translation along the three axes,<A1> <A2> <A3>
are the Euler angles of the rotation. The three angles correspond to:<A1>
around the Z
axis<A2>
around the X'
axis <A3>
around the Z''
axis One must be very careful that there is no overlap nor gap between volumes constituting the geometry.
When instantiating the geometry, STARucn checks for volume overlaps (but not gaps) and will print a
warning.
Plug-ins are modules that perform specific parts of the simulation. There are four kind of plug-ins:
Each plug-in is configured with its own parameter script, with specific keywords.
Two default generators are available:
VolumeGenerator
: Neutrons are uniformly distributed within one volume of the geometry withstring VolumeGenerator.Volume <name>
: name of the volume used for generation. The volume must exist in the geometry.double VolumeGenerator.Rate <rate>
: production rate, in Hz. If negative, all neutronsstring VolumeGenerator.Mode <mode>
: the mode define the way the velocity densityXYZ
cartesian coordinates (x,y,z), CPV
spherical coordinates along the x-axisCPVZ
spherical coordinates along the z-axis.density VolumeGenerator.Density <X> <fun> <min> <max>
: Specify the probability<X>
=X
, Y
, Z
, C
, P
, V
. The function <fun>
is given using ROOT'sTextGenerator
: Neutrons are read from a simple ascii file where each neutron is described instring FileGenerator.InputFile <name>
: name of the input file to read.This plug-in computes the time and interaction point where the neutron is going out of its current containing volume. Two techniques are used in STARucn. Both have similar configuration.
StepPropagator
: The next surface is reached through time steps following is trajectory. WhenAnalyticPropagator
: For the simpler volumes (box, cylinder, tube and torus), the analyticThe configuration script must contain the following keywords :
* double StepPropagator.StepSize <length>
: initial size (in mm) of the step. If set to -1, an
adaptative step will be used; this is the recommended mode. Fixed step is used if one need to save
the particle trajectory with many points along the trajectory.
+ double StepPropagator.Tolerance <length>
: minimal distance from the surface to which we assume the surface has been reached.
+ bool StepPropagator.UseGravity <bool>
: switch on (1) or off (0) the gravity.
For the AnalyticPropagator
, the keyword are identical, replacing StepPropagator.<X>
by AnalyticPropagator.<X>
There is only one interaction plugin available, NeutronInteraction
, that does not need any external
configuration.
Outputs of the simulation can be produced after each step and at the end of each neutron. Three default
output plug-ins are available:
CompleteRootOutputInterface
: Information on each neutron are saved into a ROOT treestring CompleteRootOutputInterface.OutputFile <file>
: name of the output file.int CompleteRootOutputInterface.TrajectoryRecord <nb>
: record the trajectorystring CompleteRootOutputInterface.TrajectoryRecordFinalVolume <volumes>
:HistogramOutputInterface
: This plug-in fills an histogram recording the number of neutronsstring HistogramOutputInterface.OutputFile <file>
: name of the output file.double HistogramOutputInterface.SnapShotTime <time>
: duration of each time bin.int HistogramOutputInterface.NbSnapShots <nb>
: number of bins.string HistogramOutputInterface.VolumeName <volume>
: volume to study. If notTextOutputInterface
: dump the information for each neutron into a text file for later use.string TextOutputInterface.OutputFile <file>
: name of the output file.bool TextOutputInterface.DoRootTree <bool>
: if 1, a ROOT tree will also be createdstring TextOutputInterface.StopMode <mode>
: saving mode.double TextOutputInterface.StopTime <time>
: for Time mode only, specify the timestring TextOutputInterface.FinalVolumes <volumes>
: for Volume mode only, listint TextOutputInterface.NbInteract <nb>
: for Interaction mode only, number ofAn additional fourth output plug-in allows to run simultaneously several output plugins: MultiOutputInterface
.
The configuration script is as follow :
int MultiOutputInterface.NbOutputs <nbmax>
: number of output plug-ins to use.mcsetup MultiOutputInterface.Output <n> <class name> <config file>
: type and<n>
-th plug-in (<n>
=1 to <nbmax>
)
This mode allow to display each neutron trajectory within the geometry, if such trajectories have been
previously generated (see CompleteRootOutputInterface
for exemple)
To run this mode you need to define the run mode as:
string RunMode Trajectory
add add the following entries in your main script:
string Trajectory.InputFile <file>
: name of the file containing the trajectories (CompleteRootOutputInterface
output)string Trajectory.InputTree <name>
: name of the output tree. If you're trajectory are generated with CompleteRootOutputInterface
, it should be starucn
.
STARucn (>v1.2) also allows to generate animated gifs diplaying the time evolution of the neutron within the geometry. Producing an animation is a two step process.
First one must run a simulation producing text snapshot of the system at every time period. This is done by configuring a standard simulation and changing the runmode from Generate
to Animate
.
The second step consists in creating the image from the output text, using the AnimateGraphics
runmode.
Both steps require a few addition to the main script:
int Animate.NbFrames <nb>
: number of snapshots,double Animate.TimeStep <time>
: time between two snapshot,string Animate.BaseName <name>
: base name of the produced files, the final gif will be <name>.gif
,string Animate.OutputDir <dir>
: output directory, as this runmode will produce many output files.The creation of the final image needs additionnary inputs:
string Animate.Display <name>
: Display mode to use. You can either use the default ROOT 3D display (<name>=StdROOT
) or the naiver OpenLG one (<name>=OpenGL
). Note that ROOT implementation of OpenGL is sometimes tricky with composite volumes.double Animate.Timefactor <value>
: time dilatation of the animation int Animate.StartFrame <nb>
: id of the first snapshot to usedouble Animate.MarkerSize <value>
: size of the markers used to display the neutron. Remove the line to get default values (0.4 for StdROOT
and 3 for OpenGL
).Neutrons can be displayed in several colors depending on their position and speed, defining one or several animset
:
animset Animate.<name> <condition> <color>
: condition is a logical condition on one or more of the seven parameters~: [x]
, [y]
, [z]
(position), [vx]
, [vy]
, [vz]
(speed), [v] (norm of the speed) and <color>
is the displayed color according to the ROOT color scheme. For exemple, animset Animate.Set1 [v]>3000 2
will display in red neutrons with a speed larger than 3000 mm/s.
Finally serval parameters are used to define the camera orientation. They can be either constant or changing within time. The genereric syntax are:
camera Animate.<name> const <value>
: specify a constant value.camera Animate.<name> function <string>
: specify a time changing value. <string>
is the definition of a TF1
ROOT object with x
as time variable.
The keywords <name>
for the camera parameters are:
PhiAngle
: rotation angle in the horizontal plane,
ThetaAngle
: rotation angle in the vetical plane.In addition, for the OpenGL
display you must specify the field of view angle (OpenGLFov
), the dolly position (OpenGLDolly
) and the center of the frame (OpenGLCenterX
, OpenGLCenterY
and OpenGLCenterZ
)
Previous: Download and install -- Next: Advanced user/Plugin developper manual