Frame

Chemfiles.FrameType

A Frame holds data for one step of a simulation. As not all formats provide all the types of information, some fields may be initialized to a default value. A Frame may contain 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.
source
Base.angleMethod
angle(
    frame::Frame,
    i::Integer,
    j::Integer,
    k::Integer
) -> Float64

Calculate the angle made by three atoms.

source
Base.lengthMethod
length(frame::Frame) -> Int64

Get the number of atoms in the frame.

source
Base.resize!Method
resize!(frame::Frame, natoms::Integer)

Resize the positions and the velocities in the 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.

source
Base.sizeMethod
size(frame::Frame) -> Int64

Get the number of atoms in the frame.

source
Base.stepMethod
step(frame::Frame) -> UInt64

Get the frame step, i.e. the frame number in the trajectory.

source
Base.viewMethod
view(frame::Frame, index::Integer) -> Chemfiles.Atom

Get the Atom at the given index of the frame without creating a copy.

Warning

This function can lead to unefined behavior when keeping the returned Atom around. Whith code like this:

frame = Frame()
resize!(frame, 3)

atom = @view frame[0]
resize!(frame, 4)

atom contains a pointer to memory owned by frame, but this pointer has been invalidated when resizing the frame. Using atom after the second call to resize! might trigger undefined behavior (segmentation fault in the best case, silent data corruption in the worst case).

source
Chemfiles.add_atom!Function
add_atom!(
    frame::Frame,
    atom::Chemfiles.Atom,
    position::Vector{Float64}
)
add_atom!(
    frame::Frame,
    atom::Chemfiles.Atom,
    position::Vector{Float64},
    velocity::Vector{Float64}
)

Add an atom and the corresponding position and velocity data to a frame.

source
Chemfiles.add_bond!Function
add_bond!(frame::Frame, i::Integer, j::Integer)
add_bond!(frame::Frame, i::Integer, j::Integer, order)

Add an additional bond to the Frame's Topology.

source
Chemfiles.add_velocities!Method
add_velocities!(frame::Frame)

Add velocities to this frame. The storage is initialized with the result of size(frame) as the number of atoms. If the frame already has velocities, this does nothing.

source
Chemfiles.dihedralMethod
dihedral(
    frame::Frame,
    i::Integer,
    j::Integer,
    k::Integer,
    m::Integer
) -> Float64

Calculate the dihedral (torsional) angle made by four unbranched atoms.

source
Chemfiles.distanceMethod
distance(frame::Frame, i::Integer, j::Integer) -> Float64

Calculate the distance between two atoms.

source
Chemfiles.guess_bonds!Method
guess_bonds!(frame::Frame)

Guess the bonds, angles, and dihedrals in the frame using a distance criteria.

source
Chemfiles.out_of_planeMethod
out_of_plane(
    frame::Frame,
    i::Integer,
    j::Integer,
    k::Integer,
    m::Integer
) -> Float64

Calculate the out-of-plane (improper) angle made by four atoms.

source
Chemfiles.positionsMethod
positions(frame::Frame) -> Chemfiles.ChemfilesArray

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.

source
Chemfiles.remove_atom!Method
remove_atom!(frame::Frame, index::Integer)

Remove the atom at index from the frame.

This function modifies all the atoms indexes after index, and invalidates any array obtained using positions or velocities.

source
Chemfiles.velocitiesMethod
velocities(frame::Frame) -> Chemfiles.ChemfilesArray

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.

source