Skip to content

Commit

Permalink
minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
AadilLatif committed Nov 16, 2023
1 parent 712b988 commit 26a85ac
Show file tree
Hide file tree
Showing 16 changed files with 6,668 additions and 61 deletions.
3,812 changes: 3,812 additions & 0 deletions .ipynb_checkpoints/Untitled-checkpoint.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions PyDSS/api/server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyDSS.api.src.web.handler import Handler
import PyDSS.api.schema as schema
from aiohttp_swagger3 import *
from aiohttp import web
#from aiohttp_swagger3 import *
#from aiohttp import web
import threading
import requests
import logging
Expand Down
2 changes: 1 addition & 1 deletion PyDSS/api/src/web/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
import asyncio
from uuid import uuid4
from aiohttp import web
#from aiohttp import web
from PyDSS.api.src.app.pydss import PyDSS
from multiprocessing import Queue, Process, Event, cpu_count
from concurrent.futures import ThreadPoolExecutor
Expand Down
2 changes: 1 addition & 1 deletion PyDSS/cli/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from PyDSS.api.server import pydss_server
from aiohttp import web
#from aiohttp import web
import logging
import click

Expand Down
2 changes: 1 addition & 1 deletion PyDSS/dssInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __init__(self, settings: SimulationSettingsModel):
self._increment_flag = True
if settings.helics.co_simulation_mode:
self._HI = HI.helics_interface(self._dssSolver, self._dssObjects, self._dssObjectsByClass, settings,
self._dssPath)
self._dssPath, self._Logger)
self._Logger.info("Simulation initialization complete")
return

Expand Down
7 changes: 5 additions & 2 deletions PyDSS/helics_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ class helics_interface:



def __init__(self, dss_solver, objects_by_name, objects_by_class, settings: SimulationSettingsModel, system_paths, default=True):
def __init__(self, dss_solver, objects_by_name, objects_by_class, settings: SimulationSettingsModel, system_paths, default=True, logger=None):
LoggerTag = getLoggerTag(settings)
self.itr = 0
self.c_seconds = 0
self.c_seconds_old = -1
self._logger = logging.getLogger(__name__)
if logger:
self._logger = logger
else:
self._logger = logging.getLogger(__name__)
self._settings = settings
self._co_convergance_error_tolerance = settings.helics.error_tolerance
self._co_convergance_max_iterations = self._settings.helics.max_co_iterations
Expand Down
84 changes: 44 additions & 40 deletions PyDSS/pyControllers/Controllers/PvVoltageRideThru.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def __init__(self, PvObj, Settings, dssInstance, ElmObjectList, dssSolver):

self.region = [3, 3, 3]

# self.voltage_hist = []
# self.power_hist = []
# self.timer_hist = []
# self.timer_act_hist = []
self.voltage_hist = []
self.power_hist = []
self.timer_hist = []
self.timer_act_hist = []

return

Expand Down Expand Up @@ -326,43 +326,47 @@ def Update(self, Priority, Time, Update):
else:
raise Exception("Valid standard setting defined. Options are: 1547-2003, 1547-2018")

# P = -sum(self._ControlledElm.GetVariable('Powers')[::2])
# self.power_hist.append(P)
# self.voltage_hist.append(uIn)
# self.timer_hist.append(self.__uViolationtime)
# self.timer_act_hist.append(self.__dssSolver.GetTotalSeconds())
# if self.Time == 59 and Priority==2:
# import matplotlib.pyplot as plt
# fig, (ax1, ax2) = plt.subplots(2,1)

# try:
# models = [MultiPolygon([self.CurrLimRegion]), self.MomentarySucessionRegion, self.TripRegion, MultiPolygon([self.NormalRegion])]
# except:
# try:
# models = [self.CurrLimRegion, self.MomentarySucessionRegion, self.TripRegion, MultiPolygon([self.NormalRegion])]
# except:
# try:
# models = [MultiPolygon([self.CurrLimRegion]), self.MomentarySucessionRegion, self.TripRegion, self.NormalRegion]
# except:
# models = [self.CurrLimRegion, self.MomentarySucessionRegion, self.TripRegion, self.NormalRegion]

# models = [i for i in models if i is not None]
P = -sum(self._ControlledElm.GetVariable('Powers')[::2])
self.power_hist.append(P)
self.voltage_hist.append(uIn)
self.timer_hist.append(self.__uViolationtime)
self.timer_act_hist.append(self.__dssSolver.GetTotalSeconds())
if self.Time == 59 and Priority==2:

