ASPECT
utilities.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2021 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_utilities_h
22 #define _aspect_material_model_utilities_h
23 
24 #include <aspect/global.h>
25 #include <deal.II/base/point.h>
26 #include <deal.II/base/symmetric_tensor.h>
27 #include <deal.II/fe/component_mask.h>
28 #include <deal.II/base/signaling_nan.h>
29 #include <deal.II/base/parameter_handler.h>
30 
31 namespace aspect
32 {
33  template <int dim> class SimulatorAccess;
34 
35  namespace MaterialModel
36  {
37  using namespace dealii;
38 
39  template <int dim> struct MaterialModelOutputs;
40  template <int dim> struct EquationOfStateOutputs;
41 
47  namespace MaterialUtilities
48  {
49  namespace Lookup
50  {
58  {
59  public:
60 
61  double
62  specific_heat(const double temperature,
63  const double pressure) const;
64 
65  double
66  density(const double temperature,
67  const double pressure) const;
68 
69  double
70  thermal_expansivity(const double temperature,
71  const double pressure) const;
72 
73  double
74  seismic_Vp(const double temperature,
75  const double pressure) const;
76 
77  double
78  seismic_Vs(const double temperature,
79  const double pressure) const;
80 
81  double
82  enthalpy(const double temperature,
83  const double pressure) const;
84 
90  double
91  dHdT (const double temperature,
92  const double pressure) const;
93 
99  double
100  dHdp (const double temperature,
101  const double pressure) const;
102 
115  std::array<std::pair<double, unsigned int>,2>
116  enthalpy_derivatives(const std::vector<double> &temperatures,
117  const std::vector<double> &pressures,
118  const unsigned int n_substeps = 1) const;
119 
120  double
121  dRhodp (const double temperature,
122  const double pressure) const;
123 
128  unsigned int
129  dominant_phase (const double temperature,
130  const double pressure) const;
131 
136  bool
137  has_dominant_phase() const;
138 
143  std::vector<std::string>
144  phase_volume_column_names() const;
145 
150  double
151  phase_volume_fraction(const int phase_id,
152  const double temperature,
153  const double pressure) const;
154 
159  std::array<double,2>
160  get_pT_steps() const;
161 
162 
169  const std::vector<std::string> &
170  get_dominant_phase_names() const;
171 
172  protected:
180  double
181  value (const double temperature,
182  const double pressure,
183  const Table<2, double> &values,
184  const bool interpol) const;
185 
191  unsigned int
192  value (const double temperature,
193  const double pressure,
194  const Table<2, unsigned int> &values) const;
195 
199  double get_nT(const double temperature) const;
200 
204  double get_np(const double pressure) const;
205 
206  ::Table<2,double> density_values;
207  ::Table<2,double> thermal_expansivity_values;
208  ::Table<2,double> specific_heat_values;
209  ::Table<2,double> vp_values;
210  ::Table<2,double> vs_values;
211  ::Table<2,double> enthalpy_values;
212  ::Table<2,unsigned int> dominant_phase_indices;
213 
220  std::vector<std::string> phase_column_names;
221  std::vector<::Table<2,double>> phase_volume_fractions;
222 
223  double delta_press;
224  double min_press;
225  double max_press;
226  double delta_temp;
227  double min_temp;
228  double max_temp;
229  unsigned int n_temperature;
230  unsigned int n_pressure;
231  unsigned int n_phases;
232  unsigned int n_columns;
235  std::vector<std::string> dominant_phase_names;
236  };
237 
243  {
244  public:
245  HeFESToReader(const std::string &material_filename,
246  const std::string &derivatives_filename,
247  const bool interpol,
248  const MPI_Comm &comm);
249  };
250 
256  {
257  public:
258  PerplexReader(const std::string &filename,
259  const bool interpol,
260  const MPI_Comm &comm);
261  };
262  }
263 
264 
265 
284  std::vector<double>
285  compute_composition_fractions(const std::vector<double> &compositional_fields,
286  const ComponentMask &field_mask = ComponentMask());
287 
293  std::vector<double>
294  compute_volume_fractions(const std::vector<double> &compositional_fields,
295  const ComponentMask &field_mask = ComponentMask());
296 
304  std::vector<double>
305  compute_volumes_from_masses(const std::vector<double> &masses,
306  const std::vector<double> &densities,
307  const bool return_as_fraction);
308 
318  {
323  };
324 
325 
326 
333  parse_compositional_averaging_operation (const std::string &parameter_name,
334  const ParameterHandler &prm);
335 
336 
337 
357  double average_value (const std::vector<double> &volume_fractions,
358  const std::vector<double> &parameter_values,
359  const CompositionalAveragingOperation &average_type);
360 
361 
362 
377  template <int dim>
378  void
380  const std::vector<double> &mass_fractions,
381  const std::vector<double> &volume_fractions,
382  const unsigned int i,
384 
385 
386 
390  namespace PhaseUtilities
391  {
398  {
401  };
402  }
403 
420  double phase_average_value (const std::vector<double> &phase_function_values,
421  const std::vector<unsigned int> &n_phases_per_composition,
422  const std::vector<double> &parameter_values,
423  const unsigned int composition,
425 
426 
427 
433  template <int dim>
435  {
440  PhaseFunctionInputs(const double temperature,
441  const double pressure,
442  const double depth,
443  const double pressure_depth_derivative,
444  const unsigned int phase_index);
445 
446  double temperature;
447  double pressure;
448  double depth;
450 
462  unsigned int phase_index;
463  };
464 
472  template <int dim>
474  {
475  public:
481  double compute_value (const PhaseFunctionInputs<dim> &in) const;
482 
487  double compute_derivative (const PhaseFunctionInputs<dim> &in) const;
488 
492  unsigned int n_phase_transitions () const;
493 
498  double get_transition_slope (const unsigned int phase_index) const;
499 
503  const std::vector<unsigned int> &
504  n_phase_transitions_for_each_composition () const;
505 
512  static
513  void
514  declare_parameters (ParameterHandler &prm);
515 
522  void
523  parse_parameters (ParameterHandler &prm);
524 
525 
526  private:
531  std::vector<double> transition_depths;
532  std::vector<double> transition_pressures;
533  std::vector<double> transition_temperatures;
534  std::vector<double> transition_widths;
535  std::vector<double> transition_pressure_widths;
536  std::vector<double> transition_slopes;
537 
545 
549  std::unique_ptr<std::vector<unsigned int>> n_phase_transitions_per_composition;
550  };
551  }
552  }
553 }
554 
555 
556 #endif
void fill_averaged_equation_of_state_outputs(const EquationOfStateOutputs< dim > &eos_outputs, const std::vector< double > &mass_fractions, const std::vector< double > &volume_fractions, const unsigned int i, MaterialModelOutputs< dim > &out)
double phase_average_value(const std::vector< double > &phase_function_values, const std::vector< unsigned int > &n_phases_per_composition, const std::vector< double > &parameter_values, const unsigned int composition, const PhaseUtilities::PhaseAveragingOperation operation=PhaseUtilities::arithmetic)
StructuredDataLookup< dim > DEAL_II_DEPRECATED
DEAL_II_DEPRECATED std::vector< double > compute_volume_fractions(const std::vector< double > &compositional_fields, const ComponentMask &field_mask=ComponentMask())
void declare_parameters(ParameterHandler &prm)
std::vector<::Table< 2, double > > phase_volume_fractions
Definition: utilities.h:221
std::unique_ptr< std::vector< unsigned int > > n_phase_transitions_per_composition
Definition: utilities.h:549
double average_value(const std::vector< double > &volume_fractions, const std::vector< double > &parameter_values, const CompositionalAveragingOperation &average_type)
CompositionalAveragingOperation parse_compositional_averaging_operation(const std::string &parameter_name, const ParameterHandler &prm)
std::vector< double > compute_volumes_from_masses(const std::vector< double > &masses, const std::vector< double > &densities, const bool return_as_fraction)
Definition: compat.h:88
std::vector< double > compute_composition_fractions(const std::vector< double > &compositional_fields, const ComponentMask &field_mask=ComponentMask())