Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the Tian Approximation in the Reactive Fluid Transport Model #6161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ subsection Material model
# values to encourage water to hydrate the overlying mantle. The polynomials defined
# in Tian et al., 2019 also reach very large values at low P-T conditions, and so limiting
# the weight percent to reasonable values is recommended.
set Maximum weight percent water in peridotite = 2
set Maximum weight percent water in gabbro = 1
set Maximum weight percent water in MORB = 2
set Maximum weight percent water in sediment = 3
subsection Tian 2019 model
set Maximum weight percent water in peridotite = 2
set Maximum weight percent water in gabbro = 1
set Maximum weight percent water in MORB = 2
set Maximum weight percent water in sediment = 3
end
end

subsection Visco Plastic
Expand Down
159 changes: 159 additions & 0 deletions include/aspect/material_model/reaction_model/tian2019_solubility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
Copyright (C) 2024 by the authors of the ASPECT code.

This file is part of ASPECT.

ASPECT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

ASPECT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with ASPECT; see the file LICENSE. If not see
<http://www.gnu.org/licenses/>.
*/

#ifndef _aspect_material_reaction_melt_tian2019_solubility_h
#define _aspect_material_reaction_melt_tian2019_solubility_h
Comment on lines +21 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you took this from the other reaction model, but that one sets a bad example here. These lines should correspond as closely as possible to the folder structure and file name. This is not technically necessary, but a convention we follow to make them easy to remember:

Suggested change
#ifndef _aspect_material_reaction_melt_tian2019_solubility_h
#define _aspect_material_reaction_melt_tian2019_solubility_h
#ifndef _aspect_material_model_reaction_model_tian2019_solubility_h
#define _aspect_material_model_reaction_model_tian2019_solubility_h


#include <aspect/material_model/interface.h>
#include <aspect/simulator_access.h>
#include <aspect/melt.h>
#include <aspect/utilities.h>


