CHFL_FRAME¶
-
typedef struct CHFL_FRAME CHFL_FRAME¶
An opaque type handling frames.
A
CHFL_FRAMEcontains data from one simulation step: the current unit cell, the 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.
Here is the full list of functions acting on CHFL_FRAME:
-
CHFL_FRAME *chfl_frame(void)¶
Create a new empty frame.
The caller of this function should free the allocated memory using
chfl_free.- Returns:
A pointer to the frame, or NULL in case of error. You can use
chfl_last_errorto learn about the error.
-
CHFL_FRAME *chfl_frame_copy(const CHFL_FRAME *frame)¶
Get a copy of a
frame.The caller of this function should free the associated memory using
chfl_free.- Returns:
A pointer to the new frame, or NULL in case of error. You can use
chfl_last_errorto learn about the error.
-
chfl_status chfl_frame_atoms_count(const CHFL_FRAME *frame, uint64_t *count)¶
Get the current number of atoms in a
framein the integer pointed to bycount- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_resize(CHFL_FRAME *frame, uint64_t size)¶
Resize the positions, velocities and topology in the
frame, to have space forsizeatoms.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.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_add_atom(CHFL_FRAME *frame, const CHFL_ATOM *atom, const chfl_vector3d position, const chfl_vector3d velocity)¶
Add an
atomand the correspondingpositionandvelocitydata to aframe.velocitycan beNULLif no velocity is associated with the atom.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_remove(CHFL_FRAME *frame, uint64_t i)¶
Remove the atom at index
iin theframe.This modify all the atoms indexes after
i, and invalidate any pointer obtained usingchfl_frame_positionsorchfl_frame_velocities.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_positions(CHFL_FRAME *frame, chfl_vector3d **positions, uint64_t *size)¶
Get a pointer to the positions array from a
frame.Positions are stored as a
size x 3array, this function set the pointer pointed to bypositionsto point to the first element of this array, and give the number of atoms in the integer pointed to bysize.If the frame is resized (by writing to it, or calling
chfl_frame_resize,chfl_frame_removeorchfl_frame_add_atom), the pointer is invalidated.If the frame memory is released using
chfl_free, the memory behind the*positionspointer is released too.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_velocities(CHFL_FRAME *frame, chfl_vector3d **velocities, uint64_t *size)¶
Get a pointer to the velocities array from a
frame.Velocities are stored as a
size x 3array, this function set the pointer pointed to byvelocitiesto point to the first element of this array, and give the number of atoms in the integer pointed to bysize.If the frame is resized (by writing to it, or calling
chfl_frame_resize,chfl_frame_removeorchfl_frame_add_atom), the pointer is invalidated.If the frame memory is released using
chfl_free, the memory behind the*velocitiespointer is released too.If the frame does not have velocity, this will return an error. You can use
chfl_frame_add_velocitiesto ensure that a frame contains velocity data before calling this function.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_has_velocities(const CHFL_FRAME *frame, bool *has_velocities)¶
Check if this
framecontains velocity data, and store the result inhas_velocities- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_add_velocities(CHFL_FRAME *frame)¶
Add velocity data to this
frame.The velocities are initialized to
(chfl_vector3d){0, 0, 0}. If the frame already has velocities, this does nothing.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_set_cell(CHFL_FRAME *frame, const CHFL_CELL *cell)¶
Set the unit cell of a
frametocell.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_set_topology(CHFL_FRAME *frame, const CHFL_TOPOLOGY *topology)¶
Set the topology of a
frametotopology.Calling this function with a topology that does not contain the right number of atom will return an error.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_add_bond(CHFL_FRAME *frame, uint64_t i, uint64_t j)¶
Add a bond between the atoms at indexes
iandjin theframe.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_bond_with_order(CHFL_FRAME *frame, uint64_t i, uint64_t j, chfl_bond_order bond_order)¶
Add a bond between the atoms at indexes
iandjwith bond orderbond_orderin theframe.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_remove_bond(CHFL_FRAME *frame, uint64_t i, uint64_t j)¶
Remove any existing bond between the atoms at indexes
iandjin theframe.This function does nothing if there is no bond between
iandj.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_clear_bonds(CHFL_FRAME *frame)¶
Remove all existing bonds, angles, dihedral angles and improper dihedral angles in the
frame.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_add_residue(CHFL_FRAME *frame, const CHFL_RESIDUE *residue)¶
Add a copy of
residueto thisframe.The residue id must not already be in this frame’s topology, and the residue must contain only atoms that are not already in another residue.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_step(const CHFL_FRAME *frame, uint64_t *step)¶
Get a
framestep, i.e. the frame number in the trajectory in the integer pointed to bystep.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_set_step(CHFL_FRAME *frame, uint64_t step)¶
Set a
framestep, i.e. the frame number in the trajectory tostep.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_guess_bonds(CHFL_FRAME *frame)¶
Guess the bonds, angles and dihedrals in a
frame.The bonds are guessed using a distance-based algorithm, and then angles and dihedrals are guessed from the bonds.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_distance(const CHFL_FRAME *frame, uint64_t i, uint64_t j, double *distance)¶
Get the distance between the atoms at indexes
iandjin theframe, accounting for periodic boundary conditions. The result is placed indistance, and expressed in angstroms.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_angle(const CHFL_FRAME *frame, uint64_t i, uint64_t j, uint64_t k, double *angle)¶
Get the angle formed by the atoms at indexes
i,jandkin theframe, accounting for periodic boundary conditions. The result is placed inangle, and expressed in radians.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_dihedral(const CHFL_FRAME *frame, uint64_t i, uint64_t j, uint64_t k, uint64_t m, double *dihedral)¶
Get the angle formed by the atoms at indexes
i,j,kandmin theframe, accounting for periodic boundary conditions. The result is placed indihedral, and expressed in radians.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_out_of_plane(const CHFL_FRAME *frame, uint64_t i, uint64_t j, uint64_t k, uint64_t m, double *distance)¶
Get the out of plane distance formed by the atoms at indexes
i,j,kandmin theframe, accounting for periodic boundary conditions. The result is placed indistanceand expressed in angstroms.This is the distance between the atom j and the ikm plane. The j atom is the center of the improper dihedral angle formed by i, j, k and m.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_set_property(CHFL_FRAME *frame, const char *name, const CHFL_PROPERTY *property)¶
Add a new
propertywith the givennameto thisframe.If a property with the same name already exists, this function override the existing property with the new one.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
CHFL_PROPERTY *chfl_frame_get_property(const CHFL_FRAME *frame, const char *name)¶
Get a property with the given
namein thisframe.This function returns
NULLif no property exists with the given name.The user of this function is responsible to deallocate memory using the
chfl_freefunction.- Returns:
A pointer to the property, or NULL in case of error. You can use
chfl_last_errorto learn about the error.
-
chfl_status chfl_frame_properties_count(const CHFL_FRAME *frame, uint64_t *count)¶
Get the number of properties associated with this
frameincount.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_frame_list_properties(const CHFL_FRAME *frame, const char *names[], uint64_t count)¶
Get the names of all properties of this
framein the pre-allocated arraynamesof sizecount.namessize must be passed in thecountparameter, and be equal to the result ofchfl_frame_properties_count.The pointers in
namesare only valid until a new property is added to the frame withchfl_frame_set_property.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.