def test_case(both=False, clean=False): """one specified scenario, simulated""" clean_files() data = """ [test_case] opf """ # remove generator g4 # remove generator g23 # set all demand 0.7 data_2 = """ [test_case_2] pf """ scenario = text_to_scenario(data) psat = read_psat("rtskillmod.m") report = simulate_scenario(psat, scenario, clean) print "result = '" + str(report_in_limits(report)) + "'" if both: # clean_files() scenario_2 = text_to_scenario(data_2) psat_2 = report_to_psat(report, psat) report_2 = simulate_scenario(psat_2, scenario_2, clean) print "result 2 = '" + str(report_in_limits(report_2)) + "'"
def upec(n_failures=100): """if we happen to have a stage one that kills the shunt bus then most bugs go away. use this to get some data.""" clean_files() clean = True data = """ [upec] opf # remove generator g33 # set all demand 0.7686144 # remove bus 6 """ scenario = text_to_scenario(data) psat = read_psat("rts2.m") tmp_psat = scenario_to_psat(scenario, psat) report = single_simulate(tmp_psat, scenario.simtype, scenario.title) new_psat = report_to_psat(report, tmp_psat) prob = read_probabilities("rts.net") failure_batch = make_failures(prob, n_failures) failure_batch.scenarios.insert(0, Scenario("basecase")) batch_simulate(failure_batch, new_psat, 100, clean) filename = scenario.title + ".bch2" with open(filename, "w") as result_file: failure_batch.csv_write(result_file)
def test005(): """simulate an islanded system by cutting all the lines across one line it is seperated. But still passes he simulation. Reoving all the generators hit the multiplier limit on fix_mismatch. A power flow is more likely to fail. Theoretically an OPF could treat the two islended sections as seperate power systems and optimise each. Unfortunatly PF doesn't yet work! """ clean_files() clean = False data = """ [example_4] pf remove line a24 remove line a19 remove line a18 remove line a15 """ scenario = text_to_scenario(data) psat = read_psat("rts.m") report = simulate_scenario(psat, scenario, clean) print "result = '" + str(report_in_limits(report)) + "'"
def example4(): """one specified scenario, simulated""" clean_files() clean = False data = """ [example_4] opf remove generator g12 """ #remove generator g33 #set all demand 0.7686144 #remove bus 6 scenario = text_to_scenario(data) psat = read_psat("rts.m") report = simulate_scenario(psat, scenario, clean) print "result = '" + str(report_in_limits(report)) + "'"
def test004(): """ run two simulations on differnt files """ clean_files() clean = False data = """ [notused] pf #set all demand 0.5 """ scenario = text_to_scenario(data) psat = read_psat("rts.m") scenario.title = "mod1" report = simulate_scenario(psat, scenario, clean) print "first result = '" + str(report_in_limits(report)) + "'" psat = read_psat("rts2.m") scenario.title = "mod2" report = simulate_scenario(psat, scenario, clean) print "second result = '" + str(report_in_limits(report)) + "'"
def sim(psat, scenario_text): scenario = text_to_scenario(scenario_text) return simulate_scenario(psat, scenario, clean)