chemmisol 0.1
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
chemmisol Namespace Reference

Namespaces

namespace  solver
 

Classes

class  AqueousSpecies
 
class  ChemicalComponent
 
class  ChemicalSpecies
 
struct  ChemicalSpeciesReagent
 
class  ChemicalSystem
 
struct  ComponentReagent
 
class  dH
 
class  EmptyReagents
 
class  FixedAqueousSpecies
 
class  FixedChemicalComponent
 
class  FixedChemicalSpecies
 
class  FixedMineralSpecies
 
class  H
 
class  Homotopy
 
class  InvalidMineralSpeciesWithUndefinedSitesCount
 
class  InvalidReaction
 
class  InvalidSpecies
 
class  MineralSpecies
 
class  MissingProducedSpeciesInReaction
 
class  Newton
 
class  Reaction
 
struct  Reagent
 
class  RegulaFalsi
 
class  Solvent
 
class  TooManyProducedSpeciesInReaction
 

Typedefs

template<typename T , std::size_t N>
using X = std::array< T, N >
 
template<typename T , std::size_t N, std::size_t P = N>
using M = std::array< std::array< T, P >, N >
 
template<typename T >
using VecX = std::vector< T >
 
template<typename T >
using VecM = std::vector< std::vector< T > >
 
template<typename X , typename M >
using AbsoluteNewton = Newton< X, M, abs >
 

Enumerations

enum  Phase { SOLVENT , AQUEOUS , MINERAL }
 
enum  Category {
  MASS , LENGTH , VOLUME , SURFACE ,
  QUANTITY
}
 

Functions

std::ostream & operator<< (std::ostream &o, const Phase &phase)
 
el::Logger * init_logger (const char *logger_id)
 
void log_to_file (el::Logger *logger, const std::string &log_file, bool terminal_logging)
 
template<typename T >
std::list< std::complex< T > > unit_roots (int n)
 
template<typename T >
std::list< std::complex< T > > roots (const std::complex< T > &c, int n)
 
template<typename T , std::size_t N, std::size_t P>
X< T, N > operator* (const M< T, N, P > &m, const X< T, P > &x)
 
template<typename T , std::size_t N>
X< T, N > operator- (const X< T, N > &x)
 
template<typename T , std::size_t N>
X< T, N > operator+ (const X< T, N > &x1, const X< T, N > &x2)
 
template<typename T , std::size_t N>
X< T, N > operator* (const T &a, const X< T, N > &x)
 
template<typename T , std::size_t N, std::size_t P>
M< T, N, P > operator* (const T &a, const M< T, N, P > &m)
 
template<typename T , std::size_t N>
double norm (const X< T, N > &x)
 
template<typename T , std::size_t N>
double norm (const X< std::complex< T >, N > &x)
 
template<typename T , std::size_t N>
X< T, N > abs (const X< T, N > &x)
 
template<typename _M >
M< typename _M::value_type::value_type, std::tuple_size< _M >::value, std::tuple_size< typename _M::value_type >::value+1 > augment (const _M &m, const X< typename _M::value_type::value_type, std::tuple_size< _M >::value > &x)
 
template<typename T , std::size_t N>
std::ostream & operator<< (std::ostream &o, const X< T, N > &x)
 
template<typename T >
VecX< T > operator* (const VecM< T > &m, const VecX< T > &x)
 
template<typename T >
VecX< T > operator- (const VecX< T > &x)
 
template<typename T >
VecX< T > operator+ (const VecX< T > &x1, const VecX< T > &x2)
 
template<typename T >
double norm (const VecX< T > &x)
 
template<typename T >
VecX< T > abs (const VecX< T > &x)
 
template<typename T >
VecM< T > augment (const VecM< T > &m, const VecX< T > &x)
 
template<typename T >
std::ostream & operator<< (std::ostream &o, const VecX< T > &x)
 
template<typename T >
double norm (const T &x)
 
template<typename T >
abs (const T &x)
 
