Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61920342
solution.pyx
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
Thu, May 9, 20:03
Size
6 KB
Mime Type
text/x-python
Expires
Sat, May 11, 20:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17577775
Attached To
rSPECMICP SpecMiCP / ReactMiCP
solution.pyx
View Options
# 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 SpecMiCP 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.
from solution cimport SpecMiCPSolution
from cython.operator cimport dereference
from database cimport DataContainer
from units cimport UnitsSet
cdef class SpecMiCPSolution:
"""Contain a solution from the SpecMiCP solver
It correspond to the AdimensionalSystemSolutionExtractor of the c++ API
This class should only be created by the SpecMiCP solver.
"""
def __dealloc__(self):
if self.extractor:
del self.extractor
if self.solution:
del self.solution
cdef void set_solution(
self,
const AdimensionalSystemSolution& solution,
shared_ptr[DataContainer] database,
UnitsSet units_set
):
"""Set the solution -- only callable from cython code !"""
self.solution = new AdimensionalSystemSolution(solution)
self.extractor = new AdimensionalSystemSolutionExtractor(
dereference(self.solution),
database,
units_set
)
cdef AdimensionalSystemSolution* _get(self):
"""Return the solution, only callable from cython code"""
return self.solution
cdef VectorXd get_main_variables(self):
"""Return the vector of main variables"""
return self.extractor.get_main_variables()
# water and gas volume fraction
# -----------------------------
def volume_fraction_water(self):
"""Return the volume fraction of water"""
return self.extractor.volume_fraction_water()
def density_water(self):
"""Return the density of water (in the correct units)"""
return self.extractor.density_water()
def porosity(self):
"""Return the porosity"""
return self.extractor.porosity()
def saturation_water(self):
"""Return the saturation of the liquid phase"""
return self.extractor.saturation_water()
def saturation_gas_phase(self):
"""Return the saturation of the gas phase"""
return self.extractor.saturation_gas_phase()
# solution properties
# -------------------
def pE(self):
"""Return pE"""
return self.extractor.pE()
def Eh(self):
"""Return Eh"""
return self.extractor.Eh()
def pH(self):
"""Return the pH of the solution"""
return self.extractor.pH()
def ionic_strength(self):
"""Return the ionic strength of the solution"""
return self.extractor.ionic_strength()
# components
def molality_component(self, index):
"""Return molality of component 'index'"""
return self.extractor.molality_component(index)
def activity_component(self, index):
"""Return the molality of component 'index'"""
return self.extractor.activity_component(index)
# minerals
# --------
def volume_fraction_mineral(self, index):
"""Return the volume fraction of mineral 'index'"""
return self.extractor.volume_fraction_mineral(index)
def mole_concentration_mineral(self, index):
"""Return the concentration (mol/V) of mineral 'index'"""
return self.extractor.mole_concentration_mineral(index)
def mass_concentration_mineral(self, index):
"""Return the concentration (M/V) of mineral 'index'"""
return self.extractor.mass_concentration_mineral(index)
def saturation_index(self, index):
"""Return the saturation index of mineral 'index'"""
return self.extractor.saturation_index(index)
# aqueous species
# ---------------
def molality_aqueous(self, index):
"""Return the molality of aqueous 'index'"""
return self.extractor.molality_aqueous(index)
def activity_aqueous(self, index):
"""Return the activity of aqueous 'index'"""
return self.extractor.activity_aqueous(index)
# gas
# ---
def fugacity_gas(self, index):
"""Return the fugacity of gas 'index'"""
return self.extractor.gas_fugacity(index)
# sorption model
# --------------
def concentration_free_surface_sites(self):
"""Return the concentration of free surface sites"""
return self.extractor.free_surface_concentration()
def molality_sorbed_species(self, index):
"""Return the molality of sorbed_species 'index'"""
return self.extractor.sorbed_species_molalities(index)
# total concentrations
# --------------------
def total_aqueous_concentration(self, index):
"""Return the total aqueous concentration of component 'index'"""
return self.extractor.total_aqueous_concentration(index)
def total_solid_concentration(self, index):
"""Return the total solid concentration of component 'index'"""
return self.extractor.total_solid_concentration(index)
def total_immobile_concentration(self, index):
"""Return the total immobile (solid+sorbed) concentration of component
'index'"""
return self.extractor.total_immobile_concentration(index)
Event Timeline
Log In to Comment