Pteros  2.0
Molecular modeling library for human beings!
pteros::Periodic_box Class Reference

Class encapsulating all operations with arbitrary triclinic periodic boxes This class stores the periodic box itself and also contains pre-computed matrices for converting laboratory coordinates to the coordinates in triclinic basis and vice versa. More...

#include <periodic_box.h>

Public Member Functions

 Periodic_box ()
 Default constructor.
 
 Periodic_box (Matrix3f_const_ref box)
 Constructor from other box.
 
 Periodic_box (Vector3f_const_ref vectors, Vector3f_const_ref angles)
 Constructor from vector lengths and angles.
 
Periodic_boxoperator= (Periodic_box other)
 Copy constructor.
 
void modify (Matrix3f_const_ref box)
 Modify the box from 3x3 matrix.
 
Eigen::Vector3f get_vector (int i)
 Get i-th box vector.
 
Eigen::Matrix3f get_matrix () const
 Get stored matrix of box vectors.
 
void scale_vectors (Vector3f_const_ref scale)
 Scale box vectors by specified factors. More...
 
Eigen::Matrix3f get_inv_matrix () const
 Get stored inverted matrix of box vectors.
 
Eigen::Vector3f lab_to_box (Vector3f_const_ref point) const
 Convert point from lab coordinates to box coordinates.
 
Eigen::Matrix3f lab_to_box_transform () const
 Return the transformation from lab coordinates to box coordinates.
 
Eigen::Vector3f box_to_lab (Vector3f_const_ref point) const
 Convert point from box coordinates to lab coordinates.
 
Eigen::Matrix3f box_to_lab_transform () const
 Return the transformation from box coordinates to lab coordinates.
 
float extent (int i) const
 Return i-th extent of the box.
 
Eigen::Vector3f extents () const
 Return the vector of box extents.
 
bool is_triclinic () const
 Is the box triclinic?
 
bool is_periodic () const
 Is the box set? If false, the system is not periodic.
 
float distance (Vector3f_const_ref point1, Vector3f_const_ref point2, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Compute a periodic distance between two points in the box Periodicity is only accouted for given set of dimensions If you need a non-periodic distance over all dimensions it is more efficient to compute it directly as: More...
 
float distance_squared (Vector3f_const_ref point1, Vector3f_const_ref point2, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 The same as distance but returns squared distance.
 
void wrap_point (Vector3f_ref point, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Wrap point to the box for given set of dimensions Origin of the box coordinates is assumed to be {0,0,0}. More...
 
bool in_box (Vector3f_const_ref point, Vector3f_const_ref origin=Eigen::Vector3f::Zero()) const
 Determine if the point is inside the box Origin of the box coordinates defaults to {0,0,0}. More...
 
Eigen::Vector3f get_closest_image (Vector3f_const_ref point, Vector3f_const_ref target, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Finds a periodic image of point, which is closest in space to target and returns it.
 
Eigen::Vector3f shortest_vector (Vector3f_const_ref point1, Vector3f_const_ref point2, Vector3i_const_ref dims=Eigen::Vector3i::Ones()) const
 Computes shortest vector from point1 to point2 between their closest images.
 
float volume ()
 Returns box volume.
 
void read_pdb_box (const char *line)
 Read box from CRYST string in PDB format. Overwrites current box!
 
std::string write_pdb_box () const
 Write box as CRYST string in PDB format.
 
void to_vectors_angles (Vector3f_ref vectors, Vector3f_ref angles) const
 Returns representation of the box as vector lengths and angles.
 
void from_vectors_angles (Vector3f_const_ref vectors, Vector3f_const_ref angles)
 Creates box from vector length and angles. More...
 

Detailed Description

Class encapsulating all operations with arbitrary triclinic periodic boxes This class stores the periodic box itself and also contains pre-computed matrices for converting laboratory coordinates to the coordinates in triclinic basis and vice versa.

Extents of the periodic box are also precomputed and stored internally. All data in the class are read-only. The user can set the box by using the constructor or by calling modify(box), than all internal data would be precomputed. Individual components of the box can't be changed. The only way to change is to get the whole box, modify the component and set it back:

Periodic_box box(some_data);
Matrix3f b = box.get_matrix();
b(1,2) *= 2.0; // Modify the box element
box.modify(b); // Set new box. This will recompute internal matrices

Member Function Documentation

void Periodic_box::scale_vectors ( Vector3f_const_ref  scale)

Scale box vectors by specified factors.

Causes recomputing internal data.

float Periodic_box::distance ( Vector3f_const_ref  point1,
Vector3f_const_ref  point2,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Compute a periodic distance between two points in the box Periodicity is only accouted for given set of dimensions If you need a non-periodic distance over all dimensions it is more efficient to compute it directly as:

float dist = (point2-point1).norm();
void Periodic_box::wrap_point ( Vector3f_ref  point,
Vector3i_const_ref  dims = Eigen::Vector3i::Ones() 
) const

Wrap point to the box for given set of dimensions Origin of the box coordinates is assumed to be {0,0,0}.

bool Periodic_box::in_box ( Vector3f_const_ref  point,
Vector3f_const_ref  origin = Eigen::Vector3f::Zero() 
) const

Determine if the point is inside the box Origin of the box coordinates defaults to {0,0,0}.

void Periodic_box::from_vectors_angles ( Vector3f_const_ref  vectors,
Vector3f_const_ref  angles 
)

Creates box from vector length and angles.

Overwrites current box! vectors = {a,b,c} angles = {a^c, b^c, a^b}


The documentation for this class was generated from the following files: