Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The below code snippet has been made as per the details of the original question.

Note 0: The method for changing the real power generation in dynamic simulation is based on @peroflofl 's answer.

Note 1: psspy.scal2 works fine for dynamic simulation as far as load increments are concerned. It however, does not change the dynamic generation values for me. So in such a case @peroflofl's code does the job. I have added a slightly modified version of his code into this snippet.

Note 2: Any slashes in the command below ' \ ' are used to split the command in multiple lines in Python2

# Housekeeping code before running the simulation for efficient changing of loads and generations.
genBus = 1
loadBus = 3
subsystemNum = 1
ierr = psspy.bsyso(subsystemNum, loadBus) #Adding Bus 3 to Subsystem 1. It is assumed that a subsystem identified by that number has not been created.
ierr, mbase1 = psspy.macdat(genBus, '1', 'MBASE')
# add dummy governor without droop and time constants to Bus 1
psspy.add_plant_model(genBus, '1', 7, r"""IEESGO""", 0, "", 0, [], [], 11, \
[0.0,0.0,0.05,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0])
psspy.machine_array_channel([-1,6, genBus], '1' ,"")

ierr = psspy.strt(0, 'ieee39_outfile.out')
psspy.run(0, 0.5, 0, 1, 0) #It is assumed that your initial values of Bus 1 generation and Bus 3 load are already set

status2num = 1 # Parameter for psspy.scal_2. Use 2 for Percent change and 3 for Incremental change. I've used 1 since you need to specify a new value.
loadChange = 75  # New load should be 75 MW

ierr, totals, moto = psspy.scal_2(subsystemNum, 1, 0, \
        [psspy._i, 2, 0, 1, 0], \
        [loadChange, status2num, 0.0, 0.0, 0.0, -0.0, 0.0]) # Now Bus 3 PLoad is 75 MW.

genChange = 100 # New generation should be 100 MW
psspy.increment_gref(genBus, '1',genChange/mbase1) # Now Bus 1 PGen is 100 MW.

psspy.run(0, 1.0, 0, 1, 0) # Run till 1.0 s

loadChange = 20 # New load should be 20 MW

ierr, totals, moto = psspy.scal_2(subsystemNum, 1, 0, \
        [psspy._i, 2, 0, 1, 0], \
        [loadChange, status2num, 0.0, 0.0, 0.0, -0.0, 0.0]) # Now Bus 3 PLoad is 20 MW.

psspy.run(0, 2.0, 0, 1, 0) # Run till 2.0 s

Assuming you are using dyntools.CHNF to record the dynamic simulation state variable values, you may then plot POWR 1 [BUS 1 BasKV_val]1 values from the .xlsx file using your preferred progarmming software.

The below code snippet has been made as per the details of the original question.

Note 0: The method for changing the real power generation in dynamic simulation is based on @peroflofl 's answer.

Note 1: psspy.scal2 works fine for dynamic simulation as far as load increments are concerned. It however, does not change the dynamic generation values for me. So in such a case @peroflofl's code does the job. I have added a slightly modified version of his code into this snippet.

Note 2: Any slashes in the command below ' \ ' are used to split the command in multiple lines in Python2

# Housekeeping code before running the simulation for efficient changing of loads and generations.
genBus = 1
loadBus = 3
subsystemNum = 1
ierr = psspy.bsyso(subsystemNum, loadBus) #Adding Bus 3 to Subsystem 1. It is assumed that a subsystem identified by that number has not been created.
ierr, mbase1 = psspy.macdat(genBus, '1', 'MBASE')
# add dummy governor without droop and time constants to Bus 1
psspy.add_plant_model(genBus, '1', 7, r"""IEESGO""", 0, "", 0, [], [], 11, \
[0.0,0.0,0.05,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0])
psspy.machine_array_channel([-1,6, genBus], '1' ,"")

ierr = psspy.strt(0, 'ieee39_outfile.out')
psspy.run(0, 0.5, 0, 1, 0) #It is assumed that your initial values of Bus 1 generation and Bus 3 load are already set

status2num changeType = 1 # Parameter for psspy.scal_2. Use 2 for Percent change and 3 for Incremental change. I've used 1 since you need to specify a new value.
loadChange = 75  # New load should be 75 MW

ierr, totals, moto = psspy.scal_2(subsystemNum, 1, 0, \
        [psspy._i, 2, 0, 1, 0], \
        [loadChange, status2num, changeType, 0.0, 0.0, 0.0, -0.0, 0.0]) # Now Bus 3 PLoad is 75 MW.

genChange = 100 # New generation should be 100 MW
psspy.increment_gref(genBus, '1',genChange/mbase1) # Now Bus 1 PGen is 100 MW.

psspy.run(0, 1.0, 0, 1, 0) # Run till 1.0 s

loadChange = 20 # New load should be 20 MW

ierr, totals, moto = psspy.scal_2(subsystemNum, 1, 0, \
        [psspy._i, 2, 0, 1, 0], \
        [loadChange, status2num, changeType, 0.0, 0.0, 0.0, -0.0, 0.0]) # Now Bus 3 PLoad is 20 MW.

psspy.run(0, 2.0, 0, 1, 0) # Run till 2.0 s

Assuming you are using dyntools.CHNF to record the dynamic simulation state variable values, you may then plot POWR 1 [BUS 1 BasKV_val]1 values from the .xlsx file using your preferred progarmming software.