Context
Monte Carlo simulation context.
Attributes
Name | Type | Description |
---|---|---|
geometry | Geometry | Geometry of the simulation. |
limit | Limit | External limits for the transport, e.g. on the kinetic energy or the particle range. |
mode | Mode | Configuration flags for the simulation. |
physics | Physics | Physics tabulations used by this context (cannot be modified). |
random_seed | number |
Random seed of the pseudo random numbers generator used by this simulation flow. |
recorder | Recorder | User supplied recorder (callback) for Monte Carlo steps. |
Note
All attributes can be modified (set) appart from the physics. See the constructor for valid argument types and automatic inference rules when setting an attribute.
Constructor
The Monte Carlo Context is the main interface to a simulation flow. Its constructor has two forms as shown in the synopsis below. Both forms require a Physics instance to be provided. The first form accepts an optionnal Mode configuration flag as second argument. The second form takes a single table argument with fields corresponding to the simulation context attributes.
Note
The Physics of the simulation context is defined at creation and cannot be modified afterwards apart from the mass fractions of composite materials. A new simulation context must be created instead.
Synopsis
pumas.Context(physics, (mode))
pumas.Context{
physics=, (geometry)=, (limit)=, (mode)=, (random_seed)=, (recorder)=}
Arguments
Name | Type | Description |
---|---|---|
physics | string or Physics |
Physics tabulations used by this context (cannot be modified afterwards). If a string argument is provided it must point to a dump of tabulations, e.g. generated with the build function. Then a new Physics instance is automatically created from these tables. |
(geometry) | string or Geometry |
Geometry of the simulation. If a string argument is provided it must reference a TabulatedMaterial of the physics. Then, an InfiniteGeometry is automatically created and filled with a UniformMedium using the corresponding material. |
(limit) | table |
External limits for the transport, e.g. on the kinetic energy or the particle range. The table keys must refer to Limit attributes, e.g. as {distance = 1000} for a 1 km limit on the travelled distance. By default no external limit is set. |
(mode) | string |
Configuration flags for the simulation. The string must indicate Mode attributes flag(s) with proper separator(s) (whitespace, comma, etc.). Default value is detailed forward . |
(random_seed) | number |
Random seed of the pseudo random numbers generator used by this simulation flow. If not provided then the random seed is initialised from the host, e.g. using /dev/urandom on Unix. |
(recorder) | function or Recorder |
User supplied recorder (callback) for Monte Carlo steps. If a function argument is provided then it is autmatically wrapped with a Recorder instance with a period of 1. |
See also
Context.medium
Get the medium corresponding to a given point Coordinates or for a at a given Monte Carlo State position for the current Geometry.
Synopsis
Context:medium(coordinates)
Context:medium(state)
Arguments
Name | Type | Description |
---|---|---|
coordinates | Coordinates | Point coordinates at which to query the geometry. |
state | State | State (position) for which to query the geometry. |
Returns
Type | Description |
---|---|
Medium | Geometry medium correpsonding to the provided Monte Carlo state. |
Note
If no geometry is defined or if the requested position is located outside of
the current geometry then nil
is returned. {: .justify}
See also
Context.random
Get onr or more pseudo random number(s) from a uniform distribution over [0,1]. A Mersenne Twister algorithm is used.
Synopsis
Context:random()
Context:random(n)
Arguments
Name | Type | Description |
---|---|---|
n | number |
Number of pseudo-random numbers to generate. Defaults to 1. |
Returns
Type | Description |
---|---|
number |
First pseudo random number in [0, 1]. |
⋮ | ⋮ |
number |
Last (nth) pseudo random number in [0, 1]. |
Note
This method returns one or more pseudo-random number as requested with the n argument.
See also
Context.transport
Transport a Monte Carlo State using the current geometry and simulation settings.
Synopsis
Context:transport(state)
Arguments
Name | Type | Description |
---|---|---|
state | State | Initial Monte Carlo state to transport. |
Warning
The provided Monte Carlo state is modified in-place, i.e. at return it contains the final step Monte Carlo data. If initial data are to be retained then the provided state might be cloned before the transport.
Returns
Type | Description |
---|---|
Event | The end step Monte Carlo event. |
table |
Size 2 table containing the initial and final Medium of the transport. |