https://mooseframework.inl.gov
GeochemistrySpeciesSwapper.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "DenseMatrix.h"
14 #include <libmesh/dense_vector.h>
15 
20 {
21 public:
29  GeochemistrySpeciesSwapper(unsigned basis_size, Real stoi_tol);
30 
31  bool operator==(const GeochemistrySpeciesSwapper & rhs) const
32  {
33  return (_stoi_tol == rhs._stoi_tol) && (_swap_matrix.m() == rhs._swap_matrix.m());
34  };
35 
50  const std::string & replace_this,
51  const std::string & with_this);
52 
67  unsigned basis_index_to_replace,
68  unsigned eqm_index_to_insert);
69 
82  const std::string & replace_this,
83  const std::string & with_this);
84 
97  unsigned basis_index_to_replace,
98  unsigned eqm_index_to_insert);
99 
115  DenseVector<Real> & bulk_composition,
116  const std::string & replace_this,
117  const std::string & with_this);
118 
134  DenseVector<Real> & bulk_composition,
135  unsigned basis_index_to_replace,
136  unsigned eqm_index_to_insert);
137 
154  bool findBestEqmSwap(unsigned basis_ind,
156  const std::vector<Real> & eqm_molality,
157  bool minerals_allowed,
158  bool gas_allowed,
159  bool sorption_allowed,
160  unsigned & best_eqm_species) const;
161 
162 private:
176  unsigned basis_index_to_replace,
177  unsigned eqm_index_to_insert);
178 
190  unsigned basis_index_to_replace,
191  unsigned eqm_index_to_insert);
192 
200  void alterBulkComposition(unsigned basis_size, DenseVector<Real> & bulk_composition) const;
201 
204 
207 
214 
217 
219  DenseVector<Real> _swap_sigma;
220 
223 
226 };
GeochemistrySpeciesSwapper(unsigned basis_size, Real stoi_tol)
DenseVector< Real > _swap_sigma
used in SVD decomposition of swap matrix
void alterMGD(ModelGeochemicalDatabase &mgd, unsigned basis_index_to_replace, unsigned eqm_index_to_insert)
Modify the ModelGeochemicalDatabase mgd to swap the indexed basis species and the indexed equilibrium...
DenseMatrix< Real > _swap_VT
used in SVD decomposition of swap matrix
DenseMatrix< Real > _inv_swap_matrix
inverse of swap matrix
DenseMatrix< Real > _swap_U
used in SVD decomposition of swap matrix
const ModelGeochemicalDatabase mgd
unsigned int m() const
bool operator==(const GeochemistrySpeciesSwapper &rhs) const
void constructInverseMatrix(const ModelGeochemicalDatabase &mgd, unsigned basis_index_to_replace, unsigned eqm_index_to_insert)
Construct the swap matrix, and its inverse, that describes the swap between the indexed basis species...
Class to swap basis species with equilibrium species.
DenseMatrix< Real > _true_swap_matrix
Before _swap_matrix.svd (a non-const method) is called, we copy _true_swap_matrix = _swap_matrix...
bool findBestEqmSwap(unsigned basis_ind, const ModelGeochemicalDatabase &mgd, const std::vector< Real > &eqm_molality, bool minerals_allowed, bool gas_allowed, bool sorption_allowed, unsigned &best_eqm_species) const
For the the given basis index, find the equilibrium index that it should be swapped with...
Real _stoi_tol
tolerance for matrix inversion and stoichiometric coefficients
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void performSwap(ModelGeochemicalDatabase &mgd, const std::string &replace_this, const std::string &with_this)
Check that replacing the named basis species with the named equilibrium species is valid...
DenseMatrix< Real > _swap_matrix
swap matrix
Data structure to hold all relevant information from the database file.
void alterBulkComposition(unsigned basis_size, DenseVector< Real > &bulk_composition) const
Calculate the bulk composition in the new basis based on the bulk composition in the original basis...
void checkSwap(const ModelGeochemicalDatabase &mgd, const std::string &replace_this, const std::string &with_this)
Check that replacing the named basis species with the named equilibrium species is valid...