psr-factory 5.0.0b10__py3-none-win_amd64.whl → 5.0.0b12__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- psr/cloud/cloud.py +15 -7
- psr/cloud/data.py +3 -1
- psr/cloud/version.py +1 -1
- psr/execqueue/client.py +113 -0
- psr/execqueue/config.py +44 -0
- psr/execqueue/db.py +220 -0
- psr/execqueue/server.py +383 -0
- psr/execqueue/watcher.py +124 -0
- psr/factory/__init__.py +1 -1
- psr/factory/api.py +48 -17
- psr/factory/factory.dll +0 -0
- psr/factory/factory.pmd +10 -0
- psr/factory/factory.pmk +14 -12
- psr/factory/factorylib.py +8 -4
- psr/factory/libcurl-x64.dll +0 -0
- psr/factory/samples/sddp_case01.py +8 -10
- psr/runner/runner.py +1 -1
- psr_factory-5.0.0b12.dist-info/METADATA +56 -0
- psr_factory-5.0.0b12.dist-info/RECORD +40 -0
- psr/factory/samples/sddp_sample_case01.py +0 -164
- psr/factory/samples/sddp_sample_case21.py +0 -241
- psr_factory-5.0.0b10.dist-info/METADATA +0 -110
- psr_factory-5.0.0b10.dist-info/RECORD +0 -37
- {psr_factory-5.0.0b10.dist-info → psr_factory-5.0.0b12.dist-info}/WHEEL +0 -0
- {psr_factory-5.0.0b10.dist-info → psr_factory-5.0.0b12.dist-info}/licenses/LICENSE.txt +0 -0
- {psr_factory-5.0.0b10.dist-info → psr_factory-5.0.0b12.dist-info}/top_level.txt +0 -0
psr/factory/factorylib.py
CHANGED
@@ -49,8 +49,12 @@ def initialize():
|
|
49
49
|
lib.psrd_set_log_level.argtypes = [ctypes.c_long]
|
50
50
|
lib.psrd_get_log_level.restype = ctypes.c_int
|
51
51
|
lib.psrd_get_log_level.argtypes = [ctypes.POINTER(ctypes.c_long)]
|
52
|
-
lib.
|
53
|
-
lib.
|
52
|
+
lib.psrd_get_log_file_path.restype = ctypes.c_int
|
53
|
+
lib.psrd_get_log_file_path.argtypes = [ctypes.c_char_p, ctypes.c_long, ctypes.c_void_p]
|
54
|
+
lib.psrd_set_diagnostics_mode.restype = ctypes.c_int
|
55
|
+
lib.psrd_set_diagnostics_mode.argtypes = [ctypes.c_long]
|
56
|
+
lib.psrd_diagnostics.restype = ctypes.c_int
|
57
|
+
lib.psrd_diagnostics.argtypes = [ctypes.c_char_p, ctypes.c_long, ctypes.c_char_p, ctypes.c_long, ctypes.c_void_p]
|
54
58
|
lib.psrd_get_default_context.restype = ctypes.c_void_p
|
55
59
|
lib.psrd_get_default_context.argtypes = [ctypes.c_void_p]
|
56
60
|
lib.psrd_new_error.restype = ctypes.c_void_p
|
@@ -321,8 +325,8 @@ def initialize():
|
|
321
325
|
lib.psrd_table_column_set_float32_values.argtypes = [ctypes.c_void_p, ctypes.c_long, ctypes.POINTER(ctypes.c_float), ctypes.c_void_p]
|
322
326
|
lib.psrd_table_column_set_float64_values.restype = ctypes.c_int
|
323
327
|
lib.psrd_table_column_set_float64_values.argtypes = [ctypes.c_void_p, ctypes.c_long, ctypes.POINTER(ctypes.c_double), ctypes.c_void_p]
|
324
|
-
lib.
|
325
|
-
lib.
|
328
|
+
lib.psrd_table_column_set_int32_values.restype = ctypes.c_int
|
329
|
+
lib.psrd_table_column_set_int32_values.argtypes = [ctypes.c_void_p, ctypes.c_long, ctypes.POINTER(ctypes.c_int), ctypes.c_void_p]
|
326
330
|
lib.psrd_table_column_set_date_values.restype = ctypes.c_int
|
327
331
|
lib.psrd_table_column_set_date_values.argtypes = [ctypes.c_void_p, ctypes.c_long, ctypes.POINTER(ctypes.c_longlong), ctypes.c_void_p]
|
328
332
|
lib.psrd_table_column_set_null_values.restype = ctypes.c_int
|
psr/factory/libcurl-x64.dll
CHANGED
Binary file
|
@@ -142,16 +142,14 @@ def create_case01(legacy: bool) -> psr.factory.Study:
|
|
142
142
|
plant3 = plant2.clone()
|
143
143
|
plant3.code = 3
|
144
144
|
plant3.name = "Thermal 3"
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
# })
|
154
|
-
# study.add(plant3)
|
145
|
+
plant3.from_dict({
|
146
|
+
"MaximumGenerationCapacity": 20.0,
|
147
|
+
"InstalledCapacity": 20.0,
|
148
|
+
"SpecificConsumption(1:3,1)": 12.5,
|
149
|
+
"RefFuels": [fuel2, ],
|
150
|
+
"RefSystem": system,
|
151
|
+
})
|
152
|
+
study.add(plant3)
|
155
153
|
|
156
154
|
return study
|
157
155
|
|
psr/runner/runner.py
CHANGED
@@ -326,7 +326,7 @@ def run_psrio(case_path, sddp_path: str, **kwargs):
|
|
326
326
|
for path in case_paths:
|
327
327
|
cmd += f' "{path}"'
|
328
328
|
|
329
|
-
|
329
|
+
exec_cmd(cmd, **kwargs)
|
330
330
|
|
331
331
|
def run_nwsddp(input_case_path: Union[str, pathlib.Path], output_case_path: Union[str, pathlib.Path], nwsddp_app_path: Union[str, pathlib.Path], mdc_file_path: Optional[Union[str, pathlib.Path]] = None, **kwargs):
|
332
332
|
if os.name != 'nt':
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: psr-factory
|
3
|
+
Version: 5.0.0b12
|
4
|
+
Summary: PSR database management module.
|
5
|
+
Author-email: "PSR Inc." <psrfactory@psr-inc.com>
|
6
|
+
License-Expression: MIT
|
7
|
+
Project-URL: documentation, https://docs.psr-inc.com/factory/
|
8
|
+
Keywords: psr,factory,sddp
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
10
|
+
Classifier: Programming Language :: C
|
11
|
+
Classifier: Programming Language :: C++
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
|
+
Classifier: Topic :: Software Development
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
20
|
+
Classifier: Operating System :: Microsoft :: Windows
|
21
|
+
Classifier: Operating System :: POSIX :: Linux
|
22
|
+
Requires-Python: >=3.9
|
23
|
+
Description-Content-Type: text/markdown
|
24
|
+
License-File: LICENSE.txt
|
25
|
+
Requires-Dist: numpy
|
26
|
+
Provides-Extra: pandas
|
27
|
+
Requires-Dist: pandas; extra == "pandas"
|
28
|
+
Provides-Extra: polars
|
29
|
+
Requires-Dist: polars; extra == "polars"
|
30
|
+
Provides-Extra: cloud
|
31
|
+
Requires-Dist: zeep; extra == "cloud"
|
32
|
+
Requires-Dist: filelock; extra == "cloud"
|
33
|
+
Requires-Dist: pefile; extra == "cloud"
|
34
|
+
Requires-Dist: boto3; extra == "cloud"
|
35
|
+
Requires-Dist: botocore; extra == "cloud"
|
36
|
+
Provides-Extra: execqueue-client
|
37
|
+
Requires-Dist: requests; extra == "execqueue-client"
|
38
|
+
Provides-Extra: execqueue-server
|
39
|
+
Requires-Dist: DateTime; extra == "execqueue-server"
|
40
|
+
Requires-Dist: Flask; extra == "execqueue-server"
|
41
|
+
Requires-Dist: python-ulid; extra == "execqueue-server"
|
42
|
+
Requires-Dist: sqlalchemy; extra == "execqueue-server"
|
43
|
+
Requires-Dist: python-dotenv; extra == "execqueue-server"
|
44
|
+
Requires-Dist: pefile; extra == "execqueue-server"
|
45
|
+
Requires-Dist: zeep; extra == "execqueue-server"
|
46
|
+
Requires-Dist: filelock; extra == "execqueue-server"
|
47
|
+
Requires-Dist: requests; extra == "execqueue-server"
|
48
|
+
Provides-Extra: all
|
49
|
+
Requires-Dist: pandas; extra == "all"
|
50
|
+
Requires-Dist: polars; extra == "all"
|
51
|
+
Requires-Dist: zeep; extra == "all"
|
52
|
+
Requires-Dist: filelock; extra == "all"
|
53
|
+
Requires-Dist: pefile; extra == "all"
|
54
|
+
Requires-Dist: boto3; extra == "all"
|
55
|
+
Requires-Dist: botocore; extra == "all"
|
56
|
+
Dynamic: license-file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
psr/apps/__init__.py,sha256=frSq1WIy5vIdU21xJIGX7U3XoAZRj0pcQmFb-R00b7I,228
|
2
|
+
psr/apps/apps.py,sha256=V8Ewht7P1I-3sSkV3dnbxbLjF2slxPjcmtzmVaLjiNY,6746
|
3
|
+
psr/apps/version.py,sha256=vs459L6JsatAkUxna7BNG-vMCaXpO1Ye8c1bmkEx4U4,194
|
4
|
+
psr/cloud/__init__.py,sha256=inZMwG7O9Fca9hg1BhqYObOYtTTJOkpuTIuXnkHJZkI,246
|
5
|
+
psr/cloud/aws.py,sha256=ro8kBNVxpGDXgZ5haceqX-MAD-0F5KFDJJ4M6rRvwS8,9915
|
6
|
+
psr/cloud/cloud.py,sha256=-FPFqoz2ZRgVH-0A3krU_uqyjr6ZQgvVp72OcVb7ucM,59124
|
7
|
+
psr/cloud/data.py,sha256=oDJyzcNsA7aAYi_qJKCUjCeGZvN-25E8KjZ-5RamNLE,4160
|
8
|
+
psr/cloud/desktop.py,sha256=JFroCMEFV1Nz3has74n7OVrGCg2lS7Ev5bcjdw2hRxY,2980
|
9
|
+
psr/cloud/log.py,sha256=Dvhz1enIWlFWeaRK7JAAuZVPfODgoEIRNcHEmbEliyQ,1366
|
10
|
+
psr/cloud/status.py,sha256=vcI4B9S6wCt9maT5NNrVwYaEgGIvy6kkC1UVpJjYbtw,3607
|
11
|
+
psr/cloud/tempfile.py,sha256=1IOeye0eKWnmBynK5K5FMWiTaEVhn4GbQ8_y0THEva0,3893
|
12
|
+
psr/cloud/version.py,sha256=BzGWSMATFzwqIImjI9tOIqJ0T3Cm-VYA3gafwqvYtAk,192
|
13
|
+
psr/cloud/xml.py,sha256=ac2lyflOQm8khPvJn0zmI26I4sfUDY6A_OTsxzbMQEs,1896
|
14
|
+
psr/execqueue/client.py,sha256=hAhoFPL6xu-o1wtoTtkTp-LCqHdXUohTbCyt9nXkdrQ,4724
|
15
|
+
psr/execqueue/config.py,sha256=3KVwASOgRlymOSPeabotgBdLVB5sPKnPQ9og2q3LQfw,1418
|
16
|
+
psr/execqueue/db.py,sha256=0pH5ksXChz6PR_GQs6OPokK3zVkY1-OZRAqYbVIEh9k,8281
|
17
|
+
psr/execqueue/server.py,sha256=mw0UzZJDzMJM6vY234_RbNpL6TEWNu6C7HvXv3qBumE,13932
|
18
|
+
psr/execqueue/watcher.py,sha256=t2sxAewrNu1AIbvv2X05kWWzCRfpn6EEG8GmT0NVjIw,4829
|
19
|
+
psr/factory/__init__.py,sha256=aW4b07XVpYmcm3W4NPIGQtN8oLiT2YafCRDEC1rp4z0,219
|
20
|
+
psr/factory/api.py,sha256=S7xoNxSKkyPEGtOLa_jBah59Edn39_wtoVQUrwrA6uk,100481
|
21
|
+
psr/factory/factory.dll,sha256=7TqTH4vgFq-UinLucMaAtnbQEVd3EZKCkf4-TEHsJkc,18432336
|
22
|
+
psr/factory/factory.pmd,sha256=XKpcyaQhVX3kF3S34ZjBtsDNr8bU6Mz8cfSFLWRu0dU,243646
|
23
|
+
psr/factory/factory.pmk,sha256=pIvKXc7mi-njtH9AJMzq8E6Ws2Dr4gma95uWs3g-hBg,579362
|
24
|
+
psr/factory/factorylib.py,sha256=-8wOx9h5oys0ZbG12OptwjzJVrgc48AgiAkBJJPKfio,27829
|
25
|
+
psr/factory/libcurl-x64.dll,sha256=of8BFlirCcMijzXKGVNBLIRDjZZXrfj5fHb37xzHlZ4,5317968
|
26
|
+
psr/factory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
+
psr/factory/samples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
+
psr/factory/samples/sddp_case01.py,sha256=jo71p9NN7dtRqMT76TEbD4S4Lut7p4ejbpu6SoSwg0Y,5034
|
29
|
+
psr/factory/samples/sddp_case21.py,sha256=-9Wk2ntjIC1-PrQDXDcnWUjV0OF9Xi_IREFb2pUWSi4,8797
|
30
|
+
psr/psrfcommon/__init__.py,sha256=WXR560XQllIjtFpWd0jiJEbUAQIyh5-6lwj-42_J95c,200
|
31
|
+
psr/psrfcommon/psrfcommon.py,sha256=NABM5ahvyfSizDC9c0Vu9dVK1pD_vOzIGFHL1oz2E1o,1464
|
32
|
+
psr/psrfcommon/tempfile.py,sha256=5S13wa2DCLYTUdwbLm_KMBRnDRJ0WDlu8GO2BmZoNdg,3939
|
33
|
+
psr/runner/__init__.py,sha256=kI9HDX-B_LMQJUHHylFHas2rNpWfNNa0pZXoIvX_Alw,230
|
34
|
+
psr/runner/runner.py,sha256=L_YOCArpkr_O-UJH6aT3K46NlEYT_o7LA1Ldk81BULQ,27326
|
35
|
+
psr/runner/version.py,sha256=mch2Y8anSXGMn9w72Z78PhSRhOyn55EwaoLAYhY4McE,194
|
36
|
+
psr_factory-5.0.0b12.dist-info/licenses/LICENSE.txt,sha256=N6mqZK2Ft3iXGHj-by_MHC_dJo9qwn0URjakEPys3H4,1089
|
37
|
+
psr_factory-5.0.0b12.dist-info/METADATA,sha256=THTUvX1YhKROKLmWdLwOmVuXdxdT8Awz8olRjlAd1sM,2294
|
38
|
+
psr_factory-5.0.0b12.dist-info/WHEEL,sha256=ZjXRCNaQ9YSypEK2TE0LRB0sy2OVXSszb4Sx1XjM99k,97
|
39
|
+
psr_factory-5.0.0b12.dist-info/top_level.txt,sha256=Jb393O96WQk3b5D1gMcrZBLKJJgZpzNjTPoldUi00ck,4
|
40
|
+
psr_factory-5.0.0b12.dist-info/RECORD,,
|
@@ -1,164 +0,0 @@
|
|
1
|
-
"""Creates SDDP 1 stage Case01 example."""
|
2
|
-
import copy
|
3
|
-
import os
|
4
|
-
|
5
|
-
import psr.factory
|
6
|
-
|
7
|
-
|
8
|
-
def get_case_path() -> str:
|
9
|
-
return os.path.join(os.path.splitext(os.path.basename(__file__))[0], "")
|
10
|
-
|
11
|
-
|
12
|
-
def create_sddp_sample_case01() -> psr.factory.Study:
|
13
|
-
blocks = 1
|
14
|
-
# Create a study object and define its basic settings.
|
15
|
-
study = psr.factory.create_study({
|
16
|
-
"Models": ["SDDP", ], # Default model: SDDP
|
17
|
-
"Blocks": blocks, # Default number of blocks: 1
|
18
|
-
"StageType": 2, # Weekly: 1 (default), Monthly: 2
|
19
|
-
})
|
20
|
-
study.from_dict({
|
21
|
-
"Description": "Caso ejemplo - DT - 1 etapa - 1 bloque",
|
22
|
-
"InitialYear": 2013,
|
23
|
-
"InitialStage": 1,
|
24
|
-
"NumberOfStages": 1,
|
25
|
-
"NumberOfSeries": 1,
|
26
|
-
})
|
27
|
-
|
28
|
-
# Study options
|
29
|
-
study.from_dict({
|
30
|
-
"Type": 2,
|
31
|
-
"InitialYearOfHydrology": 1996,
|
32
|
-
"NumberOfSystems": 1,
|
33
|
-
"AggregateInTheOperationPolicy": 0,
|
34
|
-
"UMON": "$",
|
35
|
-
"LoadSheddingInBuses": 0,
|
36
|
-
"MonitoringOfCircuitLimits": 0,
|
37
|
-
"HourlyRepresentation": 0,
|
38
|
-
"MaximumNumberOfIterations": 10,
|
39
|
-
"MinimumOutflowPenaltyHm3": 5000.0,
|
40
|
-
"DeficitSegment": [100.0, 0.0, 0.0, 0.0],
|
41
|
-
"DeficitCost": [500.0, 0.0, 0.0, 0.0],
|
42
|
-
"FutureCostStage": 4,
|
43
|
-
"FutureCostYear": 1998,
|
44
|
-
})
|
45
|
-
|
46
|
-
# Study duration
|
47
|
-
study.set("FixedDurationOfBlocks(1)", 100.0)
|
48
|
-
|
49
|
-
# By default, a study comes with one system.
|
50
|
-
system = study.get("System")[0]
|
51
|
-
system.code = 1
|
52
|
-
system.id = "s1"
|
53
|
-
system.name = "System 1"
|
54
|
-
# System's currency
|
55
|
-
system.set("SystemCurrency", "$")
|
56
|
-
# It's not required to add an existing object to the study.
|
57
|
-
|
58
|
-
# Set study to run with this unique system
|
59
|
-
study.set("CodesOfPowerSystems", [1, ])
|
60
|
-
|
61
|
-
# Create a demand segment - it's required to add at least
|
62
|
-
# an inelastic segment to a demand object.
|
63
|
-
segment = psr.factory.create("DemandSegment", study.context)
|
64
|
-
# Set demand and cost data.
|
65
|
-
segment.set_at("EnergyPerBlock(:)", "01/2013", 8.928)
|
66
|
-
# Add segment to the study.
|
67
|
-
study.add(segment)
|
68
|
-
|
69
|
-
# Create a system demand.
|
70
|
-
demand = psr.factory.create("Demand", study.context)
|
71
|
-
demand.code = 1
|
72
|
-
demand.name = "System 1"
|
73
|
-
# Associate it with the only system in the case.
|
74
|
-
demand.set("RefSystem", system)
|
75
|
-
# Associate the demand with its segments.
|
76
|
-
demand.set("RefSegments", [segment, ])
|
77
|
-
# Add demand to the study.
|
78
|
-
study.add(demand)
|
79
|
-
|
80
|
-
# Create all fuels - Thermal plants requires then.
|
81
|
-
fuel1 = psr.factory.create("Fuel", study.context)
|
82
|
-
fuel1.code = 1
|
83
|
-
fuel1.name = "Fuel 1"
|
84
|
-
fuel1.from_dict({
|
85
|
-
"Unit": "UC",
|
86
|
-
"UE": "MWh",
|
87
|
-
"Price": 0.8,
|
88
|
-
"EmissionFactor": 0.0,
|
89
|
-
"RefSystem": system,
|
90
|
-
})
|
91
|
-
study.add(fuel1)
|
92
|
-
|
93
|
-
fuel2 = psr.factory.create("Fuel", study.context)
|
94
|
-
fuel2.code = 2
|
95
|
-
fuel2.name = "Fuel 2"
|
96
|
-
fuel2.from_dict({
|
97
|
-
"Unit": "UC",
|
98
|
-
"UE": "MWh",
|
99
|
-
"Price": 1.2,
|
100
|
-
"EmissionFactor": 0.0,
|
101
|
-
"RefSystem": system,
|
102
|
-
})
|
103
|
-
study.add(fuel2)
|
104
|
-
|
105
|
-
# Create all thermal plants.
|
106
|
-
plant1 = psr.factory.create("ThermalPlant", study.context)
|
107
|
-
plant1.code = 1
|
108
|
-
plant1.name = "Thermal 1"
|
109
|
-
# Set plant's properties
|
110
|
-
t_params = {
|
111
|
-
"MaximumGenerationCapacity": 10.0,
|
112
|
-
"InstalledCapacity": 10.0,
|
113
|
-
"ThermalType": 0,
|
114
|
-
"Type": 0,
|
115
|
-
"NumberOfGeneratingUnits": 1,
|
116
|
-
"NumberOfAlternativeFuels": 0,
|
117
|
-
"CodeOfAlternativeFuels(:)": 0,
|
118
|
-
"O&MCost": 0.0,
|
119
|
-
"FuelTransportationCost": 0.0,
|
120
|
-
"SpecificConsumptionSegment(1)": 100.0,
|
121
|
-
"SpecificConsumptionSegment(2:3)": 0.0,
|
122
|
-
"SpecificConsumption(1:3,1)": 10.0,
|
123
|
-
"RefFuels": [fuel1, ],
|
124
|
-
"RefSystem": system,
|
125
|
-
}
|
126
|
-
plant1.from_dict(t_params)
|
127
|
-
|
128
|
-
# Use Python copy's module copy function to create
|
129
|
-
# a copy of an object.
|
130
|
-
plant2 = copy.copy(plant1)
|
131
|
-
plant2.code = 2
|
132
|
-
plant2.name = "Thermal 2"
|
133
|
-
plant2.set("MaximumGenerationCapacity", 5.0)
|
134
|
-
plant2.set("InstalledCapacity", 5.0)
|
135
|
-
plant2.set("SpecificConsumption(1:3,1)", 15.0)
|
136
|
-
plant2.set("RefFuels", [fuel1, ])
|
137
|
-
plant2.set("RefSystem", system)
|
138
|
-
study.add(plant2)
|
139
|
-
|
140
|
-
plant3 = plant2.clone()
|
141
|
-
plant3.code = 3
|
142
|
-
plant3.name = "Thermal 3"
|
143
|
-
plant3.from_dict({
|
144
|
-
"MaximumGenerationCapacity": 20.0,
|
145
|
-
"InstalledCapacity": 20.0,
|
146
|
-
"SpecificConsumption(1:3,1)": 12.5,
|
147
|
-
"RefFuels": [fuel2, ],
|
148
|
-
"RefSystem": system,
|
149
|
-
})
|
150
|
-
study.add(plant3)
|
151
|
-
|
152
|
-
return study
|
153
|
-
|
154
|
-
|
155
|
-
if __name__ == "__main__":
|
156
|
-
|
157
|
-
case_path = get_case_path()
|
158
|
-
os.makedirs(case_path, exist_ok=True)
|
159
|
-
print("Creating example case... ", end="")
|
160
|
-
study = create_sddp_sample_case01()
|
161
|
-
print(" OK.")
|
162
|
-
print("Saving example case in \"{}\"... ".format(case_path), end="")
|
163
|
-
study.save(case_path)
|
164
|
-
print(" OK.")
|
@@ -1,241 +0,0 @@
|
|
1
|
-
"""Creates SDDP 12 stages Case21 example."""
|
2
|
-
import copy
|
3
|
-
import os
|
4
|
-
|
5
|
-
import psr.factory
|
6
|
-
|
7
|
-
|
8
|
-
def get_case_path() -> str:
|
9
|
-
return os.path.join(os.path.splitext(os.path.basename(__file__))[0], "")
|
10
|
-
|
11
|
-
|
12
|
-
def create_sddp_sample_case21() -> psr.factory.Study:
|
13
|
-
# Create a study object and define its basic settings.
|
14
|
-
blocks = 1
|
15
|
-
# A context defines the dimensions of the study and the meaning of
|
16
|
-
# its stages. You can only share or copy data from one study to another
|
17
|
-
# if they share the same context.
|
18
|
-
context = psr.factory.get_new_context()
|
19
|
-
context.set("Models", ["SDDP", ]) # Default model: Sddp
|
20
|
-
context.set("Blocks", blocks) # Default number of blocks: 3
|
21
|
-
context.set("StageType", 2) # Weekly: 1, Monthly: 2 (default)
|
22
|
-
|
23
|
-
study = psr.factory.create_study(context)
|
24
|
-
study.set("Description", "SDDP")
|
25
|
-
study.set("InitialYear", 2016)
|
26
|
-
study.set("InitialStage", 1)
|
27
|
-
study.set("NumberOfStages", 12)
|
28
|
-
study.set("NumberOfSeries", 1)
|
29
|
-
|
30
|
-
# Study options
|
31
|
-
study.set("Type", 2)
|
32
|
-
study.set("InitialYearOfHydrology", 2016)
|
33
|
-
study.set("NumberOfSystems", 1)
|
34
|
-
study.set("AggregateInTheOperationPolicy", 1)
|
35
|
-
study.set("DeficitSegment", [100.0, 0.0, 0.0, 0.0])
|
36
|
-
study.set("DeficitCost", [1000.0, 0.0, 0.0, 0.0])
|
37
|
-
study.set("UMON", "$")
|
38
|
-
|
39
|
-
# Study duration
|
40
|
-
study.set("FixedDurationOfBlocks(1)", 100.0)
|
41
|
-
|
42
|
-
# By default, a study comes with one system.
|
43
|
-
system = study.get("System")[0]
|
44
|
-
system.code = 1
|
45
|
-
system.id = "s1"
|
46
|
-
system.name = "S1"
|
47
|
-
# System's currency
|
48
|
-
system.set("SystemCurrency", "$")
|
49
|
-
# It's not required to add an existing object to the study.
|
50
|
-
|
51
|
-
# Set study to run with this unique system
|
52
|
-
study.set("CodesOfPowerSystems", [1, ])
|
53
|
-
|
54
|
-
# Create a demand segment - it's required to add at least
|
55
|
-
# inelastic segment to a demand object.
|
56
|
-
segment = psr.factory.create("DemandSegment", context)
|
57
|
-
# Set demand and cost data.
|
58
|
-
segment.set_at("EnergyPerBlock(:)", "01/2016", 11.7)
|
59
|
-
segment.set_at("EnergyPerBlock(:)", "02/2016", 10.8)
|
60
|
-
segment.set_at("EnergyPerBlock(:)", "03/2016", 12.5)
|
61
|
-
segment.set_at("EnergyPerBlock(:)", "04/2016", 13.7)
|
62
|
-
segment.set_at("EnergyPerBlock(:)", "05/2016", 14.6)
|
63
|
-
segment.set_at("EnergyPerBlock(:)", "06/2016", 14.8)
|
64
|
-
segment.set_at("EnergyPerBlock(:)", "07/2016", 15.8)
|
65
|
-
segment.set_at("EnergyPerBlock(:)", "08/2016", 16.2)
|
66
|
-
segment.set_at("EnergyPerBlock(:)", "09/2016", 15.3)
|
67
|
-
segment.set_at("EnergyPerBlock(:)", "10/2016", 14.5)
|
68
|
-
segment.set_at("EnergyPerBlock(:)", "11/2016", 12.9)
|
69
|
-
segment.set_at("EnergyPerBlock(:)", "12/2016", 12.5)
|
70
|
-
|
71
|
-
segment.set_at("PricePerBlock(:)", "01/2016", 0.0)
|
72
|
-
# Add segment to the study.
|
73
|
-
study.add(segment)
|
74
|
-
|
75
|
-
# Create a system demand.
|
76
|
-
demand = psr.factory.create("Demand", context)
|
77
|
-
demand.code = 1
|
78
|
-
demand.name = "S1"
|
79
|
-
# Associate it with the only system in the case.
|
80
|
-
demand.set("RefSystem", system)
|
81
|
-
# Add segment to the demand.
|
82
|
-
demand.set("RefSegments", [segment, ])
|
83
|
-
# Add demand to the study.
|
84
|
-
study.add(demand)
|
85
|
-
|
86
|
-
# Create all fuels - Thermal plants requires them.
|
87
|
-
fuel1 = psr.factory.create("Fuel", context)
|
88
|
-
fuel1.code = 1
|
89
|
-
fuel1.name = "C1"
|
90
|
-
fuel1.set("Unit", "MWh")
|
91
|
-
fuel1.set("Price", 8.0)
|
92
|
-
fuel1.set("RefSystem", system)
|
93
|
-
study.add(fuel1)
|
94
|
-
|
95
|
-
fuel2 = psr.factory.create("Fuel", context)
|
96
|
-
fuel2.code = 2
|
97
|
-
fuel2.name = "C2"
|
98
|
-
fuel2.set("Unit", "MWh")
|
99
|
-
fuel2.set("Price", 12.0)
|
100
|
-
fuel2.set("RefSystem", system)
|
101
|
-
study.add(fuel2)
|
102
|
-
|
103
|
-
fuel3 = psr.factory.create("Fuel", context)
|
104
|
-
fuel3.code = 3
|
105
|
-
fuel3.name = "C3"
|
106
|
-
fuel3.set("Unit", "MWh")
|
107
|
-
fuel3.set("Price", 14.4)
|
108
|
-
fuel3.set("RefSystem", system)
|
109
|
-
study.add(fuel3)
|
110
|
-
|
111
|
-
# Create all thermal plants.
|
112
|
-
plant1 = psr.factory.create("ThermalPlant", context)
|
113
|
-
plant1.code = 1
|
114
|
-
plant1.name = "T1"
|
115
|
-
# Set plant's properties
|
116
|
-
plant1.set("MaximumGenerationCapacity", 12.0)
|
117
|
-
plant1.set("InstalledCapacity", 12.0)
|
118
|
-
plant1.set("ThermalType", 0) # Standard operation mode.
|
119
|
-
plant1.set("Type", 0) # It's an existing plant.
|
120
|
-
plant1.set("NumberOfGeneratingUnits", 1)
|
121
|
-
plant1.set("NumberOfAlternativeFuels", 0) # No alternative fuels
|
122
|
-
plant1.set("CodeOfAlternativeFuels(:)", 0)
|
123
|
-
plant1.set("O&MCost", 0.0)
|
124
|
-
plant1.set("FuelTransportationCost", 0.0)
|
125
|
-
plant1.set("SpecificConsumptionSegment(1)", 100.0)
|
126
|
-
plant1.set("SpecificConsumptionSegment(2:3)", 0.0)
|
127
|
-
plant1.set("SpecificConsumption(1:3,1)", 1.0)
|
128
|
-
plant1.set("Co2EmissionCoefficient", 1.0)
|
129
|
-
# It's required to associate a thermal plant to a fuel.
|
130
|
-
plant1.set("RefFuels", [fuel1, ])
|
131
|
-
plant1.set("RefSystem", system)
|
132
|
-
# These references are optional and can be set as None.
|
133
|
-
plant1.set("RefGasNode", None)
|
134
|
-
study.add(plant1)
|
135
|
-
|
136
|
-
plant2 = psr.factory.create("ThermalPlant", context)
|
137
|
-
plant2.code = 2
|
138
|
-
plant2.name = "T2"
|
139
|
-
plant2.set("MaximumGenerationCapacity", 8.0)
|
140
|
-
plant2.set("InstalledCapacity", 8.0)
|
141
|
-
plant2.set("ThermalType", 0)
|
142
|
-
plant2.set("Type", 0)
|
143
|
-
plant2.set("NumberOfGeneratingUnits", 1)
|
144
|
-
plant2.set("NumberOfAlternativeFuels", 0)
|
145
|
-
plant2.set("CodeOfAlternativeFuels(:)", 0)
|
146
|
-
plant2.set("O&MCost", 0.0)
|
147
|
-
plant2.set("FuelTransportationCost", 0.0)
|
148
|
-
plant2.set("SpecificConsumptionSegment(1)", 100.0)
|
149
|
-
plant2.set("SpecificConsumptionSegment(2:3)", 0.0)
|
150
|
-
plant2.set("SpecificConsumption(1:3,1)", 1.0)
|
151
|
-
plant2.set("Co2EmissionCoefficient", 1.0)
|
152
|
-
plant2.set("RefFuels", [fuel2, ])
|
153
|
-
plant2.set("RefSystem", system)
|
154
|
-
study.add(plant2)
|
155
|
-
|
156
|
-
plant3 = plant2.clone()
|
157
|
-
plant3.code = 3
|
158
|
-
plant3.name = "T3"
|
159
|
-
plant3.set("MaximumGenerationCapacity", 4.0)
|
160
|
-
plant3.set("InstalledCapacity", 4.0)
|
161
|
-
plant3.set("RefFuels", [fuel3, ])
|
162
|
-
plant3.set("RefSystem", system)
|
163
|
-
study.add(plant3)
|
164
|
-
|
165
|
-
# Define gauging station for hydro plants inflows
|
166
|
-
station1 = psr.factory.create("HydroStation", context)
|
167
|
-
station1.code = 1
|
168
|
-
station1.name = "Estacion 1"
|
169
|
-
|
170
|
-
station2 = psr.factory.create("HydroStation", context)
|
171
|
-
station2.code = 2
|
172
|
-
station2.name = "Estacion 2"
|
173
|
-
|
174
|
-
for year in (2014, 2015, 2016):
|
175
|
-
station1.set_at("Inflow", f"01/{year}", 13.5)
|
176
|
-
station1.set_at("Inflow", f"02/{year}", 40.7)
|
177
|
-
station1.set_at("Inflow", f"03/{year}", 28.8)
|
178
|
-
station1.set_at("Inflow", f"04/{year}", 25.6)
|
179
|
-
station1.set_at("Inflow", f"05/{year}", 23.8)
|
180
|
-
station1.set_at("Inflow", f"06/{year}", 27.8)
|
181
|
-
station1.set_at("Inflow", f"07/{year}", 28.8)
|
182
|
-
station1.set_at("Inflow", f"08/{year}", 18.8)
|
183
|
-
station1.set_at("Inflow", f"09/{year}", 18.2)
|
184
|
-
station1.set_at("Inflow", f"10/{year}", 29.6)
|
185
|
-
station1.set_at("Inflow", f"11/{year}", 17.7)
|
186
|
-
station1.set_at("Inflow", f"12/{year}", 26.3)
|
187
|
-
|
188
|
-
for month in range(1, 12 + 1):
|
189
|
-
station2.set_at("Vazao", f"{month:02d}/{year}", 0.0)
|
190
|
-
|
191
|
-
study.add(station1)
|
192
|
-
study.add(station2)
|
193
|
-
|
194
|
-
# Define hydroplants
|
195
|
-
hydro1 = psr.factory.create("HydroPlant", context)
|
196
|
-
hydro1.code = 1
|
197
|
-
hydro1.name = "H1"
|
198
|
-
hydro1.set("Type", 0)
|
199
|
-
hydro1.set("NumberOfUnits", 1)
|
200
|
-
hydro1.set("InstalledCapacity", 5.5)
|
201
|
-
hydro1.set("MaximumTurbinedOutflow", 55.0)
|
202
|
-
hydro1.set("MeanProductionCoefficient", 0.1)
|
203
|
-
hydro1.set("MinimumStorage", 0.0)
|
204
|
-
hydro1.set("MaximumStorage", 50.0)
|
205
|
-
hydro1.set("InitialCondition", 0.2)
|
206
|
-
hydro1.set("RefSystem", system)
|
207
|
-
hydro1.set("RefStation", station1)
|
208
|
-
study.add(hydro1)
|
209
|
-
|
210
|
-
hydro2 = hydro1.clone()
|
211
|
-
hydro2.code = 2
|
212
|
-
hydro2.name = "H2"
|
213
|
-
hydro2.set("MaximumStorage", 0.0)
|
214
|
-
hydro2.set("InitialCondition", 1.0)
|
215
|
-
hydro2.set("RefSystem", system)
|
216
|
-
hydro2.set("RefStation", station2)
|
217
|
-
study.add(hydro2)
|
218
|
-
|
219
|
-
# Connect hydro plants
|
220
|
-
connection_spill = psr.factory.create("HydroPlantConnection", context)
|
221
|
-
connection_spill.set("IsVertimento", 1)
|
222
|
-
connection_spill.set("RefPlants", [hydro1, hydro2])
|
223
|
-
study.add(connection_spill)
|
224
|
-
|
225
|
-
connection_turb = psr.factory.create("HydroPlantConnection", context)
|
226
|
-
connection_turb.set("IsTurbinamento", 1)
|
227
|
-
connection_turb.set("RefPlants", [hydro1, hydro2])
|
228
|
-
study.add(connection_turb)
|
229
|
-
|
230
|
-
return study
|
231
|
-
|
232
|
-
|
233
|
-
if __name__ == "__main__":
|
234
|
-
case_path = get_case_path()
|
235
|
-
os.makedirs(case_path, exist_ok=True)
|
236
|
-
print("Creating example case... ", end="")
|
237
|
-
study = create_sddp_sample_case21()
|
238
|
-
print(" OK.")
|
239
|
-
print("Saving example case in \"{}\"... ".format(case_path), end="")
|
240
|
-
study.save(case_path)
|
241
|
-
print(" OK.")
|
@@ -1,110 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: psr-factory
|
3
|
-
Version: 5.0.0b10
|
4
|
-
Summary: PSR database management module.
|
5
|
-
Author-email: "PSR Inc." <psrfactory@psr-inc.com>
|
6
|
-
License-Expression: MIT
|
7
|
-
Project-URL: documentation, https://docs.psr-inc.com/factory/
|
8
|
-
Keywords: psr,factory,sddp
|
9
|
-
Classifier: Development Status :: 4 - Beta
|
10
|
-
Classifier: Programming Language :: C
|
11
|
-
Classifier: Programming Language :: C++
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
18
|
-
Classifier: Topic :: Software Development
|
19
|
-
Classifier: Topic :: Scientific/Engineering
|
20
|
-
Classifier: Operating System :: Microsoft :: Windows
|
21
|
-
Classifier: Operating System :: POSIX :: Linux
|
22
|
-
Requires-Python: >=3.9
|
23
|
-
Description-Content-Type: text/markdown
|
24
|
-
License-File: LICENSE.txt
|
25
|
-
Requires-Dist: numpy
|
26
|
-
Provides-Extra: pandas
|
27
|
-
Requires-Dist: pandas; extra == "pandas"
|
28
|
-
Provides-Extra: polars
|
29
|
-
Requires-Dist: polars; extra == "polars"
|
30
|
-
Provides-Extra: cloud
|
31
|
-
Requires-Dist: zeep; extra == "cloud"
|
32
|
-
Requires-Dist: filelock; extra == "cloud"
|
33
|
-
Requires-Dist: pefile; extra == "cloud"
|
34
|
-
Requires-Dist: boto3; extra == "cloud"
|
35
|
-
Requires-Dist: botocore; extra == "cloud"
|
36
|
-
Provides-Extra: all
|
37
|
-
Requires-Dist: pandas; extra == "all"
|
38
|
-
Requires-Dist: polars; extra == "all"
|
39
|
-
Requires-Dist: zeep; extra == "all"
|
40
|
-
Requires-Dist: filelock; extra == "all"
|
41
|
-
Requires-Dist: pefile; extra == "all"
|
42
|
-
Requires-Dist: boto3; extra == "all"
|
43
|
-
Requires-Dist: botocore; extra == "all"
|
44
|
-
Dynamic: license-file
|
45
|
-
|
46
|
-
PSR Factory (version 4.0.35)
|
47
|
-
============================
|
48
|
-
|
49
|
-
Factory is a library that helps to manage SDDP cases.
|
50
|
-
It contains functions that create, load, and save studies, and also functions that create,
|
51
|
-
access, and modify objects in a study.
|
52
|
-
|
53
|
-
|
54
|
-
Installation
|
55
|
-
------------
|
56
|
-
|
57
|
-
### System-wide installation
|
58
|
-
|
59
|
-
Open the command prompt and run the following command:
|
60
|
-
|
61
|
-
```bash
|
62
|
-
pip install psr_factory-4.0.35-py3-none-win_amd64.whl
|
63
|
-
```
|
64
|
-
|
65
|
-
Factory will be available to all Python scripts in your system after importing it:
|
66
|
-
|
67
|
-
```python
|
68
|
-
import psr.factory
|
69
|
-
```
|
70
|
-
|
71
|
-
### Local/project-specific usage
|
72
|
-
|
73
|
-
Copy the folder `psr` and its contents to your project folder or a specific folder (e.g., `C:\path\to\factory`). Then, in your Python script, add the following lines:
|
74
|
-
|
75
|
-
```python
|
76
|
-
import sys
|
77
|
-
sys.path.append(r"C:\path\to\factory")
|
78
|
-
import psr.factory
|
79
|
-
```
|
80
|
-
|
81
|
-
|
82
|
-
Usage sample
|
83
|
-
------------
|
84
|
-
|
85
|
-
```python
|
86
|
-
import psr.factory
|
87
|
-
|
88
|
-
study = psr.factory.load_study(r"C:\temp\my\study")
|
89
|
-
system_1 = study.find("System.*")[0]
|
90
|
-
|
91
|
-
battery = psr.factory.create("Battery")
|
92
|
-
battery.code = 1
|
93
|
-
battery.name = "Battery 1"
|
94
|
-
battery.set("InstalledCapacity", 10.0)
|
95
|
-
battery.set("RefSystem", system_1)
|
96
|
-
study.add(battery)
|
97
|
-
|
98
|
-
study.save(r"C:\temp\my\updated_study")
|
99
|
-
```
|
100
|
-
|
101
|
-
|
102
|
-
Full documentation
|
103
|
-
------------------
|
104
|
-
|
105
|
-
The full documentation and reference is available at [https://docs.psr-inc.com/factory/](https://docs.psr-inc.com/manual/factory/).
|
106
|
-
|
107
|
-
Releases
|
108
|
-
--------
|
109
|
-
|
110
|
-
New releases can be found in the release notes at [https://psrenergy-docs.github.io/factory/releases.html](https://psrenergy-docs.github.io/factory/releases.html).
|