Example #1
0
def main_simulate(in_stream, out_stream):
    limits = Limits(open("rts.lim"))
    loadflow = Loadflow(open("rts.lf"), limits)

    for count, scenario in stream_scenario_generator(in_stream):
        result, result_reason = loadflow.simulate(scenario)
        scenario.result = result
        scenario.result_reason = result_reason
        out_stream.write(str(count) + ", " + str(scenario) + "\n")
Example #2
0
def main_simulate(in_stream, out_stream):
    limits = Limits(open("rts.lim"))
    loadflow = Loadflow(open("rts.lf"), limits)

    for count, scenario in stream_scenario_generator(in_stream):
        result, result_reason = loadflow.simulate(scenario)
        scenario.result = result
        scenario.result_reason = result_reason
        out_stream.write(str(count) + ", " + str(scenario) + "\n")
Example #3
0
def main_test(out_stream):
    """print the results and the intermediate file for
       a number of interesting scenarios. So we can check
       by hand if the intermediate file generator and the
       simulator are doing the correct thing.
    """

    batch_string = ""
    batch_string += "1, base, None, , 1.0" + windstr(1) + "\n"  # base - as normal
    batch_string += "1, half, None, , 0.5" + windstr(1) + "\n"  # half load power
    batch_string += "1, tenth, None, , 0.1" + windstr(1) + "\n"  # tenth load power
    batch_string += "1, island, None, , 1.0" + windstr(1) + ", B11\n"  # island
    batch_string += "1, slack, None, , 1.0" + windstr(1) + ", G12\n"  # removed 1 slack bus
    batch_string += "1, slack-all, None, , 1.0" + windstr(1) + ", G12, G13, G14\n"  # removed all slack busses
    batch_string += "1, line, None, , 1.0" + windstr(1) + ", A2\n"  # remove 1 line
    batch_string += "1, gen, None, , 1.0" + windstr(1) + ", G24\n"  # remove 1 generator
    batch_string += "1, bus, None, , 1.0" + windstr(1) + ", 104\n"  # remove 1 bus without generators
    batch_string += "1, bus-gen, None, , 1.0" + windstr(1) + ", 101\n"  # remove 1 bus with generators attached
    batch_string += "1, bus-slack, None, , 1.0" + windstr(1) + ", 113\n"  # remove slack bus and all slack generators
    batch_string += "1, bus-island, None, , 1.0" + windstr(1) + ", 208\n"  # remove bus that causes island
    batch_string += "1, high-load, None, , 1.10" + windstr(1) + "\n"  # load power high
    batch_string += "1, over-max, None, , 1.15" + windstr(1) + "\n"  # load power above max gen power

    if windlevel.num_wind > 0:
        batch_string += "1, wind-50, None, , 1.0" + windstr(0.5) + "\n"  # base - wind @ 50%
        batch_string += "1, wind-10, None, , 1.0" + windstr(0.1) + "\n"  # base - wind @ 10%
        batch_string += "1, wind-200, None, , 1.0" + windstr(2.0) + "\n"  # base - wind @ 200%

    in_stream = StringIO(batch_string)

    limits = Limits(open("rts.lim"))
    loadflow = Loadflow(open("rts.lf"), limits)

    for count, scenario in stream_scenario_generator(in_stream):
        intermediate_file = open(scenario.scenario_type + ".csv", "w")

        try:
            loadflow.lfgenerator(intermediate_file, scenario)
            result, result_reason = loadflow.simulate(scenario)
        except Exception, e:
            # remove `,` from message
            result, result_reason = (False, "".join(c for c in str(e) if c not in ","))

        intermediate_file.close()
        scenario.result = result
        scenario.result_reason = result_reason
        out_stream.write(str(count) + ", " + str(scenario) + "\n")
Example #4
0
def main_test(out_stream):
    """print the results and the intermediate file for
       a number of interesting scenarios. So we can check
       by hand if the intermediate file generator and the
       simulator are doing the correct thing.
    """

    batch_string = ""
    batch_string += "1, base, None, , 1.0" + windstr(1) + "\n"             # base - as normal
    batch_string += "1, half, None, , 0.5" + windstr(1) + "\n"             # half load power
    batch_string += "1, tenth, None, , 0.1" + windstr(1) + "\n"            # tenth load power
    batch_string += "1, island, None, , 1.0" + windstr(1) + ", B11\n"      # island
    batch_string += "1, slack, None, , 1.0" + windstr(1) + ", G12\n"       # removed 1 slack bus
    batch_string += "1, slack-all, None, , 1.0" + windstr(1) + ", G12, G13, G14\n"  # removed all slack busses
    batch_string += "1, line, None, , 1.0" + windstr(1) + ", A2\n"         # remove 1 line
    batch_string += "1, gen, None, , 1.0" + windstr(1) + ", G24\n"         # remove 1 generator
    batch_string += "1, bus, None, , 1.0" + windstr(1) + ", 104\n"         # remove 1 bus without generators
    batch_string += "1, bus-gen, None, , 1.0" + windstr(1) + ", 101\n"     # remove 1 bus with generators attached
    batch_string += "1, bus-slack, None, , 1.0" + windstr(1) + ", 113\n"   # remove slack bus and all slack generators
    batch_string += "1, bus-island, None, , 1.0" + windstr(1) + ", 208\n"  # remove bus that causes island
    batch_string += "1, high-load, None, , 1.10" + windstr(1) + "\n"       # load power high
    batch_string += "1, over-max, None, , 1.15" + windstr(1) + "\n"        # load power above max gen power

    if windlevel.num_wind > 0:
        batch_string += "1, wind-50, None, , 1.0" + windstr(0.5) + "\n"             # base - wind @ 50%
        batch_string += "1, wind-10, None, , 1.0" + windstr(0.1) + "\n"             # base - wind @ 10%
        batch_string += "1, wind-200, None, , 1.0" + windstr(2.0) + "\n"             # base - wind @ 200%

    in_stream = StringIO(batch_string)

    limits = Limits(open("rts.lim"))
    loadflow = Loadflow(open("rts.lf"), limits)

    for count, scenario in stream_scenario_generator(in_stream):
        intermediate_file = open(scenario.scenario_type + ".csv", "w")

        try:
            loadflow.lfgenerator(intermediate_file, scenario)
            result, result_reason = loadflow.simulate(scenario)
        except Exception, e:
            # remove `,` from message
            result, result_reason = (False, ''.join(c for c in str(e) if c not in ','))

        intermediate_file.close()
        scenario.result = result
        scenario.result_reason = result_reason
        out_stream.write(str(count) + ", " + str(scenario) + "\n")
Example #5
0
"""
Pick from the load flow (not installed capacity) of the starting base case (so
  it is the same for each MCS base-case).

Pick so that You can double the number of itentical generating units on each
bus that are to become 'wind powered'. This is to up the installed capacity
to 20% without changing where the wind farms are.
"""

from loadflow import Loadflow
import string
import random

lf = Loadflow(open("rts.lf"), None)

raw_gens = [x for x in lf.busbars.values() if x[2].strip().startswith("G")]
total_power = sum(float(x[3].strip()) for x in raw_gens)


class Gen(object):
    """docstring for Gen"""
    def __init__(self, name):
        super(Gen, self).__init__()
        self.name = name

    def __str__(self):
        # return string.join(["Gen", self.name, self.bus, str(self.power)], ", ")
        return str(self.power)


gens = []