-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconstants.py
More file actions
369 lines (337 loc) · 10.9 KB
/
Copy pathconstants.py
File metadata and controls
369 lines (337 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
"""
General Constants
=================
"""
import os
import pandas as pd
from copy import deepcopy
from multi_vector_simulator.utils.constants_json_strings import *
# path to the root of this repository (assumes this file is in src/mvs_eland/utils folder)
REPO_PATH = os.path.abspath(os.path.curdir)
PACKAGE_DATA_PATH = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "package_data"
)
# name of the default input folder
INPUT_FOLDER = "inputs"
# name of the template input folder
TEMPLATE_INPUT_FOLDER = "input_template"
# name of the json extension
JSON_EXT = "json"
# name of the csv extension
CSV_EXT = "csv"
# name of the folder containing mvs model described by .csv files
CSV_ELEMENTS = "csv_elements"
# name of the json file which should be present in the input folder if option -i json was chosen
MVS_CONFIG = "mvs_config"
JSON_FNAME = MVS_CONFIG + ".json"
# name of the json file which is should be created in the input folder if option -i csv was chosen
CSV_FNAME = "mvs_csv_config.json"
# allowed symbols for separating values in .csv files
CSV_SEPARATORS = (",", ";", "&")
# name of the folder containing timeseries described by .csv files
TIME_SERIES = "time_series"
# name of the folder containing the output of the simulation
OUTPUT_FOLDER = "MVS_outputs"
# name of the folder containing the copied content of the input folder within the output folder
INPUTS_COPY = INPUT_FOLDER
# name of the MVS log file
LOGFILE = "mvs_logfile.log"
# name of the automatically generated pdf report
PDF_REPORT = "simulation_report.pdf"
# name of lp file stored to dick
LP_FILE = "lp_file.lp"
# path of the pdf report path
REPORT_FOLDER = "report"
ASSET_FOLDER = "assets"
# variables used for the pdf report parser
ARG_PDF = "print_report"
ARG_REPORT_PATH = "report_path"
ARG_PATH_SIM_OUTPUT = "output_folder"
ARG_DEBUG_REPORT = "debug_report"
# default paths to input, output and sequences folders
DEFAULT_INPUT_PATH = os.path.join(REPO_PATH, INPUT_FOLDER)
DEFAULT_OUTPUT_PATH = os.path.join(REPO_PATH, OUTPUT_FOLDER)
PATH_INPUT_FILE = "path_input_file"
PATH_INPUT_FOLDER = "path_input_folder"
PATH_OUTPUT_FOLDER = "path_output_folder"
PATH_OUTPUT_FOLDER_INPUTS = "path_output_folder_inputs"
INPUT_TYPE = "input_type"
OVERWRITE = "overwrite"
DISPLAY_OUTPUT = "display_output"
SAVE_PNG = "save_png"
# Filenames of the json files stored to disc:
JSON_PROCESSED = "json_input_processed"
JSON_WITH_RESULTS = "json_with_results"
JSON_FILE_EXTENSION = ".json"
USER_INPUT_ARGUMENTS = (
PATH_INPUT_FILE,
PATH_INPUT_FOLDER,
PATH_OUTPUT_FOLDER,
INPUT_TYPE,
OVERWRITE,
DISPLAY_OUTPUT,
)
DEFAULT_MAIN_KWARGS = dict(
overwrite=False,
pdf_report=False,
save_png=False,
input_type=JSON_EXT,
path_input_folder=DEFAULT_INPUT_PATH,
path_output_folder=DEFAULT_OUTPUT_PATH,
display_output="info",
lp_file_output=False,
)
# list of csv filename which must be present within the CSV_ELEMENTS folder with the parameters
# associated to each of these filenames
REQUIRED_CSV_PARAMETERS = {
CONSTRAINTS: [MINIMAL_RENEWABLE_FACTOR, MAXIMUM_EMISSIONS],
ENERGY_BUSSES: [ENERGY_VECTOR],
ENERGY_CONSUMPTION: [
# DSM,
FILENAME,
# TYPE_ASSET,
OEMOF_ASSET_TYPE,
ENERGY_VECTOR,
INFLOW_DIRECTION,
UNIT,
],
ENERGY_CONVERSION: [
AGE_INSTALLED,
DEVELOPMENT_COSTS,
SPECIFIC_COSTS,
EFFICIENCY,
INFLOW_DIRECTION,
INSTALLED_CAP,
LIFETIME,
SPECIFIC_COSTS_OM,
DISPATCH_PRICE,
OPTIMIZE_CAP,
OUTFLOW_DIRECTION,
OEMOF_ASSET_TYPE,
ENERGY_VECTOR,
UNIT,
],
ENERGY_STORAGE: [
INFLOW_DIRECTION,
OPTIMIZE_CAP,
OUTFLOW_DIRECTION,
LABEL,
OEMOF_ASSET_TYPE,
STORAGE_FILENAME,
ENERGY_VECTOR,
],
ENERGY_PRODUCTION: [
AGE_INSTALLED,
DEVELOPMENT_COSTS,
SPECIFIC_COSTS,
FILENAME,
INSTALLED_CAP,
LIFETIME,
SPECIFIC_COSTS_OM,
DISPATCH_PRICE,
OPTIMIZE_CAP,
OUTFLOW_DIRECTION,
OEMOF_ASSET_TYPE,
UNIT,
ENERGY_VECTOR,
EMISSION_FACTOR,
],
ENERGY_PROVIDERS: [
ENERGY_PRICE,
FEEDIN_TARIFF,
INFLOW_DIRECTION,
OPTIMIZE_CAP,
OUTFLOW_DIRECTION,
PEAK_DEMAND_PRICING,
PEAK_DEMAND_PRICING_PERIOD,
OEMOF_ASSET_TYPE,
ENERGY_VECTOR,
EMISSION_FACTOR,
],
FIX_COST: [
AGE_INSTALLED,
DEVELOPMENT_COSTS,
SPECIFIC_COSTS,
LIFETIME,
SPECIFIC_COSTS_OM,
],
SIMULATION_SETTINGS: [
EVALUATED_PERIOD,
OUTPUT_LP_FILE,
START_DATE,
TIMESTEP,
],
PROJECT_DATA: [
COUNTRY,
LATITUDE,
LONGITUDE,
PROJECT_ID,
PROJECT_NAME,
SCENARIO_ID,
SCENARIO_NAME,
SCENARIO_DESCRIPTION,
],
ECONOMIC_DATA: [
CURR,
DISCOUNTFACTOR,
PROJECT_DURATION,
TAX,
],
}
# list of csv filename which must be present within the CSV_ELEMENTS folder
REQUIRED_CSV_FILES = tuple(REQUIRED_CSV_PARAMETERS.keys())
# list of parameters which must be present within the JSON_FNAME file with the sub-parameters
# note: if the value of a key is none, then the value is expected to be user-defined and thus cannot
# be in a required parameters dict
REQUIRED_JSON_PARAMETERS = deepcopy(REQUIRED_CSV_PARAMETERS)
REQUIRED_JSON_PARAMETERS[FIX_COST] = None
REQUIRED_JSON_PARAMETERS[ENERGY_CONSUMPTION].remove(FILENAME)
REQUIRED_JSON_PARAMETERS[ENERGY_PRODUCTION].remove(FILENAME)
REQUIRED_JSON_PARAMETERS[ENERGY_STORAGE].remove(STORAGE_FILENAME)
# references for which parameters must be present either in the json or csv input method
REQUIRED_MVS_PARAMETERS = {
JSON_EXT: REQUIRED_JSON_PARAMETERS,
CSV_EXT: REQUIRED_CSV_PARAMETERS,
}
MISSING_PARAMETERS_KEY = "missing_parameters"
EXTRA_PARAMETERS_KEY = "extra_parameters"
DEFAULT_CONSTRAINT_VALUES = {
MINIMAL_RENEWABLE_FACTOR: {UNIT: "factor", VALUE: 0},
MAXIMUM_EMISSIONS: {UNIT: "factor", VALUE: None},
MINIMAL_DEGREE_OF_AUTONOMY: {UNIT: "factor", VALUE: 0},
NET_ZERO_ENERGY: {UNIT: "bool", VALUE: False},
}
# Instroducting new parameters (later to be merged into list ll.77)
WARNING_TEXT = "warning_text"
REQUIRED_IN_CSV_ELEMENTS = "required in files"
DEFAULT_VALUE = "default"
# name of the key linking to the special type of data in a json object
DATA_TYPE_JSON_KEY = "data_type"
# possible type of variable stored into the json file
TYPE_DATETIMEINDEX = "pandas_DatetimeIndex"
TYPE_SERIES = "pandas_Series"
TYPE_DATAFRAME = "pandas_Dataframe"
TYPE_NDARRAY = "numpy_ndarray"
TYPE_TIMESTAMP = "pandas_Timestamp"
TYPE_BOOL = "bool"
TYPE_INT64 = "numpy_int64"
TYPE_STR = "str"
TYPE_NONE = "None"
TYPE_FLOAT = "float"
KNOWN_EXTRA_PARAMETERS = {
UNIT: {
DEFAULT_VALUE: "NA",
UNIT: TYPE_STR,
WARNING_TEXT: "defines the unit of power provided by a DSO (Values: str). ",
REQUIRED_IN_CSV_ELEMENTS: [ENERGY_PROVIDERS],
},
MAXIMUM_CAP: {
DEFAULT_VALUE: None,
UNIT: TYPE_NONE,
WARNING_TEXT: "allows setting a maximum capacity for an asset that is being capacity optimized (Values: None/Float). ",
REQUIRED_IN_CSV_ELEMENTS: [ENERGY_CONVERSION, ENERGY_PRODUCTION],
},
DSO_FEEDIN_CAP: {
DEFAULT_VALUE: None,
UNIT: TYPE_NONE,
WARNING_TEXT: "allows setting a maximum capacity for DSO feedin (Values: None/Float). ",
REQUIRED_IN_CSV_ELEMENTS: [ENERGY_PROVIDERS],
},
RENEWABLE_ASSET_BOOL: {
DEFAULT_VALUE: False,
UNIT: TYPE_BOOL,
WARNING_TEXT: "allows defining a energyProduction asset as either renewable (True) or non-renewable (False) source. ",
REQUIRED_IN_CSV_ELEMENTS: [ENERGY_PRODUCTION],
},
RENEWABLE_SHARE_DSO: {
DEFAULT_VALUE: 0,
UNIT: TYPE_FLOAT,
WARNING_TEXT: "allows defining the renewable share of the DSO supply (Values: Float). ",
REQUIRED_IN_CSV_ELEMENTS: [ENERGY_PROVIDERS],
},
EMISSION_FACTOR: {
DEFAULT_VALUE: 0,
UNIT: TYPE_FLOAT,
WARNING_TEXT: "allows calculating the total emissions of the energy system (Values: Float). ",
REQUIRED_IN_CSV_ELEMENTS: [
ENERGY_PRODUCTION,
ENERGY_PROVIDERS,
],
},
MAXIMUM_EMISSIONS: {
DEFAULT_VALUE: DEFAULT_CONSTRAINT_VALUES[MAXIMUM_EMISSIONS][VALUE],
UNIT: TYPE_NONE,
WARNING_TEXT: "allows setting a maximum amount of emissions of the optimized energy system (Values: None/Float). ",
REQUIRED_IN_CSV_ELEMENTS: [
CONSTRAINTS,
],
},
MINIMAL_DEGREE_OF_AUTONOMY: {
DEFAULT_VALUE: DEFAULT_CONSTRAINT_VALUES[MINIMAL_DEGREE_OF_AUTONOMY][VALUE],
UNIT: TYPE_FLOAT,
WARNING_TEXT: "allows setting a minimum degree of autonomy of the optimized energy system (Values: Float). ",
REQUIRED_IN_CSV_ELEMENTS: [
CONSTRAINTS,
],
},
SCENARIO_DESCRIPTION: {
DEFAULT_VALUE: "",
UNIT: TYPE_STR,
WARNING_TEXT: "allows giving a description for the scenario being simulated",
REQUIRED_IN_CSV_ELEMENTS: [PROJECT_DATA],
},
NET_ZERO_ENERGY: {
DEFAULT_VALUE: DEFAULT_CONSTRAINT_VALUES[NET_ZERO_ENERGY][VALUE],
UNIT: TYPE_BOOL,
WARNING_TEXT: "allows to add a net zero energy constraint to optimization problem (activate by setting to `True`). ",
REQUIRED_IN_CSV_ELEMENTS: [
CONSTRAINTS,
],
},
}
WEIGHTS_ENERGY_CARRIER = "weights_energy_carrier"
try:
energy_carriers_file = "energy_co2_conversion_factors.csv"
FILE_PATH = os.path.join(
os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
),
"docs",
)
if os.path.exists(FILE_PATH):
FILE_PATH = PACKAGE_DATA_PATH
df = pd.read_csv(
os.path.join(FILE_PATH, "energy_co2_conversion_factors.csv"), index_col=0
)
DEFAULT_WEIGHTS_ENERGY_CARRIERS = df.to_dict(orient="index")
except FileNotFoundError:
DEFAULT_WEIGHTS_ENERGY_CARRIERS = None
# dict keys in results_json file
TIMESERIES = "timeseries"
# filename of the energy system graph
ES_GRAPH = "energy_system_graph.png"
# key of the dict containing generated plots filesnames in results_json file
PATHS_TO_PLOTS = "paths_to_plots"
# keys' names of dict containing generated plots filenames
PLOTS_DEMANDS = "demands"
PLOTS_RESOURCES = "resources"
PLOTS_ES = "graphviz"
PLOTS_PERFORMANCE = "performance"
PLOTS_COSTS = "costs"
PLOTS_BUSSES = "flows_on_busses"
PLOT_SANKEY = "sankey"
# structure of the dict containing generated plots filenames in results_json file
DICT_PLOTS = {
PATHS_TO_PLOTS: {
PLOTS_BUSSES: [],
PLOTS_DEMANDS: [],
PLOTS_RESOURCES: [],
PLOTS_ES: "",
PLOTS_PERFORMANCE: [],
PLOTS_COSTS: [],
}
}
# Reading data from csv file
HEADER = "header"
# suffixes
SOC = "SOC"