Page MenuHomec4science

reaction_path.hpp
No OneTemporary

File Metadata

Created
Mon, Jul 21, 12:03

reaction_path.hpp

/*-------------------------------------------------------
- Module : specmicp
- File : reaction_path.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#ifndef SPECMICP_SPECMICP_REACTIONPATH_HPP
#define SPECMICP_SPECMICP_REACTIONPATH_HPP
//! \file reaction_path.hpp reaction path driver
#include <memory>
#include <map>
#include "database/database.hpp"
#include "micpsolver/micpsolver_structs.hpp"
#include "reduced_system_solver.hpp"
namespace specmicp {
//! \brief typedef to a reaction path amount
//!
//! The first element is the inital amount,
//! The second element is the increase to add at every step
using reaction_amount_t = std::pair<double, double>;
//! \brief A reaction path model
//!
//! Contains every data we need to run a reaction path model
struct ReactionPathModel
{
//! The amount of components
std::map<std::string, reaction_amount_t> amount_components;
//! The amount of aqueous species
std::map<std::string, reaction_amount_t> amount_aqueous;
//! The amount of minerals
std::map<std::string, reaction_amount_t> amount_minerals;
//! the number of step
int nb_step;
//! the path to the database - optional
std::string database_path;
};
//! \brief Driver to solve a reaction path model
class ReactionPathDriver
{
public:
//! \brief Initialise from a model
//!
//! Build a database from the attribute database_path of the model
ReactionPathDriver(std::shared_ptr<ReactionPathModel> model):
m_model(model)
{
read_database();
}
//! \brief Initialise the driver from a model and a raw database
ReactionPathDriver(std::shared_ptr<ReactionPathModel> model,
std::shared_ptr<database::DataContainer> data):
m_model(model),
m_database(data),
m_data(data)
{}
//! Initialize the database
void read_database();
//! Dissolve everything into components
void dissolve_to_components();
//! \brief Return the id of a species in 'list_labels' from its id
int label_to_id(const std::string& label, const std::vector<std::string>& list_labels);
//! \brief Perform one step
micpsolver::MiCPPerformance one_step(Eigen::VectorXd& x);
//! Set total aqueous concentrations
void total_aqueous_concentration(const Eigen::VectorXd& x, Eigen::VectorXd& totaq) {
m_current_solver.total_aqueous_concentration(x, totaq);
}
private:
std::shared_ptr<ReactionPathModel> m_model;
specmicp::database::Database m_database;
std::shared_ptr<specmicp::database::DataContainer> m_data;
Eigen::VectorXd m_tot_conc;
Eigen::VectorXd m_tot_conc_increase;
micpsolver::MiCPSolverOptions m_options;
ReducedSystemSolver m_current_solver;
//std::shared_ptr<ThermoData> m_thermo;
};
} // end namespace specmicp
#endif // SPECMICP_SPECMICP_REACTIONPATH_HPP

Event Timeline