template<typename T >
identity (const T &x)
 

Variables

el::Logger * core_logger
 
constexpr double pi = 3.141592653589793238462643383279502884
 
const double NA
 

Detailed Description

Main Chemmisol namespace.

Typedef Documentation

◆ X

template<typename T , std::size_t N>
using chemmisol::X = typedef std::array<T, N>

Vector type hosted by a fixed size std::array.

◆ M

template<typename T , std::size_t N, std::size_t P = N>
using chemmisol::M = typedef std::array<std::array<T, P>, N>

Matrix type hosted by a fixed size std::array.

The matrix contains N rows and P columns.

◆ VecX

template<typename T >
using chemmisol::VecX = typedef std::vector<T>

Vector type hosted by a dynamic size std::vector.

◆ VecM

template<typename T >
using chemmisol::VecM = typedef std::vector<std::vector<T> >

Matrix type hosted by a dynamic size std::vector.

◆ AbsoluteNewton

template<typename X , typename M >
using chemmisol::AbsoluteNewton = typedef Newton<X, M, abs>

Implements the absolute Newton-Raphson method, where the absolute value of x_n+1 is taken as the result of each iteration.

This variant is particularly suitable for chemical equilibrium solving, since it guarantees that x_n+1, that represents activity of species, is always positive.

Moreover, the absolute Newton-Raphson method has proven to have a much larger basin of attraction than the classical Newton-Raphson method [1].

[1] K. Meintjes and A. P. Morgan, “A methodology for solving chemical equilibrium systems,” Applied Mathematics and Computation, vol. 22, no. 4, pp. 333–361, Jun. 1987, doi: 10.1016/0096-3003(87)90076-2.

Enumeration Type Documentation

◆ Phase

Possible phases of a chemical species.

◆ Category

Describes the category of each unit.

Function Documentation

◆ operator<<() [1/3]

std::ostream & chemmisol::operator<< ( std::ostream &  o,
const Phase phase 
)

Phases stream output operator.

◆ init_logger()

el::Logger * chemmisol::init_logger ( const char *  logger_id)

Initializes and configures a chemmisol logger with the specified ID.

The method is notably used to initialize the chemmisol::core_logger with the CHEM_CORE_LOGID, but can be used to define other loggers with the same configuration ad the chemmisol::core_logger.

Parameters
logger_idID of the logger, used in Easylogging++ CLOG() and CVLOG() macros.
Returns
Initialized and configured logger.

◆ log_to_file()

void chemmisol::log_to_file ( el::Logger *  logger,
const std::string &  log_file,
bool  terminal_logging 
)

Configures the specified logger to output to the specified log file. Logging to std::cout can also be disabled thanks to the terminal_logging argument.

Any Easylogging++ logger can be configured this way, including the chemmisol::core_logger or any logger initialized with init_logger().

Parameters
loggerLogger to output to a file.
log_fileFull path to the log file.
terminal_loggingSet to false to disable std::cout logging.

◆ operator*() [1/2]

template<typename T , std::size_t N, std::size_t P>
X< T, N > chemmisol::operator* ( const M< T, N, P > &  m,
const X< T, P > &  x 
)

Computes m*x as a matrix multiplication.

Parameters
mMatrix of size N*P.
xVector of size P.
Returns
Vector of size N.

◆ operator-() [1/2]

template<typename T , std::size_t N>
X< T, N > chemmisol::operator- ( const X< T, N > &  x)

Computes -x = [-x_0, ..., -x_N-1].

Parameters
xVector of size N.
Returns
Vector of size N.

◆ operator+() [1/2]

template<typename T , std::size_t N>
X< T, N > chemmisol::operator+ ( const X< T, N > &  x1,
const X< T, N > &  x2 
)

Computes x1+x2 = [x1_0+x2_0, ..., x1_N-1 + x2_N-1].

Parameters
x1Vector of size N.
x2Vector of size N.
Returns
Vector of size N.

