Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62419013
adimensional_system_structs.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 13, 01:52
Size
11 KB
Mime Type
text/x-c
Expires
Wed, May 15, 01:52 (2 d)
Engine
blob
Format
Raw Data
Handle
17644764
Attached To
rSPECMICP SpecMiCP / ReactMiCP
adimensional_system_structs.hpp
View Options
/*-------------------------------------------------------------------------------
Copyright (c) 2014,2015 F. 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:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. 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.
3. Neither the name of the copyright holder 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 HOLDER 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_ADIMENSIONALSYSTEMSTRUCTS_HPP
#define SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSTRUCTS_HPP
#include "../../types.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
{
true
};
//!< Solve for non ideality
index_t
non_ideality_max_iter
{
10
};
//!< Max iterations for the non ideality model
scalar_t
scaling_electron
{
0.0
};
//!< Scaling the electron equation
scalar_t
non_ideality_tolerance
{
1e-8
};
//!< Tolerance for non ideality
scalar_t
under_relaxation_factor
{
0.9
};
//!< Under relaxation factor for the conservation of water
scalar_t
restart_concentration
{
-
6
};
//!< Log of the molality used to restart the computation
scalar_t
new_component_concentration
{
-
4
};
//!< Log_10 of the molality for a new component
scalar_t
start_non_ideality_computation
{
0.1
};
//!< Factor to start the non-ideality computation
scalar_t
cutoff_total_concentration
{
1e-12
};
//!< Cutoff for including components in the computation
};
//! \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
)
noexcept:
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
)
noexcept:
id_component
(
component
),
log_value
(
logvalue
)
{}
};
//! \enum SurfaceEquationType
//! \brief The model for surface sorption
enum
class
SurfaceEquationType
{
NoEquation
=
no_equation
,
//!< 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
//! \brief By default, we don't include surface sorption in the computation
SurfaceConstraint
()
noexcept:
model_type
(
SurfaceEquationType
::
NoEquation
),
concentration
(
0.0
)
{}
//! \brief When a concentration is supplied, the surface sorption model is equilibrium
SurfaceConstraint
(
scalar_t
surface_concentration
)
noexcept:
model_type
(
SurfaceEquationType
::
Equilibrium
),
concentration
(
surface_concentration
)
{}
};
//! \enum ElectronEquationType the type of the equation for the electron
enum
class
ElectronEquationType
{
NoEquation
=
no_equation
,
//!< Do not compute the concentration equation of the electron
Equilibrium
,
//!< Set the concentration of electron to be 0
FixedpE
//!< Activity of the electron is fixed
};
//! \struct ElectronConstraint
//! \brief the constraint for the electron
struct
ElectronConstraint
{
ElectronEquationType
equation_type
{
ElectronEquationType
::
NoEquation
};
//!< The equation type
scalar_t
fixed_value
;
//!< The fixed value of pE if needed
index_t
species
{
no_species
};
//!< In case of fixed pE, this is the reaction to use
//! \brief By default we assume equilibrium
ElectronConstraint
()
noexcept:
equation_type
(
ElectronEquationType
::
Equilibrium
),
fixed_value
(
0.0
)
{}
//! \brief When a value is provided, we assume that the pE is fixed
ElectronConstraint
(
scalar_t
pe_value
,
scalar_t
aqueous_species
)
noexcept:
equation_type
(
ElectronEquationType
::
FixedpE
),
fixed_value
(
pe_value
),
species
(
aqueous_species
)
{}
};
//! \struct AdimensionalSystemConstraints
//! \brief Struct to contains the "Boundary conditions" for the AdimensionalSystem
//!
//! \ingroup specmicp_api
struct
AdimensionalSystemConstraints
{
Vector
total_concentrations
;
//!< Total concentrations
WaterEquationType
water_equation
{
WaterEquationType
::
MassConservation
};
//!< Water equation
index_t
charge_keeper
{
no_species
};
//!< The equation for this component is replace by the charge balance
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
{
0.0
};
//!< Volume fraction of inert solid (inert in the equilibrium computation)
SurfaceConstraint
surface_model
{};
//!< Surface sorption model
ElectronConstraint
electron_constraint
{};
//!< constraint for the electron
AdimensionalSystemConstraints
()
:
total_concentrations
()
{}
AdimensionalSystemConstraints
(
const
Vector
&
total_concs
)
:
total_concentrations
(
total_concs
)
{}
//! \brief Set the total concentrations
void
set_total_concentrations
(
const
Vector
&
total_concs
)
{
total_concentrations
=
total_concs
;}
//! \brief Enable the conservation of water
void
enable_conservation_water
()
noexcept
{
water_equation
=
WaterEquationType
::
MassConservation
;}
//! \brief Disable the conservation of water
void
disable_conservation_water
()
noexcept
{
water_equation
=
WaterEquationType
::
NoEquation
;}
//! \brief The system is saturated
void
set_saturated_system
()
noexcept
{
water_equation
=
WaterEquationType
::
SaturatedSystem
;}
//! \brief Disable the surface sorption model
void
disable_surface_model
()
noexcept
{
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
)
noexcept
{
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
)
noexcept
{
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
)
noexcept
{
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
)
noexcept
{
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
)
noexcept
{
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
)
noexcept
{
inert_volume_fraction
=
value
;
}
// //! \brief Set the system at a fixed pE
// void set_fixed_pe(scalar_t pe_value, index_t aqueous_species) noexcept {
// electron_constraint = ElectronConstraint(pe_value, aqueous_species);
// }
};
}
// end namespace specmicp
#endif
// SPECMICP_SPECMICP_ADIMENSIONALSYSTEMSTRUCTS_HPP
Event Timeline
Log In to Comment