Skip to content

Commit d25f9d8

Browse files
authored
Merge pull request geodynamics#6432 from buchanankerswell/kinetic-driving-force
Add initial kinetic driving force cookbook
2 parents 61d4f82 + 2372194 commit d25f9d8

16 files changed

+1835
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (C) 2011 - 2025 by the authors of the ASPECT code.
2+
#
3+
# This file is part of ASPECT.
4+
#
5+
# ASPECT is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 2, or (at your option)
8+
# any later version.
9+
#
10+
# ASPECT is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with ASPECT; see the file doc/COPYING. If not see
17+
# <http://www.gnu.org/licenses/>.
18+
19+
CMAKE_MINIMUM_REQUIRED(VERSION 3.13.4)
20+
21+
FIND_PACKAGE(Aspect 3.1.0 QUIET HINTS ${Aspect_DIR} ../ ../../ $ENV{ASPECT_DIR})
22+
23+
IF (NOT Aspect_FOUND)
24+
MESSAGE(FATAL_ERROR "\n"
25+
"Could not find a valid ASPECT build/installation directory. "
26+
"Please specify the directory where you are building ASPECT by passing\n"
27+
" -D Aspect_DIR=<path to ASPECT>\n"
28+
"to cmake or by setting the environment variable ASPECT_DIR in your shell "
29+
"before calling cmake. See the section 'How to write a plugin' in the "
30+
"manual for more information.")
31+
ENDIF ()
32+
33+
DEAL_II_INITIALIZE_CACHED_VARIABLES()
34+
35+
SET(TARGET "phase-transition-kinetics")
36+
ADD_LIBRARY(${TARGET} SHARED phase-transition-kinetics.cc)
37+
ASPECT_SETUP_PLUGIN(${TARGET})

cookbooks/phase_transition_kinetics/doc/phase-transition-kinetics.md

Lines changed: 285 additions & 0 deletions
Large diffs are not rendered by default.
439 KB
Loading
407 KB
Loading
319 KB
Loading

