Page MenuHomec4science

adimensional_system_solution_extractor.hpp
No OneTemporary

File Metadata

Created
Mon, Jun 10, 21:31

adimensional_system_solution_extractor.hpp

/*-------------------------------------------------------
Copyright (c) 2014,2015 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_SPECMICP_ADIMENSIONALSYSTEMSOLUTIONEXTRACTOR_HPP
#define SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSOLUTIONEXTRACTOR_HPP
#include "common.hpp"
#include "database.hpp"
#include "adimensional_system_solution.hpp"
#include "physics/units.hpp"
#include "adimensional_system_numbering.hpp"
//! \file adimensional_system_solution_extractor.hpp Obtain data from AdimensionalSystemSolution
namespace specmicp {
//! \class AdimensionalSystemSolutionextractor
//! \brief Obtain physical variables from AdimensionalSystemSolution
//!
//! This class can't modify the solution, use #AdimensionalSystemSolutionModificator for this.
//!
//! \sa AdimensionalSystemSolutionModificator
class AdimensionalSystemSolutionExtractor:
public AdimemsionalSystemNumbering,
public units::UnitBaseClass
{
public:
// public members
// ###############
//! \brief Constructor
//!
//! \param solution Reference to a solution from the AdimensionalSystemSolution
//! \param thedatabase shared_ptr to the database
//! \param units_set Units used by the solver
AdimensionalSystemSolutionExtractor(
const AdimensionalSystemSolution& solution,
RawDatabasePtr thedatabase,
units::UnitsSet units_set):
AdimemsionalSystemNumbering(thedatabase),
units::UnitBaseClass(units_set),
m_solution(solution)
{}
// Primary variables
// =================
// water
// ------
//! \brief Return the total saturation of water
//! Deprecated, use the correct name : volume fraction
scalar_t total_saturation_water() const {
return m_solution.main_variables(dof_water());}
//! \brief Return the volume fraction of water
scalar_t volume_fraction_water() const {
return m_solution.main_variables(dof_water());}
//! \brief Return the density of water
scalar_t density_water() const;
// component
// ---------
//! \brief Return the log_10 of the molality of 'component'
scalar_t log_molality_component(index_t component) const {
if (component == 0)
return std::log10(1.0/m_data->molar_mass_basis(component, mass_unit()));
return m_solution.main_variables(dof_component(component));}
//! \brief Return the molality of 'component'
scalar_t molality_component(index_t component) const {
if (component == 0)
return 1.0/m_data->molar_mass_basis(component, mass_unit());
return pow10(log_molality_component(component));
}
// solid phases
// ------------
//! \brief Return the total saturation of 'mineral'
//! deprecated, use the volume fraction instead
scalar_t total_saturation_mineral(index_t mineral) const {
return m_solution.main_variables(dof_mineral(mineral));
}
//! \brief Return the volume fraction of 'mineral'
scalar_t volume_fraction_mineral(index_t mineral) const {
return m_solution.main_variables(dof_mineral(mineral));
}
// surface
// -------
//! \brief Return the concentration of free surface
scalar_t log_free_surface_concentration() const {
return m_solution.main_variables(dof_surface());
}
//! \brief Return the concentration of free surface
scalar_t free_surface_concentration() const {
return pow10(m_solution.main_variables(dof_surface()));
}
// Secondary variables
// ===================
//! \brief Return the ionic strength of the solution
scalar_t ionic_strength() const {return m_solution.ionic_strength;}
// component
// ---------
//! \brief Return the log_10 of the activity coefficient of 'component'
scalar_t log_activity_coefficient_component(index_t component) const {
return m_solution.log_gamma(dof_component_gamma(component));
}
//! \brief Return the activity coefficient of 'component'
scalar_t activity_coefficient_component(index_t component) const {
return pow10(log_activity_coefficient_component(component));
}
//! \brief Return the log_10 of the activity of 'component
scalar_t log_activity_component(index_t component) const {
return log_molality_component(component) + log_activity_coefficient_component(component);
}
//! \brief Return the activity of 'component'
scalar_t activity_component(index_t component) const {
return pow10(log_activity_component(component));
}
// aqueous species
// ---------------
//! \brief Return the molality of secondary specis 'aqueous'
scalar_t molality_aqueous(index_t aqueous) const {
return m_solution.secondary_molalities(dof_aqueous(aqueous));}
//! \brief Return the log10 of the activity ocefficient of secondary species 'aqueous'
scalar_t log_activity_coefficient_aqueous(index_t aqueous) const {
return m_solution.log_gamma(dof_aqueous_gamma(aqueous));
}
//! \brief Return the activity coefficient of secondary species 'aqueous'
scalar_t activity_coefficient_aqueous(index_t aqueous) const {
return pow10(log_activity_coefficient_aqueous(aqueous));
}
//! \brief Return the activity of secondary species 'aqueous'
scalar_t activity_aqueous(index_t aqueous) const {
return activity_coefficient_aqueous(aqueous)*molality_aqueous(aqueous);
}
// gas fugacity
// -------------
//! \brief Return fugacity for 'gas'
scalar_t gas_fugacity(index_t gas) const {
return m_solution.gas_fugacities(gas);
}
// Sorbed species
// --------------
//! \brief Return sorbed species molalities for 'sorbed'
scalar_t sorbed_species_molalities(index_t sorbed) const {
return m_solution.sorbed_molalities(sorbed);
}
// Tertiary variables
// ==================
// Water
// -----
//! \brief Return the saturation of water
scalar_t saturation_water() const {return volume_fraction_water()/porosity();}
//! \brief Return the mass concentration of water
scalar_t mass_concentration_water() const;
//! \brief Return the pH of the solution
scalar_t pH() const;
// Component
// ---------
//! \brief Return the total aqueous concentration
scalar_t total_aqueous_concentration(index_t component) const;
//! \brief Return the total solid concentration
scalar_t total_solid_concentration(index_t component) const;
//! \brief Return the total immobile concentration
scalar_t total_immobile_concentration(index_t component) const;
// Gas phase
// ---------
//! \brief Return the saturation of the gas phase
scalar_t saturation_gas_phase() const {return 1-saturation_water();}
//! \brief Return the total saturation of the gas phase
//! Depreacated, use volume fraction instead
scalar_t total_saturation_gas_phase() const {return porosity() - saturation_water();}
//! \brief Return the volume fraction occupied by the gas phase
scalar_t volume_fraction_gas_phase() const {return porosity() - saturation_water();}
// Component
// ---------
// Solid phases
// ------------
//! \brief Return the concentration of 'mineral'
//!
//! \param mineral Index of the mineral (in the database)
scalar_t mole_concentration_mineral(index_t mineral) const;
//! \brief Return the mass concentration of 'mineral'
//!
//! \param mineral Index of the mineral (in the database)
scalar_t mass_concentration_mineral(index_t mineral) const;
//! \brief Return the total saturation of all minerals
//! Deprecated, use the volume fraction function instead
scalar_t total_saturation_minerals() const;
//! \brief Return the volume fraction occupied by the minerals
scalar_t volume_fraction_minerals() const {return total_saturation_minerals();}
//! \brief Return the inert volume fraction
scalar_t inert_volume_fraction() const {return m_solution.inert_volume_fraction;}
//! \brief Return the porosity
scalar_t porosity() const {return 1 - total_saturation_minerals() - inert_volume_fraction();}
//! \brief Return the saturation index for 'mineral'
//!
//! \param mineral Index of the mineral (in the database)
scalar_t saturation_index(index_t mineral) const;
//! \brief Return the saturation index for 'mineral_kinetic'
//!
//! \param mineral_kinetic Index of the mineral governed by the kinetic (in the database)
scalar_t saturation_index_kinetic(index_t mineral_kinetic) const;
protected:
// private attributes
// ##################
const AdimensionalSystemSolution& m_solution;
};
//! \class AdimensionalSystemSolutionModificator
//! \brief Special class to modify (scale) the solution
//!
//! The set of modification are limited to straightforward modification that does not modify the equilibrium
class AdimensionalSystemSolutionModificator: public AdimensionalSystemSolutionExtractor
{
public:
AdimensionalSystemSolutionModificator(
AdimensionalSystemSolution& solution,
RawDatabasePtr thedatabase,
units::UnitsSet units_set):
AdimensionalSystemSolutionExtractor(solution, thedatabase, units_set),
m_nonconst_solution(solution)
{}
//! \brief Scale the solid phases with respect to the total solid concentration of a component
//!
//! \param component Index of the component (in the database)
//! \param new_value New value of the total solid concentration
void scale_total_concentration(index_t component, scalar_t new_value);
//! \brief Remove the solid phases
void remove_solids();
//! \brief Set some species to be considered as governed by kinetics
//!
//! \param[in,out] list_species list of minerals to flag as kinetics,
//! The list will contain the new indexes of the corresponding solid phases;
//! \return the vector of saturation
//!
//! This function modify the databse
Vector set_minerals_kinetics(std::vector<index_t>& list_species);
private:
AdimensionalSystemSolution& m_nonconst_solution;
};
} // end namespace specmicp
#endif // SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSOLUTIONEXTRACTOR_HPP

Event Timeline