Frames

class chemfiles::Frame

A frame contains data from one simulation step The Frame class holds data from one step of a simulation: the current topology, the positions, and the velocities of the particles in the system. If some information is missing (topology or velocity or unit cell), the corresponding data is filled with a default value. Specifically:

  • `velocities` is the `nullopt` version of `optional<Array3D>`. Here, `optional<T>` refers to the optional template as defined in [std::experimental::optional][optional]
  • `cell` is an infinite unit cell;
  • `topology` is empty, and contains no data.

[optional]: http://en.cppreference.com/w/cpp/experimental/optional

Public Functions

Frame()

Default constructor.

Frame(size_t natoms)

Constructor reserving some space for `natoms`.

Frame(Topology topology, UnitCell cell = UnitCell ())

Constructor reserving space for `topology.natoms()`, and using `cell` as unit cell. `cell` default to an `INFINITE` unit cell.

Frame clone() const

Get a clone (exact copy) of this frame.

This replace the implicit copy constructor (which is disabled) to make an explicit copy of the frame.

Span3D positions()

Get a modifiable reference to the positions.

const Array3D &positions() const

Get a const (non modifiable) reference to the positions.

optional<Span3D> velocities()

Get an optional modifiable reference to the velocities.

const optional<Array3D> &velocities() const

Get an optional const (non modifiable) reference to the velocities.

void add_velocities()

Add velocities to this frame. If velocities are already defined, this functions does nothing.

Topology &topology()

Get a modifiable reference to the internal topology.

const Topology &topology() const

Get a const (non-modifiable) reference to the internal topology.

void set_topology(const Topology &topology)

Set the system topology.

const UnitCell &cell() const

Get a const (non-modifiable) reference to the unit cell of the system.

void set_cell(const UnitCell &c)

Set the unit cell fo the system.

void resize(size_t natoms)

Resize the frame to store data for `natoms` atoms. If the new size is bigger than the old one, missing data is initializd to 0. Pre-existing values are conserved. This function only resize the velocities if the data is present.

void reserve(size_t natoms)

Reserve size in the frame to store data for `natoms` atoms. This function only reserve storage for the the velocities if the data is present.

void add_atom(Atom atom, Vector3D position, Vector3D velocity = Vector3D())

Add an `atom` at the given `position` and optionally with the given `velocity`. The `velocity` value will only be used if this frame contains velocity data.

size_t natoms() const

Get the number of atoms in the system.

void remove(size_t i)

Remove the atom at index `i` in the system. `i` must be lower than `natoms()`.

size_t step() const

Get the current simulation step.

void set_step(size_t s)

Set the current simulation step.

void guess_topology()

Guess the bonds, angles and dihedrals in the system. The bonds are guessed using a distance-based algorithm, and then angles and dihedrals are guessed from the bonds.