Skip to content

Commit adbdd1d

Browse files
committed
TO Shammya
1 parent e8c105f commit adbdd1d

File tree

16 files changed

+86
-423
lines changed

16 files changed

+86
-423
lines changed

Shammya_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 11/15/2021 10:00 AM
3+
# @Author : Paulo Radatz
4+
5+
# @File : line_example.py
6+
# @Software: PyCharm
7+
8+
import py_dss_interface
9+
import os
10+
import pathlib
11+
import numpy as np
12+
13+
script_path = os.path.dirname(os.path.abspath(__file__))
14+
15+
dss_file = pathlib.Path(script_path).joinpath("feeders", "4Bus-YY-Bal", "4Bus-YY-Bal.DSS")
16+
17+
dss = py_dss_interface.DSS()
18+
dss.text(f"compile [{dss_file}]")

feeders/4Bus-YY-Bal/4Bus-YY-Bal.DSS

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
clear
2+
Set DefaultBaseFrequency=60
3+
4+
! IEEE 4-bus test case Y-Y Stepdown Balanced
5+
! Based on script developed by Alan Dunn and Steve Sparling
6+
7+
new circuit.4BusYYbal basekV=12.47 phases=3
8+
! **** HAVE TO STIFFEN THE SOURCE UP A LITTLE; THE TEST CASE ASSUMES AN INFINITE BUS
9+
~ mvasc3=200000 200000
10+
11+
set earthmodel=carson
12+
13+
! **** DEFINE WIRE DATA
14+
new wiredata.conductor Runits=mi Rac=0.306 GMRunits=ft GMRac=0.0244 Radunits=in Diam=0.721 normamps=530
15+
new wiredata.neutral Runits=mi Rac=0.592 GMRunits=ft GMRac=0.00814 Radunits=in Diam=0.563 normamps=340
16+
17+
! **** DEFINE LINE GEOMETRY; REDUCE OUT THE NEUTRAL
18+
new linegeometry.4wire nconds=4 nphases=3 reduce=yes
19+
~ cond=1 wire=conductor units=ft x=-4 h=28
20+
~ cond=2 wire=conductor units=ft x=-1.5 h=28
21+
~ cond=3 wire=conductor units=ft x=3 h=28
22+
~ cond=4 wire=neutral units=ft x=0 h=24
23+
24+
! **** 12.47 KV LINE
25+
new line.line1 geometry=4wire length=2000 units=ft bus1=sourcebus bus2=n2
26+
27+
! **** 3-PHASE STEP-DOWN TRANSFORMER 12.47/4.16 KV Y-Y
28+
new transformer.t1 xhl=6
29+
~ wdg=1 bus=n2 conn=wye kV=12.47 kVA=6000 %r=0.5
30+
~ wdg=2 bus=n3 conn=wye kV=4.16 kVA=6000 %r=0.5
31+
32+
! **** 4.16 KV LINE
33+
new line.line2 bus1=n3 bus2=n4 geometry=4wire length=2500 units=ft
34+
35+
! **** WYE-CONNECTED 4.16 KV LOAD
36+
new load.load1 phases=3 bus1=n4 conn=wye kV=4.16 kW=5400 pf=0.9 model=1
37+
! **** HAVE TO ALLOW P, Q TO REMAIN CONSTANT TO ABOUT .79 PU -- THIS IS ASSUMED IN TEST CASE
38+
! **** DEFAULT IN DSS IS .95, BELOW WHICH IT REVERTS TO LINEAR MODEL
39+
~ vminpu=0.75 ! model will remain const p,q down to 0.75 pu voltage
40+
41+
set voltagebases=[12.47, 4.16]
42+
calcvoltagebases ! **** let DSS compute voltage bases
43+
solve
44+
45+
! Various reports ...
46+
//show voltages LN Nodes
47+
//show currents resid=yes elements ! this shows sum of phase currents
48+
//Show Powers kva Elements

line_impedance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
import pathlib
1111
import os
1212
# Creates an OpenDSS object
13-
dss = py_dss_interface.DSS(r"C:\OpenDSS_svn\Version8\Source")
13+
dss = py_dss_interface.DSS()
1414

1515
dss_file = r"C:\Users\ppra005\Box\Documents_PC\OpenDSS_forum\Jouni\line_impedances.dss"
1616

1717
dss.text(f"compile [{dss_file}]")
1818

19-
dss.name_write("line2")
20-
dss.r1_read()
19+
dss.text("new reactor.r bus1=sourcebus")
20+
21+
print("Here")

my_script.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
# Creates an OpenDSS object
77
dss_2 = py_dss_interface.DSS()
88

9-
dss = py_dss_interface.DSS(print_dss_info=True, windows_version='cpp')
9+
# dss = py_dss_interface.DSS(print_dss_info=True, windows_version='cpp')
1010

1111

1212
# dss = py_dss_interface.DSS(r"C:\Program Files\OpenDSS")
1313

14-
# dss_1 = py_dss_interface.DSSDLL()
14+
# dss_1 = py_dss_interface.DSS()
1515

1616
# If specific DLL Version, use this line below
17-
# dss = py_dss_interface.DSS(dll_folder_param=r"C:\Users\eniocc\Downloads\py_dss_interface-master\src"
18-
# r"\py_dss_interface\dll/windows\x64", dll_by_user="OpenDSSDirect.dll")
17+
dss = py_dss_interface.DSS(dll_folder_param=r"C:\PauloRadatz\GitHub\py-dss-interface\build_opendss\Debug", dll_by_user="OpenDSSC.dll")
1918
# dss.circuit.
2019
# Select the DSS model
2120
# dss_file = r"C:\MeuTCC\Paulo_Example\DSSFiles\MASTER_RedeTeste13Barras.dss"
@@ -26,8 +25,7 @@
2625
# dss.text("edit Load.671 zipv=[0.4 0.4 0.2 0.4 0.4 0.2 0.2]")
2726
dss.loads.name = "671"
2827

