Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have created a code to build the Y matrix. The problem is that I've noticed that the funtion outputYmatrix does not calculate the Y in all nodes in my case... someone knows why?

import numpy as np import pandas as pd import sqlite3 import re import psse35 import psspy import pssarrays

psspy.psseinit()

_i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar()

psspy.case(r'CASE.sav')

psspy.outputymatrix(i,i,_i,0,r'outYmatrix.txt') f = open(r'outYmatrix.txt') listaY = [] for lines in f: if lines.startswith(' ZERO') or not lines.strip(): break else: listaY.append(re.split('[,\n]',lines))

conn = sqlite3.connect(':memory:') cursor = conn.cursor() cursor.execute('CREATE TABLE YMATRIX (IBUS INT, JBUS INT, Yreal real, Yimag real)') conn.commit() [cursor.execute(f'INSERT INTO YMATRIX VALUES ({item[0]},{item[1]},{item[2]},{item[3]})')for item in listaY]

df = pd.readsql('SELECT * FROM YMATRIX ORDER BY IBUS, JBUS',conn).setindex('IBUS') df['Y'] = df.Yreal + 1j*df.Yimag df = df.astype({'Y':str}) df2 = df.resetindex().groupby([df.index, 'JBUS'])['Y'].aggregate('first').unstack().fillna('(0+0j)') Ymatrix=df2.tonumpy(complex)

print(Ymatrix.shape) print(Ymatrix)

I have created a code to build the Y matrix. The problem is that I've noticed that the funtion outputYmatrix does not calculate the Y in all nodes in my case... someone knows why?

import numpy as np import pandas as pd import sqlite3 import re import psse35 import psspy import pssarrays

psspy.psseinit()

_i = psspy.getdefaultint() psspy.getdefaultint()

_f = psspy.getdefaultreal() psspy.getdefaultreal()

_s = psspy.getdefaultchar()

psspy.case(r'CASE.sav')

psspy.outputymatrix(i,i,_i,0,r'outYmatrix.txt') i,_i,0,r'outYmatrix.txt')

f = open(r'outYmatrix.txt') open(r'outYmatrix.txt')

listaY = [] []

for lines in f: f:

if lines.startswith(' ZERO') or not lines.strip(): break
  else:
        listaY.append(re.split('[,\n]',lines))

listaY.append(re.split('[,\n]',lines))

conn = sqlite3.connect(':memory:') sqlite3.connect(':memory:')

cursor = conn.cursor() conn.cursor()

cursor.execute('CREATE TABLE YMATRIX (IBUS INT, JBUS INT, Yreal real, Yimag real)') conn.commit() real)')

conn.commit()

[cursor.execute(f'INSERT INTO YMATRIX VALUES ({item[0]},{item[1]},{item[2]},{item[3]})')for item in listaY]

df = pd.readsql('SELECT * FROM YMATRIX ORDER BY IBUS, JBUS',conn).setindex('IBUS') index('IBUS')

df['Y'] = df.Yreal + 1j*df.Yimag 1j*df.Yimag

df = df.astype({'Y':str}) df.astype({'Y':str})

df2 = df.resetindex().groupby([df.index, 'JBUS'])['Y'].aggregate('first').unstack().fillna('(0+0j)') Ymatrix=df2.tonumpy(complex)

print(Ymatrix.shape) df.reset_index().groupby([df.index, 'JBUS'])['Y'].aggregate('first').unstack().fillna('(0+0j)')

Ymatrix=df2.to_numpy(complex)

print(Ymatrix.shape)

print(Ymatrix)

click to hide/show revision 3
No.3 Revision

I have created a code to build the Y matrix. The problem is that I've noticed that the funtion outputYmatrix does not calculate the Y in all nodes in my case... someone knows why?

import numpy as np
import pandas as pd
import sqlite3
import re
import psse35
import psspy
import pssarrays

pssarrays psspy.psseinit()

psspy.psseinit()

_i = psspy.getdefaultint()

psspy.getdefaultint()

_f = psspy.getdefaultreal()

psspy.getdefaultreal()

_s = psspy.getdefaultchar()

psspy.getdefaultchar() psspy.case(r'CASE.sav')

psspy.case(r'CASE.sav')

psspy.output_y_matrix(_i,_i,_i,0,r'outYmatrix.txt')

psspy.outputymatrix(i,i,_i,0,r'outYmatrix.txt')

f = open(r'outYmatrix.txt')

open(r'outYmatrix.txt')

listaY = []

[]

for lines in f:

f:
 if lines.startswith(' ZERO') or not lines.strip(): break

 else:

     listaY.append(re.split('[,\n]',lines))

conn = sqlite3.connect(':memory:')

sqlite3.connect(':memory:')

cursor = conn.cursor()

conn.cursor()

cursor.execute('CREATE TABLE YMATRIX (IBUS INT, JBUS INT, Yreal real, Yimag real)')

real)') conn.commit()

conn.commit()

[cursor.execute(f'INSERT INTO YMATRIX VALUES ({item[0]},{item[1]},{item[2]},{item[3]})')for item in listaY]

listaY]

df = pd.readsql('SELECT pd.read_sql('SELECT * FROM YMATRIX ORDER BY IBUS, JBUS',conn).setindex('IBUS')

JBUS',conn).set_index('IBUS')

df['Y'] = df.Yreal + 1j*df.Yimag

1j*df.Yimag

df = df.astype({'Y':str})

df.astype({'Y':str})

df2 = df.reset_index().groupby([df.index, 'JBUS'])['Y'].aggregate('first').unstack().fillna('(0+0j)')

'JBUS'])['Y'].aggregate('first').unstack().fillna('(0+0j)') Ymatrix=df2.to_numpy(complex)

Ymatrix=df2.to_numpy(complex)

print(Ymatrix.shape) print(Ymatrix)

print(Ymatrix.shape)

print(Ymatrix)