Skip to content

Commit c05cc7d

Browse files
add some asserts
1 parent f621469 commit c05cc7d

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

include/aspect/material_model/rheology/compositional_plasticity_prefactors.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace aspect
3434
namespace Rheology
3535
{
3636
/**
37-
* A class that handles multiplication of viscosity for a given compositional
38-
* field. The multiplication factors for each composition (viscosity
37+
* A class that handles multiplication of the plastic parameters for a given compositional
38+
* field. The multiplication factors for each composition (plasticity
3939
* prefactors) are also declared, parsed, and in some cases calculated in this class.
4040
*/
4141
template <int dim>
@@ -61,7 +61,7 @@ namespace aspect
6161
parse_parameters (ParameterHandler &prm);
6262

6363
/**
64-
* Compute the viscosity.
64+
* Compute the plasticity weakening factor.
6565
*/
6666
std::pair<double, double>
6767
compute_weakening_factor (const MaterialModel::MaterialModelInputs<dim> &in,
@@ -73,18 +73,16 @@ namespace aspect
7373

7474
private:
7575
/**
76-
* The viscosity prefactors or terms used to calculate the viscosity
76+
* The plasticity prefactors or terms used to calculate the plasticity
7777
* prefactors, which are read in from the input file by the
7878
* parse_parameters() function. Users can choose between different schemes.
79-
* none: no viscosity change
80-
* hk04_olivine_hydration: calculate the viscosity change due to hydrogen
81-
* incorporation into olivine using Hirth & Kohlstaedt 2004 10.1029/138GM06.
82-
* This method requires a composition called 'bound_fluid' which tracks the wt%
83-
* water in the solid, which is used to compute an atomic ratio of H/Si ppm
84-
* assuming 90 mol% forsterite and 10 mol% fayalite, and finally calculates
85-
* a water fugacity.
79+
* none: no change in the plasticity parameters
80+
* porosity: calculate the change in the plasticity parameters due to the amount
81+
* of porosity at each quadrature point.
82+
* function: calculate the change in the plasticity parameters by specifying the
83+
* prefactors via a function.
8684
* The prefactor for a given compositional field is multiplied with a
87-
* base_viscosity value provided by the material model, which is then returned
85+
* cohesions and the friction angles provided by the material model, which is then returned
8886
* to the material model.
8987
*/
9088
enum WeakeningMechanism
@@ -100,13 +98,13 @@ namespace aspect
10098
std::vector<double> minimum_cohesions;
10199
std::vector<double> minimum_friction_angles;
102100
/**
103-
* Parsed functions that specify the friction angle which must be
101+
* Parsed functions that specify the plasticity prefactors which must be
104102
* given in the input file using the function method.
105103
*/
106104
std::unique_ptr<Functions::ParsedFunction<dim>> prefactor_function;
107105

108106
/**
109-
* The coordinate representation to evaluate the function for the friction angle.
107+
* The coordinate representation to evaluate the function for the plasticity prefactors.
110108
* Possible choices are depth, cartesian and spherical.
111109
*/
112110
Utilities::Coordinates::CoordinateSystem coordinate_system_prefactor_function;

source/material_model/rheology/compositional_plasticity_prefactors.cc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ namespace aspect
6161
{
6262
// Use the porosity to compute the cohesion and friction angle
6363
// The porosity is computed in the MaterialModel::MaterialModelInputs
64-
// and is available as in.porosity[i]
6564
const unsigned int porosity_idx = this->introspection().compositional_index_for_name("porosity");
6665
plasticity_parameters.first *= std::max((max_porosities_for_cohesion_prefactors[volume_fraction_index] - in.composition[i][porosity_idx]) / max_porosities_for_cohesion_prefactors[volume_fraction_index], 0.0);
6766
plasticity_parameters.second *= std::max((max_porosities_for_friction_angle_prefactors[volume_fraction_index] - in.composition[i][porosity_idx]) / max_porosities_for_friction_angle_prefactors[volume_fraction_index], 0.0);
@@ -72,7 +71,7 @@ namespace aspect
7271
}
7372
case function:
7473
{
75-
// Use a given function input per composition to get the friction angle
74+
// Use a given function input per composition to get the prefactors
7675
Utilities::NaturalCoordinate<dim> point =
7776
this->get_geometry_model().cartesian_to_other_coordinates(position, coordinate_system_prefactor_function);
7877

@@ -83,7 +82,7 @@ namespace aspect
8382
else
8483
prefactor_function->set_time (this->get_time());
8584

86-
// determine the friction angle based on position and composition
85+
// determine the prefactors based on position and composition
8786
// The volume_fraction_index is based on the number of chemical compositional fields.
8887
// However, this plugin reads a function for every compositional field, regardless of
8988
// its type. Therefore we have to get the correct index.
@@ -96,6 +95,7 @@ namespace aspect
9695
double prefactor_from_function =
9796
prefactor_function->value(Utilities::convert_array_to_point<dim>(point.get_coordinates()),index);
9897

98+
// Multiply the cohesion and the friction angle by the prefactor.
9999
plasticity_parameters.first *= prefactor_from_function;
100100
plasticity_parameters.second *= prefactor_from_function * constants::degree_to_radians;
101101

@@ -110,14 +110,14 @@ namespace aspect
110110
CompositionalPlasticityPrefactors<dim>::declare_parameters (ParameterHandler &prm)
111111
{
112112
prm.declare_entry ("Maximum porosity for cohesion prefactor", "1.0",
113-
Patterns::List(Patterns::Double(0., 1.0)),
113+
Patterns::List(Patterns::Double(std::numeric_limits<double>::epsilon(), 1.0)),
114114
"List of the maximum porosity value for calculating the prefactor for the cohesion. "
115115
"entered as a volume fraction. If chosen to be 0.1 (10 percent porosity), the "
116116
"cohesion will be linearly reduced from its default value when the model porosity is 0"
117117
"to a maximum reduction when the model porosity is 0.1. Units: none.");
118118

119119
prm.declare_entry ("Maximum porosity for friction angle prefactor", "1.0",
120-
Patterns::List(Patterns::Double(0., 1.0)),
120+
Patterns::List(Patterns::Double(std::numeric_limits<double>::epsilon(), 1.0)),
121121
"List of the maximum porosity value for calculating the prefactor for the friction "
122122
"angle, entered as a volume fraction. If chosen to be 0.1 (10 percent porosity), the "
123123
"friction angle will be linearly reduced from its default value when the model porosity is 0"
@@ -149,12 +149,14 @@ namespace aspect
149149
CompositionalPlasticityPrefactors<dim>::parse_parameters (ParameterHandler &prm)
150150
{
151151

152-
// if friction is specified as a function
153152
const unsigned int n_fields = this->n_compositional_fields() + 1;
154153
if (prm.get ("Plasticity prefactor scheme") == "none")
155154
prefactor_mechanism = none;
156-
if (prm.get ("Plasticity prefactor scheme") == "porosity")
155+
else if (prm.get ("Plasticity prefactor scheme") == "porosity")
157156
{
157+
AssertThrow(this->introspection().compositional_name_exists("porosity"),
158+
ExcMessage("The 'porosity' Plasticity prefactor scheme work only if "
159+
"is a compositional field called porosity."));
158160
prefactor_mechanism = porosity;
159161

160162
// Retrieve the list of chemical names
@@ -178,7 +180,7 @@ namespace aspect
178180
minimum_friction_angles = Utilities::MapParsing::parse_map_to_double_array (prm.get("Minimum friction angles"),
179181
options);
180182
}
181-
if (prm.get ("Plasticity prefactor scheme") == "function")
183+
else if (prm.get ("Plasticity prefactor scheme") == "function")
182184
{
183185
prefactor_mechanism = function;
184186
prm.enter_subsection("Prefactor function");
@@ -201,6 +203,8 @@ namespace aspect
201203
}
202204
prm.leave_subsection();
203205
}
206+
else
207+
AssertThrow(false, ExcMessage("Not a valid plasticity prefactor scheme"));
204208
}
205209
}
206210
}

tests/test_plastic_prefactor.prm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ subsection Material model
131131
set Cohesions = 100e6
132132
set Angles of internal friction = 30
133133
set Plasticity prefactor scheme = porosity
134-
set Maximum porosity for friction angle prefactor = 0.2
134+
set Maximum porosity for friction angle prefactor = 0.
135135
set Maximum porosity for cohesion prefactor = 0.1
136136

137137
set Minimum cohesions = 10e6

0 commit comments

Comments
 (0)