Page MenuHomec4science

adimensional_system_structs.hpp
No OneTemporary

File Metadata

Created
Fri, May 10, 18:52

adimensional_system_structs.hpp

#ifndef SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSTRUCTS_HPP
#define SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSTRUCTS_HPP
#include "common.hpp"
//! \file adimensional_system_structs.hpp Options and constraints for the AdimensionalSystem
namespace specmicp {
//! \struct AdimensionalSystemOptions
//! \brief Options for the Adimensional Systems
//!
//! It is mainly about the secondary variables fixed-point iterations
struct AdimensionalSystemOptions
{
bool non_ideality; //!< Solve for non ideality
scalar_t non_ideality_tolerance; //!< Tolerance for non ideality
index_t non_ideality_max_iter; //!< Max iterations fornon ideality
scalar_t under_relaxation_factor; //!< Under relaxation factor for the conservation of water
scalar_t restart_concentration; //!< Log of the molality used to restart the computation
scalar_t new_component_concentration; //!< Log_10 of the molality for a new component
scalar_t start_non_ideality_computation; //!< Factor to start the non-ideality computation
AdimensionalSystemOptions():
non_ideality(true),
non_ideality_tolerance(1e-8),
non_ideality_max_iter(10),
under_relaxation_factor(0.9),
restart_concentration(-6),
new_component_concentration(-4.0),
start_non_ideality_computation(0.1)
{}
};
//! \enum AqueousComponentEquationType
//! \brief Type of an aqueous component equation
enum class AqueousComponentEquationType
{
NoEquation = no_equation, //!< Not an equation, component is not present in the system
MassConservation, //!< Mass balance
ChargeBalance, //!< M.B. replaced by charge balance
FixedFugacity, //!< M.B. replaced by a fixed fugacity equation
FixedActivity //!< M.B. replaced by a fixed activity equation
};
//! \enum WaterEquationType
//! \brief The type of the equation solved for the water
enum class WaterEquationType
{
NoEquation = no_equation, //!< Amount of water is not solved
MassConservation, //!< Water is conserved
SaturatedSystem //!< System is saturated
};
//! \struct FixedFugacityConstraint
//! \brief Struct to contain information needed to solve a fix fugacity problem
struct FixedFugacityConstraint
{
index_t id_gas; //!< Index of the fixed-fugacity gas
index_t id_component; //!< Index of the corresponding component
scalar_t log_value; //!< Log_10 of the fugacity
FixedFugacityConstraint(index_t gas, index_t component, scalar_t logvalue):
id_gas(gas),
id_component(component),
log_value(logvalue)
{}
};
//! \struct FixedActivityConstraint
//! \brief Struct to contain information needed to solve a fix activity problem.
struct FixedActivityConstraint
{
index_t id_component; //!< Index of the fixed-activity component
scalar_t log_value; //!< Log_10 of the activity
FixedActivityConstraint(index_t component, scalar_t logvalue):
id_component(component),
log_value(logvalue)
{}
};
//! \enum SurfaceEquationType
//! \brief The model for surface sorption
enum class SurfaceEquationType
{
NoEquation, //!< Do not include surface sorption
Equilibrium //!< Equilibrium model
};
//! \struct SurfaceConstraint
//! This struct contains the information to set-up the surface sorption model
struct SurfaceConstraint
{
SurfaceEquationType model_type; //!< The model to use
scalar_t concentration; //!< The total concentration of sorption sites
//! By default, we don't include surface sorption in the computation
SurfaceConstraint():
model_type(SurfaceEquationType::NoEquation),
concentration(0)
{}
//! When a concentration is supplied, the surface sorption model is equilibrium
SurfaceConstraint(scalar_t surface_concentration):
model_type(SurfaceEquationType::Equilibrium),
concentration(surface_concentration)
{}
};
//! \struct AdimensionalSystemConstraints
//! \brief Struct to contains the "Boundary conditions" for the AdimensionalSystem
struct AdimensionalSystemConstraints
{
Vector total_concentrations; //!< Total concentrations
WaterEquationType water_equation; //!< Water equation
index_t charge_keeper; //!< The equation for this component is replace by the charge balance
bool saturated_system; //!> System is saturated - no gas phase
std::vector<FixedFugacityConstraint> fixed_fugacity_cs; //!< Contains information about fixed fugacity gas
std::vector<FixedActivityConstraint> fixed_activity_cs; //!< Contains information about fixed activity component
scalar_t inert_volume_fraction; //! Volume fraction of inert solid (inert in the equilibrium computation)
SurfaceConstraint surface_model; //! Surface sorption model
AdimensionalSystemConstraints():
water_equation(WaterEquationType::MassConservation),
charge_keeper(no_species),
inert_volume_fraction(0.0),
surface_model()
{}
AdimensionalSystemConstraints(const Vector& total_concs):
total_concentrations(total_concs),
water_equation(WaterEquationType::MassConservation),
charge_keeper(no_species),
inert_volume_fraction(0.0),
surface_model()
{}
//! \brief Enable the conservation of water
void enable_conservation_water() {water_equation = WaterEquationType::MassConservation;}
//! \brief Disable the conservation of water
void disable_conservation_water() {water_equation = WaterEquationType::NoEquation;}
//! \brief The system is saturated
void set_saturated_system() {water_equation = WaterEquationType::SaturatedSystem;}
//! \brief Disable the surface sorption model
void disable_surface_model() {surface_model.model_type = SurfaceEquationType::NoEquation;}
//! \brief Enable the surface sorption model
//! \param surface_sorption_model_concentration concentration of the surface sorption sites
void enable_surface_model(scalar_t surface_sorption_model_concentration) {
surface_model.model_type = SurfaceEquationType::Equilibrium;
surface_model.concentration = surface_sorption_model_concentration;
}
//! \brief Set the charge keeper to 'component'
//!
//! \param component Index of the component (in the database)
void set_charge_keeper(index_t component) {
charge_keeper = component;
}
//! \brief Add a fixed fugacity gas condition
//!
//! \param constraint struct containing the information about a fixed-fugacity constraint
void add_fixed_fugacity_gas(const FixedFugacityConstraint& constraint) {
fixed_fugacity_cs.push_back(constraint);
}
//! \brief Add a fixed fugacity gas condition
//!
//! \param gas Index of the gas (in the database)
//! \param component Index of the corresponding component (in the database)
//! \param logvalue Log_10 of the fugacity
void add_fixed_fugacity_gas(index_t gas, index_t component, scalar_t logvalue) {
fixed_fugacity_cs.push_back(FixedFugacityConstraint(gas, component, logvalue));
}
//! \brief Add a fixed activity component condition
//!
//! \param constraint struct containing the information about a fixed-activity constraint
void add_fixed_activity_component(const FixedActivityConstraint& constraint) {
fixed_activity_cs.push_back(constraint);
}
//! \brief Add a fixed activity component condition
//!
//! \param component Index of the corresponding component (in the database)
//! \param log_value Log_10 of the activity
void add_fixed_activity_component(index_t component, scalar_t log_value) {
fixed_activity_cs.push_back(FixedActivityConstraint(component, log_value));
}
//! \brief Set the inert volume fraction
//!
//! The volume fraction of the inert phase is used to offset the saturation.
//! This inert phase may correspond to aggregates or solid phases governed by kinetics.
//!
//! \param value volume fraction of the inert phase
void set_inert_volume_fraction(scalar_t value){
inert_volume_fraction = value;
}
};
} // end namespace specmicp
#endif // SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSTRUCTS_HPP

Event Timeline