Salome HOME
Merge branch 'master' into V9_merge
[tools/eficas.git] / OldCodes / ProcessOutputs_Eficas / PSEN_Cata_N1.py.ok
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 #
29 #
30
31 # import types
32 class Tuple:
33    def __init__(self,ntuple):
34      self.ntuple=ntuple
35
36    def __convert__(self,valeur):
37      if type(valeur) == types.StringType:
38        return None
39      if len(valeur) != self.ntuple:
40        return None
41      return valeur
42
43    def info(self):
44      return "Tuple de %s elements" % self.ntuple
45
46    __repr__=info
47    __str__=info
48
49 # class Matrice:
50 #   def __init__(self,nbLigs=None,nbCols=None,methodeCalculTaille=None,formatSortie="ligne",valSup=None,valMin=None,structure=None):
51 #       self.nbLigs=nbLigs
52 #       self.nbCols=nbCols
53 #       self.methodeCalculTaille=methodeCalculTaille
54 #       self.formatSortie=formatSortie
55 #       self.valSup=valSup
56 #       self.valMin=valMin
57 #       self.structure=structure
58 #
59 #   def __convert__(self,valeur):
60 #     # Attention ne verifie pas grand chose
61 #     if type(valeur) != types.ListType :
62 #       return None
63 #     return valeur
64 #
65 #   def info(self):
66 #       return "Matrice %s x %s" % (self.nbLigs, self.nbCols)
67 #
68 #       __repr__=info
69 #       __str__=info
70
71
72 #CONTEXT.debug = 1
73 JdC = JDC_CATA ( code = 'PSEN',
74                  execmodul = None,
75                  regles = ( AU_MOINS_UN ( 'CASE_SELECTION' ),
76                             # AU_MOINS_UN ( 'DIRECTORY' ),
77                             # AU_MOINS_UN ( 'DISTRIBUTION' ),
78                             # AU_MOINS_UN ( 'SIMULATION' ),
79                             # AU_PLUS_UN ( 'PSSE_PARAMETERS' ),
80                             # AU_PLUS_UN ( 'DIRECTORY' ),
81                             # AU_PLUS_UN ( 'SIMULATION' ),
82                             # AU_PLUS_UN ( 'CORRELATION' ),
83                             # AU_PLUS_UN ( 'N_1_GENERATORS' ),
84                             # AU_PLUS_UN ( 'N_1_LINES' ),
85                             # AU_PLUS_UN ( 'N_1_LOADS' ),
86                             # AU_PLUS_UN ( 'N_1_TRANSFORMERS' ),
87
88                             ),
89                  ) # Fin JDC_CATA
90
91
92 # --------------------------------------------------
93 # fin entete
94 # --------------------------------------------------
95 ## TODO : RUN
96 CASE_SELECTION = MACRO ( nom = "CASE_SELECTION",
97                       sd_prod = opsPSEN_N1.INCLUDE,
98                       op_init = opsPSEN_N1.INCLUDE_context,
99                       fichier_ini = 1,
100                       op = None,
101                       fr = "Sélectionnez les cas à analyser",
102                       ang = 'Select the cases to analyze',
103                       PSSE_path = SIMP(statut="o",typ='Repertoire',defaut='C:\Program Files (x86)\PTI\PSSE33\PSSBIN'),
104                       output_folder = SIMP(statut="o", typ="Repertoire"),
105
106
107                       BusesList = SIMP(statut = 'f', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
108                       LinesList = SIMP(statut = 'f', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
109                       TransformersList = SIMP(statut = 'f', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
110                       MaxDepth = SIMP(statut = 'o', typ = 'I', defaut = 5),
111                       OutputNewCsv = SIMP ( statut = "o",typ=bool,defaut=False,),
112                  )
113 N_PROCESSING_OPTIONS = PROC ( nom = 'N_PROCESSING_OPTIONS',
114                             op = None,
115                             ang = "Select whether the program should be displaying data ablout the different categories. The values displayed will be the min, max, and mean of each item, plus a chart.",  
116                            Output_bus_values = SIMP(statut = 'o', typ = bool, defaut = True),
117                            Output_lines_values = SIMP(statut = 'o', typ = bool, defaut = True),
118                            Output_transformer_values = SIMP(statut = 'o', typ = bool, defaut = True),
119                            Threshold_selection_for_the_treated_cases = FACT(
120                               statut = 'f',
121                               Branches = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
122                               Transformers = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
123                               High_voltage = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
124                               Low_voltage = SIMP(statut="o",typ=Tuple(3),defaut=(0,0,0),validators=VerifTypeTuple(('R','R','R'),),),
125                            ),
126                            )
127
128
129 CONTINGENCY_OPTIONS = PROC (nom = 'CONTINGENCY_OPTIONS',
130                             op = None,
131                             
132                             GeneralOptions = FACT(statut='o',
133                                 Vmin = SIMP(statut = 'o', typ = 'R', defaut = 0.9, val_min = 0),
134                                 Vmax = SIMP(statut = 'o', typ = 'R', defaut = 1.1, val_min = 0),
135                                 ContingencyRate = SIMP(statut = 'o', typ = 'TXM', defaut = 'a', into=['a', 'b']),
136                                 FlowLimitLines = SIMP(statut = 'o', typ = 'I', defaut = 120, val_min = 0),
137                                 FlowLimitTransformers = SIMP(statut = 'o', typ = 'I', defaut = 120, val_min = 0),
138                                 Tolerance = SIMP(statut = 'o', typ = 'R', defaut = 0.5, val_min = 0),
139                                 TripLines = SIMP(statut = 'o', typ = bool, defaut = True),
140                                 TripTransfos = SIMP(statut = 'o', typ = bool, defaut = True),
141                                 TripGenerators = SIMP(statut = 'o', typ = bool, defaut = True),
142                                 ),                            
143
144                             LoadFlowOptions = FACT(statut='o',
145                                 AdjustTaps = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Lock', '1 - Stepping', '2 - Direct'], defaut = '1 - Stepping'),
146                                 AdjustDCtaps = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Enable'], defaut = '1 - Enable'),
147                                 SolutionMethod = SIMP(statut = 'o', typ = 'TXM', into = ['0 - FDNS', '1 - FNSL', '2 - Optimized FDNS'], defaut = '1 - FNSL'),
148                                 AdjustSwitchedShunts = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Enable', '2 - Enable continuous mode'], defaut = '1 - Enable'),
149                                 DispatchMode = SIMP(statut = 'o', typ = 'TXM', into = ['0 - Disable', '1 - Reserve', '2 - Pmax', '3 - Inertia', '4 - Droop'], defaut = '1 - Reserve'),
150                                 FlatStart = SIMP(statut = 'o', typ = bool, defaut = False),
151                                 VarLimits = SIMP(statut = 'o', typ = 'I', defaut = 99,ang = 'if set to -1, var limits will not be applied'),
152                                 ),
153                             
154                             OutputOptions = FACT(statut='o',
155                                 consigne1 = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Output PSSE multiple contingency report to Shell?'),
156                                 MultipleContingencyReport = SIMP(statut = 'o', typ = bool, defaut = True, ang = 'Output PSSE multiple contingency report to Shell?'),
157                                 consigne2 = SIMP(statut='o',homo='information',typ = "TXM",defaut = 'Write an Excel file for the results of each case file?'),
158                                 WriteIndivExcels = SIMP(statut = 'o', typ = bool, defaut = True),
159                                 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?'),
160                                 WriteFlowDifs = SIMP(statut = 'o', typ = bool, defaut = True),                            
161                             ),
162                         )
163
164
165
166
167 CONTINGENCY_SELECTION = PROC(nom='CONTINGENCY_SELECTION',op = None,
168                       SelectionMethod = SIMP(statut='o',typ='TXM',into=['CaseSelectionFromFile','SelectAllCases','SelectWorstCases'],
169                       ),
170                       
171                       b_file = BLOC(condition="SelectionMethod=='CaseSelectionFromFile'",
172                       CaseSelectionFromFiles = FACT(
173                            statut = 'o',
174                            regles=(AU_MOINS_UN('branch_cases','transformer_cases','high_voltage_cases','low_voltage_cases',),),
175                            branch_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
176                            transformer_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde',),),
177                            high_voltage_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
178                            low_voltage_cases = SIMP(statut='o', defaut='', typ = ('Fichier', 'CSV file (*.csv);;All Files (*)','Sauvegarde'),),
179                         ),
180                         
181 #                      CaseSelectionFromFile = FACT(
182 #                           statut = 'o',
183 #                           input_path = SIMP(statut="o",typ='Repertoire'),
184 #                           branch_cases = SIMP(statut='o', typ='TXM'),
185 #                           transformer_cases = SIMP(statut='o', typ='TXM'),
186 #                           high_cases = SIMP(statut='o', typ='TXM'),
187 #                           low_cases = SIMP(statut='o', typ='TXM'),
188 #                        ),
189                         
190                         ),
191                         
192 #                      b_all = BLOC(condition="SelectionMethod=='SelectAllCases'",
193 #                      SelectAllCases = FACT(
194 #                           statut='o',
195 #                           all_cases = SIMP(statut='o', typ=bool, defaut = True),
196 #                         ),
197 #                         ),
198                          
199                       b_worst = BLOC(condition="SelectionMethod=='SelectWorstCases'",
200                       SelectWorstCases = FACT(
201                           regles = (UN_PARMI('AvgBranchLoad', 'AvgBranchLoadPercent'), UN_PARMI('AvgTransformerLoad', 'AvgTransformerLoadPercent'), UN_PARMI('AvgHighVoltage', 'AvgHighVoltagePercent'), UN_PARMI('AvgLowVoltage', 'AvgLowVoltagePercent'),),
202                           statut = 'o',
203                           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.'),
204                           AvgBranchLoad = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
205                           AvgBranchLoadPercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
206                           AvgTransformerLoad = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
207                           AvgTransformerLoadPercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
208                           AvgHighVoltage = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
209                           AvgHighVoltagePercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
210                           AvgLowVoltage = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0),
211                           AvgLowVoltagePercent = SIMP(statut = 'f', typ = 'I', defaut = 0, val_min = 0, val_max = 100),
212                         ),
213                         ),
214
215
216                       Automatic_N_2_Selection = FACT(statut='f',
217                                                      
218                           BusesList = SIMP(statut = 'o', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
219                           LinesList = SIMP(statut = 'o', typ = 'R', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
220                           TransformersList = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),                                                    
221                         ),
222
223                      MultipleContingencyList = FACT (statut='f',
224                                                           max="**",
225                                                           ComponentList=SIMP(statut='o', typ = 'TXM', max='**', homo = 'SansOrdreNiDoublon',),
226                      ),
227
228                       )
229
230 CONTINGENCY_PROCESSING = MACRO ( nom = 'CONTINGENCY_PROCESSING',
231                         sd_prod = opsPSEN_N1.PROCESS,
232                         op_init = opsPSEN_N1.PROCESS_context,
233                                                 
234                         #sd_prod=None,
235
236                         op = None,
237                         fichier_ini = 1,
238                         fr = "",
239                         ang="",
240                         XLS_file = SIMP(statut="o", typ = ('Fichier', 'XLS file (*.xls);;All Files (*)',),),
241                         TabList = SIMP(statut = 'f', typ = 'TXM', min = 0, max = '**',  homo = 'SansOrdreNiDoublon'), 
242                         
243 #                        b_highVoltage = BLOC(condition="'High Voltage 0' in TabList",
244 #                                                     HighVoltageBuses = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
245 #                                                     HighVoltageContingencies = SIMP(statut = 'o', typ = 'TXM', min = 0, max = '**', defaut = (), homo = 'SansOrdreNiDoublon'),
246 #                                                     ),
247                         
248                     )
249
250 Ordre_Des_Commandes = ('CASE_SELECTION' , 'N_PROCESSING_OPTIONS' , 'CONTINGENCY_OPTIONS' , 'CONTINGENCY_SELECTION',)