if hasattr(self, "CurrLimRegion"):

# colors = ["orange", "grey", "red", "green"]
# for m, c in zip(models, colors):
# for geom in m.geoms:
# xs, ys = geom.exterior.xy
# ax1.fill(xs, ys, alpha=0.35, fc=c, ec='none')
# ax1.set_xlim(0, 5)
# ax1.set_ylim(0, 1.20)
# ax1.scatter( self.timer_hist, self.voltage_hist)
# ax3 = ax2.twinx()
# ax2.set_ylabel('Power (kW) in green')
# ax3.set_ylabel('Voltage (p.u.) in red')
# ax2.plot(self.timer_act_hist[1:], self.power_hist[1:], c="green")
# ax3.plot(self.timer_act_hist[1:], self.voltage_hist[1:], c="red")
# fig.savefig(f"C:/Users/alatif/Desktop/pr100_opendss_model/Exports/cat1_3/{self.__Name}_{self.__Settings['Ride-through Category']}_0.8pu_short.png")

import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(2,1)

try:
models = [MultiPolygon([self.CurrLimRegion]), self.MomentarySucessionRegion, self.TripRegion, MultiPolygon([self.NormalRegion])]
except:
try:
models = [self.CurrLimRegion, self.MomentarySucessionRegion, self.TripRegion, MultiPolygon([self.NormalRegion])]
except:
try:
models = [MultiPolygon([self.CurrLimRegion]), self.MomentarySucessionRegion, self.TripRegion, self.NormalRegion]
except:
models = [self.CurrLimRegion, self.MomentarySucessionRegion, self.TripRegion, self.NormalRegion]

models = [i for i in models if i is not None]

colors = ["orange", "grey", "red", "green"]
for m, c in zip(models, colors):
for geom in m.geoms:
xs, ys = geom.exterior.xy
ax1.fill(xs, ys, alpha=0.35, fc=c, ec='none')
ax1.set_xlim(0, 60)
ax1.set_ylim(0, 1.20)
ax1.scatter( self.timer_hist, self.voltage_hist)
ax3 = ax2.twinx()
ax2.set_ylabel('Power (kW) in green')
ax3.set_ylabel('Voltage (p.u.) in red')
ax2.plot(self.timer_act_hist[1:], self.power_hist[1:], c="green")
ax3.plot(self.timer_act_hist[1:], self.voltage_hist[1:], c="red")
fig.savefig(f"test.png")
quit()

return Error

def Trip(self, uIn):
Expand Down
2 changes: 1 addition & 1 deletion PyDSS/pyPlots/Plots/NetworkGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __ExtendPCElementDict(self, Dict):
try:
PropertyName = self.__dssInstance.Properties.Name(str(i))
X = self.__dssInstance.Properties.Value(str(i))
if X is not None and X is not '' and PropertyName is not None and PropertyName is not '':
if X is not None and X != '' and PropertyName is not None and PropertyName != '':
Dict[PropertyName] = X
except:
pass
Expand Down
14 changes: 14 additions & 0 deletions PyDSS/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@
"PyDSS/pyControllers/Controllers/Settings/PvControllers.toml"
),
},
{
"name": "cpf",
"filename": os.path.join(
os.path.dirname(getattr(PyDSS, "__path__")[0]),
"PyDSS/pyControllers/Controllers/Settings/PvControllers.toml"
),
},
{
"name": "volt-var",
"filename": os.path.join(
os.path.dirname(getattr(PyDSS, "__path__")[0]),
"PyDSS/pyControllers/Controllers/Settings/PvControllers.toml"
),
},
],
ControllerType.PV_VOLTAGE_RIDETHROUGH.value: [
],
Expand Down
7 changes: 4 additions & 3 deletions PyDSS/utils/dss_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ def func():

res = [x for x in iter_elements(dss.LoadShape, func) if x is not None]
if len(set(res)) != 1:
raise InvalidConfiguration(
f"SInterval for all LoadShapes must be the same: {res}"
)
...
# raise InvalidConfiguration(
# f"SInterval for all LoadShapes must be the same: {res}"
# )
return res[0]


