Skip to content

Commit 77340a7

Browse files
committed
bugfix: crac action value mapping
1 parent 7d31e8c commit 77340a7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rao/crac/models.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def serialize_with_prefix(self, value: List[str]) -> List[str]:
1515

1616

1717
class Threshold(BaseModel):
18-
unit: Literal['megawatt', 'ampere', 'percent_imax'] = 'ampere' # Default unit is 'ampere', can be adjusted if needed
18+
unit: Literal['megawatt', 'ampere', 'percent_imax', 'kilovolt'] = 'ampere' # Default unit is 'ampere', can be adjusted if needed
1919
min: float = 0
2020
max: float = 0
2121
side: int = 1 # Default side is 1, can be adjusted if needed
@@ -43,6 +43,10 @@ class FlowCnec(Cnec):
4343
pass
4444

4545

46+
class VoltageCnec(Cnec):
47+
pass
48+
49+
4650
class TerminalsAction(BaseModel):
4751
networkElementId: str
4852
actionType: Literal['open', 'close'] | float = Field(default="open", validation_alias=AliasChoices("normalValue", "actionType"))
@@ -52,9 +56,9 @@ class TerminalsAction(BaseModel):
5256
def map_to_string_open_close(cls, value: Literal['open', 'close'] | float) -> str:
5357
if isinstance(value, float):
5458
if value:
55-
return "open"
56-
else:
5759
return "close"
60+
else:
61+
return "open"
5862
return value
5963

6064
@field_serializer("networkElementId", when_used='unless-none')
@@ -109,6 +113,7 @@ class Config:
109113
networkElementsNamePerId: Dict = Field(default_factory=dict)
110114
contingencies: List[Contingency] = Field(default_factory=list)
111115
flowCnecs: List[FlowCnec] = Field(default_factory=list)
116+
voltageCnecs: List[VoltageCnec] = Field(default_factory=list)
112117
networkActions: List[NetworkAction] = Field(default_factory=list)
113118

114119
@field_serializer("flowCnecs", mode='plain')

0 commit comments

Comments
 (0)