Table Of Contents

Previous topic

utils module

Next topic

bunch module

This Page

foundation module

The foundation module contains classes fundamental to accelerator physics and accelerator physics simulation.

Classes

class Diagnostics_write_helper

The Diagnostics_write_helper is a helper class for Diagnostics objects.

Serial Diagnostics_write_helpers write many updates to a single file. Non-serial Diagnostics_write_helpers write each update to a new file.

Public Functions

Diagnostics_write_helper(std::string const & filename, bool serial, Commxx_sptr commxx_sptr, std::string const & local_dir, int writer_rank = default_rank)

Diagnostics_write_helper()

int get_count()

Get the count for non-serial writers.

void set_count(int count)

Set the count for non-serial writers.

Parameters
  • count -

    the count

void increment_count()

bool write_locally()

int get_writer_rank()

Hdf5_file_sptr get_hdf5_file_sptr()

void finish_write()

template < class Archive >
void serialize(Archive & ar, const unsigned int version)

~Diagnostics_write_helper()

Public Static Attributes

const int default_rank

const int flush_period

class Distribution

Distribution is a virtual base class for obtaining the next number or set of numbers from a sequence according to a limited set of shapes.

Public Functions

double get()

Get the next number in the sequence (between 0 and 1).

void fill_uniform(MArray1d_view array, double min, double max)

Fill a one-dimensional array uniformly between min and max.

void fill_uniform(MArray1d_ref array, double min, double max)

Alternate form for type compatibility.

void fill_unit_gaussian(MArray1d_view array)

Fill a one-dimensional array with Gaussian distribution of zero mean and unit standard deviation.

void fill_unit_gaussian(MArray1d_ref array)

Alternate form for type compatibility.

void fill_unit_disk(MArray1d_view x_array, MArray1d_view y_array)

Fill two one-dimensional arrays such that (x,y) are distributed uniformly in the unit disk.

void fill_unit_disk(MArray1d_ref x_array, MArray1d_ref y_array)

Alternate form for type compatibility.

~Distribution()

class Four_momentum

Four_momentum provides conversion between various relativistic kinematic parameters.

Public Functions

Four_momentum()

Default constructor for internal use only.

Four_momentum(double mass)

Construct a Four_momentum in the rest frame.

Parameters
  • mass -

    in GeV/c^2

Four_momentum(double mass, double total_energy)

Construct a Four_momentum with the given total energy.

Parameters
  • mass -

    in GeV/c^2

  • total_energy -

    in GeV

void set_total_energy(double total_energy)

Set the total energy.

Parameters
  • total_energy -

    in GeV

void set_kinetic_energy(double kinetic_energy)

Set the kinetic energy.

Parameters
  • kinetic_energy -

    in GeV

void set_momentum(double momentum)

Set the momentum.

Parameters
  • momentum -

    in GeV/c

void set_gamma(double gamma)

Set the relativistic gamma factor.

Parameters
  • gamma -

    unitless

void set_beta(double beta)

Set the relativistic beta factor.

Parameters
  • beta -

    unitless

double get_mass()

Get the mass in GeV/c^2.

double get_total_energy()

Get the total energy in GeV.

double get_kinetic_energy()

Get the kinetic energy in GeV.

double get_momentum()

Get momentum in GeV/c.

double get_gamma()

Get the relativistic gamma factor.

double get_beta()

Get the relativistic beta factor.

bool equal(Four_momentum const & four_momentum, double tolerance)

Check equality to the given tolerance.

Parameters
  • four_momentum -

    another Four_momentum

  • tolerance -

    fractional accuracy for beta and gamma

template < class Archive >
void serialize(Archive & ar, const unsigned int version)

Serialization support.

class Multi_diagnostics

Multi_diagnostics contains a list of Diagnostics_sptrs.

Public Type

typedef std::list< Diagnostics_sptr >:: iterator iterator

A convenience definition of the list iterator.

Not relevant for Python.

Public Functions

Multi_diagnostics()

Construct an empty list of Diagnostics_sptrs.

void append(Diagnostics_sptr diagnostics_sptr)

Append a Diagnostics_sptr to the list.

Parameters
  • diagnostics_sptr -

    the Diagnostics_sptr

void push_back(Diagnostics_sptr diagnostics_sptr)

The same as append included for notational consistency with C++.

Parameters
  • diagnostics_sptr -

    the Diagnostics_sptr

iterator begin()

A convenience definition of the list iterator begin.

Not relevant for Python.

iterator end()

