First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
I am trying to get PSSE to run multiple simulations to compare the results to one another. As there will be many simulations, I want to "parallelize" the simulations. I have given multiprocessing.Process and multiprocessing.pool a shot and can not get it working.
Here is base code I've been trying to get to work. It solves and creates an out file in the folder if I have the pool function only iterate once. If I try to change it to multiple values, I start getting invalid temporary file or visual fortran errors.
Do I have something incorrect in the coding? Is my understanding of the pool function not correct?
import psspy,redirect,multiprocessing as m
def run_fault(x):
case, snp, out, log = x
# Redirect output from PSSE to Python
redirect.psse2py()
psspy.psseinit(12000)
# Initialize PSSE
psspy.report_output(2,out,[])
psspy.progress_output(2,out,[])
psspy.alert_output(2,out,[])
psspy.prompt_output(2,out,[])
# Load case
psspy.case(case)
psspy.rstr(snp)
psspy.conl(-1,1,1)
psspy.conl(-1,1,2,[0,0],[100,0,0,100])
psspy.conl(-1,1,3)
# Convert generators:
psspy.cong()
# Solve for dynamics
psspy.ordr()
psspy.fact()
psspy.tysl()
# Initialize and run the case
psspy.strt(0,out)
psspy.run(0,1,1,1,1)
psspy.pssehalt_2()
if __name__ == "__main__":
folder = r"C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\dyn"
redirect.psse2py()
psspy.psseinit()
# Generate processes to run
size = 2
arglist = []
for i in range(size):
arglist.append((folder+`i+1`+r"\savnw.sav",folder+`i+1`+r"\savnw.snp",
folder+`i+1`+r"\savnw.out",folder+`i+1`+r"\savnw.log"))
pool = m.Pool()
P = pool.map(func=run_fault, iterable=arglist)
pool.close()
pool.join()
Any help would be appreciated.