Page MenuHomec4science

data_container.hpp
No OneTemporary

File Metadata

Created
Sat, Jun 29, 22:54

data_container.hpp

/*-------------------------------------------------------
- Module : database
- File : data_container.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#ifndef SPECMICP_DATABASE_DATACONTAINER_HPP
#define SPECMICP_DATABASE_DATACONTAINER_HPP
//! \file data_container.hpp Storage class for thermodynamics database
#include "common_def.hpp"
#include <map>
#include "boost/range/irange.hpp"
namespace specmicp {
namespace database {
using range_t = boost::iterator_range<boost::range_detail::integer_iterator<int>>;
//! \brief Storage class - Contains the database
//!
//! - Should not be accessed directly but through interfaces
//! Correct interfaces are subclasses of DatabaseModule
//! - Should be shared with a smart pointer
struct DataContainer
{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
DataContainer():
is_canonical(false)
{}
// Basis
// ------
int nb_component; //!< Number of components == size of the basis
vector_labels_t labels_basis; //!< labels of the components
std::map<std::string, int> map_labels_basis; //!< map labels <-> id
data_vector_t molar_mass_basis; //!< molar mass of the basis // (g/mol)
Eigen::Matrix<double, Eigen::Dynamic, 3> param_aq; //!< Aqueous parameters (both for basis and secondary species)
// Secondary aqueous species
// -------------------------
int nb_aqueous; //!< Number of aqueous species (not taking into acount the basis)
vector_labels_t labels_aqueous; //!< labels of the aqueous species
reaction_mat_t nu_aqueous; //!< Stoechiometric coefficient for aqueous species
logK_vector_t logk_aqueous; //!< LogK for aqueous species
// Minerals
// ---------
int nb_mineral; //!< Number of minerals (used in computation)
vector_labels_t labels_minerals; //!< labels of the minerals
reaction_mat_t nu_mineral; //!< Stoichiometric coefficient for minerals
logK_vector_t logk_mineral; //!< LogK for minerals
data_vector_t _molar_volume_mineral; //!< molar volume of mineral (cm3/mol)
int nb_mineral_kinetic; //!< Number of minerals (governed by kinetics)
vector_labels_t labels_minerals_kinetic; //!< labels of the minerals (governed by kinetics)
reaction_mat_t nu_mineral_kinetic; //!< Stoichiometric coefficient for minerals (governed by kinetics)
logK_vector_t logk_mineral_kinetic; //!< LogK for minerals (governed by kinetics)
data_vector_t _molar_volume_mineral_kinetic; //!< molar volume of mineral (cm3/mol)
// Gas
// ----
int nb_gas; //!< Number of gas
vector_labels_t labels_gas; //!< labels of the gas phase
reaction_mat_t nu_gas; //!< Stoichiometric coefficient for the gas
logK_vector_t logk_gas; //!< log(K) gas
// Ranges
// ------
range_t range_component() { return boost::irange(0, nb_component);}
range_t range_aqueous_component() { return boost::irange(1, nb_component);}
range_t range_aqueous() { return boost::irange(0, nb_aqueous);}
range_t range_mineral() { return boost::irange(0, nb_mineral);}
// Status
// ------
bool is_canonical; //!< true if the database is in canonical form
// Computed variables
// ------------------
// The following functions are provided for convenience
// They provide variables computed from the main data
//! \brief Return the molar mass (kg/mol) of a mineral
double molar_mass_mineral(int m);
//! \brief Return the molar mass (kg/mol) of a mineral governed by kinetic
double molar_mass_mineral_kinetic(int m);
//! \brief Return the molar volume (m^3/mol) of a mineral
double molar_volume_mineral(int m);
//! \brief Return the molar volume (m^3/mol) of a mineral governed by kinetic
double molar_volume_mineral_kinetic(int m);
};
} // end namespace database
} // end namespace specmicp
#endif // SPECMICP_DATABASE_DATACONTAINER_HPP

Event Timeline