CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::Clexulator Class Reference

#include <Clexulator.hh>

Detailed Description

Evaluates correlations.

CASM generates code for very efficient calculation of basis functions via the print_clexulator function. This source code may be compiled, linked, and used at runtime via Clexulator.

Definition at line 440 of file Clexulator.hh.

Public Types

typedef Clexulator_impl::Base::size_type size_type
 

Public Member Functions

 Clexulator ()
 
 Clexulator (std::string name, fs::path dirpath, PrimNeighborList &nlist, std::string compile_options, std::string so_options)
 Construct a Clexulator. More...
 
 Clexulator (const Clexulator &B)
 Copy constructor. More...
 
 Clexulator (Clexulator &&B)
 Move constructor. More...
 
 ~Clexulator ()
 
Clexulatoroperator= (Clexulator B)
 Assignment operator. More...
 
bool initialized () const
 Is runtime library loaded? More...
 
std::string name () const
 Name. More...
 
size_type nlist_size () const
 Neighbor list size. More...
 
size_type corr_size () const
 Number of correlations. More...
 
size_type n_point_corr () const
 Valid range for neighbor_ind argument to calc_point_corr. More...
 
ClexParamPack const & param_pack () const
 Obtain const reference to abstract ClexParamPack object. More...
 
ClexParamPackparam_pack ()
 Obtain reference to abstract ClexParamPack object. More...
 
ClexParamKey const & param_key (std::string const &_param_name) const
 Obtain ClexParamKey for a particular parameter. More...
 
void set_evaluation (ClexParamKey const _param_key, std::vector< std::function< double(ConfigDoF const &)> > const &_basis_set)
 Alter evaluation of parameters specified by. More...
 
void set_evaluation (ClexParamKey const _param_key, std::vector< std::function< double(std::vector< double > const &)> > const &_basis_set)
 Alter evaluation of parameters specified by. More...
 
void set_evaluation (ClexParamKey const _param_key, std::string _eval_type)
 Alter evaluation of parameters specified by. More...
 
std::string check_evaluation (ClexParamKey const _param_key) const
 Check evaluation mode of parameters specified by. More...
 
const std::set< UnitCell > & neighborhood () const
 The UnitCellCoord involved in calculating the basis functions, relative origin UnitCell. More...
 
const std::set< UnitCell > & neighborhood (size_type linear_orbit_index) const
 The UnitCellCoord involved in calculating the basis functions for a particular orbit, relative origin UnitCell. More...
 
const PrimNeighborList::Matrix3Typeweight_matrix () const
 The weight matrix used for ordering the neighbor list. More...
 
void calc_global_corr_contribution (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, double *_corr_begin, double *_corr_end) const
 Calculate contribution to global correlations from one unit cell. More...
 
void calc_global_corr_contribution (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end) const
 Calculate contribution to global correlations from one unit cell. More...
 
void calc_restricted_global_corr_contribution (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, double *_corr_begin, double *_corr_end, size_type const *_corr_ind_begin, size_type const *_corr_ind_end) const
 Calculate contribution to select global correlations from one unit cell. More...
 
void calc_point_corr (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, int neighbor_ind, double *_corr_begin, double *_corr_end) const
 Calculate point correlations about basis site 'neighbor_ind'. More...
 
void calc_restricted_point_corr (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, int neighbor_ind, double *_corr_begin, double *_corr_end, size_type const *_corr_ind_begin, size_type const *_corr_ind_end) const
 Calculate select point correlations about basis site 'neighbor_ind'. More...
 
void calc_delta_point_corr (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, int neighbor_ind, int occ_i, int occ_f, double *_corr_begin, double *_corr_end) const
 Calculate the change in point correlations due to changing an occupant. More...
 
void calc_restricted_delta_point_corr (ConfigDoF const &_input_configdof, long int const *_nlist_begin, long int const *_nlist_end, int neighbor_ind, int occ_i, int occ_f, double *_corr_begin, double *_corr_end, size_type const *_corr_ind_begin, size_type const *_corr_ind_end) const
 Calculate the change in select point correlations due to changing an occupant. More...
 

Private Attributes

std::string m_name
 
std::unique_ptr< Clexulator_impl::Basem_clex
 
std::shared_ptr< RuntimeLibrarym_lib
 

Friends

void swap (Clexulator &first, Clexulator &second)
 Swap. More...
 

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ Clexulator() [1/4]

CASM::Clexulator::Clexulator ( )
inline