namespace aspect
{
namespace MaterialModel
{
using namespace dealii;

namespace ReactionModel
{

/**
* A melt model that calculates melt fraction and entropy change
* according to the melting model for dry peridotite of Katz, 2003.
* This also includes a computation of the latent heat of melting (if the latent heat
* heating model is active).
*
* These functions can be used in the calculation of melting and melt transport
* in the melt_simple material model and can be extended to other material models
*
* @ingroup ReactionModel
*/
template <int dim>
class Tian2019Solubility : public ::aspect::SimulatorAccess<dim>
{
public:
// constructor
Tian2019Solubility();

/**
* Declare the parameters this function takes through input files.
*/
static
void
declare_parameters (ParameterHandler &prm);

/**
* Read the parameters from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm);
Comment on lines +57 to +68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put these functions at the end of the list of public functions here and in the source file. This is just a convention we (try to) follow, but it makes navigating the source files easier.
A typical class structure in ASPECT looks like this (with many functions being optional):


class ClassName
{
  constructor();

  initialize();

  all_other_minor_functions();

  main_function(in this case melt_fraction);

  declare_parameters();

  parse_parameters();

  private:

  ... all member variables and private functions
}



/**
* Compute the free fluid fraction that can be present in the material based on the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be present or is present? I think you mean is present because can be present would be 100%?

* fluid content of the material and the fluid solubility for the given input conditions.
* @p in and @p melt_fractions need to have the same size.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no melt_fractions variable

*
* @param in Object that contains the current conditions.
* @param melt_fractions Vector of doubles that is filled with the
* allowable free fluid fraction for each given input conditions.
Comment on lines +77 to +78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to the new interface, i.e. explain what porosity_idx and q are.

*/
double
melt_fraction (const MaterialModel::MaterialModelInputs<dim> &in,
const unsigned int porosity_idx,
unsigned int q) const;

/**
* Compute the maximum allowed bound water content at the input
* pressure and temperature conditions. This is used to determine
* how free water interacts with the solid phase.
* @param in Object that contains the current conditions.
* @param q unsigned int from 0-3 indexing which rock phase the equilbrium
* bound water content is being calculated for
Comment on lines +90 to +91
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, is that really the meaning of q? We usually use q as an index for the quadrature point to index into the vectors that are contained inside in. Please clarify and if you use this variable for something else, maybe find a different name unless it has to be q for other reasons.

*/
std::vector<double> tian_equilibrium_bound_water_content(const MaterialModel::MaterialModelInputs<dim> &in,
unsigned int q) const;

private:
/**
* Parameters for the solubility model of Tian et al., 2019.
*/
Comment on lines +97 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment here is redundant now. All of these parameters are from Tian et al since this is the Tian et al plugin.


/**
* The maximum water content for each of the 4 rock types in the tian approximation
* method. These are important for keeping the polynomial bounded within reasonable
* values.
*/
double tian_max_peridotite_water;
double tian_max_gabbro_water;
double tian_max_MORB_water;
double tian_max_sediment_water;

/**
*
* The following coefficients are taken from a publication from Tian et al., 2019, and can be found
* in Table 3 (Gabbro), Table B1 (MORB), Table B2 (Sediments) and Table B3 (peridotite).
* LR refers to the effective enthalpy change for devolatilization reactions,
* csat is the saturated mass fraction of water in the solid, and Td is the
* onset temperature of devolatilization for water.
*/
std::vector<double> LR_peridotite_poly_coeffs {-19.0609, 168.983, -630.032, 1281.84, -1543.14, 1111.88, -459.142, 95.4143, 1.97246};
std::vector<double> csat_peridotite_poly_coeffs {0.00115628, 2.42179};
std::vector<double> Td_peridotite_poly_coeffs {-15.4627, 94.9716, 636.603};

std::vector<double> LR_gabbro_poly_coeffs {-1.81745, 7.67198, -10.8507, 5.09329, 8.14519};
std::vector<double> csat_gabbro_poly_coeffs {-0.0176673, 0.0893044, 1.52732};
std::vector<double> Td_gabbro_poly_coeffs {-1.72277, 20.5898, 637.517};

std::vector<double> LR_MORB_poly_coeffs {-1.78177, 7.50871, -10.4840, 5.19725, 7.96365};
std::vector<double> csat_MORB_poly_coeffs {0.0102725, -0.115390, 0.324452, 1.41588};
std::vector<double> Td_MORB_poly_coeffs {-3.81280, 22.7809, 638.049};

std::vector<double> LR_sediment_poly_coeffs {-2.03283, 10.8186, -21.2119, 18.3351, -6.48711, 8.32459};
std::vector<double> csat_sediment_poly_coeffs {-0.150662, 0.301807, 1.01867};
std::vector<double> Td_sediment_poly_coeffs {2.83277, -24.7593, 85.9090, 524.898};
Comment on lines +119 to +133
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these numbers are fixed and will never change during the program runtime. You can tell this to the compiler, which will then optimize the code further and also prevent you from accidentally changing the values by changing their type from std::vector<double> to constexpr std::array<double,N> where N is the number of values in this array. Initialization and access to these arrays can remain unchanged.


/**
* The polynomials breakdown above certain pressures, 10 GPa for peridotite, 26 GPa for gabbro, 16 GPa for MORB,
* and 50 GPa for sediment. These cutoff pressures were determined by extending the pressure range in Tian et al. (2019)
* and observing where the maximum allowed water contents jump towards infinite values.
*/
const std::vector<double> pressure_cutoffs {10, 26, 16, 50};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, make this a constexpr std::array


std::vector<std::vector<double>> devolatilization_enthalpy_changes {LR_peridotite_poly_coeffs, LR_gabbro_poly_coeffs, \
LR_MORB_poly_coeffs, LR_sediment_poly_coeffs
};

std::vector<std::vector<double>> water_mass_fractions {csat_peridotite_poly_coeffs, csat_gabbro_poly_coeffs, \
csat_MORB_poly_coeffs, csat_sediment_poly_coeffs
};

std::vector<std::vector<double>> devolatilization_onset_temperatures {Td_peridotite_poly_coeffs, Td_gabbro_poly_coeffs, \
Td_MORB_poly_coeffs, Td_sediment_poly_coeffs
};
};
}

}
}

#endif
75 changes: 6 additions & 69 deletions include/aspect/material_model/reactive_fluid_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
#include <aspect/geometry_model/interface.h>

#include <aspect/melt.h>
#include <aspect/utilities.h>
#include <aspect/geometry_model/interface.h>
#include <aspect/material_model/reaction_model/katz2003_mantle_melting.h>


#include <aspect/material_model/reaction_model/tian2019_solubility.h>

namespace aspect
{
Expand Down Expand Up @@ -64,18 +61,6 @@ namespace aspect
* @}
*/


