This repository has been archived by the owner on Dec 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sogno-platform/version-for-git-without-cov…
…ee-powerflow Voltage control strategy using Dual Ascent method working. Powerflow used as class in covee. Adressing issue: #1
- Loading branch information
Showing
51 changed files
with
2,383 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import numpy as np | ||
import csv | ||
import os | ||
import coloredlogs, logging, threading | ||
from submodules.dmu.dmu import dmu | ||
from submodules.dmu.httpSrv import httpSrv | ||
from submodules.dmu.mqttClient import mqttClient | ||
import time | ||
import sys | ||
import requests | ||
import json | ||
import csv | ||
|
||
coloredlogs.install(level='DEBUG', | ||
fmt='%(asctime)s %(levelname)-8s %(name)s[%(process)d] %(message)s', | ||
field_styles=dict( | ||
asctime=dict(color='green'), | ||
hostname=dict(color='magenta'), | ||
levelname=dict(color='white', bold=True), | ||
programname=dict(color='cyan'), | ||
name=dict(color='blue'))) | ||
logging.info("Program Start") | ||
|
||
if bool(os.getenv('MQTT_ENABLED')): | ||
mqtt_url = str(os.getenv('MQTTURL')) | ||
mqtt_port = int(os.getenv('MQTTPORT')) | ||
mqtt_user = str(os.getenv('MQTTUSER')) | ||
mqtt_password = str(os.getenv('MQTTPASS')) | ||
else: | ||
mqtt_url = "mqtt" | ||
mqtt_port = 1883 | ||
mqtt_password = "" | ||
mqtt_user = "" | ||
|
||
############################ Start the Server ####################################################### | ||
|
||
''' Initialize objects ''' | ||
dmuObj = dmu() | ||
|
||
''' Start mqtt client ''' | ||
mqttObj = mqttClient(mqtt_url, dmuObj, mqtt_port, mqtt_user, mqtt_password) | ||
|
||
time.sleep(2.0) | ||
####################################################################################################### | ||
|
||
flex_offer = {"variables": [],"flex_output": {}} | ||
flex_request_dict = {} | ||
|
||
# Receive flexibility_request | ||
dmuObj.addElm("flex_values", {}) | ||
mqttObj.attachSubscriber("/edgeflex/goflex/flex_request","json","flex_values") | ||
|
||
# Send flexibility_output | ||
dmuObj.addElm("flex_input", {}) | ||
mqttObj.attachPublisher("/edgeflex/goflex/flex_result","json","flex_input") | ||
|
||
while True: | ||
flex_request = dmuObj.getDataSubset("flex_values") | ||
if flex_request: | ||
flex_output = {} | ||
print(flex_request) | ||
for i in flex_request["variables"]: | ||
if flex_request["flex_dict"][i]: | ||
logging.info("flexibility request " + str(i) + " = " + str(flex_request["flex_dict"][i])) | ||
logging.info(" ") | ||
time.sleep(2) | ||
###################### PREPARE THE ANSWER ########### | ||
vector_node_name = [7,9,10] | ||
vector_position = [] | ||
for i in range(len(flex_request["active_nodes"])): | ||
if any(flex_request["active_nodes"][i]+1 == t for t in vector_node_name): | ||
vector_position.append(flex_request["active_nodes"].index(flex_request["active_nodes"][i])) | ||
predictions = [1] | ||
flex_output = {"variable":["active_power", "reactive_power"], | ||
"active_power": {"vector_position":vector_position,"prediction": predictions,"flex_value": {"pred_"+str(predictions[j]):[list(np.round(np.random.rand(1)*abs(flex_request["flex_dict"]["active_power"]["pred_"+str(predictions[j])]["node_"+str(i)]), 2))[0] for i in vector_node_name ] for j in range(len(predictions))} }, | ||
"reactive_power": {"vector_position":vector_position,"prediction": predictions,"flex_value": {"pred_"+str(predictions[j]):[list(np.round(np.random.rand(1)*abs(flex_request["flex_dict"]["reactive_power"]["pred_"+str(predictions[j])]["node_"+str(i)]), 2))[0] for i in vector_node_name ] for j in range(len(predictions))} } | ||
} | ||
print(flex_output) | ||
dmuObj.setDataSubset(flex_output,"flex_input") | ||
time.sleep(0.5) | ||
break | ||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.