-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: use yaml objects in mapper
BREAKING CHANGE: H2O no longer supported in fluid composition, use 'water'
- Loading branch information
Showing
32 changed files
with
760 additions
and
873 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: v8.22 to v8.23 | ||
description: v8.22 to v8.23 migration | ||
sidebar_position: -11 | ||
--- | ||
|
||
# v8.22 to v8.23 | ||
|
||
In this migration guide you will find: | ||
|
||
1. [YAML changes](#yaml-migration) | ||
|
||
## Yaml migration | ||
|
||
### Migration overview | ||
|
||
This doc guides you through migrating an existing eCalc™ model from version v8.22 to v8.23. | ||
|
||
We try to make this as easy as possible, and provide a step-by-step migration guide. | ||
|
||
### 1. Changes to COMPOSITION | ||
- `H2O` is no longer allowed in a fluid composition, `water` should be used instead | ||
|
||
```yaml | ||
MODELS: | ||
- NAME: <name of fluid model, for reference> | ||
TYPE: FLUID | ||
FLUID_MODEL_TYPE: COMPOSITION | ||
EOS_MODEL: <eos model> | ||
COMPOSITION: | ||
# This is old | ||
H2O: <mole fraction> | ||
# This is new | ||
water: <mole fraction> | ||
nitrogen: <mole fraction> | ||
CO2: <mole fraction> | ||
methane: <mole fraction, required> | ||
ethane: <mole fraction> | ||
propane: <mole fraction> | ||
i_butane: <mole fraction> | ||
n_butane: <mole fraction> | ||
i_pentane: <mole fraction> | ||
n_pentane: <mole fraction> | ||
n_hexane: <mole fraction> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 41 additions & 13 deletions
54
src/libecalc/presentation/yaml/energy_model_validation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,45 @@ | ||
import datetime | ||
from datetime import datetime | ||
from typing import Dict, Union | ||
|
||
from libecalc.presentation.yaml.yaml_keywords import EcalcYamlKeywords | ||
from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model import ( | ||
YamlEnergyUsageModelCompressor, | ||
YamlEnergyUsageModelCompressorSystem, | ||
YamlEnergyUsageModelCompressorTrainMultipleStreams, | ||
YamlEnergyUsageModelDirect, | ||
YamlEnergyUsageModelTabulated, | ||
) | ||
|
||
|
||
def validate_energy_usage_models(model: dict, consumer_name: str): | ||
energy_models = [] | ||
for key, value in model.items(): | ||
if isinstance(key, datetime.date) and value[EcalcYamlKeywords.type] not in energy_models: | ||
energy_models.append(value[EcalcYamlKeywords.type]) | ||
def validate_energy_usage_models( | ||
model: Union[ | ||
YamlEnergyUsageModelDirect, | ||
YamlEnergyUsageModelCompressor, | ||
YamlEnergyUsageModelCompressorSystem, | ||
YamlEnergyUsageModelTabulated, | ||
YamlEnergyUsageModelCompressorTrainMultipleStreams, | ||
Dict[ | ||
datetime, | ||
Union[ | ||
YamlEnergyUsageModelDirect, | ||
YamlEnergyUsageModelCompressor, | ||
YamlEnergyUsageModelCompressorSystem, | ||
YamlEnergyUsageModelTabulated, | ||
YamlEnergyUsageModelCompressorTrainMultipleStreams, | ||
], | ||
], | ||
], | ||
consumer_name: str, | ||
): | ||
if isinstance(model, dict): | ||
# Temporal model since dict | ||
energy_model_types = [] | ||
for value in model.values(): | ||
if value.type not in energy_model_types: | ||
energy_model_types.append(value.type) | ||
|
||
if len(energy_models) > 1: | ||
energy_models_list = ", ".join(energy_models) | ||
raise ValueError( | ||
"Energy model type cannot change over time within a single consumer." | ||
f" The model type is changed for '{consumer_name}': {energy_models_list}", | ||
) | ||
if len(energy_model_types) > 1: | ||
energy_models_list = ", ".join(energy_model_types) | ||
raise ValueError( | ||
"Energy model type cannot change over time within a single consumer." | ||
f" The model type is changed for '{consumer_name}': {energy_models_list}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.