Skip to content

Commit 70f4496

Browse files
authored
Merge pull request #6211 from gassmoeller/add_conductivity_interface
Implement thermal conductivity plugins
2 parents aa2bf45 + 11a545b commit 70f4496

File tree

6 files changed

+225
-11
lines changed

6 files changed

+225
-11
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
New: ASPECT now has an interface for plugins that describe thermal
2+
conductivity. This is useful to share functionality to compute
3+
thermal conductivity across material models. Material models can,
4+
but do not have to make use of these plugins.
5+
<br>
6+
(Rene Gassmoeller, 2025/01/27)

include/aspect/material_model/simpler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <aspect/material_model/interface.h>
2525
#include <aspect/material_model/rheology/constant_viscosity.h>
2626
#include <aspect/material_model/equation_of_state/linearized_incompressible.h>
27+
#include <aspect/material_model/thermal_conductivity/constant.h>
2728

2829
namespace aspect
2930
{
@@ -74,8 +75,7 @@ namespace aspect
7475
*/
7576

7677
private:
77-
double k_value;
78-
78+
ThermalConductivity::Constant<dim> thermal_conductivity;
7979
Rheology::ConstantViscosity constant_rheology;
8080
EquationOfState::LinearizedIncompressible<dim> equation_of_state;
8181
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Copyright (C) 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_material_model_thermal_conductivity_constant_h
22+
#define _aspect_material_model_thermal_conductivity_constant_h
23+
24+
#include <aspect/material_model/thermal_conductivity/interface.h>
25+
26+
27+
namespace aspect
28+
{
29+
namespace MaterialModel
30+
{
31+
namespace ThermalConductivity
32+
{
33+
using namespace dealii;
34+
35+
/**
36+
* A class that implements a constant thermal conductivity.
37+
*
38+
* @ingroup MaterialModels
39+
*/
40+
template <int dim>
41+
class Constant : public Interface<dim>
42+
{
43+
public:
44+
/**
45+
* Function to compute the thermal conductivities in @p out given the
46+
* inputs in @p in.
47+
*/
48+
void evaluate (const MaterialModel::MaterialModelInputs<dim> &in,
49+
MaterialModel::MaterialModelOutputs<dim> &out) const override;
50+
51+
/**
52+
* Declare the parameters this plugin takes through input files.
53+
*/
54+
static
55+
void
56+
declare_parameters (ParameterHandler &prm);
57+
58+
/**
59+
* Read the parameters from the parameter file.
60+
*/
61+
void
62+
parse_parameters (ParameterHandler &prm) override;
63+
64+
private:
65+
/**
66+
* The thermal conductivity.
67+
*/
68+
double k;
69+
};
70+
}
71+
}
72+
}
73+
74+
#endif
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright (C) 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_material_model_thermal_conductivity_interface_h
22+
#define _aspect_material_model_thermal_conductivity_interface_h
23+
24+
#include <aspect/global.h>
25+
#include <aspect/plugins.h>
26+
#include <aspect/material_model/interface.h>
27+
28+
29+
namespace aspect
30+
{
31+
namespace MaterialModel
32+
{
33+
namespace ThermalConductivity
34+
{
35+
using namespace dealii;
36+
37+
/**
38+
* A base class for parametrizations of the thermal conductivity. Classes derived
39+
* from this class will need to implement a function that computes the thermal
40+
* conductivities in @p out given the inputs in @p in. Derived classes can in addition
41+
* implement the functions of the base class Plugins::InterfaceBase as needed (e.g.
42+
* to read in input parameters or update the parametrization at the beginning of time steps).
43+
*
44+
* @ingroup MaterialModels
45+
*/
46+
template <int dim>
47+
class Interface : public Plugins::InterfaceBase
48+
{
49+
public:
50+
/**
51+
* Function to compute the thermal conductivities in @p out given the
52+
* inputs in @p in.
53+
*/
54+
virtual
55+
void evaluate (const MaterialModel::MaterialModelInputs<dim> &in,
56+
MaterialModel::MaterialModelOutputs<dim> &out) const = 0;
57+
};
58+
}
59+
}
60+
}
61+
62+
#endif

source/material_model/simpler.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ namespace aspect
4444
// The Simpler model does not depend on composition
4545
EquationOfStateOutputs<dim> eos_outputs (1);
4646

47+
thermal_conductivity.evaluate(in,out);
48+
4749
for (unsigned int i=0; i<in.n_evaluation_points(); ++i)
4850
{
4951
equation_of_state.evaluate(in, i, eos_outputs);
@@ -52,7 +54,6 @@ namespace aspect
5254
out.densities[i] = eos_outputs.densities[0];
5355
out.thermal_expansion_coefficients[i] = eos_outputs.thermal_expansion_coefficients[0];
5456
out.specific_heat[i] = eos_outputs.specific_heat_capacities[0];
55-
out.thermal_conductivities[i] = k_value;
5657
out.compressibilities[i] = eos_outputs.compressibilities[0];
5758

5859
for (unsigned int c=0; c<in.composition[i].size(); ++c)
@@ -71,11 +72,7 @@ namespace aspect
7172
prm.enter_subsection("Simpler model");
7273
{
7374
EquationOfState::LinearizedIncompressible<dim>::declare_parameters (prm);
74-
75-
prm.declare_entry ("Thermal conductivity", "4.7",
76-
Patterns::Double (0.),
77-
"The value of the thermal conductivity $k$. "
78-
"Units: \\si{\\watt\\per\\meter\\per\\kelvin}.");
75+
ThermalConductivity::Constant<dim>::declare_parameters (prm);
7976
Rheology::ConstantViscosity::declare_parameters(prm,5e24);
8077
}
8178
prm.leave_subsection();
@@ -94,9 +91,7 @@ namespace aspect
9491
prm.enter_subsection("Simpler model");
9592
{
9693
equation_of_state.parse_parameters (prm);
97-
98-
k_value = prm.get_double ("Thermal conductivity");
99-
94+
thermal_conductivity.parse_parameters (prm);
10095
constant_rheology.parse_parameters(prm);
10196
}
10297
prm.leave_subsection();
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Copyright (C) 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+
#include <aspect/material_model/thermal_conductivity/constant.h>
22+
23+
namespace aspect
24+
{
25+
namespace MaterialModel
26+
{
27+
namespace ThermalConductivity
28+
{
29+
template <int dim>
30+
void
31+
Constant<dim>::evaluate (const MaterialModel::MaterialModelInputs<dim> &/*in*/,
32+
MaterialModel::MaterialModelOutputs<dim> &out) const
33+
{
34+
for (auto &thermal_conductivity: out.thermal_conductivities)
35+
thermal_conductivity = k;
36+
}
37+
38+
39+
40+
template <int dim>
41+
void
42+
Constant<dim>::declare_parameters (ParameterHandler &prm)
43+
{
44+
prm.declare_entry ("Thermal conductivity", "4.7",
45+
Patterns::Double (0.),
46+
"The value of the thermal conductivity $k$. "
47+
"Units: \\si{\\watt\\per\\meter\\per\\kelvin}.");
48+
}
49+
50+
51+
52+
template <int dim>
53+
void
54+
Constant<dim>::parse_parameters (ParameterHandler &prm)
55+
{
56+
k = prm.get_double ("Thermal conductivity");
57+
}
58+
}
59+
}
60+
}
61+
62+
// explicit instantiations
63+
namespace aspect
64+
{
65+
namespace MaterialModel
66+
{
67+
namespace ThermalConductivity
68+
{
69+
#define INSTANTIATE(dim) \
70+
template class Constant<dim>;
71+
72+
ASPECT_INSTANTIATE(INSTANTIATE)
73+
74+
#undef INSTANTIATE
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)