Definition at line 444 of file Clexulator.hh.

◆ Clexulator() [2/4]

CASM::Clexulator::Clexulator ( std::string  name,
fs::path  dirpath,
PrimNeighborList nlist,
std::string  compile_options,
std::string  so_options 
)

Construct a Clexulator.

Parameters
nameClass name for the Clexulator, typically 'X_Clexulator', with X referring to the system of interest (i.e. 'NiAl_Clexulator')
dirpathDirectory containing the source code and compiled object file.
nlist,APrimNeighborList to be updated to include the neighborhood of this Clexulator
compile_optionsCompilation options
so_optionsShared library compilation options

If 'name' is 'X_Clexulator', and 'dirpath' is '/path/to':

  • Looks for '/path/to/X_Clexulator.so' and tries to load it.
  • If not found, looks for 'path/to/X_Clexulator.cc' and tries to compile and load it.
  • If unsuccesful, will throw std::runtime_error.

The Clexulator has shared ownership of the loaded library, so it is preferrable to duplicate the Clexulator using it's copy constructor rather than construct another using this constructor which will re-load the library.

Definition at line 32 of file Clexulator.cc.

◆ Clexulator() [3/4]

CASM::Clexulator::Clexulator ( const Clexulator B)

Copy constructor.

Definition at line 76 of file Clexulator.cc.

◆ Clexulator() [4/4]

CASM::Clexulator::Clexulator ( Clexulator &&  B)

Move constructor.

Definition at line 83 of file Clexulator.cc.

◆ ~Clexulator()

CASM::Clexulator::~Clexulator ( )

Definition at line 85 of file Clexulator.cc.

Member Function Documentation

◆ calc_delta_point_corr()

void CASM::Clexulator::calc_delta_point_corr ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
int  neighbor_ind,
int  occ_i,
int  occ_f,
double *  _corr_begin,
double *  _corr_end 
) const
inline

Calculate the change in point correlations due to changing an occupant.

neighbor_ind Basis site index about which to calculate correlations

occ_i,occ_f Initial and final occupant variable

_corr_begin Pointer to beginning of data structure where difference in correlations are written

Call using:

UnitCellCoord bijk(b,i,j,k); // b,i,j,k of site to get delta
point correlations int l_index = my_supercell.find(bijk); // Linear index
of site in Configuration int occ_i=0, occ_f=1; // Swap from occupant 0 to
occupant 1 myclexulator.calc_delta_point_corr(my_configdof,
my_supercell.get_nlist(l_index).begin(), b, occ_i, occ_f,
correlation_array.begin());
Eigen::VectorXd correlations(const Configuration &config, Clexulator const &clexulator)
Returns correlations using 'clexulator'.

Definition at line 679 of file Clexulator.hh.

◆ calc_global_corr_contribution() [1/2]

void CASM::Clexulator::calc_global_corr_contribution ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end 
) const
inline

Calculate contribution to global correlations from one unit cell.

Parameters
_corr_beginPointer to beginning of data structure where correlations are written

Call using:

UnitCellCoord bijk(0,i,j,k); // i,j,k of unit cell to get
contribution from int l_index = my_supercell.find(bijk); // Linear index
of site in Configuration
myclexulator.calc_global_corr_contribution(my_configdof,
my_supercell.get_nlist(l_index).begin(),
my_supercell.get_nlist(l_index).end());

Definition at line 576 of file Clexulator.hh.

◆ calc_global_corr_contribution() [2/2]

void CASM::Clexulator::calc_global_corr_contribution ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
double *  _corr_begin,
double *  _corr_end 
) const
inline

Calculate contribution to global correlations from one unit cell.

Parameters
_corr_beginPointer to beginning of data structure where correlations are written

Call using:

UnitCellCoord bijk(0,i,j,k); // i,j,k of unit cell to get
contribution from int l_index = my_supercell.find(bijk); // Linear index
of site in Configuration
myclexulator.calc_global_corr_contribution(my_configdof,
my_supercell.get_nlist(l_index).begin(), correlation_array.begin());

Definition at line 552 of file Clexulator.hh.

◆ calc_point_corr()

void CASM::Clexulator::calc_point_corr ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
int  neighbor_ind,
double *  _corr_begin,
double *  _corr_end 
) const
inline

Calculate point correlations about basis site 'neighbor_ind'.

neighbor_ind Basis site index about which to calculate correlations

