Skip to content

Commit a975be6

Browse files
authored
Add loadflow parameters (#764)
Signed-off-by: Hugo Marcellin <[email protected]>
1 parent 63a7b1d commit a975be6

File tree

60 files changed

+3620
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3620
-17
lines changed

package-lock.json

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@ag-grid-community/locale": "^33.1.0",
3838
"@hello-pangea/dnd": "^18.0.1",
3939
"@material-symbols/svg-400": "^0.31.2",
40+
"@mui/base": "^5.0.0-beta.40-0",
4041
"@react-querybuilder/dnd": "^8.2.0",
4142
"@react-querybuilder/material": "^8.2.0",
4243
"autosuggest-highlight": "^3.3.4",

src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const styles = {
3737
dialogPaper: {
3838
'.MuiDialog-paper': {
3939
width: 'auto',
40-
minWidth: '1100px',
40+
minWidth: '60vw',
4141
margin: 'auto',
4242
},
4343
},

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export * from './topBar';
2121
export * from './treeViewFinder';
2222
export * from './notifications';
2323
export * from './icons';
24+
export * from './parameters';
2425
export * from './menus';

src/components/inputs/reactHookForm/DirectoryItemsInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { fetchDirectoryElementPath } from '../../../services';
2626
import { ElementAttributes } from '../../../utils';
2727

2828
export const NAME = 'name';
29+
export const DESCRIPTION_INPUT = 'description';
2930

3031
const styles = {
3132
formDirectoryElements1: {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
import { Grid } from '@mui/material';
8+
import { FormattedMessage } from 'react-intl';
9+
import { LineSeparator } from './line-separator';
10+
import { parametersStyles } from '../parameters-style';
11+
import { MuiSelectInput } from '../../inputs';
12+
import { PROVIDER } from './constant';
13+
14+
export interface ProviderParamProps {
15+
options: { id: string; label: string }[];
16+
}
17+
18+
const styles = {
19+
providerParam: {
20+
height: 'fit-content',
21+
justifyContent: 'space-between',
22+
},
23+
};
24+
25+
export function ProviderParam({ options }: Readonly<ProviderParamProps>) {
26+
return (
27+
<>
28+
<Grid xl={8} container sx={styles.providerParam} paddingRight={1}>
29+
<Grid item xs sx={parametersStyles.parameterName}>
30+
<FormattedMessage id="Provider" />
31+
</Grid>
32+
<Grid item container xs={2} sx={parametersStyles.controlItem}>
33+
<MuiSelectInput name={PROVIDER} size="small" fullWidth options={options} />
34+
</Grid>
35+
</Grid>
36+
<Grid container paddingTop={1} paddingRight={1} xl={8}>
37+
<LineSeparator />
38+
</Grid>
39+
</>
40+
);
41+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
export enum ComputingType {
9+
LOAD_FLOW = 'LOAD_FLOW',
10+
SECURITY_ANALYSIS = 'SECURITY_ANALYSIS',
11+
SENSITIVITY_ANALYSIS = 'SENSITIVITY_ANALYSIS',
12+
NON_EVACUATED_ENERGY_ANALYSIS = 'NON_EVACUATED_ENERGY_ANALYSIS',
13+
SHORT_CIRCUIT = 'SHORT_CIRCUIT',
14+
SHORT_CIRCUIT_ONE_BUS = 'SHORT_CIRCUIT_ONE_BUS',
15+
DYNAMIC_SIMULATION = 'DYNAMIC_SIMULATION',
16+
DYNAMIC_SECURITY_ANALYSIS = 'DYNAMIC_SECURITY_ANALYSIS',
17+
VOLTAGE_INITIALIZATION = 'VOLTAGE_INITIALIZATION',
18+
STATE_ESTIMATION = 'STATE_ESTIMATION',
19+
}
20+
21+
export const isValidComputingType = (value: string | undefined): boolean => {
22+
return Object.values(ComputingType).includes(value as ComputingType);
23+
};
24+
25+
export const formatComputingTypeLabel = (type: ComputingType): string | undefined => {
26+
switch (type) {
27+
case ComputingType.LOAD_FLOW:
28+
return 'LoadFlow';
29+
case ComputingType.SECURITY_ANALYSIS:
30+
return 'SecurityAnalysis';
31+
case ComputingType.SENSITIVITY_ANALYSIS:
32+
return 'SensitivityAnalysis';
33+
case ComputingType.NON_EVACUATED_ENERGY_ANALYSIS:
34+
return 'NonEvacuatedEnergy';
35+
case ComputingType.SHORT_CIRCUIT:
36+
return 'ShortCircuit';
37+
case ComputingType.VOLTAGE_INITIALIZATION:
38+
return 'VoltageInit';
39+
case ComputingType.DYNAMIC_SIMULATION:
40+
return 'DynamicSimulation';
41+
case ComputingType.DYNAMIC_SECURITY_ANALYSIS:
42+
return 'DynamicSecurityAnalysis';
43+
case ComputingType.STATE_ESTIMATION:
44+
return 'StateEstimation';
45+
default:
46+
console.warn(`Unrecognized computing type while formatting its label : ${type}`);
47+
return undefined;
48+
}
49+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright © 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
export const PROVIDER = 'provider';
9+
export const VOLTAGE_LEVEL = 'voltageLevel';
10+
11+
export const PARAM_SA_PROVIDER = 'provider';
12+
export const PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD = 'flowProportionalThreshold';
13+
export const PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD = 'lowVoltageProportionalThreshold';
14+
export const PARAM_SA_LOW_VOLTAGE_ABSOLUTE_THRESHOLD = 'lowVoltageAbsoluteThreshold';
15+
export const PARAM_SA_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD = 'highVoltageProportionalThreshold';
16+
export const PARAM_SA_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD = 'highVoltageAbsoluteThreshold';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
export * from './computing-type';
9+
export * from './constant';
10+
export * from './line-separator';
11+
export * from './parameters';
12+
export * from './parameters-creation-dialog';
13+
export * from './ProviderParam';
14+
export * from './widget';
15+
export * from './voltage-level-table';
16+
export * from './limitreductions';
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { NumberSchema } from 'yup';
9+
import { UUID } from 'crypto';
10+
import yup from '../../../../utils/yupConfig';
11+
import {
12+
PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD,
13+
PARAM_SA_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD,
14+
PARAM_SA_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD,
15+
PARAM_SA_LOW_VOLTAGE_ABSOLUTE_THRESHOLD,
16+
PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD,
17+
PARAM_SA_PROVIDER,
18+
} from '../constant';
19+
20+
export const LIMIT_REDUCTIONS_FORM = 'limitReductionsForm';
21+
export const VOLTAGE_LEVELS_FORM = 'voltageLevelsForm';
22+
export const IST_FORM = 'istForm';
23+
export const LIMIT_DURATION_FORM = 'limitReductionForm';
24+
25+
export interface IVoltageLevel {
26+
nominalV: number;
27+
lowBound: number;
28+
highBound: number;
29+
}
30+
31+
export interface ILimitDuration {
32+
lowBound: number;
33+
lowClosed: boolean;
34+
highBound: number;
35+
highClosed: boolean;
36+
}
37+
38+
export interface ITemporaryLimitReduction {
39+
reduction: number;
40+
limitDuration: ILimitDuration;
41+
}
42+
43+
export interface ILimitReductionsByVoltageLevel {
44+
voltageLevel: IVoltageLevel;
45+
permanentLimitReduction: number;
46+
temporaryLimitReductions: ITemporaryLimitReduction[];
47+
}
48+
49+
export interface ISAParameters {
50+
uuid?: UUID;
51+
[PARAM_SA_PROVIDER]: string;
52+
limitReductions: ILimitReductionsByVoltageLevel[];
53+
[PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD]: number;
54+
[PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD]: number;
55+
[PARAM_SA_LOW_VOLTAGE_ABSOLUTE_THRESHOLD]: number;
56+
[PARAM_SA_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD]: number;
57+
[PARAM_SA_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD]: number;
58+
}
59+
60+
export enum TabValues {
61+
'General' = 0,
62+
'LimitReductions' = 1,
63+
}
64+
65+
export const TAB_INFO = [
66+
{ label: TabValues[TabValues.General], developerModeOnly: false },
67+
{ label: TabValues[TabValues.LimitReductions], developerModeOnly: false },
68+
];
69+
70+
export interface IColumnsDef {
71+
label: string;
72+
dataKey: string;
73+
tooltip: string;
74+
width?: string;
75+
}
76+
77+
export const COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS: IColumnsDef[] = [
78+
{
79+
label: 'voltageRange',
80+
dataKey: VOLTAGE_LEVELS_FORM,
81+
tooltip: 'voltageRange',
82+
},
83+
{
84+
label: 'IST',
85+
dataKey: IST_FORM,
86+
tooltip: 'IST',
87+
},
88+
];
89+
90+
/* TODO: a cleaner solution can be done by using yup.array()
91+
Instead of creating a schema for each limit duration individually,
92+
we can use yup.array() to define an array of limit durations directly. */
93+
const getLimitDurationsFormSchema = (nbLimits: number) => {
94+
const limitDurationsFormSchema: Record<string, NumberSchema> = {};
95+
for (let i = 0; i < nbLimits; i++) {
96+
limitDurationsFormSchema[LIMIT_DURATION_FORM + i] = yup
97+
.number()
98+
.min(0, 'RealPercentage')
99+
.max(1, 'RealPercentage')
100+
.nullable()
101+
.required();
102+
}
103+
return limitDurationsFormSchema;
104+
};
105+
106+
export const getLimitReductionsFormSchema = (nbTemporaryLimits: number) => {
107+
return yup
108+
.object()
109+
.shape({
110+
[LIMIT_REDUCTIONS_FORM]: yup.array().of(
111+
yup.object().shape({
112+
[VOLTAGE_LEVELS_FORM]: yup.string(),
113+
[IST_FORM]: yup.number().min(0, 'RealPercentage').max(1, 'RealPercentage').nullable().required(),
114+
...getLimitDurationsFormSchema(nbTemporaryLimits),
115+
})
116+
),
117+
})
118+
.required();
119+
};
120+
121+
export const getSAParametersFromSchema = (limitReductions?: ILimitReductionsByVoltageLevel[]) => {
122+
const providerSchema = yup.object().shape({
123+
[PARAM_SA_PROVIDER]: yup.string().required(),
124+
});
125+
126+
const limitReductionsSchema = getLimitReductionsFormSchema(
127+
limitReductions?.length ? limitReductions[0].temporaryLimitReductions.length : 0
128+
);
129+
130+
const thresholdsSchema = yup.object().shape({
131+
[PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD]: yup
132+
.number()
133+
.min(0, 'NormalizedPercentage')
134+
.max(100, 'NormalizedPercentage')
135+
.required(),
136+
[PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD]: yup
137+
.number()
138+
.min(0, 'NormalizedPercentage')
139+
.max(100, 'NormalizedPercentage')
140+
.required(),
141+
[PARAM_SA_LOW_VOLTAGE_ABSOLUTE_THRESHOLD]: yup.number().required(),
142+
[PARAM_SA_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD]: yup
143+
.number()
144+
.min(0, 'NormalizedPercentage')
145+
.max(100, 'NormalizedPercentage')
146+
.required(),
147+
[PARAM_SA_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD]: yup.number().required(),
148+
});
149+
150+
return yup.object().shape({
151+
...providerSchema.fields,
152+
...limitReductionsSchema.fields,
153+
...thresholdsSchema.fields,
154+
});
155+
};

0 commit comments

Comments
 (0)