faunus
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
Faunus::XTCTrajectoryFrame Struct Reference

Base data structure for native XTC format as used in Gromacs and supported by the C library. More...

#include <io.h>

Public Member Functions

 XTCTrajectoryFrame (int number_of_atoms)
 Creates an empty XTC trajectory frame for given number of coordinates (atoms). More...
 
 XTCTrajectoryFrame (const TrajectoryFrame &frame)
 Creates an XTC trajectory frame from TrajectoryFrame and converts data accordingly. More...
 
template<RequirePointIterator begin_iterator, class end_iterator >
 XTCTrajectoryFrame (int step, float time, const Point &box, begin_iterator coordinates_begin, end_iterator coordinates_end)
 Creates an XTC trajectory frame from scalar parameters and input iterator and converts data accordingly. More...
 
XTCTrajectoryFrameoperator= (const TrajectoryFrame &frame)
 Copies TrajectoryFrame and converts data. More...
 
void importFrame (const TrajectoryFrame &frame)
 Imports data from a TrajectoryFrame. More...
 
template<RequirePointIterator begin_iterator, class end_iterator >
void importFrame (const int step, const float time, const Point &box, begin_iterator coordinates_begin, end_iterator coordinates_end)
 Imports data from scalar parameters and an input iterator over coordinates. More...
 
void exportFrame (TrajectoryFrame &frame) const
 Exports data from a TrajectoryFrame. More...
 
template<RequirePointIterator begin_iterator, RequirePointIterator end_iterator>
void exportFrame (int &step, float &time, Point &box, begin_iterator coordinates_begin, end_iterator coordinates_end) const
 Exports data to scalar paramers and output iterator over atomic coordinates. More...
 

Public Attributes

XdrFile::matrix xtc_box
 box tensor; only diagonal elements are used
 
std::unique_ptr< XdrFile::rvec[]> xtc_coordinates
 C-style array of particle coordinates.
 
int xtc_step = 0
 current frame number
 
float xtc_time = 0.0
 current time (unit?)
 
int number_of_atoms = 0
 number of coordinates (atoms) in each frame
 
float precision = 1000.0
 output precision
 

Protected Types

using XTCFloat = float
 
using XTCMatrix = Eigen::Matrix< XTCFloat, 3, 3, Eigen::RowMajor >
 
using XTCVector = Eigen::Matrix< XTCFloat, 3, 1 >
 

Protected Member Functions

void importTimestamp (int step, float time)
 Imports and converts step and timestamp. More...
 
void importBox (const Point &box)
 Imports and converts simulation box dimensions. More...
 
void importCoordinates (const PointVector &coordinates, const Point &offset)
 Imports and converts atomic coordinates. More...
 
template<RequirePointIterator begin_iterator, typename end_iterator >
void importCoordinates (begin_iterator begin, end_iterator end, const Point &offset) const
 Imports and converts atomic coordinates. More...
 
void exportTimestamp (int &step, float &time) const
 Exports and converts step and timestamp. More...
 
void exportBox (Point &box) const
 Exports and converts simulation box dimensions. More...
 
void exportCoordinates (PointVector &coordinates, const Point &offset) const
 Exports and converts atomic coordinates. More...
 
template<RequirePointIterator begin_iterator, typename end_iterator >
void exportCoordinates (begin_iterator begin, end_iterator end, const Point &offset) const
 Exports and converts atomic coordinates. More...
 

Detailed Description

Base data structure for native XTC format as used in Gromacs and supported by the C library.

Import methods do the data conversion from the Faunus native format to the XTC format, and export methods do the oposite.

By convention, XTC has coordinates' origin in a corner (main box's coordinates are always positive), while Faunus has coordinates' origin in the center of the simulation box. During conversion the corresponding offset is subtracted, or added, respectively.

XTC format uses floats (Faunus doubles) and dimensions are in nanometers (Faunus ångströms). XTC library requires raw 2D C-style arrays for coordinates in row-major format. XTC tensor of the simulation box is converted to an XYZ point pressuming orthogonal geometry bacause of current limitation of Faunus. XTC format does not support variable number of coordinates (atoms) between frames.

Constructor & Destructor Documentation

◆ XTCTrajectoryFrame() [1/3]

Faunus::XTCTrajectoryFrame::XTCTrajectoryFrame ( int  number_of_atoms)

Creates an empty XTC trajectory frame for given number of coordinates (atoms).

Parameters
number_of_atomsnumber of coordinates (atoms)

◆ XTCTrajectoryFrame() [2/3]

Faunus::XTCTrajectoryFrame::XTCTrajectoryFrame ( const TrajectoryFrame frame)

Creates an XTC trajectory frame from TrajectoryFrame and converts data accordingly.

Parameters
framesource trajectory frame

◆ XTCTrajectoryFrame() [3/3]

template<RequirePointIterator begin_iterator, class end_iterator >
Faunus::XTCTrajectoryFrame::XTCTrajectoryFrame ( int  step,
float  time,
const Point box,
begin_iterator  coordinates_begin,
end_iterator  coordinates_end 
)
inline

Creates an XTC trajectory frame from scalar parameters and input iterator and converts data accordingly.

Template Parameters
begin_iterator
end_iterator
Parameters
[in]stepframe step
[in]timetimestamp in picoseconds
[in]boxbox dimensions (xyz) in nanometers
[in]coordinates_begininput iterator with coordinates in nanometers
[in]coordinates_endinput iterator's end

