Skip to content

Commit

Permalink
add an option to make it crash when look-up table does not cover the …
Browse files Browse the repository at this point in the history
…range, and manually set it for entropy method
  • Loading branch information
RanpengLi committed Jan 10, 2025
1 parent 8b5abd1 commit 0487d4e
Show file tree
Hide file tree
Showing 9 changed files with 51,281 additions and 51,342 deletions.
22,402 changes: 11,201 additions & 11,201 deletions data/material-model/entropy-table/pyrtable/material_table_entropy_pressure.txt

Large diffs are not rendered by default.

80,004 changes: 40,002 additions & 40,002 deletions data/material-model/entropy-table/pyrtable/material_table_temperature_pressure.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions doc/modules/changes/20241028_ranpengli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changed: The entropy reader throws when the range of the provided look-up table
does not fully cover the entropy-pressure range in the model.
<br>
(Ranpeng Li, 2025/01/10)
6 changes: 5 additions & 1 deletion include/aspect/structured_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ namespace aspect
* @param component The index (starting at 0) of the data column to be
* returned. The index is therefore less than the number of data
* columns in the data file (or specified in the constructor).
* @param crash_if_not_in_range If set to true, the function will throw
* when the requested position is outside the range of the coordinates
* provided by the data file.
*/
double
get_data(const Point<dim> &position,
const unsigned int component) const;
const unsigned int component,
const bool crash_if_not_in_range = false) const;

