Frame type and associated functions

type Frame

A Frame holds data for one step of a simulation. As not all formats provides all the types of informations, some fields may be initialized to a default value. A Frame may contains the following data:

  • Positions for all the atoms in the system;
  • Velocities for all the atoms in the system;
  • The Topology of the system;
  • The UnitCell of the system.

function Frame(ptr::Ptr{lib.CHFL_FRAME})

A Frame holds data for one step of a simulation. As not all formats provides all the types of informations, some fields may be initialized to a default value. A Frame may contains the following data:

  • Positions for all the atoms in the system;
  • Velocities for all the atoms in the system;
  • The Topology of the system;
  • The UnitCell of the system.
function Frame()
Create a new empty Frame.
function deepcopy(frame::Frame)
Make a deep copy of a frame.
function size(frame::Frame)
Get the frame size, i.e. the current number of atoms.
function resize!(frame::Frame, natoms::Integer)
Resize the positions and the velocities in a frame, to make space for natoms atoms. This function may invalidate any pointer to the positions or the velocities if the new size is bigger than the old one. In all the cases, previous data is conserved. This function conserve the presence or absence of velocities.
function positions(frame::Frame)
Get the positions in a Frame as an array. The positions are readable and writable from this array. If the frame is resized (by writing to it, or calling resize!), the array is invalidated.
function velocities(frame::Frame)

Get the velocities in a Frame as an array. The velocities are readable and writable from this array. If the frame is resized (by writing to it, or calling resize!), the array is invalidated.

If the frame do not have velocity, this function will error. You can use add_velocities! to add velocities to a frame before calling this function.

function add_velocities!(frame::Frame)
Add velocities to this frame. The storage is initialized with the result of size(frame) as number of atoms. If the frame already have velocities, this does nothing.
function has_velocities(frame::Frame)
Check if a frame contains velocity data or not.
function add_atom!(frame::Frame, atom::Atom, position::Vector{Float64}, velocity::Vector{Float64} = Float64[0.0, 0.0, 0.0])
Add an atom and the corresponding position and velocity data to a frame.
function remove_atom!(frame::Frame, index::Integer)

Remove the atom at index from the frame.

This modify all the atoms indexes after index, and invalidate any array obtained using positions or velocities.

function set_cell!(frame::Frame, cell::UnitCell)
Set the cell associated with a frame.
function set_topology!(frame::Frame, topology::Topology)
Set the topology associated with a frame.
function step(frame::Frame)
Get the frame step, i.e. the frame number in the trajectory.
function step(frame::Frame, index)
function set_step!(frame::Frame, step::Integer)
Set the frame step to step.
function guess_bonds!(frame::Frame)
Guess the bonds, angles and dihedrals in the frame using a distance criteria.
function add_bond!(frame::Frame, i::Integer, j::Integer)
Add an additional bond to the Frames’s Topology.
function remove_bond!(frame::Frame, i::Integer, j::Integer)
Remove a bond from the Frames’s Topology.
function add_residue!(frame::Frame, residue::Residue)
Add a residue to the Frames’s Topology.
function distance(frame::Frame, i::Integer, j::Integer)
Calculate the distance between two atoms.
function angle(frame::Frame, i::Integer, j::Integer, k::Integer)
Calculate the angle made by three atoms.
function dihedral(frame::Frame, i::Integer, j::Integer, k::Integer, m::Integer)
Calculate the dihedral (torsional) angle made by four unbranched atoms.
function out_of_plane(frame::Frame, i::Integer, j::Integer, k::Integer, m::Integer)
Calculate the out-of-plane (improper) angle made by four atoms.
function property(frame::Frame, name::String)
Get a named property for the given atom.
function set_property!(frame::Frame, name::String, property)
Set a named property for the given Frame.