/**
* Compute the maximum allowed bound water content at the input
* pressure and temperature conditions. This is used to determine
* how free water interacts with the solid phase.
* @param in Object that contains the current conditions.
* @param q unsigned int from 0-3 indexing which rock phase the equilbrium
* bound water content is being calculated for
*/
std::vector<double> tian_equilibrium_bound_water_content(const MaterialModel::MaterialModelInputs<dim> &in,
unsigned int q) const;

/**
* Compute the free fluid fraction that can be present in the material based on the
* fluid content of the material and the fluid solubility for the given input conditions.
Expand Down Expand Up @@ -160,64 +145,16 @@ namespace aspect
*/
double fluid_reaction_time_scale;

/**
* The maximum water content for each of the 4 rock types in the tian approximation
* method. These are important for keeping the polynomial bounded within reasonable
* values.
*/
double tian_max_peridotite_water;
double tian_max_gabbro_water;
double tian_max_MORB_water;
double tian_max_sediment_water;

/**
*
* The following coefficients are taken from a publication from Tian et al., 2019, and can be found
* in Table 3 (Gabbro), Table B1 (MORB), Table B2 (Sediments) and Table B3 (peridotite).
* LR refers to the effective enthalpy change for devolatilization reactions,
* csat is the saturated mass fraction of water in the solid, and Td is the
* onset temperature of devolatilization for water.
*/
std::vector<double> LR_peridotite_poly_coeffs {-19.0609, 168.983, -630.032, 1281.84, -1543.14, 1111.88, -459.142, 95.4143, 1.97246};
std::vector<double> csat_peridotite_poly_coeffs {0.00115628, 2.42179};
std::vector<double> Td_peridotite_poly_coeffs {-15.4627, 94.9716, 636.603};

std::vector<double> LR_gabbro_poly_coeffs {-1.81745, 7.67198, -10.8507, 5.09329, 8.14519};
std::vector<double> csat_gabbro_poly_coeffs {-0.0176673, 0.0893044, 1.52732};
std::vector<double> Td_gabbro_poly_coeffs {-1.72277, 20.5898, 637.517};

std::vector<double> LR_MORB_poly_coeffs {-1.78177, 7.50871, -10.4840, 5.19725, 7.96365};
std::vector<double> csat_MORB_poly_coeffs {0.0102725, -0.115390, 0.324452, 1.41588};
std::vector<double> Td_MORB_poly_coeffs {-3.81280, 22.7809, 638.049};

std::vector<double> LR_sediment_poly_coeffs {-2.03283, 10.8186, -21.2119, 18.3351, -6.48711, 8.32459};
std::vector<double> csat_sediment_poly_coeffs {-0.150662, 0.301807, 1.01867};
std::vector<double> Td_sediment_poly_coeffs {2.83277, -24.7593, 85.9090, 524.898};

/**
* The polynomials breakdown above certain pressures, 10 GPa for peridotite, 26 GPa for gabbro, 16 GPa for MORB,
* and 50 GPa for sediment. These cutoff pressures were determined by extending the pressure range in Tian et al. (2019)
* and observing where the maximum allowed water contents jump towards infinite values.
*/
const std::vector<double> pressure_cutoffs {10, 26, 16, 50};

std::vector<std::vector<double>> devolatilization_enthalpy_changes {LR_peridotite_poly_coeffs, LR_gabbro_poly_coeffs, \
LR_MORB_poly_coeffs, LR_sediment_poly_coeffs
};

std::vector<std::vector<double>> water_mass_fractions {csat_peridotite_poly_coeffs, csat_gabbro_poly_coeffs, \
csat_MORB_poly_coeffs, csat_sediment_poly_coeffs
};

std::vector<std::vector<double>> devolatilization_onset_temperatures {Td_peridotite_poly_coeffs, Td_gabbro_poly_coeffs, \
Td_MORB_poly_coeffs, Td_sediment_poly_coeffs
};

/*
* Object for computing Katz 2003 melt parameters
*/
ReactionModel::Katz2003MantleMelting<dim> katz2003_model;

/*
* Object for computing Tian 2019 parameterized solubility parameters
*/
ReactionModel::Tian2019Solubility<dim> tian2019_model;

/**
* Enumeration for selecting which type of scheme to use for
* reactions between fluids and solids. The available
Expand Down
Loading