First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
It is great if your solution doesn't blow up and you never need to flat start, but sometimes you can try alternative solving functions to get your case back to a normal state. Try the below function rather than a typical single solve.
def solve():
"""
Function to run Newton-Raphson load flow. If the original solve is unsuccessful, several more attempts are made with alternative parameters.
Returns True only if the case is solved without ignoring reactive limits.
"""
# Allow 200 iterations
psspy.solution_parameters_3([_i,200,_i],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f])
# Normal full newton
psspy.fnsl([1,0,0,1,1,0,99,0])
reactive_ignored = False
if psspy.solved() != 0:
# If normal full newton didn't work:
# Flat start decoupled
psspy.fdns([0,0,0,1,1,1,99,0])
if psspy.solved() == 0:
# If flat start worked, now do a full netwon
psspy.fnsl([0,0,0,1,1,0,99,0])
else:
psspy.fdns([1,0,0,1,1,1,99,0])
psspy.fnsl([0,0,0,1,1,0,99,0])
psspy.fnsl([1,0,0,1,1,0,99,0])
# Try ignoring reactive limits
if psspy.solved > 0:
reactive_ignored = True
psspy.fnsl([1,0,0,1,1,1,-1,0])
psspy.fnsl([0,0,0,1,1,0,99,0])
if psspy.solved() == 0:
reactive_ignored = False
if psspy.solved > 0:
psspy.fdns([1,0,0,1,1,1,-1,0])
reactive_ignored = True
if psspy.solved() == 0:
psspy.fdns([0,0,0,1,1,1,99,0])
if reactive_ignored:
print "\nSolved successfully, but reactive limits were ignored."
return False
else:
print "\nSolved successfully!"
return True
else:
print "\nUnable to solve case."
return False