Skip to content

Commit

Permalink
Merge pull request #6211 from gassmoeller/add_conductivity_interface
Browse files Browse the repository at this point in the history
Implement thermal conductivity plugins
  • Loading branch information
tjhei authored Jan 28, 2025
2 parents aa2bf45 + 11a545b commit 70f4496
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 11 deletions.
6 changes: 6 additions & 0 deletions doc/modules/changes/20250127_gassmoeller
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
New: ASPECT now has an interface for plugins that describe thermal
conductivity. This is useful to share functionality to compute
thermal conductivity across material models. Material models can,
but do not have to make use of these plugins.
<br>
(Rene Gassmoeller, 2025/01/27)
4 changes: 2 additions & 2 deletions include/aspect/material_model/simpler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <aspect/material_model/interface.h>
#include <aspect/material_model/rheology/constant_viscosity.h>
#include <aspect/material_model/equation_of_state/linearized_incompressible.h>
#include <aspect/material_model/thermal_conductivity/constant.h>

namespace aspect
{
Expand Down Expand Up @@ -74,8 +75,7 @@ namespace aspect
*/

private:
double k_value;

ThermalConductivity::Constant<dim> thermal_conductivity;
Rheology::ConstantViscosity constant_rheology;
EquationOfState::LinearizedIncompressible<dim> equation_of_state;
};
Expand Down
74 changes: 74 additions & 0 deletions include/aspect/material_model/thermal_conductivity/constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Copyright (C) 2025 - 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_model_thermal_conductivity_constant_h
#define _aspect_material_model_thermal_conductivity_constant_h

#include <aspect/material_model/thermal_conductivity/interface.h>


namespace aspect
{
namespace MaterialModel
{
namespace ThermalConductivity
{
using namespace dealii;

/**
* A class that implements a constant thermal conductivity.
*
* @ingroup MaterialModels
*/
template <int dim>
class Constant : public Interface<dim>
{
public:
/**
* Function to compute the thermal conductivities in @p out given the
* inputs in @p in.
*/
void evaluate (const MaterialModel::MaterialModelInputs<dim> &in,
MaterialModel::MaterialModelOutputs<dim> &out) const override;

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

/**
* Read the parameters from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm) override;

private:
/**
* The thermal conductivity.
*/
double k;
};
}
}
}

#endif
62 changes: 62 additions & 0 deletions include/aspect/material_model/thermal_conductivity/interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright (C) 2025 - 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_model_thermal_conductivity_interface_h
#define _aspect_material_model_thermal_conductivity_interface_h

#include <aspect/global.h>
#include <aspect/plugins.h>
#include <aspect/material_model/interface.h>


namespace aspect
{
namespace MaterialModel
{
namespace ThermalConductivity
{
using namespace dealii;

/**
* A base class for parametrizations of the thermal conductivity. Classes derived
* from this class will need to implement a function that computes the thermal
* conductivities in @p out given the inputs in @p in. Derived classes can in addition
* implement the functions of the base class Plugins::InterfaceBase as needed (e.g.
* to read in input parameters or update the parametrization at the beginning of time steps).
*
* @ingroup MaterialModels
*/
template <int dim>
class Interface : public Plugins::InterfaceBase
{
public:
/**
* Function to compute the thermal conductivities in @p out given the
* inputs in @p in.
*/
virtual
void evaluate (const MaterialModel::MaterialModelInputs<dim> &in,
MaterialModel::MaterialModelOutputs<dim> &out) const = 0;
};
}
}
}

#endif
13 changes: 4 additions & 9 deletions source/material_model/simpler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace aspect
// The Simpler model does not depend on composition
EquationOfStateOutputs<dim> eos_outputs (1);

thermal_conductivity.evaluate(in,out);

for (unsigned int i=0; i<in.n_evaluation_points(); ++i)
{
equation_of_state.evaluate(in, i, eos_outputs);
Expand All @@ -52,7 +54,6 @@ namespace aspect
out.densities[i] = eos_outputs.densities[0];
out.thermal_expansion_coefficients[i] = eos_outputs.thermal_expansion_coefficients[0];
out.specific_heat[i] = eos_outputs.specific_heat_capacities[0];
out.thermal_conductivities[i] = k_value;
out.compressibilities[i] = eos_outputs.compressibilities[0];

for (unsigned int c=0; c<in.composition[i].size(); ++c)
Expand All @@ -71,11 +72,7 @@ namespace aspect
prm.enter_subsection("Simpler model");
{
EquationOfState::LinearizedIncompressible<dim>::declare_parameters (prm);

prm.declare_entry ("Thermal conductivity", "4.7",
Patterns::Double (0.),
"The value of the thermal conductivity $k$. "
"Units: \\si{\\watt\\per\\meter\\per\\kelvin}.");
ThermalConductivity::Constant<dim>::declare_parameters (prm);
Rheology::ConstantViscosity::declare_parameters(prm,5e24);
}
prm.leave_subsection();
Expand All @@ -94,9 +91,7 @@ namespace aspect
prm.enter_subsection("Simpler model");
{
equation_of_state.parse_parameters (prm);

k_value = prm.get_double ("Thermal conductivity");

thermal_conductivity.parse_parameters (prm);
constant_rheology.parse_parameters(prm);
}
prm.leave_subsection();
Expand Down
77 changes: 77 additions & 0 deletions source/material_model/thermal_conductivity/constant.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Copyright (C) 2025 - 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/>.
*/

#include <aspect/material_model/thermal_conductivity/constant.h>

namespace aspect
{
namespace MaterialModel
{
namespace ThermalConductivity
{
template <int dim>
void
Constant<dim>::evaluate (const MaterialModel::MaterialModelInputs<dim> &/*in*/,
MaterialModel::MaterialModelOutputs<dim> &out) const
{
for (auto &thermal_conductivity: out.thermal_conductivities)
thermal_conductivity = k;
}



template <int dim>
void
Constant<dim>::declare_parameters (ParameterHandler &prm)
{
prm.declare_entry ("Thermal conductivity", "4.7",
Patterns::Double (0.),
"The value of the thermal conductivity $k$. "
"Units: \\si{\\watt\\per\\meter\\per\\kelvin}.");
}



template <int dim>
void
Constant<dim>::parse_parameters (ParameterHandler &prm)
{
k = prm.get_double ("Thermal conductivity");
}
}
}
}

// explicit instantiations
namespace aspect
{
namespace MaterialModel
{
namespace ThermalConductivity
{
#define INSTANTIATE(dim) \
template class Constant<dim>;

ASPECT_INSTANTIATE(INSTANTIATE)

#undef INSTANTIATE
}
}
}

0 comments on commit 70f4496

Please sign in to comment.