/**
* Returns the gradient of the function based on the bilinear
Expand Down
2 changes: 1 addition & 1 deletion source/material_model/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ namespace aspect
EntropyReader::temperature(const double entropy,
const double pressure) const
{
const double temperature = material_lookup->get_data({entropy,pressure}, 0);
const double temperature = material_lookup->get_data({entropy,pressure}, 0, true);
return temperature;
}

Expand Down
31 changes: 30 additions & 1 deletion source/structured_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,38 @@ namespace aspect
template <int dim>
double
StructuredDataLookup<dim>::get_data(const Point<dim> &position,
const unsigned int component) const
const unsigned int component,
const bool crash_if_not_in_range) const
{
Assert(component<n_components, ExcMessage("Invalid component index"));

if (crash_if_not_in_range)
{
const std::vector<double> &x_coordinates = get_interpolation_point_coordinates(0);

AssertThrow (position[0] >= x_coordinates[0] && position[0] <= x_coordinates[x_coordinates.size()-1],
ExcMessage("The requested position "
+ std::to_string(position[0])
+ " is outside the range of the data (maximum value = "
+ std::to_string(x_coordinates[0])
+ " , minimum value = "
+ std::to_string(x_coordinates[x_coordinates.size()-1])
+ ")."
));

const std::vector<double> &y_coordinates = get_interpolation_point_coordinates(1);

AssertThrow (position[1] >= y_coordinates[0] && position[1] <= y_coordinates[y_coordinates.size()-1],
ExcMessage("The requested position "
+ std::to_string(position[1])
+ " is outside the range of the data (maximum value = "
+ std::to_string(y_coordinates[0])
+ " , minimum value = "
+ std::to_string(y_coordinates[y_coordinates.size()-1])
+ ")."
));
}

return data[component]->value(position);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/entropy_plasticity.prm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ subsection Initial composition model
set Coordinate system = spherical
set Variable names = r,phi
set Function expression = 2535.08 + 10 * sin(2*phi)*sin(pi*(r-6371000)/2890000) - 1878.618 * erfc((6371000-r)/(2*sqrt(1.152e-6*5e7*31557600))) + \
486.368 * max(erfc((r-3481000)/(2*sqrt(1.152e-6*5e8*31557600))), exp(-((phi - 3/4*pi)^2)/(2*(1/35*pi)^2) - ((r-3481000)^2)/(2*400000^2)) );0
100 * max(erfc((r-3481000)/(2*sqrt(1.152e-6*5e8*31557600))), exp(-((phi - 3/4*pi)^2)/(2*(1/35*pi)^2) - ((r-3481000)^2)/(2*400000^2)) );0

#set Function expression = 2687.748 + 10 * sin(2*phi)*sin(pi*(r-6371000)/2890000) - 2031.286 * erfc((6371000-r)/(2*sqrt(1.152e-6*5e7*31557600))) + 333.7 * erfc((r-3481000)/(2*sqrt(1.152e-6*5e8*31557600)));0
end
Expand Down
166 changes: 35 additions & 131 deletions tests/entropy_plasticity/screen-output
Original file line number Diff line number Diff line change
Expand Up @@ -9,177 +9,81 @@ Number of degrees of freedom: 17,184 (6,528+864+3,264+3,264+3,264)
Solving temperature system... 0 iterations.
Solving entropy system ... 0 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 97+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.63904e-16, 1.61442e-16, 0, 0.00367688
Relative nonlinear residual (total system) after nonlinear iteration 1: 0.00367688
Solving Stokes system (GMG)... 75+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.61151e-16, 1.59986e-16, 0, 0.00372447
Relative nonlinear residual (total system) after nonlinear iteration 1: 0.00372447

Copying properties into prescribed temperature field... done.
Solving temperature system... 0 iterations.
Solving entropy system ... 0 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 72+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.63904e-16, 1.61442e-16, 0, 0.00195243
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.00195243
Solving Stokes system (GMG)... 52+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.61151e-16, 1.59986e-16, 0, 0.000935405
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.000935405

Copying properties into prescribed temperature field... done.
Solving temperature system... 0 iterations.
Solving entropy system ... 0 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 64+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.63904e-16, 1.61442e-16, 0, 8.95835e-05
Relative nonlinear residual (total system) after nonlinear iteration 3: 8.95835e-05
Solving Stokes system (GMG)... 44+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.61151e-16, 1.59986e-16, 0, 5.67375e-05
Relative nonlinear residual (total system) after nonlinear iteration 3: 5.67375e-05

Copying properties into prescribed temperature field... done.
Solving temperature system... 0 iterations.
Solving entropy system ... 0 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 49+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.63904e-16, 1.61442e-16, 0, 5.0626e-06
Relative nonlinear residual (total system) after nonlinear iteration 4: 5.0626e-06
Solving Stokes system (GMG)... 32+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.61151e-16, 1.59986e-16, 0, 2.72951e-06
Relative nonlinear residual (total system) after nonlinear iteration 4: 2.72951e-06


Postprocessing:
Writing graphical output: output-entropy_plasticity/solution/solution-00000
RMS, max velocity: 0.039 m/year, 0.467 m/year
Temperature min/avg/max: 321 K, 2008 K, 3448 K
Mass fluxes through boundary parts: -1.598e-06 kg/yr, 9.92e-07 kg/yr
Compositions min/max/mass: 600/2976/2.237e+17 // 3514/5130/3.852e+17

*** Timestep 1: t=199658 years, dt=199658 years
Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 11 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 78+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 2.61476e-05, 0.00115486, 0, 0.000363459
Relative nonlinear residual (total system) after nonlinear iteration 1: 0.00115486

Copying properties into prescribed temperature field... done.
Solving temperature system... 9 iterations.
Solving entropy system ... 11 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 76+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.00224359, 0.000328539, 0, 0.000282533
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.00224359

Copying properties into prescribed temperature field... done.
Solving temperature system... 8 iterations.
Solving entropy system ... 11 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 70+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.000631761, 9.10519e-05, 0, 7.59395e-05
Relative nonlinear residual (total system) after nonlinear iteration 3: 0.000631761
RMS, max velocity: 0.0117 m/year, 0.0483 m/year
Temperature min/avg/max: 321 K, 1974 K, 2582 K
Mass fluxes through boundary parts: -6.434e-07 kg/yr, 2.108e-07 kg/yr
Compositions min/max/mass: 600/2950/2.228e+17 // 3514/5130/3.853e+17

*** Timestep 1: t=400000 years, dt=400000 years
Copying properties into prescribed temperature field... done.
Solving temperature system... 8 iterations.
Solving entropy system ... 10 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 62+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.000176959, 2.28632e-05, 0, 1.79573e-05
Relative nonlinear residual (total system) after nonlinear iteration 4: 0.000176959

Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 9 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 57+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 4.39517e-05, 5.25597e-06, 0, 4.016e-06
Relative nonlinear residual (total system) after nonlinear iteration 5: 4.39517e-05

Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 9 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 50+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 9.96903e-06, 1.1388e-06, 0, 8.54258e-07
Relative nonlinear residual (total system) after nonlinear iteration 6: 9.96903e-06


Postprocessing:
RMS, max velocity: 0.0442 m/year, 0.57 m/year
Temperature min/avg/max: 321 K, 2007 K, 3448 K
Mass fluxes through boundary parts: -1.621e-06 kg/yr, 1.003e-06 kg/yr
Compositions min/max/mass: 600/2986/2.237e+17 // 3514/5130/3.852e+17

*** Timestep 2: t=384366 years, dt=184708 years
Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 11 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 76+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 2.64282e-05, 0.00048469, 0, 0.000319382
Relative nonlinear residual (total system) after nonlinear iteration 1: 0.00048469
Solving Stokes system (GMG)... 56+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 4.27436e-05, 0.000983831, 0, 0.00038342
Relative nonlinear residual (total system) after nonlinear iteration 1: 0.000983831

Copying properties into prescribed temperature field... done.
Solving temperature system... 9 iterations.
Solving entropy system ... 10 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 67+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.00317547, 9.18909e-05, 0, 8.97411e-05
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.00317547

Copying properties into prescribed temperature field... done.
Solving temperature system... 8 iterations.
Solving entropy system ... 9 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 60+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.00017361, 1.19549e-05, 0, 1.73366e-05
Relative nonlinear residual (total system) after nonlinear iteration 3: 0.00017361

Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 8 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 49+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 2.38815e-05, 9.61741e-07, 0, 1.16635e-06
Relative nonlinear residual (total system) after nonlinear iteration 4: 2.38815e-05

Copying properties into prescribed temperature field... done.
Solving temperature system... 6 iterations.
Solving entropy system ... 6 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 34+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.89356e-06, 5.36067e-08, 0, 5.50108e-08
Relative nonlinear residual (total system) after nonlinear iteration 5: 1.89356e-06


Postprocessing:
RMS, max velocity: 0.0502 m/year, 0.818 m/year
Temperature min/avg/max: 321 K, 2006 K, 3448 K
Mass fluxes through boundary parts: -1.637e-06 kg/yr, 1.046e-06 kg/yr
Compositions min/max/mass: 600/2986/2.236e+17 // 3513/5130/3.852e+17

*** Timestep 3: t=400000 years, dt=15634.2 years
Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 7 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 63+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 2.46452e-05, 2.5067e-05, 0, 7.81458e-06
Relative nonlinear residual (total system) after nonlinear iteration 1: 2.5067e-05
Solving Stokes system (GMG)... 47+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.00196115, 3.87599e-05, 0, 3.99673e-05
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.00196115

Copying properties into prescribed temperature field... done.
Solving temperature system... 8 iterations.
Solving entropy system ... 7 iterations.
Solving entropy system ... 6 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 54+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 0.00030441, 3.82669e-06, 0, 7.23454e-06
Relative nonlinear residual (total system) after nonlinear iteration 2: 0.00030441
Solving Stokes system (GMG)... 39+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 7.9364e-05, 2.26612e-06, 0, 4.94645e-06
Relative nonlinear residual (total system) after nonlinear iteration 3: 7.9364e-05

Copying properties into prescribed temperature field... done.
Solving temperature system... 7 iterations.
Solving entropy system ... 6 iterations.
Solving entropy system ... 5 iterations.
Copying properties into prescribed compositional field density_field... done.
Solving Stokes system (GMG)... 42+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 7.71754e-06, 3.59224e-07, 0, 9.10599e-07
Relative nonlinear residual (total system) after nonlinear iteration 3: 7.71754e-06
Solving Stokes system (GMG)... 30+0 iterations.
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 4.49419e-06, 1.64894e-07, 0, 3.88155e-07
Relative nonlinear residual (total system) after nonlinear iteration 4: 4.49419e-06


Postprocessing:
RMS, max velocity: 0.0507 m/year, 0.841 m/year
Temperature min/avg/max: 321 K, 2006 K, 3448 K
Mass fluxes through boundary parts: -1.722e-06 kg/yr, 1.055e-06 kg/yr
Compositions min/max/mass: 600/2989/2.236e+17 // 3513/5130/3.852e+17
RMS, max velocity: 0.0115 m/year, 0.0485 m/year
Temperature min/avg/max: 321 K, 1973 K, 2582 K
Mass fluxes through boundary parts: -6.546e-07 kg/yr, 1.938e-07 kg/yr
Compositions min/max/mass: 600/2950/2.227e+17 // 3516/5130/3.853e+17

Termination requested by criterion: end time

Expand Down
6 changes: 2 additions & 4 deletions tests/entropy_plasticity/statistics
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@
# 27: Minimal value for composition density_field
# 28: Maximal value for composition density_field
# 29: Global mass for composition density_field
0 0.000000000000e+00 0.000000000000e+00 768 7392 3264 6528 4 0 0 4294967292 278 286 286 output-entropy_plasticity/solution/solution-00000 3.89724518e-02 4.67399599e-01 3.21018877e+02 2.00757498e+03 3.44750753e+03 4.47006654e-01 -1.59815547e-06 9.91962974e-07 6.00000000e+02 2.97625563e+03 2.23741621e+17 3.51431122e+03 5.13045059e+03 3.85216157e+17
1 1.996576577256e+05 1.996576577256e+05 768 7392 3264 6528 6 46 61 4294967290 387 399 399 "" 4.41762729e-02 5.69736081e-01 3.21018877e+02 2.00684655e+03 3.44750753e+03 4.46813590e-01 -1.62078206e-06 1.00346451e-06 6.00000000e+02 2.98563135e+03 2.23690620e+17 3.51367980e+03 5.13045059e+03 3.85225361e+17
2 3.843657524378e+05 1.847080947123e+05 768 7392 3264 6528 5 37 44 4294967291 281 291 291 "" 5.01562464e-02 8.18084445e-01 3.21018877e+02 2.00617889e+03 3.44750753e+03 4.46636632e-01 -1.63676911e-06 1.04617727e-06 6.00000000e+02 2.98552383e+03 2.23643652e+17 3.51305713e+03 5.13045059e+03 3.85233771e+17
3 4.000000000000e+05 1.563424756215e+04 768 7392 3264 6528 3 22 20 4294967293 156 162 162 "" 5.06901714e-02 8.40850160e-01 3.21018877e+02 2.00612466e+03 3.44750753e+03 4.46622259e-01 -1.72159968e-06 1.05534597e-06 6.00000000e+02 2.98888782e+03 2.23639684e+17 3.51300258e+03 5.13045059e+03 3.85234480e+17
0 0.000000000000e+00 0.000000000000e+00 768 7392 3264 6528 4 0 0 4294967292 199 207 207 output-entropy_plasticity/solution/solution-00000 1.16744285e-02 4.83332658e-02 3.21018877e+02 1.97425661e+03 2.58226935e+03 4.38175918e-01 -6.43354928e-07 2.10810795e-07 6.00000000e+02 2.95000000e+03 2.22829153e+17 3.51431122e+03 5.13045059e+03 3.85325153e+17
1 4.000000000000e+05 4.000000000000e+05 768 7392 3264 6528 4 32 28 4294967292 168 176 176 "" 1.14747703e-02 4.84865775e-02 3.21018877e+02 1.97279434e+03 2.58226935e+03 4.37788354e-01 -6.54584656e-07 1.93770116e-07 6.00000000e+02 2.95000000e+03 2.22727088e+17 3.51550463e+03 5.13045059e+03 3.85343592e+17

0 comments on commit 0487d4e

Please sign in to comment.