First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Now to Steps 1 & 2:
Copy the loadflow solution (bus based reports without wide format output option) from the output bar and save it in text file format.
Read file with a python script and parse using regular expressions as follows:
import numpy as np
import matplotlib.pyplot as plt
import re, string
text_file = open("loadflow.txt", "r")
a = text_file.read()
text_file.close()
b = re.sub('\r\n', '', a)
lines = re.split('BUS', b)
genDat = []
for line in lines:
if re.search('GENERATION', line):
genDat.append(re.search('^\s*(\d{5}).*(?:TO)\s*(\d{5})(?:\s*\S*){2}\s*(\d)\s*([0-9]+(?:\.[0-9]*)?)', line).groups())
genDat = [list(i) for i in genDat]
That bit of code picks all the generation data for me. I use similar bits for extracting the load and line data.