World Builder  1.1.0-pre
A geodynamic initial conditions generator
tian2019_water_content.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 - 2024 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 
21 
22 #include "world_builder/nan.h"
28 #include "world_builder/world.h"
29 
30 
31 namespace WorldBuilder
32 {
33 
34  using namespace Utilities;
35 
36  namespace Features
37  {
38  namespace SubductingPlateModels
39  {
40  namespace Composition
41  {
42  TianWaterContent::TianWaterContent(WorldBuilder::World *world_)
43  :
44  min_depth(NaN::DSNAN),
45  max_depth(NaN::DSNAN),
46  density(NaN::DSNAN)
47  {
48  this->world = world_;
49  this->name = "water content";
50  }
51 
53  = default;
54 
55  void
56  TianWaterContent::declare_entries(Parameters &prm, const std::string & /*unused*/)
57  {
58  // Document plugin and require entries if needed.
59  // Add compositions to the required parameters.
60  prm.declare_entry("", Types::Object({"compositions"}),
61  "TianWaterContent compositional model. Sets bound water content as a compositional field. The returned "
62  "water content is based on the the temperature and pressure at a point within the world. Currently, "
63  "the bound water content can be determined for four different lithologies: 'sediment', mid-ocean "
64  "ridge basalt ('MORB'), 'gabbro', and 'peridotite', using parameterized phase diagrams from Tian et al., 2019 "
65  "(https://doi.org/10.1029/2019GC008488). The pressure is lithostatic, calculated with a constant user defined "
66  "density, and is limited by a user defined cutoff pressure (in GPa) for each lithology. This is required because the "
67  "parameterization breaks down at large pressures. Recommended cutoff pressures are 10 GPa is used for 'peridotite', "
68  "26 GPa is used for 'gabbro', 16 GPa is used for 'MORB', and 1 GPa is used for 'sediment'.");
69 
70  // Declare entries of this plugin
71  prm.declare_entry("min distance slab top", Types::Double(0),
72  "todo The depth in meters from which the composition of this feature is present.");
73  prm.declare_entry("max distance slab top", Types::Double(std::numeric_limits<double>::max()),
74  "todo The depth in meters to which the composition of this feature is present.");
75  prm.declare_entry("density", Types::Double(3000.0),
76  "The reference density used for determining the lithostatic pressure for calculating "
77  "the bound water content.");
78  prm.declare_entry("compositions", Types::Array(Types::UnsignedInt(),0),
79  "A list with the labels of the composition which are present there.");
80  prm.declare_entry("lithology", Types::String("peridotite"),
81  "The lithology used to determine which polynomials to use for calculating the water content. Valid options are: "
82  "'sediment', 'MORB', 'gabbro', and 'peridotite'.");
83  prm.declare_entry("initial water content", Types::Double(5),
84  "The value of the initial water content (in wt%) for the lithology at the trench. This represents the "
85  "max value applied to this lithology.");
86  prm.declare_entry("cutoff pressure", Types::Double(10),
87  "The upper bound for the pressure, in GPa, for the specified lithology in the Tian parameterization. This is necessary because "
88  "the parameterization breaks down for high pressures. It is recommended that 10 GPa is used for 'peridotite', 26 GPa is used for "
89  "'gabbro', 16 GPa is used for 'MORB', and 1 GPa is used for 'sediment'.");
90  prm.declare_entry("operation", Types::String("replace", std::vector<std::string> {"replace", "replace defined only", "add", "subtract"}),
91  "Whether the value should replace any value previously defined at this location (replace) or "
92  "add the value to the previously define value. Replacing implies that all compositions not "
93  "explicitly defined are set to zero. To only replace the defined compositions use the replace only defined option.");
94 
95  }
96 
97  void
99  {
100  min_depth = prm.get<double>("min distance slab top");
101  max_depth = prm.get<double>("max distance slab top");
102  density = prm.get<double>("density");
103  compositions = prm.get_vector<unsigned int>("compositions");
104  max_water_content = prm.get<double>("initial water content");
105  cutoff_pressure = prm.get<double>("cutoff pressure");
106  operation = string_operations_to_enum(prm.get<std::string>("operation"));
107  std::string lithology_string = prm.get<std::string>("lithology");
108 
109  if (lithology_string=="peridotite")
111  else if (lithology_string=="gabbro")
113  else if (lithology_string=="MORB")
115  else if (lithology_string=="sediment")
117  }
118 
119 
120  double
122  double temperature) const
123  {
124  double ln_LR_value = 0;
125  double ln_c_sat_value = 0;
126  double Td_value = 0;
127  std::vector<double> LR_polynomial_coeffs;
128  std::vector<double> c_sat_polynomial_coeffs;
129  std::vector<double> Td_polynomial_coeffs;
130 
131  // Calculate the c_sat value from Tian et al., 2019
132  if (lithology_type == sediment)
133  {
134  for (unsigned int c_sat_index = 0; c_sat_index < c_sat_poly[lithology_type].size(); ++c_sat_index)
135  ln_c_sat_value += c_sat_poly[lithology_type][c_sat_index] * (std::pow(std::log10(pressure), c_sat_poly[lithology_type].size() - 1 - c_sat_index));
136  }
137  else
138  {
139  for (unsigned int c_sat_index = 0; c_sat_index < c_sat_poly[lithology_type].size(); ++c_sat_index)
140  ln_c_sat_value += c_sat_poly[lithology_type][c_sat_index] * (std::pow(pressure, c_sat_poly[lithology_type].size() - 1 - c_sat_index));
141  }
142 
143  // Calculate the LR value from Tian et al., 2019
144  for (unsigned int LR_coeff_index = 0; LR_coeff_index < LR_poly[lithology_type].size(); ++LR_coeff_index)
145  ln_LR_value += LR_poly[lithology_type][LR_coeff_index] * (std::pow(1/pressure, LR_poly[lithology_type].size() - 1 - LR_coeff_index));
146 
147  // Calculate the Td value from Tian et al., 2019
148  for (unsigned int Td_coeff_index = 0; Td_coeff_index < Td_poly[lithology_type].size(); ++Td_coeff_index)
149  Td_value += Td_poly[lithology_type][Td_coeff_index] * (std::pow(pressure, Td_poly[lithology_type].size() - 1 - Td_coeff_index));
150 
151  double partition_coeff = std::exp(ln_c_sat_value) * std::exp(std::exp(ln_LR_value) * (1/temperature - 1/Td_value));
152  return partition_coeff;
153  }
154 
155 
156  double
157  TianWaterContent::get_composition(const Point<3> &position_in_cartesian_coordinates,
158  const double depth,
159  const unsigned int composition_number,
160  double composition,
161  const double /*feature_min_depth*/,
162  const double /*feature_max_depth*/,
164  const AdditionalParameters & /*additional_parameters*/) const
165  {
166  if (distance_from_plane.distance_from_plane <= max_depth && distance_from_plane.distance_from_plane >= min_depth)
167  {
168  // The polynomials break down for pressures less than 0.5 GPa, and for pressures above a user defined cutoff pressure
169  // ensure that the pressure is never below 0.5 GPa
170  const double lithostatic_pressure = std::max(0.5, std::min(density * 9.81 * depth / 1e9, cutoff_pressure)); // GPa
171  const double slab_temperature = world->properties(position_in_cartesian_coordinates.get_array(), depth, {{{1,0,0}}})[0];
172  double partition_coefficient = calculate_water_content(lithostatic_pressure,
173  slab_temperature);
174  // The partition_coefficient is output as a percentage, but geodynamic modeling software
175  // typically deal with fractions, so we divide by 100 below
176  partition_coefficient = std::min(max_water_content, partition_coefficient) / 100;
177 
178  for (unsigned int i = 0; i < compositions.size(); ++i)
179  {
180  if (compositions[i] == composition_number)
181  {
182  return apply_operation(operation,composition, partition_coefficient);
183  }
184  }
185 
186  if (operation == Operations::REPLACE)
187  {
188  return 0.0;
189  }
190  }
191  return composition;
192  }
194  } // namespace Composition
195  } // namespace SubductingPlateModels
196  } // namespace Features
197 } // namespace WorldBuilder
198 
199 
const double DSNAN
Definition: nan.h:41
std::vector< double > properties(const std::array< double, 2 > &point, const double depth, const std::vector< std::array< unsigned int, 3 >> &properties) const
Definition: world.cc:315
double get_composition(const Point< 3 > &position, const double depth, const unsigned int composition_number, double composition, const double feature_min_depth, const double feature_max_depth, const WorldBuilder::Utilities::PointDistanceFromCurvedPlanes &distance_from_planes, const AdditionalParameters &additional_parameters) const override final
const std::array< double, dim > & get_array() const
Definition: point.h:393
Operations string_operations_to_enum(const std::string &operation)
static void declare_entries(Parameters &prm, const std::string &parent_name="")
#define WB_REGISTER_FEATURE_SUBDUCTING_PLATE_COMPOSITION_MODEL(classname, name)
Definition: interface.h:155
double apply_operation(const Operations operation, const double old_value, const double new_value)
void declare_entry(const std::string &name, const Types::Interface &type, const std::string &documentation)
Definition: parameters.cc:197
std::vector< T > get_vector(const std::string &name)
T get(const std::string &name)