_corr_begin Pointer to beginning of data structure where correlations are written

Call using:

UnitCellCoord bijk(b,i,j,k); // b,i,j,k of site to get point
correlations int l_index = my_supercell.find(bijk); // Linear index of
site in Configuration myclexulator.calc_point_corr(my_configdof,
my_supercell.get_nlist(l_index).begin(), b, correlation_array.begin());

Definition at line 626 of file Clexulator.hh.

◆ calc_restricted_delta_point_corr()

void CASM::Clexulator::calc_restricted_delta_point_corr ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
int  neighbor_ind,
int  occ_i,
int  occ_f,
double *  _corr_begin,
double *  _corr_end,
size_type const *  _corr_ind_begin,
size_type const *  _corr_ind_end 
) const
inline

Calculate the change in select point correlations due to changing an occupant.

neighbor_ind Basis site index about which to calculate correlations

occ_i,occ_f Initial and final occupant variable

_corr_begin Pointer to beginning of data structure where difference in correlations are written

Parameters
_corr_ind_begin,_corr_ind_endPointers to range indicating which correlations should be calculated

Call using:

UnitCellCoord bijk(b,i,j,k); // b,i,j,k of site to get delta
point correlations int l_index = my_supercell.find(bijk); // Linear index
of site in Configuration int occ_i=0, occ_f=1; // Swap from occupant 0 to
occupant 1 std::vector<int> _corr_ind = {0, 2, 4, 6}; // Get contribution
to correlations 0, 2, 4, and 6
myclexulator.calc_restricted_delta_point_corr(my_configdof,
my_supercell.get_nlist(l_index).begin(),
b,
occ_i,
occ_f,
correlation_array.begin(),
correlation_array.end(),
_corr_ind.begin(),
_corr_ind.end());

Definition at line 716 of file Clexulator.hh.

◆ calc_restricted_global_corr_contribution()

void CASM::Clexulator::calc_restricted_global_corr_contribution ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
double *  _corr_begin,
double *  _corr_end,
size_type const *  _corr_ind_begin,
size_type const *  _corr_ind_end 
) const
inline

Calculate contribution to select global correlations from one unit cell.

Parameters
_corr_beginPointer to beginning of data structure where correlations are written
_corr_ind_begin,_corr_ind_endPointers to range indicating which correlations should be calculated

Call using:

UnitCellCoord bijk(0,i,j,k); // i,j,k of unit cell to get
contribution from int l_index = my_supercell.find(bijk); // Linear index
of site in Configuration std::vector<int> _corr_ind = {0, 2, 4, 6}; // Get
contribution to correlations 0, 2, 4, and 6
myclexulator.calc_restricted_global_corr_contribution(my_configdof,
my_supercell.get_nlist(l_index).begin(),
correlation_array.begin(),
_corr_ind.begin(),
_corr_ind.end());

Definition at line 603 of file Clexulator.hh.

◆ calc_restricted_point_corr()

void CASM::Clexulator::calc_restricted_point_corr ( ConfigDoF const &  _input_configdof,
long int const *  _nlist_begin,
long int const *  _nlist_end,
int  neighbor_ind,
double *  _corr_begin,
double *  _corr_end,
size_type const *  _corr_ind_begin,
size_type const *  _corr_ind_end 
) const
inline

Calculate select point correlations about basis site 'neighbor_ind'.

neighbor_ind Basis site index about which to calculate correlations

_corr_begin Pointer to beginning of data structure where correlations are written

Parameters
_corr_ind_begin,_corr_ind_endPointers to range indicating which correlations should be calculated

Call using:

UnitCellCoord bijk(b,i,j,k); // b,i,j,k of site to get point
correlations int l_index = my_supercell.find(bijk); // Linear index of
site in Configuration std::vector<int> _corr_ind = {0, 2, 4, 6}; // Get
contribution to correlations 0, 2, 4, and 6
myclexulator.calc_restricted_point_corr(my_configdof,
my_supercell.get_nlist(l_index).begin(), b, correlation_array.begin(),
_corr_ind.begin(), _corr_ind.end());

Definition at line 651 of file Clexulator.hh.

◆ check_evaluation()

std::string CASM::Clexulator::check_evaluation ( ClexParamKey const  _param_key) const

Check evaluation mode of parameters specified by.

