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 example3(): """one random failure""" psat = read_psat("rts.m") prob = read_probabilities("rts.net") batch = make_failures(prob, 1) scenario = batch[0] report = simulate_scenario(psat, scenario) print "result =", report_in_limits(report), "."
def example1(n=100): """make `n` outages, simulate them, and save the resulting batch""" psat = read_psat("rts.m") prob = read_probabilities("rts.net") batch = make_failures(prob, n) batch_simulate(batch, psat, 30) with open("rts.bch", "w") as result_file: batch.write(result_file)