OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
minimal_runner.MinimalRunner Class Reference

Inherits object.

Public Member Functions

def __init__
 
def make_field_solver
 
def make_distribution
 
def make_beam
 
def null_drift
 
def make_ring
 
def make_option
 
def make_line
 
def make_track
 
def make_track_run
 
def make_element_iterable
 
def preprocess
 
def postprocess
 
def execute
 
def execute_fork
 

Public Attributes

 field_solver
 
 distribution
 
 line
 
 ring
 
 beam
 
 track
 
 run
 
 track_run
 
 option
 
 tmp_dir
 
 distribution_filename
 
 max_steps
 
 r0
 
 momentum
 
 mass
 
 steps_per_turn
 
 time_per_turn
 
 run_name
 
 exit_code
 
 verbose
 

Static Public Attributes

string distribution_str
 
string ring_error = "Failed to append ring to the line. Try running make_ring()"
 

Detailed Description

Class to run a minimal OPAL setup.

Individual methods make_foo handle set up of each OPAL "global" object:
- self.field_solver
- self.distribution
- self.beam
- self.track
- self.track_run
- self.line
- self.ring
Explicitly, the OPAL routines are only called in make_foo and run_one so
that there is no OPAL things initialised and run_one_fork can be safely
called.

There are three hooks for user to overload and do stuff:
- make_element_iterable: add extra elements to the line
- preprocess: add some stuff to do just before tracking starts
- postprocess: add some stuff to do just after tracking ends
user can do postprocessing after calling run_one, but run_one_fork isolates
memory allocation into a forked process so parent process does not have
access to memory for e.g. checking details of the field maps, etc.

Definition at line 35 of file minimal_runner.py.

Constructor & Destructor Documentation

def minimal_runner.MinimalRunner.__init__ (   self)
Initialise to empty data

Definition at line 58 of file minimal_runner.py.

Member Function Documentation

def minimal_runner.MinimalRunner.execute (   self)
Set up and run a simulation

Definition at line 253 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.execute_fork().

def minimal_runner.MinimalRunner.execute_fork (   self)
Set up and run a simulation in a fork of the current process. The 

This method is memory safe - resources are only created in the
forked process, which is destroyed when the process concludes. The
downside is that resources (e.g. lattice objects, etc) are destroyed
when the process concludes. If something is needed, overload the
preprocess and postprocess routines to do anything just before or just
after tracking.

Returns the return code of the forked process, given by self.exit_code
from the forked MinimalRunner. This can be used as a simple flag for
comms from the child to the parent process (e.g. for testing purposes).
For example, postprocess(self) can be overloaded to set an exit code.

Tested in linux, I don't know about OSX. Unlikely to work in any
Windows environment.

Definition at line 278 of file minimal_runner.py.

References Constraint.execute(), DVar.execute(), Objective.execute(), OptimizeCmd.execute(), System.execute(), Title.execute(), Echo.execute(), Value.execute(), Help.execute(), Call.execute(), Quit.execute(), PSystem.execute(), Stop.execute(), Select.execute(), Option.execute(), MacroCmd.execute(), DefaultVisitor.execute(), WhileStatement.execute(), IfStatement.execute(), CompoundStatement.execute(), OrbitThreader.execute(), SimpleStatement.execute(), OpalTrimCoil.execute(), Object.execute(), OpalParser.execute(), ParallelCyclotronTracker.execute(), Statement.execute(), SpecificElementVisitor< ELEM >.execute(), BeamlineVisitor.execute(), DumpFields.execute(), DumpEMFields.execute(), ParallelTTracker.execute(), ThickTracker.execute(), Distribution.execute(), minimal_runner.MinimalRunner.execute(), PyOpal::PyOpalObjectNS::PyOpalObject< C >.execute(), and minimal_runner.MinimalRunner.exit_code.

Here is the call graph for this function:

def minimal_runner.MinimalRunner.make_beam (   self)
Make a beam

The beam holds the global/default beam distribution information, such as
the mass of particles in the beam, number of particles in the beam and
so on.

Definition at line 123 of file minimal_runner.py.

References minimal_runner.MinimalRunner.beam, minimal_runner.MinimalRunner.mass, minimal_runner.MinimalRunner.momentum, and minimal_runner.MinimalRunner.time_per_turn.

def minimal_runner.MinimalRunner.make_distribution (   self)
Make a distribution

The distribution is the initial beam distribution of the PyOPAL
simulation. In this example, a distribution loaded from a tempfile is
called, where the tempfile is written to disk dynamically at runtime.

Definition at line 105 of file minimal_runner.py.

References minimal_runner.MinimalRunner.distribution, minimal_runner.MinimalRunner.distribution_filename, and minimal_runner.MinimalRunner.distribution_str.

def minimal_runner.MinimalRunner.make_element_iterable (   self)
Return an iterable (e.g. list) of elements to append to the line