A convenience definition of the list iterator end.

Not relevant for Python.

class Random_distribution

Random_distribution provides a Distribution of random numbers.

The random seed is maintained across multiple processors. The implementation uses random numbers from the GNU Scientific Library.

Public Type

Generator enum

Values:

  • ranlxd2 -
  • mt19937 -
Public Functions

Random_distribution(unsigned long int seed, Commxx const & comm, Generator generator = ranlxd2)

Construct a Random_distribution.

Parameters
  • seed -

    The random number seed. If seed == 0, the seed is obtained from Random_distribution::get_default_seed().

  • comm -

    Distribute the seed across the processors in this communicator.

  • generator -

    The underlying random number generator to be used.

void set_seed(unsigned long int seed)

Set the random number generator seed.

Parameters
  • seed -

    The seed.

unsigned long int get_original_seed()

Get the seed used to start the random number generator.

double get()

Get the next random number between 0 and 1.

void fill_uniform(MArray1d_view array, double min, double max)

Fill a one-dimensional array uniformly between min and max.

void fill_unit_gaussian(MArray1d_view array)

Fill a one-dimensional array with Gaussian distribution of zero mean and unit standard deviation.

void fill_unit_disk(MArray1d_view x_array, MArray1d_view y_array)

Fill two one-dimensional arrays such that (x,y) are distributed uniformly in the unit disk.

~Random_distribution()

Public Static Functions

unsigned long int get_default_seed(const char * device = “/dev/urandom”)

Generate a random seed.

Attempt to read from device if present. Otherwise, use the system clock.

Parameters
  • device -

    Read from pathname device.

class Reference_particle

Reference_particle stores the four momentum of the reference frame with respect to the lab frame (defined to be along the axis of the accelerator) as well as the six-dimensional state vector of the the reference particle in the reference frame.

Reference particle also keeps track of the total path length of the reference particle trajectory.

Public Functions

Reference_particle()

Default constructor for internal use only.

Reference_particle(int charge, double mass, double total_energy)

Construct a Reference_particle with a given mass and total energy.

Parameters
  • mass -

    in GeV/c^2

  • charge -

    in units of e

  • total_energy -

    in GeV in the lab frame

Reference_particle(int charge, Four_momentum const & four_momentum)

Construct a Reference_particle with a given four momentum.

Parameters
  • charge -

    in units of e

  • four_momentum -

    in the lab frame

Reference_particle(int charge, Four_momentum const & four_momentum, Const_MArray1d_ref state)

Construct a Reference_particle with a given four momentum and state in the reference frame.

Parameters
  • charge -

    in units of e

  • four_momentum -

    in the lab frame

  • state -

    is a six-dimensional state vector

void set_four_momentum(Four_momentum const & four_momentum)

Set the four momentum.

Parameters
  • four_momentum -

    in the lab frame

void set_state(Const_MArray1d_ref state)

Set the state vector in the reference frame.

Parameters
  • state -

    is a six-dimensional state vector

void set_total_energy(double total_energy)

Set the total energy.

Parameters
  • total_energy -

    in GeV in the lab frame

void increment_trajectory(double length)

Increment the trajectory length.

Parameters
  • length -

    in m

void start_repetition()

Start a new repetition.

void set_trajectory(int repetition, double repetition_length, double s)

Manually set trajectory parameters.

Parameters
  • repetition -

    starting at 0

  • repetition_length -

    in m

  • s -

    in m

int get_charge()

Return the Reference_particle charge in units of e.

Four_momentum const & get_four_momentum()

Get the four momentum in the lab frame.

Const_MArray1d_ref get_state()

Get the six-dimensional state vector in the reference frame.

double get_beta()

Get the relativistic beta in the lab frame.

double get_gamma()

Get the relativistic gamma in the lab frame.

double get_momentum()

Get the momentum in GeV/c in the lab frame.

double get_total_energy()

Get the total energy in GeV in the lab frame.

double get_s()

Get the total path length in m of the reference particle trajectory.

double get_s_n()

Get the distance traveled in m since the beginning of the current repetition.

int get_repetition()

Get the number of repetition.

double get_repetition_length()

Get the repetition length in m.

bool equal(Reference_particle const & reference_particle, double tolerance)

Check equality to the given tolerance.

Parameters

template < class Archive >
void serialize(Archive & ar, const unsigned int version)

Serialization support.

Typedefs

typedef boost::shared_ptr< Diagnostics_write_helper > Diagnostics_write_helper_sptr