Expand Down
2,767 changes: 2,767 additions & 0 deletions Untitled.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ New Line.PVL_110 phases=1 bus1=110_2.1 bus2=110-PV.1 linecode=6 length=10 units=
New Line.PVL_111 phases=1 bus1=111_2.1 bus2=111-PV.1 linecode=6 length=10 units=ft
New Line.PVL_113 phases=1 bus1=113_2.1 bus2=113-PV.1 linecode=6 length=10 units=ft
New Line.PVL_112 phases=1 bus1=112_2.1 bus2=112-PV.1 linecode=6 length=10 units=ft
!New PVSystem.pvgnem_mpx000635970 phases=1 bus=110-PV.1 kv=0.24 kva=20 pf=1.0 irradiance=1 Pmpp=20 yearly=pv_MPX000635970 !was kva=3.1, Pmpp=3.1
!New PVSystem.pvgnem_mpx000460267 phases=1 bus=111-PV.1 kv=0.24 kva=8.5 pf=1.0 irradiance=1 Pmpp=8.5 yearly=pv_MPX000460267
!New PVSystem.pvgnem_mpx000594341 phases=1 bus=113-PV.1 kv=0.24 kva=4.6 pf=1.0 irradiance=1 Pmpp=4.6 yearly=pv_MPX000594341
!New PVSystem.pvgui_mpx000637601 phases=1 bus=112-PV.1 kv=0.24 kva=5.5 pf=1.0 irradiance=1.01069592198581 Pmpp=5.5 yearly=pv_MPX000637601
!New PVSystem.pvgui_mpx000460267 phases=1 bus=111-PV.1 kv=0.24 kva=3.9 pf=1.0 irradiance=0.925303188892118 Pmpp=3.9 yearly=pv_MPX000460267
!New Generator.gen_1 phases=1 bus=111-PV.1 kv=0.24 kva=3.9 kw=1.0
New PVSystem.pvgnem_mpx000635970 phases=1 bus=110-PV.1 kv=0.24 kva=20 pf=1.0 irradiance=1 Pmpp=20 yearly=pv_MPX000635970 !was kva=3.1, Pmpp=3.1
New PVSystem.pvgnem_mpx000460267 phases=1 bus=111-PV.1 kv=0.24 kva=8.5 pf=1.0 irradiance=1 Pmpp=8.5 yearly=pv_MPX000460267
New PVSystem.pvgnem_mpx000594341 phases=1 bus=113-PV.1 kv=0.24 kva=4.6 pf=1.0 irradiance=1 Pmpp=4.6 yearly=pv_MPX000594341
New PVSystem.pvgui_mpx000637601 phases=1 bus=112-PV.1 kv=0.24 kva=5.5 pf=1.0 irradiance=1.01069592198581 Pmpp=5.5 yearly=pv_MPX000637601
New PVSystem.pvgui_mpx000460267 phases=1 bus=111-PV.1 kv=0.24 kva=3.9 pf=1.0 irradiance=0.925303188892118 Pmpp=3.9 yearly=pv_MPX000460267
New Generator.gen_1 phases=1 bus=111-PV.1 kv=0.24 kva=3.9 kw=1.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"FeederHeadLine": "Line.sl_9", "FeederHeadLoading": 0.0904677875475182, "FeederHeadLoadKW": -4.5116401079406145, "FeederHeadLoadKVar": -0.5808926493998611, "ReversePowerFlow": false}
{"FeederHeadLine": "Line.sl_9", "FeederHeadLoading": 0.06933724108556384, "FeederHeadLoadKW": -3.494342080342113, "FeederHeadLoadKVar": -0.035208296922618953, "ReversePowerFlow": false}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
""
,%Fuel,%Reserve,Balanced,D,DutyStart,FuelkWh,H,MVA,Refuel,ShaftData,ShaftModel,UseFuel,UserData,UserModel,Vmaxpu,Vminpu,Vpu,XRdp,Xd,Xdp,Xdpp,basefreq,bus1,class,conn,daily,debugtrace,dispmode,dispvalue,duty,enabled,forceon,kVA,kW,kv,kvar,like,maxkvar,minkvar,model,pf,phases,pvfactor,spectrum,status,yearly
Generator.gen_1,100,20,No,0,0,0,1,0.0039,No,,,No,,,1.1,0.9,1,20,1,0.28,0.2,60,111-pv.1,1,wye,,No,Default,0,,Yes,No,3.9,1,0.24,0.539742822138087,,1.07948564427617,-1.07948564427617,1,0.88,1,0.1,defaultgen,Variable,
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
""
,phases,bus1,kv,irradiance,Pmpp,%Pmpp,Temperature,pf,conn,kvar,kVA,%Cutin,%Cutout,EffCurve,P-TCurve,%R,%X,model,Vminpu,Vmaxpu,Balanced,LimitCurrent,yearly,daily,duty,Tyearly,Tdaily,Tduty,class,UserModel,UserData,debugtrace,VarFollowInverter,DutyStart,WattPriority,PFPriority,%PminNoVars,%PminkvarMax,kvarMax,kvarMaxAbs,spectrum,basefreq,enabled,like
PVSystem.pvgnem_mpx000635970,1,110-pv.1,0.24,1,20,100,25,1,wye,0,20,20,20,,,50,0,1,0.9,1.1,No,No,pv_mpx000635970,,,,,,1,,,No,No,0,No,No,-1,-1,20,20,,60,Yes,
PVSystem.pvgnem_mpx000460267,1,111-pv.1,0.24,1,8.5,100,25,1,wye,0,8.5,20,20,,,50,0,1,0.9,1.1,No,No,pv_mpx000460267,,,,,,1,,,No,No,0,No,No,-1,-1,8.5,8.5,,60,Yes,
PVSystem.pvgnem_mpx000594341,1,113-pv.1,0.24,1,4.6,100,25,1,wye,0,4.6,20,20,,,50,0,1,0.9,1.1,No,No,pv_mpx000594341,,,,,,1,,,No,No,0,No,No,-1,-1,4.6,4.6,,60,Yes,
PVSystem.pvgui_mpx000637601,1,112-pv.1,0.24,1.01069592198581,5.5,100,25,1,wye,0,5.5,20,20,,,50,0,1,0.9,1.1,No,No,pv_mpx000637601,,,,,,1,,,No,No,0,No,No,-1,-1,5.5,5.5,,60,Yes,
PVSystem.pvgui_mpx000460267,1,111-pv.1,0.24,0.925303188892118,3.9,100,25,1,wye,0,3.9,20,20,,,50,0,1,0.9,1.1,No,No,pv_mpx000460267,,,,,,1,,,No,No,0,No,No,-1,-1,3.9,3.9,,60,Yes,
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
,%R,%Rs,%imag,%loadloss,%noloadloss,Core,LeadLag,MaxTap,MinTap,NumTaps,Ratings,RdcOhms,Rneut,Seasons,WdgCurrents,X12,X13,X23,XHL,XHT,XLT,XRConst,XfmrCode,Xneut,Xscarray,bank,basefreq,bus,buses,conn,conns,emergamps,emerghkVA,enabled,faultrate,flrise,hsrise,kV,kVA,kVAs,kVs,like,m,n,normamps,normhkVA,pctperm,phases,ppm_antifloat,repair,sub,subname,tap,taps,thermal,wdg,windings
Transformer.tsf,0.38195,"['0.38195', '0.38195']",0,0.7639,0.0851,shell,Lag,1.1,0.9,32,['1100'],0.0049867392,-1,1,"0.6136701, (112.66), 18.27444, (-67.39), ",2.1,35,30,2.1,35,30,No,,0,['2.1'],,60,tsf.1,"['sourcebus.1', 'tsf.1']",wye,"['wye', 'wye']",6.94444444444444,50,Yes,0.007,65,15,0.24,37.5,"['37.5', '37.5']","['7.2', '0.24']",,0.8,0.8,5.72916666666667,41.25,0,1,1,0,No,,1,"['1', '1']",2,2,2
Transformer.tsf,0.38195,"['0.38195', '0.38195']",0,0.7639,0.0851,shell,Lag,1.1,0.9,32,['1100'],0.0049867392,-1,1,"0.4714305, (119.42), 14.00612, (-60.581), ",2.1,35,30,2.1,35,30,No,,0,['2.1'],,60,tsf.1,"['sourcebus.1', 'tsf.1']",wye,"['wye', 'wye']",6.94444444444444,50,Yes,0.007,65,15,0.24,37.5,"['37.5', '37.5']","['7.2', '0.24']",,0.8,0.8,5.72916666666667,41.25,0,1,1,0,No,,1,"['1', '1']",2,2,2

0 comments on commit 26a85ac

Please sign in to comment.