CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::xtal::Coordinate Class Reference

#include <Coordinate.hh>

+ Inheritance diagram for CASM::xtal::Coordinate:

Detailed Description

Represents cartesian and fractional coordinates.

Definition at line 34 of file Coordinate.hh.

Public Types

typedef Eigen::Vector3d vector_type
 
typedef vector_type::Index size_type
 

Public Member Functions

 Coordinate (const Lattice &_home)
 Minimal constructor only takes a lattice. More...
 
 Coordinate (Eigen::Ref< const vector_type > const &_vec, const Lattice &_home, COORD_TYPE _mode)
 
 Coordinate (double _x, double _y, double _z, const Lattice &_home, COORD_TYPE _mode)
 
Coordinate_impl::FracCoordinate frac ()
 Set the fractional coordinate vector. More...
 
const vector_typefrac () const
 const Access the fractional coordinate vector More...
 
const vector_typeconst_frac () const
 user override to force const Access the fractional coordinate vector More...
 
Coordinate_impl::FracCoordinateComponent frac (size_type index)
 Set a component of the fractional coordinate vector. More...
 
const double & frac (size_type index) const
 const Access a component of the fractional coordinate vector More...
 
const double & const_frac (size_type index) const
 user override to force const Access the fractional coordinate vector More...
 
Coordinate_impl::CartCoordinate cart ()
 Set Cartesian coordinate vector and update fractional coordinate vector. More...
 
const vector_typecart () const
 const Access the Cartesian coordinate vector More...
 
const vector_typeconst_cart () const
 user override to force const Access the Cartesian coordinate vector More...
 
Coordinate_impl::CartCoordinateComponent cart (size_type index)
 Set a component of the Cartesian coordinate vector. More...
 
const double & cart (size_type index) const
 const Access a component of the Cartesian coordinate vector More...
 
const double & const_cart (size_type index) const
 const Access a component of the Cartesian coordinate vector More...
 
vector_type as_vec (COORD_TYPE _mode) const
 
Coordinateoperator+= (const Coordinate &RHS)
 Positive translation of this coordinate by RHS.cart() More...
 
Coordinateoperator-= (const Coordinate &RHS)
 Negative translation of this coordinate by RHS.cart() More...
 
Coordinate operator- () const
 unary minus of this coordinate More...
 
bool operator== (const Coordinate &RHS) const
 
bool operator!= (const Coordinate &RHS) const
 
bool almost_equal (const Coordinate &RHS) const
 
bool compare (const Coordinate &RHS) const
 Returns true if this->min_dist(RHS)<this->lattice().tol() More...
 
bool compare (const Coordinate &RHS, Coordinate &translation) const
 
bool compare_type (const Coordinate &RHS) const
 Return true – Exists to allow duck-typing with Site. More...
 
bool within ()
 
bool within (Coordinate &translation)
 
bool is_within () const
 Checks to see if coordinate is in the unit cell, but does not translate it. More...
 
int voronoi_number () const
 
int voronoi_number (const Lattice &cell) const
 
bool voronoi_within ()
 Map coordinate into the voronoi cell using a lattice translation. More...
 
bool voronoi_within (Coordinate &translation)
 
bool is_lattice_shift (double tol=TOL) const
 
void set_lattice (const Lattice &new_lat, COORD_TYPE mode)
 Change the home lattice of the coordinate, selecting one representation (either CART or FRAC) that remains invariant. More...
 
const Latticehome () const
 Access the home lattice of the coordinate. More...
 
const Latticelattice () const
 Access the home lattice of the coordinate. More...
 
void read (std::istream &stream, COORD_TYPE mode)
 
