Skip to content

Commit b592db7

Browse files
authored
Merge pull request #6131 from lhy11009/discrete_phase_funcion_2
Discrete phase function
2 parents 8277698 + bfa3bb3 commit b592db7

File tree

20 files changed

+1210
-4
lines changed

20 files changed

+1210
-4
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is a data output from HeFESTo
2+
# Independent variables are T(K) and P(bar)
3+
# POINTS: 2 2
4+
T(K) P(bar) s,J/K/kg rho,kg/m3 alpha,1/K cp,J/K/kg vp,km/s vs,km/s h,J/kg dominant_phase_index,1
5+
250.0 0.0 509.74740059944844 3332.8967443100287 1.9781287327429287e-05 748.5636509347647 8.116376883289359 4.7495273882440685 -13445454.390915 0.0
6+
4000.0 0.0 3804.799798825367 2879.31713365359 0.00012376961201237974 1865.6003296108431 5.89690417370827 3.068046128481904 -8401781.805825338 0.0
7+
250.0 400781.25 326.1989261514726 4738.970221094591 9.15389351114028e-06 565.4531513648064 11.974450477467947 6.779618381631337 -3722250.1404551915 1.0
8+
4000.0 400781.25 3394.028743328079 4373.768154238075 2.6303932404721963e-05 1362.8625515701538 10.986106548987486 5.8231315598976465 873079.6281181354 1.0

doc/modules/changes/20241107_lhy11009

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Added: there is now a new class of phase function that handles discrete phase transitions
2+
by looking up the most dominant phases in a lookup table. This function can be used
3+
to make the rheology of the visco-plastic material model dependent on the dominant
4+
mineral phase.
5+
<br>
6+
(Haoyuan Li, 2024/11/07)

include/aspect/material_model/utilities.h

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,191 @@ namespace aspect
549549
unsigned int phase_index;
550550
};
551551

552+
/**
553+
* A class that bundles functionality to look up the dominant phase in
554+
* tables for each respective composition and export the values
555+
* of phase functions. The class can handle arbitrary numbers of
556+
* dominant phases for each composition, but the calling side
557+
* has to determine how to use the return values of this object
558+
* (e.g. in terms of density or viscosity).
559+
*/
560+
template <int dim>
561+
class PhaseFunctionDiscrete: public ::aspect::SimulatorAccess<dim>
562+
{
563+
public:
564+
565+
/**
566+
* The initialization process loads the contents of the material files
567+
* for the respective compositions.
568+
*/
569+
void initialize();
570+
571+
/**
572+
* Percentage of material that has already undergone the phase
573+
* transition to the higher-pressure material. For this class
574+
* this function only returns 1.0 or 0.0, depending on whether
575+
* the selected phase transition has been crossed or not.
576+
*/
577+
double compute_value (const PhaseFunctionInputs<dim> &in) const;
578+
579+
/**
580+
* No valid implementation exists for this function, as the derivative of a
581+
* discrete function is undefined at locations of phase jumps. This function raises an
582+
* error to ensure that a phase derivative request is not made for this phase function.
583+
*/
584+
double compute_derivative () const;
585+
586+
/**
587+
* Return the total number of phase transitions.
588+
*/
589+
unsigned int n_phase_transitions () const;
590+
591+
/**
592+
* Return the total number of phases.
593+
*/
594+
unsigned int n_phases () const;
595+
596+
/**
597+
* Return the total number of phases over all chemical compositions.
598+
*/
599+
unsigned int n_phases_over_all_chemical_compositions () const;
600+
601+
/**
602+
* Return how many phase transitions there are for each chemical composition.
603+
*/
604+
const std::vector<unsigned int> &
605+
n_phase_transitions_for_each_chemical_composition () const;
606+
607+
/**
608+
* Return how many phases there are for each chemical composition.
609+
*/
610+
const std::vector<unsigned int> &
611+
n_phases_for_each_chemical_composition () const;
612+
613+
/**
614+
* Return how many phase transitions there are for each composition.
615+
* Note, that most likely you only need the number of phase transitions
616+
* for each chemical composition, so use the function above instead.
617+
* This function is only kept for backward compatibility.
618+
*/
619+
const std::vector<unsigned int> &
620+
n_phase_transitions_for_each_composition () const;
621+
622+
/**
623+
* Return how many phases there are for each composition.
624+
* Note, that most likely you only need the number of phase transitions
625+
* for each chemical composition, so use the function above instead.
626+
* This function is only kept for backward compatibility.
627+
*/
628+
const std::vector<unsigned int> &
629+
n_phases_for_each_composition () const;
630+
631+
/**
632+
* Declare the parameters this class takes through input files.
633+
* Note that this class does not declare its own subsection,
634+
* i.e. the parameters will be declared in the subsection that
635+
* was active before calling this function.
636+
*/
637+
static
638+
void
639+
declare_parameters (ParameterHandler &prm);
640+
641+
/**
642+
* Read the parameters this class declares from the parameter file.
643+
* Note that this class does not declare its own subsection,
644+
* i.e. the parameters will be parsed from the subsection that
645+
* was active before calling this function.
646+
*/
647+
void
648+
parse_parameters (ParameterHandler &prm);
649+
650+
651+
private:
652+
/**
653+
* Directory path where data files are stored.
654+
*/
655+
std::string data_directory;
656+
657+
/**
658+
* List of file names containing material data for each composition.
659+
*/
660+
std::vector<std::string> material_file_names;
661+
662+
/**
663+
* Minimum temperature values for each composition in the P-T table.
664+
*/
665+
std::vector<double> minimum_temperature;
666+
667+
/**
668+
* Maximum temperature values for each composition in the P-T table.
669+
*/
670+
std::vector<double> maximum_temperature;
671+
672+
/**
673+
* Temperature intervals used for each composition in the P-T table.
674+
*/
675+
std::vector<double> interval_temperature;
676+
677+
/**
678+
* Minimum pressure values for each composition in the P-T table.
679+
*/
680+
std::vector<double> minimum_pressure;
681+
682+
/**
683+
* Maximum pressure values for each composition in the P-T table.
684+
*/
685+
std::vector<double> maximum_pressure;
686+
687+
/**
688+
* Pressure intervals used for each composition in the P-T table.
689+
*/
690+
std::vector<double> interval_pressure;
691+
692+
/**
693+
* List of pointers to objects that read and process data we get from
694+
* material data files. There is one pointer/object per lookup file.
695+
*/
696+
std::vector<std::unique_ptr<Utilities::StructuredDataLookup<2>>> material_lookup;
697+
698+
/**
699+
* List of phase indicators of the most dominant phases in the material data files
700+
* to construct the different phase transitions in this class. For a description of
701+
* the use of the phase indicators, please see the documentation of the input parameter
702+
* 'Phase transition indicators' in the function declare_parameters().
703+
*/
704+
std::vector<unsigned int> transition_indicators;
705+
706+
/**
707+
* A vector that stores how many phase transitions there are for each compositional field.
708+
*/
709+
std::unique_ptr<std::vector<unsigned int>> n_phase_transitions_per_composition;
710+
711+
/**
712+
* A vector that stores how many phases there are for each compositional field.
713+
*/
714+
std::vector<unsigned int> n_phases_per_composition;
715+
716+
/**
717+
* A vector that stores how many phase transitions there are for each chemical compositional field.
718+
*/
719+
std::vector<unsigned int> n_phase_transitions_per_chemical_composition;
720+
721+
/**
722+
* A vector that stores how many phases there are for each chemical compositional field.
723+
*/
724+
std::vector<unsigned int> n_phases_per_chemical_composition;
725+
726+
/**
727+
* Total number of phases over all compositional fields
728+
*/
729+
unsigned int n_phases_total;
730+
731+
/**
732+
* Total number of phases over all compositional fields
733+
*/
734+
unsigned int n_phases_total_chemical_compositions;
735+
};
736+
552737
/**
553738
* A class that bundles functionality to compute the values and
554739
* derivatives of phase functions. The class can handle arbitrary

include/aspect/material_model/visco_plastic.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ namespace aspect
181181
class ViscoPlastic : public MaterialModel::Interface<dim>, public ::aspect::SimulatorAccess<dim>
182182
{
183183
public:
184+
/**
185+
* Initialization function. Loads the material data and sets up
186+
* pointers if it is required.
187+
*/
188+
void
189+
initialize () override;
184190

185191
void evaluate(const MaterialModel::MaterialModelInputs<dim> &in,
186192
MaterialModel::MaterialModelOutputs<dim> &out) const override;
@@ -261,6 +267,16 @@ namespace aspect
261267
*/
262268
MaterialUtilities::PhaseFunction<dim> phase_function;
263269

270+
/**
271+
* Determines whether to look up the dominant phases for each composition in its respective lookup table.
272+
*/
273+
bool use_dominant_phase_for_viscosity;
274+
275+
/**
276+
* Object that handles discrete phase transitions for the rheology if requested by the variable use_dominant_phase_for_viscosity.
277+
*/
278+
std::unique_ptr<MaterialUtilities::PhaseFunctionDiscrete<dim>> phase_function_discrete;
279+
264280
};
265281

266282
}

include/aspect/structured_data.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ namespace aspect
248248
*/
249249
double get_maximum_component_value(const unsigned int component) const;
250250

251+
/**
252+
* Retrieve the number of table points for a given dimension.
253+
* Equivalent to calling get_interpolation_point_coordinates().size().
254+
*
255+
* @param dimension The index of the dimension for which to get the number of table points.
256+
* @return The number of points along the specified dimension.
257+
*/
258+
unsigned int get_number_of_coordinates(const unsigned int dimension) const;
259+
251260
private:
252261
/**
253262
* The number of data components read in (=columns in the data file).

0 commit comments

Comments
 (0)