flag = 2 # 2 = all non-tx branches 4 = all two-winding and non-transformer branches entry = 1 #1 = every branch once 2 = every branch from both sides ties = 1 # 1 = inside subsystem lines, # 2 = ties only, # 3 = everything ierr,ratio = psspy.atrnreal(sid,2,ties,flag,entry,['RATIO2']) ratio =ratio[0] fromflow = [] for i in range(0,len(bus_num)): k = i + 1 fromflow.append(brnflo(bus_num[1],bus_num[0],str(k))) ReactivePowerDifference = abs(fromflow[0].imag - fromflow[1].imag) RealPowerDifference = abs(fromflow[0].real - fromflow[1].real) # Determine the Load Buses to scale up the load psspy.bsys(0,0,[ 0.2, 999.],0,[],5,ScaleLoadAtBuses,0,[],0,[]) ierr,load_bus = psspy.alodbusint(0,1,['NUMBER']) load_bus = load_bus[0] # determine which transformer should be controlled and how to control. tapChangeDirection = [] for i in range(0,2): tapChangeDirection.append(0) if TransformerToControl: for i in range(0,len(TransformerToControl)): if TransformerToControl[i] == "TX4LTC_CTL": TransformerToControlIndex = 4 TransformerRatioIndex = 0 elif TransformerToControl[i] == "TX5LTC_CTL": TransformerToControlIndex = 5 TransformerRatioIndex = 1 if Control[i] == "RAISE":
PSSE_CASE = case_name_constant % current_percentage psspy.case(PSSE_CASE) # silent the output output = StringIO.StringIO() with silence(output): #pick the bus in Dominion Area 345 is the index of Dominion psspy.case(savecase) # psspy.bsys(0,0,[ 0.2, 999.],1,[],0,[],0,[],0,[]) ierr, all_bus = psspy.abusint(-1, 1, ['NUMBER']) bus_num = all_bus[0] #Load Bus psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num) ierr, load_bus = psspy.alodbusint(1, 1, ['NUMBER']) load_bus = load_bus[0] # Gen Bus psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num) ierr, gen_bus = psspy.agenbusint(1, 1, ['NUMBER']) gen_bus = gen_bus[0] #change the load and the generation percentage = 1 - (current_percentage - 5) / current_percentage pssepylib.change_load(load_bus, percentage) increment = pssepylib.LoadIncreaseMW(load_bus, percentage) pssepylib.change_gen(gen_bus, increment) # try: # load_real_sum = sum(load_real)
def findAllLoadBuses(bus_num): psspy.bsys(sid = 1,numbus = len(bus_num), buses = bus_num) ierr,load_bus = psspy.alodbusint(1,1,['NUMBER']) load_bus = load_bus[0] return load_bus
# find all the buses psspy.bsys(0, 0, [0.0, 0.0], 1, [1], 0, [], 0, [], 0, []) ierr, all_bus = psspy.abusint(0, 1, ['number']) bus_num = all_bus[0] #List of all machines psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num) ierr, machine_bus = psspy.amachint(1, 1, ['NUMBER']) machine_bus = machine_bus[0] ierr, machine_id = psspy.amachchar(1, 1, ['ID']) machine_id = machine_id[0] #List of all load psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num) ierr, load_bus = psspy.alodbusint(1, 1, ['NUMBER']) load_bus = load_bus[0] ierr, load_id = psspy.aloadchar(1, 1, ['ID']) load_id = load_id[0] #List of branches ierr, internal_linesfbtb = psspy.abrnint(sid=1, ties=1, flag=1, string=['FROMNUMBER', 'TONUMBER']) ierr, internal_linesid = psspy.abrnchar(sid=1, ties=1, flag=1, string=['ID']) #Building the list of contingencies
# Set the time step for the dynamic simulation psspy.dynamics_solution_params(realar=[_f, _f, 0.005, _f, _f, _f, _f, _f]) psspy.machine_array_channel([1, 2, 6000]) # Monitor Kvilldal Power psspy.machine_array_channel([2, 7, 6000]) # Monitor Kvilldal Frequency ierr = psspy.strt(outfile=outputfile) # Tell PSS/E to write to the output file # List all in service buses sid = 1 # Create subsystem based on voltage range sid = psspy.bsys(1, 1, [0, 1000]) # Get bus numbers load_ids = test = psspy.alodbusint(1, 2, 'NUMBER')[1][0] # Standard deviation of the loads sd = 0.001 # Simulation parameters t = 1 # Start time of the simulation T = 90 # End time of the simulation dt = 1 # How often to step the load steps = int(T / dt) # Calculate how many times the loads should be stepped pmu_td = 4 # To tell PSS/E to write to screen and file at PMU frequency # Make all the loads in the system into Wiener proceesses loads = [ load_models.WienerProcessLoad(load_num, steps, sd, dt) for load_num in load_ids
def get_load_bus(bus_num): # Get the Load Buses Numbers psspy.bsys(0, 0, [0.2, 999.], 0, [], len(bus_num), bus_num, 0, [], 0, []) ierr, load_bus = psspy.alodbusint(sid=0, flag=1, string=['NUMBER']) load_bus = load_bus[0] return load_bus