diff --git a/Model_Library b/Model_Library index e5ce585a5ef69a3307214fbe7e6798311c07e918..1f64708b9f8c06056497f854438f272a3afa146c 160000 --- a/Model_Library +++ b/Model_Library @@ -1 +1 @@ -Subproject commit e5ce585a5ef69a3307214fbe7e6798311c07e918 +Subproject commit 1f64708b9f8c06056497f854438f272a3afa146c diff --git a/examples/connections/prosumer.json b/examples/connections/prosumer.json new file mode 100644 index 0000000000000000000000000000000000000000..204efd7cc522f65fb5d1cc8731e2def48a42e187 --- /dev/null +++ b/examples/connections/prosumer.json @@ -0,0 +1,51 @@ +{ + "components": { + "source": { + "type": "ElectricalGeneration" + }, + "sink": { + "type": "ElectricalConsumption" + }, + "buffer": { + "type": "ElectricalGrid", + "additional_model_logic": { + "input_penalty": { + "type": "additional_operational_objective", + "value": [1.0, "input_1"] + }, + "output_penalty": { + "type": "additional_operational_objective", + "value": [1.0, "output_1"] + } + } + } + }, + "connections": [ + { + "type": "OneToOne", + "from": "source.output_1", + "to": "buffer.input_1" + }, + { + "type": "OneToOne", + "from": "buffer.output_1", + "to": "sink.input_1" + }, + { + "type": "Sum", + "members": [ + "source.output_1", + "sink.input_1" + ], + "loss_factor": 0.5, + "capacity": 1.0 + }, + { + "type": "OneToOne", + "from": "source.output_1", + "to": "sink.input_1", + "loss_factor": 0.5, + "capacity": 1.0 + } + ] +} \ No newline at end of file diff --git a/examples/connections/runme.py b/examples/connections/runme.py new file mode 100644 index 0000000000000000000000000000000000000000..cf0be98471a14036723b59db8cefe62a788e9793 --- /dev/null +++ b/examples/connections/runme.py @@ -0,0 +1,49 @@ +""" +MIT License + +Copyright (c) 2023 RWTH Aachen University + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +# import gurobipy + +# model = gurobipy.read('out.mps') +# model.computeIIS() +# model.write('out.ilp') + +from Model_Library.dynamics import TrivialArchitecture, TrivialDynamic, Profile +from Model_Library.topology import Prosumer + +import json +import numpy as np + +dynamic = TrivialDynamic(np.ones(1, dtype=int)) + +with open("prosumer.json") as f: + prosumer_json = json.load(f) + +prosumer_json["components"]["source"]["generation"] = Profile(np.array([10.0]), dynamic) +prosumer_json["components"]["sink"]["consumption"] = Profile(np.array([10.0]), dynamic) + +prosumer = Prosumer("my_prosumer", prosumer_json) + +prosumer.optimize("key", TrivialArchitecture(dynamic), []) + +prosumer.save_results("output_files")