Skip to content

Commit

Permalink
Handle correctly degC/km units in Gradients and Gradient1
Browse files Browse the repository at this point in the history
  • Loading branch information
natakokota committed Jun 9, 2024
1 parent becec79 commit a44d7d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/geophires_x/Reservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,15 @@ def read_parameters(self, model: Model) -> None:
parts = ParameterReadIn.Name.split(' ')
position = int(parts[1]) - 1
model.reserv.gradient.value[position] = ParameterToModify.value
if model.reserv.gradient.value[position] > 1.0:
model.reserv.gradient.CurrentUnits = ParameterToModify.CurrentUnits
if model.reserv.gradient.value[position] > 1.0 and ParameterToModify.CurrentUnits == TemperatureGradientUnit.DEGREESCPERM:
# TODO refactor to avoid heuristic-based unit conversions
model.reserv.gradient.value[position] = model.reserv.gradient.value[
position] / 1000.0 # convert C/m
model.reserv.gradient.CurrentUnits = TemperatureGradientUnit.DEGREESCPERM
# model.reserv.gradient.CurrentUnits = TemperatureGradientUnit.DEGREESCPERM
elif model.reserv.gradient.value[position] <= 1.0 and ParameterToModify.CurrentUnits == TemperatureGradientUnit.DEGREESCPERKM:
model.reserv.gradient.value[position] = model.reserv.gradient.value[
position] * 1000.0 # convert C/km

if model.reserv.gradient.value[position] < 1e-6:
# convert 0 C/m gradients to very small number, avoids divide by zero errors later
Expand Down

0 comments on commit a44d7d7

Please sign in to comment.