Multi Resolution Molecular Dynamics 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
mrmd::util Namespace Reference

Utility functions used throughout the library. More...

Classes

class  ExponentialMovingAverage
 Calculates the exponential moving average (EMA) for values added with append. More...
class  IsInSymmetricSlab
 Predicate to check if a point is within an axis-aligned slab. More...
struct  Random
 GPU compatible random number generator. More...

Functions

KOKKOS_INLINE_FUNCTION constexpr real_t degToRad (const real_t &grd)
 converts degree to radians
KOKKOS_INLINE_FUNCTION constexpr real_t radToDeg (const real_t &rad)
 converts radians to degree
void dumpView (const std::string &filename, const ScalarView &view)
 Dump a scalar view to a text file.
void dumpView (const std::string &filename, const MultiView &view)
 Dump a multi view to a text file.
std::string getEnvironmentVariable (const std::string &variable)
ExponentialMovingAverage & operator<< (ExponentialMovingAverage &lhs, const real_t &rhs)
void updateInterpolate (const data::MultiHistogram &target, const data::MultiHistogram &input)
 Linear interpolation of data contained in input MultiHistogram onto grid of target histogram, adding the interpolated data to the data already contained in target.
KOKKOS_INLINE_FUNCTION real_t lerp (const real_t &left, const real_t &right, const real_t &factor)
 Linear interpolation between two values.
template<class T, class... P>
void grow (Kokkos::View< T, P... > &view, idx_t size, real_t safetyMargin=1.1_r)
KOKKOS_INLINE_FUNCTION real_t dot3 (real_t const *const a, real_t const *const b)
KOKKOS_INLINE_FUNCTION real_t sqr (const real_t &sqr)
KOKKOS_INLINE_FUNCTION real_t powInt (const real_t &x, const idx_t n)
KOKKOS_INLINE_FUNCTION real_t approxErfc (const real_t &x, real_t &expX2)
 "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Table" Milton Abramowitz (1970) "Rational Approximations", equation 7.1.27:
KOKKOS_INLINE_FUNCTION real_t approxErfc (const real_t &x)
template<typename HEAD>
void printTable (HEAD head)
template<typename HEAD, typename... TAIL>
void printTable (HEAD head, TAIL... tail)
template<typename HEAD>
void printTableSep (HEAD)
template<typename HEAD, typename... TAIL>
void printTableSep (HEAD, TAIL... tail)
data::Atoms fillDomainWithAtoms (const data::Subdomain &subdomain, const idx_t &numAtoms, const real_t &maxVelocity, const real_t &inputMass)
 Helper function to provide an initial atoms ensamble.

Detailed Description

Utility functions used throughout the library.

Angle handling, interpolation, random numbers, small math helpers, moving averages and the simulation setup helpers used by the examples.

Function Documentation

◆ approxErfc() [1/2]

KOKKOS_INLINE_FUNCTION real_t mrmd::util::approxErfc ( const real_t & x)

◆ approxErfc() [2/2]

KOKKOS_INLINE_FUNCTION real_t mrmd::util::approxErfc ( const real_t & x,
real_t & expX2 )

"Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Table" Milton Abramowitz (1970) "Rational Approximations", equation 7.1.27:

accuracy: 1.5x10^-7

Parameters
xevaluation point
expX2intermediate value std::exp(-x * x)

◆ degToRad()

KOKKOS_INLINE_FUNCTION constexpr real_t mrmd::util::degToRad ( const real_t & grd)
constexpr

converts degree to radians

◆ dot3()

KOKKOS_INLINE_FUNCTION real_t mrmd::util::dot3 ( real_t const *const a,
real_t const *const b )

◆ dumpView() [1/2]

void mrmd::util::dumpView ( const std::string & filename,
const MultiView & view )

Dump a multi view to a text file.

Parameters
filenameoutput filename
viewview that should be written to file

◆ dumpView() [2/2]

void mrmd::util::dumpView ( const std::string & filename,
const ScalarView & view )

Dump a scalar view to a text file.

Parameters
filenameoutput filename
viewview that should be written to file

◆ fillDomainWithAtoms()

data::Atoms mrmd::util::fillDomainWithAtoms ( const data::Subdomain & subdomain,
const idx_t & numAtoms,
const real_t & maxVelocity,
const real_t & inputMass )

Helper function to provide an initial atoms ensamble.

Parameters
subdomainArea where to place atoms.
numAtomsHow many atoms to place.
maxVelocityMaximial initial absolute velocity of the atoms.
inputMassMass of the atoms.
Returns
Atoms data structure with all atoms initialized.

◆ getEnvironmentVariable()

std::string mrmd::util::getEnvironmentVariable ( const std::string & variable)
inline

◆ grow()

template<class T, class... P>
void mrmd::util::grow ( Kokkos::View< T, P... > & view,
idx_t size,
real_t safetyMargin = 1.1_r )

◆ lerp()

KOKKOS_INLINE_FUNCTION real_t mrmd::util::lerp ( const real_t & left,
const real_t & right,
const real_t & factor )

Linear interpolation between two values.

Parameters
leftleft value
rightright value
factorinterpolation factor in [0, 1]
Returns
interpolated value

◆ operator<<()

ExponentialMovingAverage & mrmd::util::operator<< ( ExponentialMovingAverage & lhs,
const real_t & rhs )
inline

◆ powInt()

KOKKOS_INLINE_FUNCTION real_t mrmd::util::powInt ( const real_t & x,
const idx_t n )

◆ printTable() [1/2]

template<typename HEAD>
void mrmd::util::printTable ( HEAD head)

◆ printTable() [2/2]

template<typename HEAD, typename... TAIL>
void mrmd::util::printTable ( HEAD head,
TAIL... tail )

◆ printTableSep() [1/2]

template<typename HEAD>
void mrmd::util::printTableSep ( HEAD )

◆ printTableSep() [2/2]

template<typename HEAD, typename... TAIL>
void mrmd::util::printTableSep ( HEAD ,
TAIL... tail )

◆ radToDeg()

KOKKOS_INLINE_FUNCTION constexpr real_t mrmd::util::radToDeg ( const real_t & rad)
constexpr

converts radians to degree

◆ sqr()

KOKKOS_INLINE_FUNCTION real_t mrmd::util::sqr ( const real_t & sqr)

◆ updateInterpolate()

void mrmd::util::updateInterpolate ( const data::MultiHistogram & target,
const data::MultiHistogram & input )

Linear interpolation of data contained in input MultiHistogram onto grid of target histogram, adding the interpolated data to the data already contained in target.

Data for target grid points outside of the grid range of the input MultiHistogram is not updated.

Parameters
inputMultiHistogram containing data to interpolate on coarse grid.
targetMultiHistogram defining the grid to interpolate onto and containing the data to be updated by interpolating the data from input.