Skip to content

Commit 539b843

Browse files
committed
fix: validate pressures before computing pressure ratios in simplified train
Move validate_pressures() call before create_compressor_model() to prevent divide-by-zero warning when suction pressure is zero. The validation error was already raised, but after the division had already been attempted.
1 parent da4cd0f commit 539b843

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/libecalc/presentation/yaml/mappers/consumer_function_mapper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,12 @@ def _map_compressor(
13131313
discharge_pressure=discharge_pressure,
13141314
)
13151315

1316+
if suction_pressure is not None and discharge_pressure is not None:
1317+
validate_pressures(
1318+
suction_pressure=suction_pressure,
1319+
discharge_pressure=discharge_pressure,
1320+
)
1321+
13161322
compressor_model, fluid_model = self._compressor_model_mapper.create_compressor_model(
13171323
model.energy_function, operational_data=operational_data
13181324
)
@@ -1321,12 +1327,6 @@ def _map_compressor(
13211327
if consumes != consumption_type:
13221328
raise InvalidConsumptionType(actual=consumption_type, expected=consumes)
13231329

1324-
if suction_pressure is not None and discharge_pressure is not None:
1325-
validate_pressures(
1326-
suction_pressure=suction_pressure,
1327-
discharge_pressure=discharge_pressure,
1328-
)
1329-
13301330
model_id = uuid4()
13311331
# Register the compressor model and its evaluation input in the process service
13321332
# - If it is a sampled model, or a turbine model wrapping a sampled model, treat as non-process.

0 commit comments

Comments
 (0)