https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeochemicalDatabaseReader.C
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
12
13#include "MooseUtils.h"
14#include "Conversion.h"
15#include "string"
16#include <fstream>
17
19 const FileName filename,
20 const bool reexpress_free_electron,
21 const bool use_piecewise_interpolation,
22 const bool remove_all_extrapolated_secondary_species)
23 : _filename(filename)
24{
27
28 if (reexpress_free_electron)
30
31 if (use_piecewise_interpolation && _root["Header"].contains("logk model"))
32 _root["Header"]["logk model"] = "piecewise-linear";
33
34 if (remove_all_extrapolated_secondary_species)
36
40}
41
42void
43GeochemicalDatabaseReader::read(const FileName filename)
44{
46
47 // Read the JSON database
48 std::ifstream jsondata(filename);
49 jsondata >> _root;
50}
51
52void
53GeochemicalDatabaseReader::validate(const FileName filename, const nlohmann::json & db)
54{
55 // Validate the JSON database so that we don't have to check array sizes,
56 // check for conversion issues, etc when extracting data using get methods
58 dbv.validate();
59}
60
61void
63{
64 if (!_root.contains("free electron") || !_root["free electron"].contains("e-") ||
65 !_root["free electron"]["e-"]["species"].contains("O2(g)"))
66 return;
67 if (!_root.contains("basis species") || !_root["basis species"].contains("O2(aq)"))
68 return;
69 if (!_root.contains("gas species") || !_root["gas species"].contains("O2(g)") ||
70 !_root["gas species"]["O2(g)"]["species"].contains("O2(aq)") ||
71 (_root["gas species"]["O2(g)"]["species"].size() != 1))
72 return;
73
74 // remove O2(g) in the "e-" and replace with O2(aq)
75 const std::string stoi_o2g =
76 nlohmann::to_string(_root["free electron"]["e-"]["species"]["O2(g)"]);
77 _root["free electron"]["e-"]["species"].erase("O2(g)");
78 _root["free electron"]["e-"]["species"]["O2(aq)"] = stoi_o2g;
79 const Real stoi = getReal(stoi_o2g);
80
81 // alter equilibrium constants
82 if (!_root["Header"].contains("temperatures"))
83 return;
84 for (unsigned i = 0; i < _root["Header"]["temperatures"].size(); ++i)
85 {
86 const Real logk_e = getReal(_root["free electron"]["e-"]["logk"][i]);
87 const Real logk_o2 = getReal(_root["gas species"]["O2(g)"]["logk"][i]);
88 const Real newk = logk_e + stoi * logk_o2;
89 _root["free electron"]["e-"]["logk"][i] = std::to_string(newk);
90 }
91}
92
93void
95{
96 if (_root.contains("secondary species"))
97 {
98 std::set<std::string> remove; // items to remove
99 for (const auto & item : _root["secondary species"].items())
100 if (item.value().contains("note"))
101 remove.insert(item.key());
102
103 for (const auto & name : remove)
104 _root["secondary species"].erase(name);
105 }
106}
107
108std::string
110{
111 return _root["Header"]["activity model"];
112}
113
114std::string
116{
117 return _root["Header"]["fugacity model"];
118}
119
120std::string
122{
123 return _root["Header"]["logk model"];
124}
125
126void
128{
129 if (_root["Header"].contains("temperatures"))
130 {
131 auto temperatures = _root["Header"]["temperatures"];
132 _temperature_points.resize(temperatures.size());
133 for (unsigned int i = 0; i < temperatures.size(); ++i)
134 _temperature_points[i] = getReal(temperatures[i]);
135 }
136}
137
138const std::vector<Real> &
143
144std::vector<Real>
146{
147 // Read pressure points
148 if (_root["Header"].contains("pressures"))
149 {
150 auto pressures = _root["Header"]["pressures"];
151 _pressure_points.resize(pressures.size());
152 for (unsigned int i = 0; i < pressures.size(); ++i)
153 _pressure_points[i] = getReal(pressures[i]);
154 }
155
156 return _pressure_points;
157}
158
159void
161{
162 if (getActivityModel() == "debye-huckel")
163 {
164 if (_root["Header"].contains("adh"))
165 {
166 std::vector<Real> adhvals(_root["Header"]["adh"].size());
167 for (unsigned int i = 0; i < _root["Header"]["adh"].size(); ++i)
168 adhvals[i] = getReal(_root["Header"]["adh"][i]);
169 _debye_huckel.adh = adhvals;
170 }
171
172 if (_root["Header"].contains("bdh"))
173 {
174 std::vector<Real> bdhvals(_root["Header"]["bdh"].size());
175 for (unsigned int i = 0; i < _root["Header"]["bdh"].size(); ++i)
176 bdhvals[i] = getReal(_root["Header"]["bdh"][i]);
177 _debye_huckel.bdh = bdhvals;
178 }
179
180 if (_root["Header"].contains("bdot"))
181 {
182 std::vector<Real> bdotvals(_root["Header"]["bdot"].size());
183 for (unsigned int i = 0; i < _root["Header"]["bdot"].size(); ++i)
184 bdotvals[i] = getReal(_root["Header"]["bdot"][i]);
185 _debye_huckel.bdot = bdotvals;
186 }
187 }
188}
189
192{
193 if (getActivityModel() != "debye-huckel")
194 mooseError("Attempted to get Debye-Huckel activity parameters but the activity model is ",
196 return _debye_huckel;
197}
198
199std::map<std::string, GeochemistryElements>
201{
202 if (_root.contains("elements"))
203 {
204 for (auto & el : _root["elements"].items())
205 {
206 _elements[el.key()].name = el.value()["name"];
207 _elements[el.key()].molecular_weight = getReal(el.value()["molecular weight"]);
208 }
209 }
210
211 return _elements;
212}
213
214std::map<std::string, GeochemistryBasisSpecies>
215GeochemicalDatabaseReader::getBasisSpecies(const std::vector<std::string> & names)
216{
217 // Parse the basis species specified in names
218 for (const auto & species : names)
219 if (_root["basis species"].contains(species))
220 {
222
223 auto basis_species = _root["basis species"][species];
224 dbs.name = species;
225 dbs.radius = getReal(basis_species["radius"]);
226 dbs.charge = getReal(basis_species["charge"]);
227 dbs.molecular_weight = getReal(basis_species["molecular weight"]);
228
229 std::map<std::string, Real> elements;
230 for (auto & el : basis_species["elements"].items())
231 elements[el.key()] = getReal(el.value());
232
233 dbs.elements = elements;
234
235 _basis_species[species] = dbs;
236 }
237 else
238 mooseError(species + " does not exist in database " + _filename);
239
240 return _basis_species;
241}
242
243std::map<std::string, GeochemistryEquilibriumSpecies>
244GeochemicalDatabaseReader::getEquilibriumSpecies(const std::vector<std::string> & names)
245{
246 // Parse the secondary species specified in names
247 for (const auto & species : names)
248 if (_root["secondary species"].contains(species) or _root["free electron"].contains(species))
249 {
251
252 auto sec_species = _root["secondary species"].contains(species)
253 ? _root["secondary species"][species]
254 : _root["free electron"][species];
255 dbs.name = species;
256 dbs.radius = getReal(sec_species["radius"]);
257 dbs.charge = getReal(sec_species["charge"]);
258 dbs.molecular_weight = getReal(sec_species["molecular weight"]);
259
260 std::vector<Real> eq_const(sec_species["logk"].size());
261 for (unsigned int i = 0; i < sec_species["logk"].size(); ++i)
262 eq_const[i] = getReal(sec_species["logk"][i]);
263
264 dbs.equilibrium_const = eq_const;
265
266 std::map<std::string, Real> basis_species;
267 for (auto & bs : sec_species["species"].items())
268 basis_species[bs.key()] = getReal(bs.value());
269
270 dbs.basis_species = basis_species;
271
272 _equilibrium_species[species] = dbs;
273 }
274 else
275 mooseError(species + " does not exist in database " + _filename);
276
278}
279
280std::map<std::string, GeochemistryMineralSpecies>
281GeochemicalDatabaseReader::getMineralSpecies(const std::vector<std::string> & names)
282{
283 // Parse the mineral species specified in names
284 for (const auto & species : names)
285 if (_root["mineral species"].contains(species))
286 {
288
289 auto mineral_species = _root["mineral species"][species];
290 dbs.name = species;
291 dbs.molecular_weight = getReal(mineral_species["molecular weight"]);
292 dbs.molecular_volume = getReal(mineral_species["molar volume"]);
293
294 std::vector<Real> eq_const(mineral_species["logk"].size());
295 for (unsigned int i = 0; i < mineral_species["logk"].size(); ++i)
296 eq_const[i] = getReal(mineral_species["logk"][i]);
297
298 dbs.equilibrium_const = eq_const;
299
300 std::map<std::string, Real> basis_species;
301 for (auto & bs : mineral_species["species"].items())
302 basis_species[bs.key()] = getReal(bs.value());
303
304 dbs.basis_species = basis_species;
305
306 // recover sorption information, if any
307 std::map<std::string, Real> species_and_sorbing_density;
308 dbs.surface_area = 0.0;
309 if (_root["sorbing minerals"].contains(species))
310 {
311 auto sorbing_mineral = _root["sorbing minerals"][species];
312 dbs.surface_area = getReal(sorbing_mineral["surface area"]);
313
314 for (auto & site : sorbing_mineral["sorbing sites"].items())
315 species_and_sorbing_density[site.key()] = getReal(site.value());
316 }
317 dbs.sorption_sites = species_and_sorbing_density;
318
319 _mineral_species[species] = dbs;
320 }
321 else
322 mooseError(species + " does not exist in database " + _filename);
323
324 return _mineral_species;
325}
326
327std::map<std::string, GeochemistryGasSpecies>
328GeochemicalDatabaseReader::getGasSpecies(const std::vector<std::string> & names)
329{
330 // Parse the gas species specified in names
331 for (const auto & species : names)
332 if (_root["gas species"].contains(species))
333 {
335
336 auto gas_species = _root["gas species"][species];
337 dbs.name = species;
338 dbs.molecular_weight = getReal(gas_species["molecular weight"]);
339
340 std::vector<Real> eq_const(gas_species["logk"].size());
341 for (unsigned int i = 0; i < gas_species["logk"].size(); ++i)
342 eq_const[i] = getReal(gas_species["logk"][i]);
343
344 dbs.equilibrium_const = eq_const;
345
346 std::map<std::string, Real> basis_species;
347 for (auto & bs : gas_species["species"].items())
348 basis_species[bs.key()] = getReal(bs.value());
349
350 dbs.basis_species = basis_species;
351
352 // Optional fugacity coefficients
353 if (gas_species.contains("chi"))
354 {
355 std::vector<Real> chi(gas_species["chi"].size());
356 for (unsigned int i = 0; i < gas_species["chi"].size(); ++i)
357 chi[i] = getReal(gas_species["chi"][i]);
358
359 dbs.chi = chi;
360 }
361
362 if (gas_species.contains("Pcrit"))
363 dbs.Pcrit = getReal(gas_species["Pcrit"]);
364
365 if (gas_species.contains("Tcrit"))
366 dbs.Tcrit = getReal(gas_species["Tcrit"]);
367
368 if (gas_species.contains("omega"))
369 dbs.omega = getReal(gas_species["omega"]);
370
371 _gas_species[species] = dbs;
372 }
373 else
374 mooseError(species + " does not exist in database " + _filename);
375
376 return _gas_species;
377}
378
379std::map<std::string, GeochemistryRedoxSpecies>
380GeochemicalDatabaseReader::getRedoxSpecies(const std::vector<std::string> & names)
381{
382 // Parse the redox species specified in names
383 for (const auto & species : names)
384 if (_root["redox couples"].contains(species))
385 {
387
388 auto redox_species = _root["redox couples"][species];
389 dbs.name = species;
390 dbs.radius = getReal(redox_species["radius"]);
391 dbs.charge = getReal(redox_species["charge"]);
392 dbs.molecular_weight = getReal(redox_species["molecular weight"]);
393
394 std::vector<Real> eq_const(redox_species["logk"].size());
395 for (unsigned int i = 0; i < redox_species["logk"].size(); ++i)
396 eq_const[i] = getReal(redox_species["logk"][i]);
397
398 dbs.equilibrium_const = eq_const;
399
400 std::map<std::string, Real> basis_species;
401 for (auto & bs : redox_species["species"].items())
402 basis_species[bs.key()] = getReal(bs.value());
403
404 dbs.basis_species = basis_species;
405
406 _redox_species[species] = dbs;
407 }
408 else
409 mooseError(species + " does not exist in database " + _filename);
410
411 return _redox_species;
412}
413
414std::map<std::string, GeochemistryOxideSpecies>
415GeochemicalDatabaseReader::getOxideSpecies(const std::vector<std::string> & names)
416{
417 // Parse the oxide species specified in names
418 for (auto & species : names)
419 if (_root["oxides"].contains(species))
420 {
422
423 auto oxide_species = _root["oxides"][species];
424 dbs.name = species;
425 dbs.molecular_weight = getReal(oxide_species["molecular weight"]);
426
427 std::map<std::string, Real> basis_species;
428 for (auto & bs : oxide_species["species"].items())
429 basis_species[bs.key()] = getReal(bs.value());
430
431 dbs.basis_species = basis_species;
432
433 _oxide_species[species] = dbs;
434 }
435 else
436 mooseError(species + " does not exist in database " + _filename);
437
438 return _oxide_species;
439}
440
441std::map<std::string, GeochemistrySurfaceSpecies>
442GeochemicalDatabaseReader::getSurfaceSpecies(const std::vector<std::string> & names)
443{
444 // Parse the secondary species specified in names
445 for (const auto & species : names)
446 if (_root["surface species"].contains(species))
447 {
449
450 auto surface_species = _root["surface species"][species];
451 dbs.name = species;
452 dbs.charge = getReal(surface_species["charge"]);
453 dbs.molecular_weight = getReal(surface_species["molecular weight"]);
454 dbs.log10K = getReal(surface_species["log K"]);
455 dbs.dlog10KdT = getReal(surface_species["dlogK/dT"]);
456
457 std::map<std::string, Real> basis_species;
458 for (auto & bs : surface_species["species"].items())
459 basis_species[bs.key()] = getReal(bs.value());
460
461 dbs.basis_species = basis_species;
462
463 _surface_species[species] = dbs;
464 }
465 else
466 mooseError(species + " does not exist in database " + _filename);
467
468 return _surface_species;
469}
470
471void
473{
474 if (_root["Header"].contains("neutral species"))
475 {
476 auto neutral_species = _root["Header"]["neutral species"];
477 for (auto & ns : neutral_species.items())
478 {
479 std::vector<std::vector<Real>> coeffs;
480
481 for (auto & nsac : ns.value().items())
482 {
483 if (nsac.key() == "note")
484 continue;
485 std::vector<Real> coeffvec(nsac.value().size());
486
487 for (unsigned int i = 0; i < coeffvec.size(); ++i)
488 coeffvec[i] = getReal(nsac.value()[i]);
489
490 coeffs.push_back(coeffvec);
491 }
492
493 // GeochemistryNeutralSpeciesActivity expects four vectos, so
494 // add empty vectors if coeffs.size() != 4
495 coeffs.resize(4, {});
496
498
499 _neutral_species_activity[ns.key()] = nsa;
500 }
501 }
502}
503
504const std::map<std::string, GeochemistryNeutralSpeciesActivity> &
506{
507 if (!_root["Header"].contains("neutral species"))
508 mooseError("No neutral species activity coefficients in database");
510}
511
512std::vector<std::string>
513GeochemicalDatabaseReader::equilibriumReactions(const std::vector<std::string> & names) const
514{
515 std::vector<std::map<std::string, Real>> basis_species(names.size());
516
517 for (unsigned int i = 0; i < names.size(); ++i)
518 {
519 auto species = names[i];
520
521 if (_root["secondary species"].contains(species))
522 {
523 auto sec_species = _root["secondary species"][species];
524
525 // The basis species in this reaction
526 std::map<std::string, Real> this_basis_species;
527 for (auto & bs : sec_species["species"].items())
528 this_basis_species[bs.key()] = getReal(bs.value());
529
530 basis_species[i] = this_basis_species;
531 }
532 else
533 mooseError(species + " does not exist in database " + _filename);
534 }
535
536 auto reactions = printReactions(names, basis_species);
537
538 return reactions;
539}
540
541std::vector<std::string>
542GeochemicalDatabaseReader::mineralReactions(const std::vector<std::string> & names) const
543{
544 std::vector<std::map<std::string, Real>> basis_species(names.size());
545
546 for (unsigned int i = 0; i < names.size(); ++i)
547 {
548 const auto species = names[i];
549
550 if (_root["mineral species"].contains(species))
551 {
552 auto min_species = _root["mineral species"][species];
553
554 // The basis species in this reaction
555 std::map<std::string, Real> this_basis_species;
556 for (auto & bs : min_species["species"].items())
557 this_basis_species[bs.key()] = getReal(bs.value());
558
559 basis_species[i] = this_basis_species;
560 }
561 else
562 mooseError(species + " does not exist in database " + _filename);
563 }
564
565 auto reactions = printReactions(names, basis_species);
566
567 return reactions;
568}
569
570std::vector<std::string>
571GeochemicalDatabaseReader::gasReactions(const std::vector<std::string> & names) const
572{
573 std::vector<std::map<std::string, Real>> basis_species(names.size());
574
575 for (unsigned int i = 0; i < names.size(); ++i)
576 {
577 const auto species = names[i];
578
579 if (_root["gas species"].contains(species))
580 {
581 auto gas_species = _root["gas species"][species];
582
583 // The basis species in this reaction
584 std::map<std::string, Real> this_basis_species;
585 for (auto & bs : gas_species["species"].items())
586 this_basis_species[bs.key()] = getReal(bs.value());
587
588 basis_species[i] = this_basis_species;
589 }
590 else
591 mooseError(species + " does not exist in database " + _filename);
592 }
593
594 auto reactions = printReactions(names, basis_species);
595
596 return reactions;
597}
598
599std::vector<std::string>
600GeochemicalDatabaseReader::redoxReactions(const std::vector<std::string> & names) const
601{
602 std::vector<std::map<std::string, Real>> basis_species(names.size());
603
604 for (unsigned int i = 0; i < names.size(); ++i)
605 {
606 const auto species = names[i];
607
608 if (_root["redox couples"].contains(species))
609 {
610 auto redox_species = _root["redox couples"][species];
611
612 // The basis species in this reaction
613 std::map<std::string, Real> this_basis_species;
614 for (auto & bs : redox_species["species"].items())
615 this_basis_species[bs.key()] = getReal(bs.value());
616
617 basis_species[i] = this_basis_species;
618 }
619 else
620 mooseError(species + " does not exist in database " + _filename);
621 }
622
623 auto reactions = printReactions(names, basis_species);
624
625 return reactions;
626}
627
628std::vector<std::string>
629GeochemicalDatabaseReader::oxideReactions(const std::vector<std::string> & names) const
630{
631 std::vector<std::map<std::string, Real>> basis_species(names.size());
632
633 for (unsigned int i = 0; i < names.size(); ++i)
634 {
635 const auto species = names[i];
636
637 if (_root["oxides"].contains(species))
638 {
639 auto oxide_species = _root["oxides"][species];
640
641 // The basis species in this reaction
642 std::map<std::string, Real> this_basis_species;
643 for (auto & bs : oxide_species["species"].items())
644 this_basis_species[bs.key()] = getReal(bs.value());
645
646 basis_species[i] = this_basis_species;
647 }
648 else
649 mooseError(species + " does not exist in database " + _filename);
650 }
651
652 auto reactions = printReactions(names, basis_species);
653
654 return reactions;
655}
656
657std::vector<std::string>
659 const std::vector<std::string> & names,
660 const std::vector<std::map<std::string, Real>> & basis_species) const
661{
662 std::vector<std::string> reactions;
663
664 for (unsigned int i = 0; i < names.size(); ++i)
665 {
666 std::string reaction = "";
667 for (auto & bs : basis_species[i])
668 {
669 if (bs.second < 0.0)
670 {
671 if (bs.second == -1.0)
672 reaction += " - " + bs.first;
673 else
674 reaction += " " + Moose::stringify(bs.second) + bs.first;
675 }
676 else
677 {
678 if (bs.second == 1.0)
679 reaction += " + " + bs.first;
680 else
681 reaction += " + " + Moose::stringify(bs.second) + bs.first;
682 }
683 }
684
685 // Trim off leading +
686 if (reaction.size() > 1 && reaction[1] == '+')
687 reaction.erase(1, 2);
688
689 reactions.push_back(names[i] + " =" + reaction);
690 }
691
692 return reactions;
693}
694
695std::vector<std::string>
697{
698 std::vector<std::string> names;
699 if (_root.contains("mineral species"))
700 for (auto & item : _root["mineral species"].items())
701 names.push_back(item.key());
702 return names;
703}
704
705std::vector<std::string>
707{
708 std::vector<std::string> names;
709 if (_root.contains("secondary species"))
710 for (auto & item : _root["secondary species"].items())
711 names.push_back(item.key());
712
713 if (_root.contains("free electron"))
714 for (const auto & nm : _root["free electron"].items())
715 names.push_back(nm.key());
716 return names;
717}
718
719std::vector<std::string>
721{
722 std::vector<std::string> names;
723 if (_root.contains("redox couples"))
724 for (const auto & item : _root["redox couples"].items())
725 names.push_back(item.key());
726 return names;
727}
728
729std::vector<std::string>
731{
732 std::vector<std::string> names;
733 if (_root.contains("surface species"))
734 for (const auto & item : _root["surface species"].items())
735 names.push_back(item.key());
736 return names;
737}
738
739const FileName &
741{
742 return _filename;
743}
744
745bool
747{
748 return _root["basis species"].contains(name);
749}
750
751bool
753{
754 return _root["redox couples"].contains(name);
755}
756
757bool
759{
760 return _root["sorbing minerals"].contains(name);
761}
762
763bool
765{
766 return _root["secondary species"].contains(name) || _root["free electron"].contains(name);
767}
768
769bool
771{
772 return _root["gas species"].contains(name);
773}
774
775bool
777{
778 return _root["mineral species"].contains(name);
779}
780
781bool
783{
784 return _root["oxides"].contains(name);
785}
786
787bool
789{
790 return _root["surface species"].contains(name);
791}
792
793std::string
795{
796 std::string output;
797 for (auto & item : _root.items())
798 if (_root[item.key()].contains(name))
799 {
800 std::ostringstream os;
801 os << item.value()[name].dump(4);
802 output = os.str();
803 }
804
805 if (output.empty())
806 mooseError(name + " is not a species in the database");
807
808 return name + ":\n" + output;
809}
810
811Real
812GeochemicalDatabaseReader::getReal(const nlohmann::json & node)
813{
814 if (node.is_string())
815 return MooseUtils::convert<Real>(node);
816 return node;
817}
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
void mooseError(Args &&... args)
const std::string name
Definition Setup.h:21
GeochemistryDebyeHuckel _debye_huckel
Debye-Huckel activity coefficients.
std::map< std::string, GeochemistryNeutralSpeciesActivity > _neutral_species_activity
Neutral species activity coefficients.
bool isBasisSpecies(const std::string &name) const
Checks if species is of given type.
std::vector< std::string > oxideReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all oxide reactions.
void validate(const FileName filename, const nlohmann::json &db)
Validate the thermodynamic database.
std::vector< std::string > printReactions(const std::vector< std::string > &names, const std::vector< std::map< std::string, Real > > &basis_species) const
Generates a formatted vector of strings representing all reactions.
void setNeutralSpeciesActivity()
Copy the Debye-Huckel parameters for computing neutral species activity (if any) found in the databas...
std::map< std::string, GeochemistryEquilibriumSpecies > _equilibrium_species
Secondary equilibrium species and free electron data read from the database.
const GeochemistryDebyeHuckel & getDebyeHuckel() const
Get the Debye-Huckel activity coefficients.
bool isSurfaceSpecies(const std::string &name) const
bool isOxideSpecies(const std::string &name) const
std::map< std::string, GeochemistryMineralSpecies > _mineral_species
Mineral species data read from the database.
std::map< std::string, GeochemistryRedoxSpecies > _redox_species
Redox species (couples) data read from the database.
void removeExtrapolatedSecondarySpecies()
After parsing the database file, remove any secondary species that have extrapolated equilibrium cons...
bool isSorbingMineral(const std::string &name) const
returns True iff name is the name of a sorbing mineral
std::map< std::string, GeochemistryGasSpecies > getGasSpecies(const std::vector< std::string > &names)
Get the gas species information.
const FileName _filename
Database filename.
std::vector< std::string > gasReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all gas reactions.
std::map< std::string, GeochemistryOxideSpecies > _oxide_species
Oxide species data read from the database.
std::map< std::string, GeochemistryElements > _elements
Elements and their molecular weight read from the database.
std::vector< std::string > mineralReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all mineral reactions.
std::vector< std::string > secondarySpeciesNames() const
Returns a list of all the names of the "secondary species" and "free electron" in the database.
std::map< std::string, GeochemistryEquilibriumSpecies > getEquilibriumSpecies(const std::vector< std::string > &names)
Get the secondary equilibrium species information.
GeochemicalDatabaseReader(const FileName filename, const bool reexpress_free_electron=true, const bool use_piecewise_interpolation=false, const bool remove_all_extrapolated_secondary_species=false)
Parse the file.
bool isMineralSpecies(const std::string &name) const
std::vector< Real > _pressure_points
Pressure points in database.
void setTemperatures()
Copy the temperature points (if any) found in the database into _temperature_points.
std::map< std::string, GeochemistryBasisSpecies > _basis_species
Basis species data read from the database.
std::map< std::string, GeochemistrySurfaceSpecies > _surface_species
Surface sorbing species data read from the database.
std::map< std::string, GeochemistryRedoxSpecies > getRedoxSpecies(const std::vector< std::string > &names)
Get the redox species (couples) information.
std::vector< std::string > equilibriumReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all aqueous equilibrium reactions.
void read(const FileName filename)
Parse the thermodynamic database.
std::string getFugacityModel() const
Get the fugacity model type.
std::vector< std::string > mineralSpeciesNames() const
Returns a list of all the names of the "mineral species" in the database.
bool isSecondarySpecies(const std::string &name) const
Returns true if name is a "secondary species" or "free electron" in the database.
std::map< std::string, GeochemistryBasisSpecies > getBasisSpecies(const std::vector< std::string > &names)
Get the basis (primary) species information.
std::vector< Real > _temperature_points
Temperature points in database.
std::vector< std::string > redoxReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all redox reactions.
bool isRedoxSpecies(const std::string &name) const
std::map< std::string, GeochemistryOxideSpecies > getOxideSpecies(const std::vector< std::string > &names)
Get the oxide species information.
const FileName & filename() const
Filename of database.
void setDebyeHuckel()
Copy the Debye-Huckel parameters (if any) found in the database into _debye_huckel.
std::vector< std::string > surfaceSpeciesNames() const
Returns a list of all the names of the "surface species" in the database.
std::map< std::string, GeochemistryElements > getElements()
Get all the elements.
const std::vector< Real > & getTemperatures() const
Get the temperature points that the equilibrium constant is defined at.
void reexpressFreeElectron()
Sometimes the free electron's equilibrium reaction is defined in terms of O2(g) which is not a basis ...
std::string getSpeciesData(const std::string name) const
String representation of JSON species object contents.
std::map< std::string, GeochemistryGasSpecies > _gas_species
Gas species data read from the database.
const std::map< std::string, GeochemistryNeutralSpeciesActivity > & getNeutralSpeciesActivity() const
Get the neutral species activity coefficients.
std::vector< Real > getPressures()
Get the pressure points that the equilibrium constant is defined at.
std::string getActivityModel() const
Get the activity model type.
std::string getLogKModel() const
Get the equilibrium constant model type.
std::map< std::string, GeochemistrySurfaceSpecies > getSurfaceSpecies(const std::vector< std::string > &names)
Get the surface sorbing species information.
std::vector< std::string > redoxCoupleNames() const
Returns a list of all the names of the "redox couples" in the database.
bool isGasSpecies(const std::string &name) const
std::map< std::string, GeochemistryMineralSpecies > getMineralSpecies(const std::vector< std::string > &names)
Get the mineral species information.
static Real getReal(const nlohmann::json &node)
Class for validating MOOSE geochemical database.
void validate()
Validate the thermodynamic database.
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
std::string stringify(const T &t)
Data structure for basis (primary) species.
std::map< std::string, Real > elements
Data structure for Debye-Huckel activity coefficients.
Data structure for secondary equilibrium species.
std::map< std::string, Real > basis_species
Data structure for mineral species.
std::vector< Real > equilibrium_const
std::map< std::string, Real > basis_species
Data structure for mineral species.
std::map< std::string, Real > basis_species
std::map< std::string, Real > sorption_sites
Data structure for neutral species activity coefficients.
Data structure for oxide species.
std::map< std::string, Real > basis_species
Data structure for redox species.
std::map< std::string, Real > basis_species
Data structure for sorbing surface species.
std::map< std::string, Real > basis_species