void print (std::ostream &stream, COORD_TYPE mode, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
 
void print (std::ostream &stream, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
 
void print_axis (std::ostream &stream, COORD_TYPE mode, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
 Print normalized vector. More...
 
double dist (const Coordinate &neighbor) const
 distance (in Angstr) of neighbor from *this More...
 
double min_dist (const Coordinate &neighbor) const
 Returns distance (in Angstr) to nearest periodic image of neighbor. More...
 
Coordinate min_translation (const Coordinate &neighbor) const
 Returns translation coordinate (in Angstr) to nearest periodic image of neighbor. More...
 
double robust_min_dist (const Coordinate &neighbor) const
 Returns distance (in Angstr) to nearest periodic image of neighbor. More...
 
double min_dist2 (const Coordinate &neighbor, const Eigen::Ref< const Eigen::Matrix3d > &metric) const
 

Static Public Member Functions

static Coordinate origin (const Lattice &_home)
 construct a coordinate describing origin of _home lattice More...
 

Private Member Functions

void _update_cart ()
 
void _update_frac ()
 
void _set_frac (const Eigen::Ref< const vector_type > &f)
 
void _set_frac (size_type ind, double val)
 
void _set_cart (const Eigen::Ref< const vector_type > &c)
 
void _set_cart (size_type ind, double val)
 

Private Attributes

Lattice const * m_home
 
vector_type m_frac_coord
 
vector_type m_cart_coord
 

Member Typedef Documentation

◆ size_type

typedef vector_type::Index CASM::xtal::Coordinate::size_type

Definition at line 37 of file Coordinate.hh.

◆ vector_type

typedef Eigen::Vector3d CASM::xtal::Coordinate::vector_type

Definition at line 36 of file Coordinate.hh.

Constructor & Destructor Documentation

◆ Coordinate() [1/3]

CASM::xtal::Coordinate::Coordinate ( const Lattice _home)
inlineexplicit

Minimal constructor only takes a lattice.

Definition at line 47 of file Coordinate.hh.

◆ Coordinate() [2/3]

CASM::xtal::Coordinate::Coordinate ( Eigen::Ref< const vector_type > const &  _vec,
const Lattice _home,
COORD_TYPE  _mode 
)

◆ Coordinate() [3/3]

CASM::xtal::Coordinate::Coordinate ( double  _x,
double  _y,
double  _z,
const Lattice _home,
COORD_TYPE  _mode 
)

Definition at line 21 of file Coordinate.cc.

Member Function Documentation

◆ _set_cart() [1/2]

void CASM::xtal::Coordinate::_set_cart ( const Eigen::Ref< const vector_type > &  c)
inlineprivate

Definition at line 264 of file Coordinate.hh.

◆ _set_cart() [2/2]

void CASM::xtal::Coordinate::_set_cart ( size_type  ind,
double  val 
)
inlineprivate

Definition at line 269 of file Coordinate.hh.

◆ _set_frac() [1/2]

void CASM::xtal::Coordinate::_set_frac ( const Eigen::Ref< const vector_type > &  f)
inlineprivate

Definition at line 254 of file Coordinate.hh.

◆ _set_frac() [2/2]

void CASM::xtal::Coordinate::_set_frac ( size_type  ind,
double  val 
)
inlineprivate

Definition at line 259 of file Coordinate.hh.

◆ _update_cart()

void CASM::xtal::Coordinate::_update_cart ( )
inlineprivate

Definition at line 247 of file Coordinate.hh.

◆ _update_frac()

void CASM::xtal::Coordinate::_update_frac ( )
inlineprivate

Definition at line 249 of file Coordinate.hh.

◆ almost_equal()

bool CASM::xtal::Coordinate::almost_equal ( const Coordinate RHS) const

Definition at line 66 of file Coordinate.cc.

◆ as_vec()

vector_type CASM::xtal::Coordinate::as_vec ( COORD_TYPE  _mode) const
inline

Definition at line 103 of file Coordinate.hh.

◆ cart() [1/4]

Coordinate_impl::CartCoordinate CASM::xtal::Coordinate::cart ( )
inline

Set Cartesian coordinate vector and update fractional coordinate vector.

Definition at line 562 of file Coordinate.hh.

◆ cart() [2/4]

const vector_type& CASM::xtal::Coordinate::cart ( ) const
inline

const Access the Cartesian coordinate vector

Definition at line 87 of file Coordinate.hh.

◆ cart() [3/4]

Coordinate_impl::CartCoordinateComponent CASM::xtal::Coordinate::cart ( Coordinate::size_type  index)
inline

Set a component of the Cartesian coordinate vector.

Definition at line 567 of file Coordinate.hh.

◆ cart() [4/4]

const double& CASM::xtal::Coordinate::cart ( size_type  index) const
inline

const Access a component of the Cartesian coordinate vector

Definition at line 96 of file Coordinate.hh.

◆ compare() [1/2]

bool CASM::xtal::Coordinate::compare ( const Coordinate RHS) const

Returns true if this->min_dist(RHS)<this->lattice().tol()

Definition at line 72 of file Coordinate.cc.

◆ compare() [2/2]

bool CASM::xtal::Coordinate::compare ( const Coordinate RHS,
Coordinate translation 
) const

Returns true if this->min_dist(RHS)<this->lattice().tol() if true, calculates

Parameters
translationsuch that *this = (RHS+translation)

Definition at line 78 of file Coordinate.cc.

◆ compare_type()

bool CASM::xtal::Coordinate::compare_type ( const Coordinate RHS) const

Return true – Exists to allow duck-typing with Site.

Definition at line 84 of file Coordinate.cc.

◆ const_cart() [1/2]

const vector_type& CASM::xtal::Coordinate::const_cart ( ) const
inline

user override to force const Access the Cartesian coordinate vector

Definition at line 90 of file Coordinate.hh.

◆ const_cart() [2/2]

const double& CASM::xtal::Coordinate::const_cart ( size_type  index) const
inline

const Access a component of the Cartesian coordinate vector

Definition at line 99 of file Coordinate.hh.

◆ const_frac() [1/2]

const vector_type& CASM::xtal::Coordinate::const_frac ( ) const
inline

user override to force const Access the fractional coordinate vector

Definition at line 68 of file Coordinate.hh.

◆ const_frac() [2/2]

const double& CASM::xtal::Coordinate::const_frac ( size_type  index) const
inline

user override to force const Access the fractional coordinate vector

Definition at line 78 of file Coordinate.hh.

◆ dist()

double CASM::xtal::Coordinate::dist ( const Coordinate neighbor) const

distance (in Angstr) of neighbor from *this

Definition at line 148 of file Coordinate.cc.

◆ frac() [1/4]

Coordinate_impl::FracCoordinate CASM::xtal::Coordinate::frac ( )
inline

Set the fractional coordinate vector.

Definition at line 550 of file Coordinate.hh.

◆ frac() [2/4]

const vector_type& CASM::xtal::Coordinate::frac ( ) const
inline

const Access the fractional coordinate vector

Definition at line 64 of file Coordinate.hh.

◆ frac() [3/4]

Coordinate_impl::FracCoordinateComponent CASM::xtal::Coordinate::frac ( Coordinate::size_type  index)
inline

Set a component of the fractional coordinate vector.

Definition at line 555 of file Coordinate.hh.

◆ frac() [4/4]

const double& CASM::xtal::Coordinate::frac ( size_type  index) const
inline

const Access a component of the fractional coordinate vector

Definition at line 74 of file Coordinate.hh.

◆ home()

const Lattice& CASM::xtal::Coordinate::home ( ) const
inline

Access the home lattice of the coordinate.

Definition at line 200 of file Coordinate.hh.

◆ is_lattice_shift()

bool CASM::xtal::Coordinate::is_lattice_shift ( double  tol = TOL) const

Checks to see if coordinate is at a lattice translation with respect to the origin

Definition at line 311 of file Coordinate.cc.

◆ is_within()

bool CASM::xtal::Coordinate::is_within ( ) const

Checks to see if coordinate is in the unit cell, but does not translate it.

Definition at line 244 of file Coordinate.cc.

◆ lattice()

const Lattice& CASM::xtal::Coordinate::lattice ( ) const
inline

Access the home lattice of the coordinate.

Definition at line 206 of file Coordinate.hh.

◆ min_dist()

double CASM::xtal::Coordinate::min_dist ( const Coordinate neighbor) const

Returns distance (in Angstr) to nearest periodic image of neighbor.

Is unsafe if min_dist is comparable to half a lattice vector in length

Definition at line 152 of file Coordinate.cc.

◆ min_dist2()

double CASM::xtal::Coordinate::min_dist2 ( const Coordinate neighbor,
const Eigen::Ref< const Eigen::Matrix3d > &  metric 
) const

Finds same shift as min_dist but returns shift(CART).transpose()*metric*shift(CART)

Definition at line 178 of file Coordinate.cc.

◆ min_translation()

Coordinate CASM::xtal::Coordinate::min_translation ( const Coordinate neighbor) const

Returns translation coordinate (in Angstr) to nearest periodic image of neighbor.

This version calculates the translation such that (neighbor+translation) is the nearest periodic image of neighbor

Definition at line 156 of file Coordinate.cc.

◆ operator!=()

bool CASM::xtal::Coordinate::operator!= ( const Coordinate RHS) const
inline

Definition at line 125 of file Coordinate.hh.

◆ operator+=()

Coordinate & CASM::xtal::Coordinate::operator+= ( const Coordinate RHS)

Positive translation of this coordinate by RHS.cart()

Definition at line 37 of file Coordinate.cc.

◆ operator-()

Coordinate CASM::xtal::Coordinate::operator- ( ) const

unary minus of this coordinate

Definition at line 54 of file Coordinate.cc.

◆ operator-=()

Coordinate & CASM::xtal::Coordinate::operator-= ( const Coordinate RHS)

Negative translation of this coordinate by RHS.cart()

Definition at line 44 of file Coordinate.cc.

◆ operator==()

bool CASM::xtal::Coordinate::operator== ( const Coordinate RHS) const

Definition at line 60 of file Coordinate.cc.

◆ print() [1/2]

void CASM::xtal::Coordinate::print ( std::ostream &  stream,
char  term = 0,
Eigen::IOFormat  format = Eigen::IOFormat(7, 12) 
) const

Definition at line 102 of file Coordinate.cc.

◆ print() [2/2]

void CASM::xtal::Coordinate::print ( std::ostream &  stream,
COORD_TYPE  mode,
char  term = 0,
Eigen::IOFormat  format = Eigen::IOFormat(7, 12) 
) const

Definition at line 121 of file Coordinate.cc.

◆ print_axis()

void CASM::xtal::Coordinate::print_axis ( std::ostream &  stream,
COORD_TYPE  mode,
char  term = 0,
Eigen::IOFormat  format = Eigen::IOFormat(7, 12) 
) const

Print normalized vector.

Definition at line 135 of file Coordinate.cc.

◆ read()

void CASM::xtal::Coordinate::read ( std::istream &  stream,
COORD_TYPE  mode 
)

Definition at line 88 of file Coordinate.cc.

◆ robust_min_dist()

double CASM::xtal::Coordinate::robust_min_dist ( const Coordinate neighbor) const

Returns distance (in Angstr) to nearest periodic image of neighbor.

It is safe in all cases, because it uses the lattice Wigner-Seitz cell to determine the nearest image, but this makes it slower than min_dist

Definition at line 168 of file Coordinate.cc.

◆ set_lattice()

void CASM::xtal::Coordinate::set_lattice ( const Lattice new_lat,
COORD_TYPE  mode 
)

Change the home lattice of the coordinate, selecting one representation (either CART or FRAC) that remains invariant.

Parameters
invariant_mode

invariant_mode == CART: Cartesian coordinates stay the same, and fractional coordinates are updated Ex: (my_coord.set_lattice(superlattice, CART); // this is how superlattices get filled.

invariant_mode == FRAC: Fractional coordinates stay the same, and Cartesian coordinates are updated Ex: you can apply a strain by changing the lattice and keepin FRAC invariant (my_coord.set_lattice(strained_lattice, FRAC); Ex: you can apply a rotation by changing the lattice and keeping FRAC invariant (my_coord.set_lattice(rotated_lattice, FRAC);

Definition at line 190 of file Coordinate.cc.

◆ voronoi_number() [1/2]

int CASM::xtal::Coordinate::voronoi_number ( ) const

Number of periodic images of this coordinate that are on voronoi cell boundary of its home lattice

Definition at line 259 of file Coordinate.cc.

◆ voronoi_number() [2/2]

int CASM::xtal::Coordinate::voronoi_number ( const Lattice cell) const

Number of periodic images of this coordinate that are on voronoi cell boundary of 'cell'

Definition at line 265 of file Coordinate.cc.

◆ voronoi_within() [1/2]

bool CASM::xtal::Coordinate::voronoi_within ( )

Map coordinate into the voronoi cell using a lattice translation.

Definition at line 274 of file Coordinate.cc.

◆ voronoi_within() [2/2]

bool CASM::xtal::Coordinate::voronoi_within ( Coordinate translation)

Same as voronoi_within(), but lattice translation is stored in Coordinate translation such that coord_after = coord_before + translation returns true if *this was already within the voronoi cell

Definition at line 290 of file Coordinate.cc.

◆ within() [1/2]

bool CASM::xtal::Coordinate::within ( )

Map coordinate into the unit cell using a lattice translation returns true if *this was already within the unit cell

Definition at line 205 of file Coordinate.cc.

◆ within() [2/2]

bool CASM::xtal::Coordinate::within ( Coordinate translation)

Same as within(), but lattice translation is stored in Coordinate translation, such that coord_after = coord_before + translation returns true if *this was already within the unit cell

Definition at line 223 of file Coordinate.cc.

Member Data Documentation

◆ m_cart_coord

vector_type CASM::xtal::Coordinate::m_cart_coord
private

Definition at line 281 of file Coordinate.hh.

◆ m_frac_coord

vector_type CASM::xtal::Coordinate::m_frac_coord
private

Definition at line 281 of file Coordinate.hh.

◆ m_home

Lattice const* CASM::xtal::Coordinate::m_home
private

Definition at line 279 of file Coordinate.hh.


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