Member Function Documentation

◆ exportBox()

void Faunus::XTCTrajectoryFrame::exportBox ( Point box) const
protected

Exports and converts simulation box dimensions.

Parameters
[out]boxsimulation box dimensions in nanometers (xyz)

◆ exportCoordinates() [1/2]

void Faunus::XTCTrajectoryFrame::exportCoordinates ( PointVector coordinates,
const Point offset 
) const
protected

Exports and converts atomic coordinates.

Offset is subtracted from all coordinates to account different coordinates' origin.

Parameters
[out]coordinatesatomic coordinates in nanometers
[in]offsetoffset in nanometers to subtract from all coordinates upon conversion
Exceptions
std::runtime_errorwhen the source box is not orthogonal

◆ exportCoordinates() [2/2]

template<RequirePointIterator begin_iterator, typename end_iterator >
void Faunus::XTCTrajectoryFrame::exportCoordinates ( begin_iterator  begin,
end_iterator  end,
const Point offset 
) const
inlineprotected

Exports and converts atomic coordinates.

Offset is subtracted to all coordinates to account different coordinates' origin.

Template Parameters
begin_iterator
end_iterator
Parameters
[out]beginoutput iterator with coordinates in nanometers
[out]endoutput iterator's end
[in]offsetoffset in nanometers to subtract from all coordinates upon conversion

◆ exportFrame() [1/2]

void Faunus::XTCTrajectoryFrame::exportFrame ( TrajectoryFrame frame) const

Exports data from a TrajectoryFrame.

Parameters
frametarget frame
Exceptions
std::runtime_errorwhen the number of coordinates does not match

◆ exportFrame() [2/2]

template<RequirePointIterator begin_iterator, RequirePointIterator end_iterator>
void Faunus::XTCTrajectoryFrame::exportFrame ( int &  step,
float &  time,
Point box,
begin_iterator  coordinates_begin,
end_iterator  coordinates_end 
) const
inline

Exports data to scalar paramers and output iterator over atomic coordinates.

Template Parameters
begin_iterator
end_iterator
Parameters
[out]stepframe step
[out]timeframe timestamp
[out]boxbox dimensions (xyz) in nanometers
[out]coordinates_beginoutput iterator with coordinates in nanometers
[out]coordinates_endoutput iterator's end
Exceptions
std::runtime_errorwhen the number of coordinates does not match

◆ exportTimestamp()

void Faunus::XTCTrajectoryFrame::exportTimestamp ( int &  step,
float &  time 
) const
protected

Exports and converts step and timestamp.

Parameters
[out]stepframe step
[out]timeframe timestamp

◆ importBox()

void Faunus::XTCTrajectoryFrame::importBox ( const Point box)
protected

Imports and converts simulation box dimensions.

Parameters
[in]boxsimulation box dimensions in nanometers (xyz)

◆ importCoordinates() [1/2]

void Faunus::XTCTrajectoryFrame::importCoordinates ( const PointVector coordinates,
const Point offset 
)
protected

Imports and converts atomic coordinates.

Offset is added to all coordinates to account different coordinates' origin.

Parameters
[in]coordinatesatomic coordinates in nanometers
[in]offsetoffset in nanometers to add to all coordinates upon conversion

◆ importCoordinates() [2/2]

template<RequirePointIterator begin_iterator, typename end_iterator >
void Faunus::XTCTrajectoryFrame::importCoordinates ( begin_iterator  begin,
end_iterator  end,
const Point offset 
) const
inlineprotected

Imports and converts atomic coordinates.

Offset is added to all coordinates to account different coordinates' origin.

Template Parameters
begin_iterator
end_iterator
Parameters
[in]begininput iterator with coordinates in nanometers
[in]endinput iterator's end
[in]offsetoffset in nanometers to add to all coordinates upon conversion

◆ importFrame() [1/2]

void Faunus::XTCTrajectoryFrame::importFrame ( const TrajectoryFrame frame)

Imports data from a TrajectoryFrame.

Parameters
framesource frame
Exceptions
std::runtime_errorwhen the number of coordinates does not match

◆ importFrame() [2/2]

template<RequirePointIterator begin_iterator, class end_iterator >
void Faunus::XTCTrajectoryFrame::importFrame ( const int  step,
const float  time,
const Point box,
begin_iterator  coordinates_begin,
end_iterator  coordinates_end 
)
inline

Imports data from scalar parameters and an input iterator over coordinates.

Template Parameters
begin_iterator
end_iterator
Parameters
[in]stepframe step
[in]timeframe timestamp
[in]boxbox dimensions (xyz) in nanometers
[in]coordinates_begininput iterator with coordinates in nanometers
[in]coordinates_endinput iterator's end
Exceptions
std::runtime_errorwhen the number of coordinates does not match

◆ importTimestamp()

void Faunus::XTCTrajectoryFrame::importTimestamp ( int  step,
float  time 
)
protected

Imports and converts step and timestamp.

Parameters
[in]stepframe step
[in]timeframe timestamp

◆ operator=()

XTCTrajectoryFrame & Faunus::XTCTrajectoryFrame::operator= ( const TrajectoryFrame frame)

Copies TrajectoryFrame and converts data.

Calls importFrame.

The number of coordinates is immutable to prevent mistakes.

Parameters
framesource frame
Exceptions
std::runtime_errorwhen the number of coordinates does not match

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