Beispiel #1
0
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)) + "'"
Beispiel #2
0
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)) + "'"
Beispiel #3
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)) + "'"
Beispiel #4
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)) + "'"
Beispiel #5
0
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)) + "'"
Beispiel #6
0
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), "."
Beispiel #7
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)) + "'"
Beispiel #8
0
def example5():

    clean_files()
    clean = False

    data = """
           [base] opf
           [dead_slack] opf
             remove generator g12
           [two_dead_slack] opf
             remove generator g12
             remove generator g13
           [three_dead_slack] opf
             remove generator g12
             remove generator g15
           [four_dead_slack] opf
             remove generator g13
             remove generator g12
           [five_dead_slack] opf
             remove generator g15
             remove generator g12
           [all_dead_slack] opf
             remove generator g12
             remove generator g13
             remove generator g15
           [rem_bus_1] opf
             remove bus 1
           [rem_li_a1] opf
             remove line a1
           [rem_gen_g1] opf
             remove generator g1
           [set_double] opf
             set all demand 2.0
           [set_half] opf
             set all demand 0.5
           """

    #data = """
    #       [fail_001] pf
    #         remove generator g32
    #         remove generator g13
    #"""

    batch = SimulationBatch()
    batch.read(StringIO(data))
    psat = read_psat("rts.m")

    for scenario in batch:
        report = simulate_scenario(psat, scenario, clean)
        print "result = '" + str(report_in_limits(report)) + "'"
Beispiel #9
0
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)) + "'"
Beispiel #10
0
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)) + "'"
Beispiel #11
0
def test007():
    """batch and single should gave same results"""
    
    clean_files()

    psat = read_psat("rts2.m")
    # prob = read_probabilities("rts.net")
    # batch = make_outages(prob, 2)

    data = """
[batch0] opf
  remove generator g1
  remove generator g4
  remove generator g31
  set all demand 0.3987456
  result pass
[batch1] opf
  remove generator g22
  remove generator g24
  set all demand 0.6670332
  result fail
           """

    batch = SimulationBatch()
    batch.read(StringIO(data))

    batch_simulate(batch, psat, 10, False)

    with open("rts.bch", "w") as result_file:
        batch.write(result_file)

    for n, scenario in enumerate(batch):
        scenario.title = "single" + str(n)
        report = simulate_scenario(psat, scenario, False) 
        scenario.result = report_in_limits(report)
    
    with open("rts2.bch", "w") as result_file:
        batch.write(result_file)