By default, returns an empty list. User can overload this method.

Definition at line 231 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_line().

def minimal_runner.MinimalRunner.make_field_solver (   self)
Make an empty fieldsolver

The fieldsolver has the job of solving the space charge problem on
successive time steps. In this example, the FieldSolver is switched off
(i.e. set to type = "NONE").

Definition at line 83 of file minimal_runner.py.

References minimal_runner.MinimalRunner.field_solver.

def minimal_runner.MinimalRunner.make_line (   self)
def minimal_runner.MinimalRunner.make_option (   self)
Options enable setting of global control variables.

No options are set by default. For a full list of variables see the
Option docs.

Definition at line 174 of file minimal_runner.py.

References minimal_runner.MinimalRunner.option, ffa_field_mapper.FFAFieldMapper.verbose, and minimal_runner.MinimalRunner.verbose.

def minimal_runner.MinimalRunner.make_ring (   self)
Make a RingDefinition object.

The RingDefinition holds default parameters for a ring initial
conditions, in particular the initial cylindrical coordinates for the
first element placement and beam, and the minimum and maximum radius
allowed before particles are considered lost. The ring can be appended
to self.line and used with OPAL cyclotron mode.

Definition at line 157 of file minimal_runner.py.

References minimal_runner.MinimalRunner.r0, and minimal_runner.MinimalRunner.ring.

def minimal_runner.MinimalRunner.make_track (   self)
Make a track object.

The track object handles the interface between tracking and the beam
elements.

Definition at line 203 of file minimal_runner.py.

References minimal_runner.MinimalRunner.max_steps, minimal_runner.MinimalRunner.steps_per_turn, and minimal_runner.MinimalRunner.track.

def minimal_runner.MinimalRunner.make_track_run (   self)
Make a TrackRun

The TrackRun handles the interface between the Track, distribution,
field solver and calls the actual tracking routines.

Definition at line 217 of file minimal_runner.py.

References minimal_runner.MinimalRunner.track_run.

def minimal_runner.MinimalRunner.null_drift (   cls)
Returns a drift of length 0

OPAL requires at least one element in each beam line. For this simplest
example a drift of length 0 is used.

Definition at line 143 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_line().

def minimal_runner.MinimalRunner.postprocess (   self)
Perform any postprocessing steps after the tracking is executed

This method can be overloaded with user required steps.

Definition at line 246 of file minimal_runner.py.

def minimal_runner.MinimalRunner.preprocess (   self)
Perform any preprocessing steps just before the trackrun is executed

This method can be overloaded with user required steps.

Definition at line 239 of file minimal_runner.py.

Member Data Documentation

minimal_runner.MinimalRunner.beam

Definition at line 64 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_beam().

minimal_runner.MinimalRunner.distribution

Definition at line 61 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_distribution().

minimal_runner.MinimalRunner.distribution_filename

Definition at line 71 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_distribution().

string minimal_runner.MinimalRunner.distribution_str
static
Initial value:
1 = """1
2 0.0 0.0 0.0 0.0 0.0 0.0
3 """

Definition at line 307 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_distribution().

minimal_runner.MinimalRunner.exit_code

Definition at line 80 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.execute_fork().

minimal_runner.MinimalRunner.field_solver

Definition at line 60 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_field_solver().

minimal_runner.MinimalRunner.line

Definition at line 62 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_line().

minimal_runner.MinimalRunner.mass

Definition at line 76 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_beam().

minimal_runner.MinimalRunner.max_steps

Definition at line 73 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_track().

minimal_runner.MinimalRunner.momentum

Definition at line 75 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_beam().

minimal_runner.MinimalRunner.option

Definition at line 68 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_option().

minimal_runner.MinimalRunner.r0

Definition at line 74 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_ring().

minimal_runner.MinimalRunner.ring
string minimal_runner.MinimalRunner.ring_error = "Failed to append ring to the line. Try running make_ring()"
static

Definition at line 311 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_line().

minimal_runner.MinimalRunner.run

Definition at line 66 of file minimal_runner.py.

minimal_runner.MinimalRunner.run_name

Definition at line 79 of file minimal_runner.py.

minimal_runner.MinimalRunner.steps_per_turn

Definition at line 77 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_track().

minimal_runner.MinimalRunner.time_per_turn

Definition at line 78 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_beam().

minimal_runner.MinimalRunner.tmp_dir

Definition at line 70 of file minimal_runner.py.

minimal_runner.MinimalRunner.track

Definition at line 65 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_track().

minimal_runner.MinimalRunner.track_run

Definition at line 67 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_track_run().

minimal_runner.MinimalRunner.verbose

Definition at line 81 of file minimal_runner.py.

Referenced by minimal_runner.MinimalRunner.make_option().


The documentation for this class was generated from the following file: