Skip to content

Commit ea5118f

Browse files
committed
Renamed the variable phase_index to phase_transition_index
1 parent f37c7fc commit ea5118f

File tree

6 files changed

+54
-48
lines changed

6 files changed

+54
-48
lines changed

doc/modules/changes/20241201_lhy11009

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Changed: Renamed the variable 'PhaseFunctionInputs::phase_index' to
2+
PhaseFunctionInputs::phase_transition_index'. The new variable name
3+
is more precise since it is used to index phase transitions rather than phases.
4+
Material models that make use of the old name will have to be adjusted.
5+
<br>
6+
(Haoyuan Li, 2024/12/01)

include/aspect/material_model/utilities.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ namespace aspect
528528
const double pressure,
529529
const double depth,
530530
const double pressure_depth_derivative,
531-
const unsigned int phase_index);
531+
const unsigned int phase_transition_index);
532532

533533
double temperature;
534534
double pressure;
@@ -546,7 +546,7 @@ namespace aspect
546546
* which only has information that there are two phase functions
547547
* and what their properties are.
548548
*/
549-
unsigned int phase_index;
549+
unsigned int phase_transition_index;
550550
};
551551

552552
/**
@@ -775,14 +775,14 @@ namespace aspect
775775

776776
/**
777777
* Return the Clapeyron slope (dp/dT of the transition) for
778-
* phase transition number @p phase_index.
778+
* phase transition number @p phase_transition_index.
779779
*/
780-
double get_transition_slope (const unsigned int phase_index) const;
780+
double get_transition_slope (const unsigned int phase_transition_index) const;
781781

782782
/**
783-
* Return the depth for phase transition number @p phase_index.
783+
* Return the depth for phase transition number @p phase_transition_index.
784784
*/
785-
double get_transition_depth (const unsigned int phase_index) const;
785+
double get_transition_depth (const unsigned int phase_transition_index) const;
786786

787787
/**
788788
* Return how many phase transitions there are for each chemical composition.

source/material_model/grain_size.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ namespace aspect
576576

577577
for (unsigned int k=0; k<n_phase_transitions; ++k)
578578
{
579-
phase_inputs.phase_index = k;
579+
phase_inputs.phase_transition_index = k;
580580
phase_function_values[k] = phase_function->compute_value(phase_inputs);
581581
}
582582

source/material_model/utilities.cc

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,14 +1149,14 @@ namespace aspect
11491149
const double pressure_,
11501150
const double depth_,
11511151
const double pressure_depth_derivative_,
1152-
const unsigned int phase_index_)
1152+
const unsigned int phase_transition_index_)
11531153

11541154
:
11551155
temperature(temperature_),
11561156
pressure(pressure_),
11571157
depth(depth_),
11581158
pressure_depth_derivative(pressure_depth_derivative_),
1159-
phase_index(phase_index_)
1159+
phase_transition_index(phase_transition_index_)
11601160
{}
11611161

11621162

@@ -1208,7 +1208,7 @@ namespace aspect
12081208
unsigned int n_comp = 0;
12091209
for (unsigned int n_relevant_fields = 0 ; n_relevant_fields < this->introspection().n_chemical_composition_fields() + 1 ; n_relevant_fields ++)
12101210
{
1211-
if (in.phase_index < start_phase_transition_index + n_phase_transitions_per_chemical_composition[n_relevant_fields])
1211+
if (in.phase_transition_index < start_phase_transition_index + n_phase_transitions_per_chemical_composition[n_relevant_fields])
12121212
{
12131213
n_comp = n_relevant_fields ;
12141214
break;
@@ -1246,7 +1246,7 @@ namespace aspect
12461246
}
12471247

12481248
// determine the value of phase function to facilitate the exact transition
1249-
if ((matched_phase_transition_index != numbers::invalid_unsigned_int) && in.phase_index <= matched_phase_transition_index)
1249+
if ((matched_phase_transition_index != numbers::invalid_unsigned_int) && in.phase_transition_index <= matched_phase_transition_index)
12501250
function_value = 1.0;
12511251
else
12521252
function_value = 0.0;
@@ -1424,13 +1424,13 @@ namespace aspect
14241424
double
14251425
PhaseFunction<dim>::compute_value (const PhaseFunctionInputs<dim> &in) const
14261426
{
1427-
AssertIndexRange (in.phase_index, transition_temperature_lower_limits.size());
1428-
AssertIndexRange (in.phase_index, transition_temperature_upper_limits.size());
1427+
AssertIndexRange (in.phase_transition_index, transition_temperature_lower_limits.size());
1428+
AssertIndexRange (in.phase_transition_index, transition_temperature_upper_limits.size());
14291429

14301430
// the percentage of material that has undergone the transition
14311431
double function_value;
1432-
if (in.temperature < transition_temperature_lower_limits[in.phase_index] ||
1433-
in.temperature >= transition_temperature_upper_limits[in.phase_index])
1432+
if (in.temperature < transition_temperature_lower_limits[in.phase_transition_index] ||
1433+
in.temperature >= transition_temperature_upper_limits[in.phase_transition_index])
14341434
{
14351435
// assign 0.0 if temperature is out of range
14361436
function_value = 0.0;
@@ -1439,40 +1439,40 @@ namespace aspect
14391439
{
14401440
if (use_depth_instead_of_pressure)
14411441
{
1442-
AssertIndexRange (in.phase_index, transition_depths.size());
1442+
AssertIndexRange (in.phase_transition_index, transition_depths.size());
14431443

14441444
// calculate the deviation from the transition point (convert temperature to depth)
1445-
double depth_deviation = in.depth - transition_depths[in.phase_index];
1445+
double depth_deviation = in.depth - transition_depths[in.phase_transition_index];
14461446

14471447
if (in.pressure_depth_derivative != 0.0)
14481448
{
1449-
AssertIndexRange (in.phase_index, transition_slopes.size());
1450-
AssertIndexRange (in.phase_index, transition_temperatures.size());
1449+
AssertIndexRange (in.phase_transition_index, transition_slopes.size());
1450+
AssertIndexRange (in.phase_transition_index, transition_temperatures.size());
14511451

1452-
depth_deviation -= transition_slopes[in.phase_index] / in.pressure_depth_derivative
1453-
* (in.temperature - transition_temperatures[in.phase_index]);
1452+
depth_deviation -= transition_slopes[in.phase_transition_index] / in.pressure_depth_derivative
1453+
* (in.temperature - transition_temperatures[in.phase_transition_index]);
14541454
}
14551455

14561456
// use delta function for width = 0
1457-
AssertIndexRange (in.phase_index, transition_widths.size());
1458-
if (transition_widths[in.phase_index] == 0)
1457+
AssertIndexRange (in.phase_transition_index, transition_widths.size());
1458+
if (transition_widths[in.phase_transition_index] == 0)
14591459
function_value = (depth_deviation > 0) ? 1. : 0.;
14601460
else
1461-
function_value = 0.5*(1.0 + std::tanh(depth_deviation / transition_widths[in.phase_index]));
1461+
function_value = 0.5*(1.0 + std::tanh(depth_deviation / transition_widths[in.phase_transition_index]));
14621462
}
14631463
else
14641464
{
14651465
// calculate the deviation from the transition point (convert temperature to pressure)
1466-
AssertIndexRange (in.phase_index, transition_pressures.size());
1467-
const double pressure_deviation = in.pressure - transition_pressures[in.phase_index]
1468-
- transition_slopes[in.phase_index] * (in.temperature - transition_temperatures[in.phase_index]);
1466+
AssertIndexRange (in.phase_transition_index, transition_pressures.size());
1467+
const double pressure_deviation = in.pressure - transition_pressures[in.phase_transition_index]
1468+
- transition_slopes[in.phase_transition_index] * (in.temperature - transition_temperatures[in.phase_transition_index]);
14691469

14701470
// use delta function for width = 0
1471-
AssertIndexRange (in.phase_index, transition_pressure_widths.size());
1472-
if (transition_pressure_widths[in.phase_index] == 0)
1471+
AssertIndexRange (in.phase_transition_index, transition_pressure_widths.size());
1472+
if (transition_pressure_widths[in.phase_transition_index] == 0)
14731473
function_value = (pressure_deviation > 0) ? 1. : 0.;
14741474
else
1475-
function_value = 0.5*(1.0 + std::tanh(pressure_deviation / transition_pressure_widths[in.phase_index]));
1475+
function_value = 0.5*(1.0 + std::tanh(pressure_deviation / transition_pressure_widths[in.phase_transition_index]));
14761476
}
14771477
}
14781478

@@ -1499,30 +1499,30 @@ namespace aspect
14991499
// phase transition based on depth
15001500
if (use_depth_instead_of_pressure)
15011501
{
1502-
const Point<dim,double> transition_point = this->get_geometry_model().representative_point(transition_depths[in.phase_index]);
1503-
const Point<dim,double> transition_plus_width = this->get_geometry_model().representative_point(transition_depths[in.phase_index] + transition_widths[in.phase_index]);
1504-
const Point<dim,double> transition_minus_width = this->get_geometry_model().representative_point(transition_depths[in.phase_index] - transition_widths[in.phase_index]);
1502+
const Point<dim,double> transition_point = this->get_geometry_model().representative_point(transition_depths[in.phase_transition_index]);
1503+
const Point<dim,double> transition_plus_width = this->get_geometry_model().representative_point(transition_depths[in.phase_transition_index] + transition_widths[in.phase_transition_index]);
1504+
const Point<dim,double> transition_minus_width = this->get_geometry_model().representative_point(transition_depths[in.phase_transition_index] - transition_widths[in.phase_transition_index]);
15051505
transition_pressure = this->get_adiabatic_conditions().pressure(transition_point);
15061506
pressure_width = 0.5 * (this->get_adiabatic_conditions().pressure(transition_plus_width)
15071507
- this->get_adiabatic_conditions().pressure(transition_minus_width));
1508-
width_temp = transition_widths[in.phase_index];
1508+
width_temp = transition_widths[in.phase_transition_index];
15091509
}
15101510
// using pressure instead of depth to define the phase transition
15111511
else
15121512
{
1513-
transition_pressure = transition_pressures[in.phase_index];
1514-
pressure_width = transition_pressure_widths[in.phase_index];
1515-
width_temp = transition_pressure_widths[in.phase_index];
1513+
transition_pressure = transition_pressures[in.phase_transition_index];
1514+
pressure_width = transition_pressure_widths[in.phase_transition_index];
1515+
width_temp = transition_pressure_widths[in.phase_transition_index];
15161516
}
15171517

15181518
// calculate the deviation from the transition point
15191519
const double pressure_deviation = in.pressure - transition_pressure
1520-
- transition_slopes[in.phase_index] * (in.temperature - transition_temperatures[in.phase_index]);
1520+
- transition_slopes[in.phase_transition_index] * (in.temperature - transition_temperatures[in.phase_transition_index]);
15211521

15221522
// calculate the analytical derivative of the phase function
15231523
if (
1524-
(in.temperature < transition_temperature_lower_limits[in.phase_index]) ||
1525-
(in.temperature >= transition_temperature_upper_limits[in.phase_index])
1524+
(in.temperature < transition_temperature_lower_limits[in.phase_transition_index]) ||
1525+
(in.temperature >= transition_temperature_upper_limits[in.phase_transition_index])
15261526
)
15271527
{
15281528
// return 0 if temperature is out of range
@@ -1609,19 +1609,19 @@ namespace aspect
16091609
template <int dim>
16101610
double
16111611
PhaseFunction<dim>::
1612-
get_transition_slope (const unsigned int phase_index) const
1612+
get_transition_slope (const unsigned int phase_transition_index) const
16131613
{
1614-
return transition_slopes[phase_index];
1614+
return transition_slopes[phase_transition_index];
16151615
}
16161616

16171617

16181618

16191619
template <int dim>
16201620
double
16211621
PhaseFunction<dim>::
1622-
get_transition_depth (const unsigned int phase_index) const
1622+
get_transition_depth (const unsigned int phase_transition_index) const
16231623
{
1624-
return transition_depths[phase_index];
1624+
return transition_depths[phase_transition_index];
16251625
}
16261626

16271627

source/material_model/visco_plastic.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace aspect
8080

8181
for (unsigned int j=0; j < phase_function.n_phase_transitions(); ++j)
8282
{
83-
phase_inputs.phase_index = j;
83+
phase_inputs.phase_transition_index = j;
8484
phase_function_values[j] = phase_function.compute_value(phase_inputs);
8585
}
8686
}
@@ -141,7 +141,7 @@ namespace aspect
141141
// Compute value of phase functions
142142
for (unsigned int j=0; j < phase_function.n_phase_transitions(); ++j)
143143
{
144-
phase_inputs.phase_index = j;
144+
phase_inputs.phase_transition_index = j;
145145
phase_function_values[j] = phase_function.compute_value(phase_inputs);
146146
}
147147

@@ -209,7 +209,7 @@ namespace aspect
209209
{
210210
for (unsigned int j=0; j < phase_function_discrete->n_phase_transitions(); ++j)
211211
{
212-
phase_inputs.phase_index = j;
212+
phase_inputs.phase_transition_index = j;
213213
phase_function_discrete_values[j] = phase_function_discrete->compute_value(phase_inputs);
214214
}
215215
isostrain_viscosities =

tests/composite_viscous_outputs_phases.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void f(const aspect::SimulatorAccess<dim> &simulator_access,
169169
// Compute value of phase functions
170170
for (unsigned int j=0; j < phase_function.n_phase_transitions(); ++j)
171171
{
172-
phase_inputs.phase_index = j;
172+
phase_inputs.phase_transition_index = j;
173173
phase_function_values[j] = phase_function.compute_value(phase_inputs);
174174
}
175175

0 commit comments

Comments
 (0)