Example #1
0
def test008():
    clean = False
    
    def copy_psat(in_filename, out_filename):
        psat = read_psat(in_filename + ".m")
        with open(out_filename + ".m", "w") as psat_stream:
            psat.write(psat_stream)
            
    def sim(psat, scenario_text):
        scenario = text_to_scenario(scenario_text)
        return simulate_scenario(psat, scenario, clean)
        
    data = """
           [base] opf
               set all demand 0.6
           """

    copy_psat("rts", "psat_base")
    psat = read_psat("psat_base.m")
    report = sim(psat, data)
    print "base result = '" + str(report_in_limits(report)) + "'"
    opf_psat = report_to_psat(report, psat)
    opf_report = single_simulate(opf_psat, "pf", "one", clean)
    print "opf result = '" + str(report_in_limits(opf_report)) + "'"
    
    opf_psat_2 = report_to_psat(opf_report, opf_psat)
    opf_report_2 = single_simulate(opf_psat_2, "pf", "two", clean)
    print "opf result 2 = '" + str(report_in_limits(opf_report_2)) + "'"
Example #2
0
def test001():
    """
    a system after OPF should not depend on the values of generator.p or
    generator.v. These should be set by the OPF routine based upon price.

    You have to temporarily delete assert(in_limits) for this to work.
    
    It requires looking at the resulting files to make sure they are the 
    same as well as checking the output on the console.
    """

    clean_files()
    clean = False

    psat = read_psat("rts.m")
    report = single_simulate(psat, "opf", "base", clean)
    print "base result = '" + str(report_in_limits(report)) + "'"

    for gen in psat.generators.values():
        gen.p = 1.0
        gen.v = 1.0
    report = single_simulate(psat, "opf", "unit", clean)
    print "unit result = '" + str(report_in_limits(report)) + "'"

    for gen in psat.generators.values():
        gen.p = 10.0
        gen.v = 10.0
    report = single_simulate(psat, "opf", "ten", clean)
    print "ten  result = '" + str(report_in_limits(report)) + "'"

    for gen in psat.generators.values():
        gen.p = 0.0
        gen.v = 0.0
    report = single_simulate(psat, "opf", "zero", clean)
    print "zero result = '" + str(report_in_limits(report)) + "'"
Example #3
0
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)
Example #4
0
def test002():
    """
    make sure that limits are hit when we set them really low
    """

    clean_files()
    clean = False

    psat = read_psat("rts.m")
    report = single_simulate(psat, "pf", "base", clean)
    print "base result = '" + str(report_in_limits(report)) + "'"

    for line in psat.lines.values():
        line.i_limit = 0.01
        #line.p_limit = 0.01
        line.s_limit = 0.01
    report = single_simulate(psat, "opf", "small", clean)
    print "small result = '" + str(report_in_limits(report)) + "'"