Parameters
_param_key,whichcan be one of (at least) "READ" (i.e., read from ClexParamPack), "CUSTOM", or "DEFAULT" (i.e., the Clexulator's default implementation)

Definition at line 131 of file Clexulator.cc.

◆ corr_size()

size_type CASM::Clexulator::corr_size ( ) const
inline

Number of correlations.

Definition at line 480 of file Clexulator.hh.

◆ initialized()

bool CASM::Clexulator::initialized ( ) const
inline

Is runtime library loaded?

Definition at line 471 of file Clexulator.hh.

◆ n_point_corr()

size_type CASM::Clexulator::n_point_corr ( ) const
inline

Valid range for neighbor_ind argument to calc_point_corr.

  • For periodic clex, this is the number of sublattices.
  • For local clex, this is the neighbor list size.

Definition at line 486 of file Clexulator.hh.

◆ name()

std::string CASM::Clexulator::name ( ) const
inline

Name.

Definition at line 474 of file Clexulator.hh.

◆ neighborhood() [1/2]

const std::set<UnitCell>& CASM::Clexulator::neighborhood ( ) const
inline

The UnitCellCoord involved in calculating the basis functions, relative origin UnitCell.

Definition at line 523 of file Clexulator.hh.

◆ neighborhood() [2/2]

const std::set<UnitCell>& CASM::Clexulator::neighborhood ( size_type  linear_orbit_index) const
inline

The UnitCellCoord involved in calculating the basis functions for a particular orbit, relative origin UnitCell.

Definition at line 529 of file Clexulator.hh.

◆ nlist_size()

size_type CASM::Clexulator::nlist_size ( ) const
inline

Neighbor list size.

Definition at line 477 of file Clexulator.hh.

◆ operator=()

Clexulator & CASM::Clexulator::operator= ( Clexulator  B)

Assignment operator.

Definition at line 91 of file Clexulator.cc.

◆ param_key()

ClexParamKey const & CASM::Clexulator::param_key ( std::string const &  _param_name) const

Obtain ClexParamKey for a particular parameter.

Definition at line 97 of file Clexulator.cc.

◆ param_pack() [1/2]

ClexParamPack& CASM::Clexulator::param_pack ( )
inline

Obtain reference to abstract ClexParamPack object.

Definition at line 492 of file Clexulator.hh.

◆ param_pack() [2/2]

ClexParamPack const& CASM::Clexulator::param_pack ( ) const
inline

Obtain const reference to abstract ClexParamPack object.

Definition at line 489 of file Clexulator.hh.

◆ set_evaluation() [1/3]

void CASM::Clexulator::set_evaluation ( ClexParamKey const  _param_key,
std::string  _eval_type 
)

Alter evaluation of parameters specified by.

Parameters
_param_key,usingthe string
_eval_type,whichcan be at least either "READ" (i.e., read from ClexParamPack) or "DEFAULT" (i.e., the Clexulator's default implementation)

Definition at line 123 of file Clexulator.cc.

◆ set_evaluation() [2/3]

void CASM::Clexulator::set_evaluation ( ClexParamKey const  _param_key,
std::vector< std::function< double(ConfigDoF const &)> > const &  _basis_set 
)

Alter evaluation of parameters specified by.

Parameters
_param_key,usinga custom double -> double function set

Definition at line 104 of file Clexulator.cc.

◆ set_evaluation() [3/3]

void CASM::Clexulator::set_evaluation ( ClexParamKey const  _param_key,
std::vector< std::function< double(std::vector< double > const &)>  ,
const &  _basis_set 
)

Alter evaluation of parameters specified by.

Parameters
_param_key,usinga custom int -> double function set

Definition at line 112 of file Clexulator.cc.

◆ weight_matrix()

const PrimNeighborList::Matrix3Type& CASM::Clexulator::weight_matrix ( ) const
inline

The weight matrix used for ordering the neighbor list.

Definition at line 534 of file Clexulator.hh.

Friends And Related Function Documentation

◆ swap

void swap ( Clexulator first,
Clexulator second 
)
friend

Swap.

Definition at line 462 of file Clexulator.hh.

Member Data Documentation

◆ m_clex

std::unique_ptr<Clexulator_impl::Base> CASM::Clexulator::m_clex
private

Definition at line 730 of file Clexulator.hh.

◆ m_lib

std::shared_ptr<RuntimeLibrary> CASM::Clexulator::m_lib
private

Definition at line 731 of file Clexulator.hh.

◆ m_name

std::string CASM::Clexulator::m_name
private

Definition at line 729 of file Clexulator.hh.


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