![]() |
AlmaBTE
1.3
A solver of the space- and time-dependent Boltzmann transport equation for phonons
|
Miscellaneous convenience resources. More...
#include <tuple>
#include <vector>
#include <string>
#include <memory>
#include <limits>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/mpi.hpp>
#include <constants.hpp>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <unsupported/Eigen/Splines>
Go to the source code of this file.
Classes | |
class | alma::Container_comparator< T > |
Comparator function object template for a container of comparable objects. More... | |
class | alma::Min_keeper< T > |
Convenience class for updating a minimum value and keeping track of all the objects associated to it. More... | |
Functions | |
template<typename T , typename... Args> | |
std::unique_ptr< T > | alma::make_unique (Args &&... args) |
Emulation of C++14's make_unique. | |
template<typename T > | |
std::tuple< std::vector< typename T::key_type >, std::vector< typename T::mapped_type > > | alma::split_keys_and_values (const T &input) |
Put the keys and values of a map (or similar) into separate vectors. More... | |
void | alma::flush_istream (std::istream &f) |
Read from f until ' ' is found. More... | |
template<typename T > | |
std::vector< T > | alma::tokenize_homogeneous_line (std::string &line, const std::string sep=" \) |
Try to tokenize a line into homogeneous tokens. More... | |
bool | alma::starts_with_character (const std::string &line, const std::string &chars) |
Check whether a line starts with a character from a given set. More... | |
bool | alma::almost_equal (const double a, const double b, const double abstol=1e-8, const double reltol=1e-5) |
Approximate comparation between doubles. More... | |
double | alma::ssqrt (double x) |
"Signed square root" of real numbers, that converts purely imaginary numbers to negative values. More... | |
template<typename T > | |
int | alma::signum (const T &arg) |
Compute the sign of an argument. More... | |
std::string | alma::get_timestamp () |
Build a timestamp in our preferred format. More... | |
std::array< std::size_t, 2 > | alma::my_jobs (std::size_t njobs, std::size_t nprocs, std::size_t my_id) |
Compute the minimum and maximum indices of the jobs that must be executed in the current process. More... | |
template<typename T , typename U > | |
U | alma::python_mod (const T &n, const U &d) |
Alternative modulus operation with a behavior similar to the % operator in Python. More... | |
double | alma::bose_einstein (double omega, double T) |
Bose-Einstein distribution. More... | |
double | alma::bose_einstein_kernel (double omega, double T) |
Integration kernel for the specific heat, thermal conductivity and other integrals. More... | |
Eigen::VectorXi | alma::reduce_integers (const Eigen::Ref< const Eigen::VectorXi > &vector) |
Divide a vector of integers by the GCD of their coefficients. More... | |
std::string | alma::engineer_format (double x, bool insert_space=false) |
Convert a numerical value to a string that uses engineering prefix. | |
Eigen::VectorXd | alma::logSpace (double min, double max, int N) |
Construct a vector with N logarithmically spaced values from min to max. More... | |
Eigen::VectorXd | alma::splineInterpolation (const Eigen::Ref< const Eigen::VectorXd > &X, const Eigen::Ref< const Eigen::VectorXd > &Y, const Eigen::Ref< const Eigen::VectorXd > &Xtarget) |
Perform spline interpolation of a tabulated function Y(X) at Xtarget. More... | |
Eigen::VectorXd | alma::linearInterpolation (const Eigen::Ref< const Eigen::VectorXd > &X, const Eigen::Ref< const Eigen::VectorXd > &Y, const Eigen::Ref< const Eigen::VectorXd > &Xtarget) |
Perform linear interpolation of a tabulated function Y(X) at Xtarget. More... | |
template<class Archive , typename S > | |
void | boost::serialization::save (Archive &ar, const Eigen::Triplet< S > &t, const unsigned int version) |
Allow boost to serialize an Eigen::Triplet. | |
template<class Archive , typename S > | |
void | boost::serialization::load (Archive &ar, Eigen::Triplet< S > &t, const unsigned int version) |
Allow boost to unserialize an Eigen::Triplet. | |
template<class Archive , typename S > | |
void | boost::serialization::serialize (Archive &ar, Eigen::Triplet< S > &t, const unsigned int version) |
Dummy function allowing us to implement save() and load() separately. More... | |
Miscellaneous convenience resources.
|
inline |
Approximate comparation between doubles.
[in] | a | - first value |
[in] | b | - second value |
[in] | abstol | - Maximum absolute tolerance |
[in] | reltol | - Maximum relative tolerance |
|
inline |
Bose-Einstein distribution.
[in] | omega | - angular frequency in rad/ps |
[in] | T | - temperature in K |
|
inline |
Integration kernel for the specific heat, thermal conductivity and other integrals.
This function implements the calculation of (x / sinh(x))^2, where x = hbar * omega / (2 * kB *T).
[in] | omega | - angular frequency in rad/ps |
[in] | T | - temperature in K |
|
inline |
Read from f until '
' is found.
This function is meant to be called after reading data from f using >> and before using std::getline() on it.
[in] | f | - istream from which to read |
|
inline |
Build a timestamp in our preferred format.
|
inline |
Perform linear interpolation of a tabulated function Y(X) at Xtarget.
X must be strictly ascending (no duplicate entries).
|
inline |
Construct a vector with N logarithmically spaced values from min to max.
|
inline |
Compute the minimum and maximum indices of the jobs that must be executed in the current process.
Split njobs jobs among nproc processes and return the minimum and maximum indices of the jobs that must be assigned to the current process, bundled in an array. More specifically, return jmin and jmax so that we can write a for loop like for (auto j = jmin; j < jmax; ++j)
[in] | njobs | - number of jobs |
[in] | nprocs | - number of process |
[in] | my_id | - id of the current process |
|
inline |
Alternative modulus operation with a behavior similar to the % operator in Python.
[in] | n | - numerator |
[in] | d | - denominator |
|
inline |
Divide a vector of integers by the GCD of their coefficients.
[in] | vector | - the original vector |
void boost::serialization::serialize | ( | Archive & | ar, |
Eigen::Triplet< S > & | t, | ||
const unsigned int | version | ||
) |
|
inline |
Compute the sign of an argument.
[in] | arg | - anything that can be constructed passing 0 as the only argument and that supports operator - |
|
inline |
Perform spline interpolation of a tabulated function Y(X) at Xtarget.
std::tuple<std::vector<typename T::key_type>, std::vector<typename T::mapped_type> > alma::split_keys_and_values | ( | const T & | input | ) |
Put the keys and values of a map (or similar) into separate vectors.
|
inline |
"Signed square root" of real numbers, that converts purely imaginary numbers to negative values.
[in] | x | - argument of the square root |
|
inline |
Check whether a line starts with a character from a given set.
[in] | line | - string containing the line |
[in] | chars | - string containing the set of characters |
|
inline |
Try to tokenize a line into homogeneous tokens.
This function tries to split a line into fields that can all be cast into the same type and return a vector of tokens. boost::bad_lexical_cast will be thrown in case of failure.
[in] | line | - line of text to tokenize |
[in] | sep | - field separators |