Line data Source code
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 : #include "GeochemicalModelDefinition.h" 11 : #include "GeochemistryKineticRate.h" 12 : 13 : registerMooseObject("GeochemistryApp", GeochemicalModelDefinition); 14 : 15 : InputParameters 16 1516 : GeochemicalModelDefinition::validParams() 17 : { 18 1516 : InputParameters params = GeneralUserObject::validParams(); 19 3032 : params.addRequiredParam<FileName>("database_file", "The name of the geochemical database file"); 20 3032 : params.addParam<bool>( 21 : "reexpress_free_electron", 22 3032 : true, 23 : "If true then if: (1) the 'free electron' appears in the database file; and (2) its " 24 : "equilibrium reaction includes O2(g); and (3) O2(g) is a gas; and (4) O2(g)'s equilibrium " 25 : "reaction is O2(g)=O2(eq); and (5) O2(aq) exists as a basis species in the database file; " 26 : "then reexpress the free electron's equilibrium reaction in terms of O2(aq). Note that if " 27 : "you choose 'reexpress_free_electron=false' and these other 5 conditions are true, then the " 28 : "'free electron' will not be available as a secondary species"); 29 3032 : params.addParam<bool>( 30 : "piecewise_linear_interpolation", 31 3032 : false, 32 : "If true then use a piecewise-linear interpolation of logK and Debye-Huckel parameters, " 33 : "regardless of the interpolation type specified in the database file. This can be useful " 34 : "for comparing with results using other geochemistry software"); 35 3032 : params.addRequiredParam<std::vector<std::string>>( 36 : "basis_species", 37 : "A list of basis components relevant to the aqueous-equilibrium problem. H2O must appear " 38 : "first in this list. These components must be chosen from the 'basis species' in the " 39 : "database, the sorbing sites (if any) and the decoupled redox states that are in " 40 : "disequilibrium (if any)."); 41 3032 : params.addParam<std::vector<std::string>>( 42 : "equilibrium_minerals", 43 : {}, 44 : "A list of minerals that are in equilibrium with the aqueous solution. All members of this " 45 : "list must be in the 'minerals' section of the database file"); 46 3032 : params.addParam<std::vector<std::string>>( 47 : "equilibrium_gases", 48 : {}, 49 : "A list of gases that are in equilibrium with the aqueous solution and can have their " 50 : "fugacities fixed, at least for some time and spatial location. All members of this list " 51 : "must be in the 'gas' section of the database file"); 52 3032 : params.addParam<std::vector<std::string>>( 53 : "kinetic_minerals", 54 : {}, 55 : "A list of minerals whose dynamics are governed by a rate law. These are not in equilibrium " 56 : "with the aqueous solution. All members of this list must be in the 'minerals' section of " 57 : "the database " 58 : "file."); 59 3032 : params.addParam<std::vector<std::string>>( 60 : "kinetic_redox", 61 : {}, 62 : "A list alternative oxidation states (eg Fe+++) whose dynamics are governed by a rate law. " 63 : "These are not in equilibrium with the aqueous solution. All members of this list must be " 64 : "in the " 65 : "'redox couples' section of the database file."); 66 3032 : params.addParam<std::vector<std::string>>( 67 : "kinetic_surface_species", 68 : {}, 69 : "A list surface sorbing species whose dynamics are governed by a rate law. These are not in " 70 : "equilibrium with the aqueous solution. All members of this list must be in the 'surface " 71 : "species' section of the database file."); 72 3032 : params.addParam<std::string>( 73 : "redox_oxygen", 74 : "O2(aq)", 75 : "The name of the oxygen species that appears in redox reactions. For redox pairs that are " 76 : "in disequilibrium to be correctly recorded, and hence their Nernst potentials to be " 77 : "computed easily, redox_oxygen must be a basis species and it must appear in the reaction " 78 : "for each redox pair"); 79 3032 : params.addParam<std::string>( 80 : "redox_electron", 81 : "e-", 82 : "The name of the free electron. For redox pairs that are in disequilibrium to be correctly " 83 : "recorded, and hence their Nernst potentials to be computed eqsily, the equilibrium reaction " 84 : "for redox_electron must involve redox_oxygen, and the basis species must be chosen to that " 85 : "redox_electron is an equilibrium species"); 86 3032 : params.addParam<std::vector<UserObjectName>>( 87 : "kinetic_rate_descriptions", 88 : {}, 89 : "A list of GeochemistryKineticRate UserObject names that define the kinetic rates. If a " 90 : "kinetic species has no rate prescribed to it, its reaction rate will be zero"); 91 3032 : params.addParam<bool>( 92 : "remove_all_extrapolated_secondary_species", 93 3032 : false, 94 : "After reading the database file, immediately remove all secondary species that have " 95 : "extrapolated equilibrium constants. Sometimes these extrapolations are completely crazy " 96 : "and those secondary species greatly impact the results"); 97 : 98 1516 : params.addClassDescription("User object that parses a geochemical database file, and only " 99 : "retains information relevant to the current geochemical model"); 100 : 101 1516 : return params; 102 0 : } 103 : 104 758 : GeochemicalModelDefinition::GeochemicalModelDefinition(const InputParameters & parameters) 105 : : GeneralUserObject(parameters), 106 1516 : _db(getParam<FileName>("database_file"), 107 1516 : getParam<bool>("reexpress_free_electron"), 108 1516 : getParam<bool>("piecewise_linear_interpolation"), 109 758 : getParam<bool>("remove_all_extrapolated_secondary_species")), 110 6064 : _model(_db, 111 : getParam<std::vector<std::string>>("basis_species"), 112 : getParam<std::vector<std::string>>("equilibrium_minerals"), 113 : getParam<std::vector<std::string>>("equilibrium_gases"), 114 : getParam<std::vector<std::string>>("kinetic_minerals"), 115 : getParam<std::vector<std::string>>("kinetic_redox"), 116 : getParam<std::vector<std::string>>("kinetic_surface_species"), 117 1516 : getParam<std::string>("redox_oxygen"), 118 1516 : getParam<std::string>("redox_electron")) 119 : { 120 1597 : for (const auto & kr : getParam<std::vector<UserObjectName>>("kinetic_rate_descriptions")) 121 81 : _model.addKineticRate(getUserObjectByName<GeochemistryKineticRate>(kr).getRateDescription()); 122 758 : } 123 : 124 : void 125 4692 : GeochemicalModelDefinition::initialize() 126 : { 127 4692 : } 128 : 129 : void 130 4692 : GeochemicalModelDefinition::execute() 131 : { 132 4692 : } 133 : 134 : void 135 4692 : GeochemicalModelDefinition::finalize() 136 : { 137 4692 : } 138 : 139 : const ModelGeochemicalDatabase & 140 1658 : GeochemicalModelDefinition::getDatabase() const 141 : { 142 1658 : return _model.modelGeochemicalDatabase(); 143 : } 144 : 145 : const PertinentGeochemicalSystem & 146 933 : GeochemicalModelDefinition::getPertinentGeochemicalSystem() const 147 : { 148 933 : return _model; 149 : } 150 : 151 : const GeochemicalDatabaseReader & 152 933 : GeochemicalModelDefinition::getOriginalFullDatabase() const 153 : { 154 933 : return _db; 155 : }