29-
dss.circuit.to
30-
dss.loads.names
28+
3129

3230
expected = ['671_new']
3331
dss.cktelement.bus_names = expected

setup.py

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import urllib.request
1414
import zipfile
1515
import shutil
16+
import pathlib
1617

1718
# Set up logging
1819
log_file = 'build_log.txt'
@@ -51,49 +52,9 @@ def run(self):
5152

5253
logging.info("Checking for required dependencies...")
5354

54-
55-
# List of required dependencies
56-
# dependencies = ["cmake", "make", "gcc", "g++"]
57-
#
58-
# # Check each dependency and attempt installation if missing
59-
# for dep in dependencies:
60-
# try:
61-
# subprocess.check_call([dep, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
62-
# logging.info(f"{dep} is installed.")
63-
# except:
64-
# logging.warning(f"{dep} is not installed. Attempting to install...")
65-
# try:
66-
# # Install dependency using apt-get (Debian/Ubuntu)
67-
# subprocess.check_call(["sudo", "apt-get", "update"])
68-
# subprocess.check_call(["sudo", "apt-get", "install", "-y", dep])
69-
# logging.info(f"Successfully installed {dep}.")
70-
# except:
71-
# logging.error(f"Failed to install {dep}. Please install it manually")
72-
73-
dependencies = ["cmake", "gcc", "make"]
74-
75-
for dep in dependencies:
76-
try:
77-
subprocess.check_call([dep, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
78-
logging.info(f"{dep} is installed.")
79-
except:
80-
logging.warning(f"{dep} is not installed. Attempting to install...")
81-
try:
82-
# First try winget
83-
subprocess.check_call(["winget", "install", "-e", "--id", f"{dep}"])
84-
logging.info(f"Successfully installed {dep} using winget.")
85-
except:
86-
logging.warning(f"winget failed to install {dep}. Trying choco...")
87-
try:
88-
subprocess.check_call(["choco", "install", dep, "-y"])
89-
logging.info(f"Successfully installed {dep} using choco.")
90-
except:
91-
logging.error(f"Failed to install {dep}. Please install it manually")
92-
93-
logging.info(f"OpenDSS source folder '{source_dir}' not found. Downloading from {download_url}...")
94-
9555
# Check if the OpenDSS source code is available; if not, download it
9656
if not os.path.exists(source_dir):
57+
logging.info(f"OpenDSS source folder '{source_dir}' not found. Downloading from {download_url}...")
9758
self.download_source_code()
9859

9960
# Create a build directory if it doesn't exist
@@ -164,17 +125,17 @@ def build_opendss(self):
164125
logging.info(f"Running CMake command: {' '.join(cmake_command)} in {build_folder}")
165126
# subprocess.check_call(cmake_command, cwd=build_folder)
166127
result = subprocess.run(cmake_command, cwd=build_folder, capture_output=True, text=True, shell=True)
167-
logging.info(f"{result.stdout}")
168-
logging.info(f"{result.stderr}")
128+
# logging.info(f"{result.stdout}")
129+
# logging.info(f"{result.stderr}")
169130
logging.info("CMake configuration completed successfully.")
170131

171132
# Step 4: Compile
172133
compile_command = [r"C:\Program Files\CMake\bin\cmake.exe", "--build", ".", "-j", "4"]
173134
logging.info(f"Running compilation command: {' '.join(compile_command)} in {build_folder}")
174135
# subprocess.check_call(compile_command, cwd=build_folder)
175136
result = subprocess.run(compile_command, cwd=build_folder, capture_output=True, text=True, shell=True)
176-
logging.info(f"{result.stdout}")
177-
logging.info(f"{result.stderr}")
137+
# logging.info(f"{result.stdout}")
138+
# logging.info(f"{result.stderr}")
178139
logging.info("OpenDSS build completed successfully.")
179140

180141
# Define the target directory for the compiled library
@@ -184,6 +145,7 @@ def build_opendss(self):
184145
os.makedirs(target_lib_dir)
185146
logging.info(f"Created target directory: {target_lib_dir}")
186147

148+
build_folder = pathlib.Path(build_folder).joinpath("Debug")
187149
# Move all files from the build folder to the target directory
188150
logging.info(f"Moving all files from {build_folder} to {target_lib_dir}")
189151
for filename in os.listdir(build_folder):
@@ -231,6 +193,7 @@ def read(*names, **kwargs):
231193
'opendss_official/windows/cpp/x64/*.dll',
232194
'opendss_official/windows/cpp/x86/*.dll',
233195
'opendss_official/linux/cpp/*.so',
196+
'opendss_official/linux/cpp/*.dll',
234197
]
235198
},
236199
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
@@ -266,8 +229,8 @@ def read(*names, **kwargs):
266229
extras_require={
267230
"dev": ["pytest", "pytest-cov", "sphinx-rtd-theme", "nbsphinx", "black", "pre-commit", "tox", "twine", "ipython", "flake8"],
268231
},
269-
cmdclass={
270-
'build_opendss_linux': BuildOpenDSSLinux,
271-
'install': CustomInstallCommand, # Custom install command
272-
},
232+
# cmdclass={
233+
# 'build_opendss_linux': BuildOpenDSSLinux,
234+
# 'install': CustomInstallCommand, # Custom install command
235+
# },
273236
)

src/py_dss_interface/opendss_official/windows/delphi/x86/ComPorts.ini

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

src/py_dss_interface/opendss_official/windows/delphi/x86/License.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)