cookbooks/phase_transition_kinetics/phase-transition-kinetics.cc

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
/*
2+
Copyright (C) 2011 - 2025 by the authors of the ASPECT code.
3+
4+
This file is part of ASPECT.
5+
6+
ASPECT is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2, or (at your option)
9+
any later version.
10+
11+
ASPECT 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 General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with ASPECT; see the file LICENSE. If not see
18+
<http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#ifndef _aspect_cookbooks_phase_transition_kinetics_phase_transition_kinetics_h
22+
#define _aspect_cookbooks_phase_transition_kinetics_phase_transition_kinetics_h
23+
24+
#include <deal.II/base/patterns.h>
25+
#include <deal.II/base/types.h>
26+
27+
#include <aspect/adiabatic_conditions/interface.h>
28+
#include <aspect/geometry_model/interface.h>
29+
#include <aspect/material_model/equation_of_state/interface.h>
30+
#include <aspect/material_model/interface.h>
31+
#include <aspect/simulator_access.h>
32+
#include <aspect/utilities.h>
33+
34+
#include <vector>
35+
36+
namespace aspect
37+
{
38+
namespace MaterialModel
39+
{
40+
/**
41+
* A material model that reads in thermodynamic data from an ascii .txt file.
42+
* The thermodynamic data are evaluated along an adiabatic reference profile and
43+
* used to compute a reaction rate between two phases (or fixed mineral assemblages)
44+
* using the operator splitting technique. Average material properties are computed from
45+
* the mass fractions of the reacting phases. The model is considered compressible.
46+
*
47+
* The viscosity is computed as
48+
* \f[
49+
* \eta(z,T) = \eta_r(z) \eta_0 \exp\left(-A \frac{T - \bar{T}}{\bar{T}}\right)."
50+
* \f]
51+
*
52+
* where $\eta_r(z)$ is a depth-dependent viscosity prefactor, $\eta_0$ is the
53+
* reference viscosity, $A$ is the thermal viscosity exponent, $T$ is the full
54+
* temperature, and $\bar{T}$ is the reference adiabatic temperature.
55+
*
56+
* @ingroup MaterialModels
57+
*/
58+
59+
template <int dim>
60+
class PhaseTransitionKinetics : public MaterialModel::Interface<dim>, public ::aspect::SimulatorAccess<dim>
61+
{
62+
public:
63+
/**
64+
* Constructor. Initialize variables.
65+
*/
66+
PhaseTransitionKinetics();
67+
68+
/**
69+
* Initialization function. This function is called once at the
70+
* beginning of the program after parse_parameters is run and after
71+
* the SimulatorAccess (if applicable) is initialized.
72+
*/
73+
void
74+
initialize() override;
75+
76+
/**
77+
* @name Qualitative properties one can ask a material model
78+
* @{
79+
*/
80+
81+
/**
82+
* Return whether the model is compressible or not.
83+
*/
84+
bool
85+
is_compressible() const override;
86+
87+
/**
88+
* @}
89+
*/
90+
91+
/**
92+
* Evaluate material properties.
93+
*/
94+
void
95+
evaluate(const MaterialModel::MaterialModelInputs<dim> &in, MaterialModel::MaterialModelOutputs<dim> &out) const override;
96+
97+
/**
98+
* @name Functions used in dealing with run-time parameters
99+
* @{
100+
*/
101+
102+
/**
103+
* Declare the parameters this class takes through input files.
104+
*/
105+
static void
106+
declare_parameters(ParameterHandler &prm);
107+
108+
/**
109+
* Read the parameters this class declares from the parameter file.
110+
*/
111+
void
112+
parse_parameters(ParameterHandler &prm) override;
113+
114+
/**
115+
* @}
116+
*/
117+
118+
/**
119+
* Add the named outputs for reaction rates.
120+
*/
121+
void
122+
create_additional_named_outputs(MaterialModel::MaterialModelOutputs<dim> &out) const override;
123+
124+
private:
125+
/**
126+
* Object that stores the thermodynamic data used for computing the equation
127+
* of state and phase reaction. The thermodynamic data are evaluated along a
128+
* reference adiabatic profile.
129+
*
130+
* Data is read from a tab-separated .txt file with the following required columns:
131+
*
132+
* pressure density_a density_b thermal_expansivity_a thermal_expansivity_b
133+
* specific_heat_a specific_heat_b compressibility_a compressibility_b
134+
* delta_molar_gibbs delta_molar_entropy delta_molar_volume
135+
*
136+
* Note: "a" and "b" represent phases "a" and "b".
137+
*/
138+
Utilities::AsciiDataProfile<dim> profile;
139+
140+
/**
141+
* Column indices from the thermodynamic data along an adiabatic profile.
142+
* The pressure column is used for searching the table via interpolation.
143+
* All other columns store thermodynamic data required for calculating
144+
* the thermodynamic driving force in the PhaseTransitionKinetics material model.
145+
*
146+
* Note: "a" and "b" represent phases "a" and "b" and "dG", "dS", "dV"
147+
* represent the differences in the molar Gibbs free energy, molar entropy,
148+
* and molar volume of phases "a" and "b". For example, $\text{dG}$ =
149+
* $\text{G}_b$ - $\text{G}_a$
150+
*/
151+
unsigned int rho_a_idx;
152+
unsigned int rho_b_idx;
153+
unsigned int alpha_a_idx;
154+
unsigned int alpha_b_idx;
155+
unsigned int beta_a_idx;
156+
unsigned int beta_b_idx;
157+
unsigned int cp_a_idx;
158+
unsigned int cp_b_idx;
159+
unsigned int dG_idx;
160+
unsigned int dS_idx;
161+
unsigned int dV_idx;
162+
163+
/**
164+
* The reference viscosity.
165+
*
166+
* Units: Pa s
167+
*/
168+
double viscosity;
169+
170+
/**
171+
* The minimum viscosity.
172+
*
173+
* Units: Pa s
174+
*/
175+
double minimum_viscosity;
176+
177+
/**
178+
* The maximum viscosity.
179+
*
180+
* Units: Pa s
181+
*/
182+
183+
double maximum_viscosity;
184+
185+
/**
186+
* The constant $A$ in the temperature dependence of viscosity
187+
* $\exp\left(-A \frac{T - \bar{T}}{\bar{T}}\right).$
188+
*
189+
* Units: none
190+
*/
191+
double thermal_viscosity_exponent;
192+
193+
/**
194+
* A list of depths that determine the locations of the jumps in
195+
* the piece-wise constant function $\eta_r(z)$, which describes the
196+
* depth dependence of viscosity.
197+
*
198+
* Units: m
199+
*/
200+
std::vector<double> transition_depths;
201+
202+
/**
203+
* A list of constants that make up the piece-wise constant function
204+
* $\eta_r(z)$, which determines the depth dependence of viscosity,
205+
* and is multiplied with the reference viscosity and the
206+
* temperature dependence to compute the viscosity $\eta(z,T)$.
207+
*
208+
* Units: none
209+
*/
210+
std::vector<double> viscosity_prefactors;
211+
212+
/**
213+
* The reference thermal conductivity
214+
*
215+
* Units: W/m/k
216+
*/
217+
double k;
218+
219+
/**
220+
* The kinetic prefactor Q used to calculate the reaction rate
221+
* $\frac{dX}{dt} = Q \Delta G (1 - X)$
222+
*
223+
* Units: J/mol/s
224+
*/
225+
double Q_kinetic_prefactor;
226+
};
227+
} // namespace MaterialModel
228+
} // namespace aspect
229+
230+
#endif

0 commit comments

Comments
 (0)