◆ norm() [1/3]

template<typename T , std::size_t N>
double chemmisol::norm ( const X< T, N > &  x)

Computes the euclidean norm of the vector.

◆ abs() [1/3]

template<typename T , std::size_t N>
X< T, N > chemmisol::abs ( const X< T, N > &  x)

Computes the absolute value the vector.

◆ augment() [1/2]

template<typename _M >
M< typename _M::value_type::value_type, std::tuple_size< _M >::value, std::tuple_size< typename _M::value_type >::value+1 > chemmisol::augment ( const _M &  m,
const X< typename _M::value_type::value_type, std::tuple_size< _M >::value > &  x 
)

Implements the augment operation used by the Gaussian elimination algortihm for fixed size matrices and vectors.

Returns a new matrix corresponding to the concatenation of m and x, where x represents the last column of the new matrix.

Parameters
mMatrix of size N*P.
xVector of size N.
Returns
Matrix of size N*(P+1).
Template Parameters
_MFixed size matrix type.

◆ operator<<() [2/3]

template<typename T , std::size_t N>
std::ostream & chemmisol::operator<< ( std::ostream &  o,
const X< T, N > &  x 
)

Fixed size vector stream output operator.

The vector is serialized as "[x0, ..., xn]".

◆ operator*() [2/2]

template<typename T >
VecX< T > chemmisol::operator* ( const VecM< T > &  m,
const VecX< T > &  x 
)

Computes m*x as a matrix multiplication.

Parameters
mMatrix of size N*P.
xVector of size P.
Returns
Vector of size N.

◆ operator-() [2/2]

template<typename T >
VecX< T > chemmisol::operator- ( const VecX< T > &  x)

Computes -x = [-x_0, ..., -x_N-1].

Parameters
xVector of size N.
Returns
Vector of size N.

◆ operator+() [2/2]

template<typename T >
VecX< T > chemmisol::operator+ ( const VecX< T > &  x1,
const VecX< T > &  x2 
)

Computes x1+x2 = [x1_0+x2_0, ..., x1_N-1 + x2_N-1].

The behavior is unspecified if x1 and x2 are not the same size.

Parameters
x1Vector of size N.
x2Vector of size N.
Returns
Vector of size N.

◆ norm() [2/3]

template<typename T >
double chemmisol::norm ( const VecX< T > &  x)

Computes the euclidean norm of the vector.

◆ abs() [2/3]

template<typename T >
VecX< T > chemmisol::abs ( const VecX< T > &  x)

Computes the absolute value the vector.

◆ augment() [2/2]

template<typename T >
VecM< T > chemmisol::augment ( const VecM< T > &  m,
const VecX< T > &  x 
)

Implements the augment operation used by the Gaussian elimination algortihm for dynamic size matrices and vectors.

Returns a new matrix corresponding to the concatenation of m and x, where x represents the last column of the new matrix.

The behavior is unspecified if the size of x is not equal to the count of rows in m.

Parameters
mMatrix of size N*P.
xVector of size N.
Returns
Matrix of size N*(P+1).

◆ operator<<() [3/3]

template<typename T >
std::ostream & chemmisol::operator<< ( std::ostream &  o,
const VecX< T > &  x 
)

Dynamic size vector stream output operator.

The vector is serialized as "[x0, ..., xn]".

◆ norm() [3/3]

template<typename T >
double chemmisol::norm ( const T &  x)

Returns the norm of the scalar value x, i.e. its absolute value.

◆ abs() [3/3]

template<typename T >
T chemmisol::abs ( const T &  x)

Returns the absolute value of the scalar value x.

◆ identity()

template<typename T >
T chemmisol::identity ( const T &  x)

Identity method, that returns x itself.

Variable Documentation

◆ core_logger

el::Logger* chemmisol::core_logger
extern

Pointer to the Easylogging++ Logger used internally by the chemmisol library.

◆ NA

const double chemmisol::NA
extern