Salome HOME
bug
[tools/eficas.git] / ProcessOutputs_Eficas / PSEN_Cata_N1.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # --------------------------------------------------
22 # debut entete
23 # --------------------------------------------------
24
25 #from Accas import ASSD, JDC_CATA, AU_MOINS_UN, PROC, SIMP, FACT, OPER, MACRO, BLOC, A_VALIDATOR
26 from Accas import *
27 import opsPSEN_N1
28 import pn
29 #
30 #class loi      ( ASSD ) : pass
31 #class variable ( ASSD ) : pass
32 class sd_charge     ( ASSD ) : pass
33 class sd_generateur ( ASSD ) : pass
34 class sd_ligne     ( ASSD ) : pass
35 class sd_transfo ( ASSD ) : pass
36 class sd_moteur ( ASSD ) : pass
37 #
38
39 # import types
40 class Tuple:
41    def __init__(self,ntuple):
42      self.ntuple=ntuple
43
44    def __convert__(self,valeur):
45      import types
46      if type(valeur) == types.StringType:
47        return None
48      if len(valeur) != self.ntuple:
49        return None
50      return valeur
51
52    def info(self):
53      return "Tuple de %s elements" % self.ntuple
54
55    __repr__=info
56    __str__=info
57
58 # class Matrice:
59 #   def __init__(self,nbLigs=None,nbCols=None,methodeCalculTaille=None,formatSortie="ligne",valSup=None,valMin=None,structure=None):
60 #       self.nbLigs=nbLigs
61 #       self.nbCols=nbCols
62 #       self.methodeCalculTaille=methodeCalculTaille
63 #       self.formatSortie=formatSortie
64 #       self.valSup=valSup
65 #       self.valMin=valMin
66 #       self.structure=structure
67 #
68 #   def __convert__(self,valeur):
69 #     # Attention ne verifie pas grand chose
70 #     if type(valeur) != types.ListType :
71 #       return None
72 #     return valeur
73 #
74 #   def info(self):
75 #       return "Matrice %s x %s" % (self.nbLigs, self.nbCols)
76 #
77 #       __repr__=info
78 #       __str__=info
79
80
81 #CONTEXT.debug = 1
82 JdC = JDC_CATA ( code = 'PSEN',
83                  execmodul = None,
84                  regles = ( AU_MOINS_UN ( 'CASE_SELECTION', 'CONTINGENCY_PROCESSING' ),
85                             AU_MOINS_UN ( 'CONTINGENCY_SELECTION','N_PROCESSING_OPTIONS','CONTINGENCY_PROCESSING' ),
86                             PRESENT_PRESENT ( 'CONTINGENCY_SELECTION','CONTINGENCY_OPTIONS' ),
87                             PRESENT_PRESENT ( 'CONTINGENCY_PROCESSING','CONTINGENCY_OPTIONS' ),
88                              AU_MOINS_UN ( 'SIMULATION' ),
89                             # AU_PLUS_UN ( 'PSSE_PARAMETERS' ),
90                             AU_PLUS_UN ( 'CASE_SELECTION' ),
91                             AU_PLUS_UN ( 'CONTINGENCY_OPTIONS' ),
92                             AU_PLUS_UN ( 'CONTINGENCY_SELECTION' ),
93                             AU_PLUS_UN ( 'CONTINGENCY_PROCESSING' ),
94                             AU_PLUS_UN ( 'N_PROCESSING_OPTIONS' ),
95                             # AU_PLUS_UN ( 'N_1_LINES' ),
96                             # AU_PLUS_UN ( 'N_1_LOADS' ),
97                             # AU_PLUS_UN ( 'N_1_TRANSFORMERS' ),
98
99                             ),
100                  ) # Fin JDC_CATA
101
102 MODIFICATION_CATALOGUE = MACRO ( nom = "MODIFICATION_CATALOGUE",
103                      sd_prod = pn.modification_catalogue,
104                      op_init=  pn.modification_catalogue2,
105                      op=None,
106                      UIinfo={"groupes":("CACHE")},
107                      Fonction=SIMP(statut='o', typ='TXM', into=['ajoutDefinitionMC']),
108                      Etape=SIMP(statut='o', typ='TXM',),
109                      Genea=SIMP(statut='o', typ='TXM', min=0, max='**'),
110                      NomSIMP=SIMP(statut='o', typ='TXM',),
111                      TypeSIMP=SIMP(statut='o', typ='TXM',),
112                      PhraseArguments=SIMP(statut='o', typ='TXM',),)
113
114
115 # --------------------------------------------------
116 # fin entete
117 # --------------------------------------------------
118 ## TODO : RUN
119 CASE_SELECTION = MACRO ( nom = "CASE_SELECTION",
120                       sd_prod = opsPSEN_N1.INCLUDE,
121                       op_init = opsPSEN_N1.INCLUDE_context,
122                       fichier_ini = 1,
123                       op = None,
124                       fr = "Selectionnez les cas a analyser",
125                       ang = 'Select the cases to analyze',
126                       PSSE_path = SIMP(statut="o",typ='Repertoire',defaut='C:\Program Files (x86)\PTI\PSSE33\PSSBIN'),
127                       output_folder = SIMP(statut="o", typ="Repertoire"),
128
129
130                       BusesList = SIMP(statut = 'f', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
131                       LinesList = SIMP(statut = 'f', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
132                       TransformersList = SIMP(statut = 'f', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
133                       MaxDepth = SIMP(statut = 'o', typ = 'I', defaut = 5),
134                       OutputNewCsv = SIMP ( statut = "o",typ=bool,defaut=False,),
135                  )
136 N_PROCESSING_OPTIONS = PROC ( nom = 'N_PROCESSING_OPTIONS',
137                             op = None,
138                             ang = "Select whether the program should be displaying data about the different categories.\nThe values displayed will be the min, max, and mean of each item, plus a chart.",
139                            Output_bus_values = SIMP(statut = 'o', typ = bool, defaut = True),
140                            Output_lines_values = SIMP(statut = 'o', typ = bool, defaut = True),
141                            Output_transformer_values = SIMP(statut = 'o', typ = bool, defaut = True),
142                            Threshold_selection_for_the_treated_cases = FACT(
143                               statut = 'f',
144                               Branches = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
145                               Transformers = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
146                               High_voltage = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
147                               Low_voltage = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
148                            ),
149                            )
150
151
152 CONTINGENCY_OPTIONS = PROC (nom = 'CONTINGENCY_OPTIONS',
153                             op = None,
154
155                             GeneralOptions = FACT(statut='o',
156                                 Vmin = SIMP(statut = 'o', typ = 'R', defaut = 0.9, val_min = 0),
157                                 Vmax = SIMP(statut = 'o', typ = 'R', defaut = 1.1, val_min = 0),
158                                 ContingencyRate = SIMP(statut = 'o', typ = 'TXM', defaut = 'a', into=['a', 'b']),
159                                 FlowLimitLines = SIMP(statut = 'o', typ = 'I', defaut = 120, val_min = 0),
160                                 FlowLimitTransformers = SIMP(statut = 'o', typ = 'I', defaut = 120, val_min = 0),
161                                 Tolerance = SIMP(statut = 'o', typ = 'R', defaut = 0.5, val_min = 0),
162                                 TripLines = SIMP(statut = 'o', typ = bool, defaut = True),
163                                 TripTransfos = SIMP(statut = 'o', typ = bool, defaut = True),
164                                 TripGenerators = SIMP(statut = 'o', typ = bool, defaut = True),
165                                 TripBuses = SIMP(statut = 'o', typ = bool, defaut = False),
166                                 ),
167
168                             LoadFlowOptions = FACT(statut='o',
169                                 AdjustTaps = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Lock', '1 - Stepping', '2 - Direct'], defaut = '1 - Stepping'),
170                                 AdjustDCtaps = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Enable'], defaut = '1 - Enable'),
171                                 SolutionMethod = SIMP(statut = 'o', typ = 'TXM', into = ['0 - FDNS', '1 - FNSL', '2 - Optimized FDNS'], defaut = '1 - FNSL'),
172                                 AdjustSwitchedShunts = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Enable', '2 - Enable continuous mode'], defaut = '1 - Enable'),
173                                 DispatchMode = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Reserve', '2 - Pmax', '3 - Inertia', '4 - Droop'], defaut = '1 - Reserve'),
174                                 FlatStart = SIMP(statut = 'o', typ = bool, defaut = False),
175                                 VarLimits = SIMP(statut = 'o', typ = 'I', defaut = 99,ang = 'if set to -1, var limits will not be applied'),
176                                 ),
177
178 #                            OutputOptions = FACT(statut='o',
179 #                                consigne1 = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Output PSSE multiple contingency report to Shell?'),
180 #                                MultipleContingencyReport = SIMP(statut = 'o', typ = bool, defaut = True, ang = 'Output PSSE multiple contingency report to Shell?'),
181 #                                consigne2 = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Write an Excel file for the results of each case file?'),
182 #                                WriteIndivExcels = SIMP(statut = 'o', typ = bool, defaut = True),
183 #                                consigne3 = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Add a tab in Excel results file for the differences between the max flow rate (MVAR) and the actual flow rate in lines and transformers?'),
184 #                                WriteFlowDifs = SIMP(statut = 'o', typ = bool, defaut = True),
185 #                            ),
186                         )
187
188
189
190
191 CONTINGENCY_SELECTION = PROC(nom='CONTINGENCY_SELECTION',op = None,
192                       SelectionMethod = SIMP(statut='o',typ='TXM',into=['CaseSelectionFromFile','SelectAllCases','SelectWorstCases'],
193                       ),
194
195                       b_file = BLOC(condition="SelectionMethod=='CaseSelectionFromFile'",
196                       CaseSelectionFromFiles = FACT(
197                            statut = 'o',
198                            case = FACT(statut='o',max='**',
199                                        case_name=SIMP(statut='o',typ='TXM'),
200                                        csv_file= SIMP(statut='o', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)',),),),
201 #                           regles=(AU_MOINS_UN('branch_cases','transformer_cases','high_voltage_cases','low_voltage_cases',),),
202 #                           branch_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
203 #                           transformer_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde',),),
204 #                           high_voltage_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
205 #                           low_voltage_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
206                         ),
207
208 #                      CaseSelectionFromFile = FACT(
209 #                           statut = 'o',
210 #                           input_path = SIMP(statut="o",typ='Repertoire'),
211 #                           branch_cases = SIMP(statut='o', typ='TXM'),
212 #                           transformer_cases = SIMP(statut='o', typ='TXM'),
213 #                           high_cases = SIMP(statut='o', typ='TXM'),
214 #                           low_cases = SIMP(statut='o', typ='TXM'),
215 #                        ),
216
217                         ),
218
219 #                      b_all = BLOC(condition="SelectionMethod=='SelectAllCases'",
220 #                      SelectAllCases = FACT(
221 #                           statut='o',
222 #                           all_cases = SIMP(statut='o', typ=bool, defaut = True),
223 #                         ),
224 #                         ),
225
226                       b_worst = BLOC(condition="SelectionMethod=='SelectWorstCases'",
227                       SelectWorstCases = FACT(
228                           regles = (AU_MOINS_UN('AvgLineLoad', 'AvgLineLoadPercent','AvgTransformerLoad','AvgTransformerLoadPercent','AvgHighVoltage', 'AvgHighVoltagePercent','AvgLowVoltage', 'AvgLowVoltagePercent'),
229                                     EXCLUS('AvgLineLoad', 'AvgLineLoadPercent'),EXCLUS('AvgTransformerLoad','AvgTransformerLoadPercent'),EXCLUS('AvgHighVoltage', 'AvgHighVoltagePercent'),EXCLUS('AvgLowVoltage', 'AvgLowVoltagePercent'),),
230                           statut = 'o',
231                           consigne = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Choose at least one of the potential selection criteria from the SelectWorstCases list on the right.'),
232                           AvgLineLoad = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
233                           AvgLineLoadPercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
234                           AvgTransformerLoad = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
235                           AvgTransformerLoadPercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
236                           AvgHighVoltage = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
237                           AvgHighVoltagePercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
238                           AvgLowVoltage = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
239                           AvgLowVoltagePercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
240                         ),
241                         ),
242
243
244                       Automatic_N_2_Selection = FACT(statut='f',
245
246                           BusesList = SIMP(statut = 'o', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
247                           LinesList = SIMP(statut = 'o', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
248                           TransformersList = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
249                         ),
250
251                      MultipleContingencyList = FACT (statut='f',
252                                                           max="**",
253                                                           ComponentList=SIMP(statut='o', typ = 'TXM', max='**', homo = 'SansOrdreNiDoublon',),
254                      ),
255
256                       )
257
258 CONTINGENCY_PROCESSING = MACRO ( nom = 'CONTINGENCY_PROCESSING',
259                         sd_prod = opsPSEN_N1.PROCESS,
260                         op_init = opsPSEN_N1.PROCESS_context,
261
262                         #sd_prod=None,
263
264                         op = None,
265                         fichier_ini = 1,
266                         fr = "",
267                         ang="",
268                         XLS_file = SIMP(statut="o", typ = ('Fichier', 'XLS file (*.xls);;All Files (*)',),),
269                         b_TabList = BLOC(condition="XLS_file != None and XLS_file != ''",
270                             TabList = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'), ),
271
272 #                        b_highVoltage = BLOC(condition="'High Voltage 0' in TabList",
273 #                                                     HighVoltageBuses = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
274 #                                                     HighVoltageContingencies = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
275 #                                                     ),
276
277                     )
278
279 Ordre_Des_Commandes = ('CASE_SELECTION' , 'N_PROCESSING_OPTIONS' , 'CONTINGENCY_SELECTION', 'CONTINGENCY_OPTIONS' ,'CONTINGENCY_PROCESSING',)
280 Classement_Commandes_Ds_Arbre = ('CASE_SELECTION' , 'N_PROCESSING_OPTIONS' , 'CONTINGENCY_SELECTION', 'CONTINGENCY_OPTIONS' ,'CONTINGENCY_PROCESSING',)