Пример #1
0
def test_repeated_topology_buildup(settings):
    """Test to catch a strange bug when trying to cycle through a number of countries
    when building up did destroy the code. Disabled for full PSSE model for time reasons"""

    # noinspection PyUnusedLocal
    logger = logging.getLogger('')

    if settings.settings_name != SettingsEnum.PSSETest:
        return True

    for country in settings.countries:
        logging.debug(f'test for country {country}:')

        try:
            file_contents = open_file(settings)
        except FileNotFoundError:
            print(f'\n{settings.input_file_name} not found, skipping test for that file.')
            return

        branches, gens, nodes = read_grid(file_contents, settings)
        nodes = create_nodes_and_update_branches_with_node_info(branches)

        set_node_country(nodes, settings)
        validate_topology(nodes, branches)

        merge_tie_lines(branches, nodes)
        validate_topology(nodes, branches)
Пример #2
0
def branches_generators_nodes(name_file_settings):
    BGN = collections.namedtuple('BranchesGeneratorsNodes',
                                 'name branches generators nodes settings')

    name = name_file_settings.name
    file_contents = name_file_settings.file
    settings = name_file_settings.settings

    if file_contents is None:
        return BGN(name, None, None, None, settings)

    branches, generators, nodes = read_grid(file_contents, settings)
    validate_topology(nodes, branches)

    return BGN(name, branches, generators, nodes, settings)
Пример #3
0
def branches_generators_nodes_preprocessed_nonmerged(name_file_settings):
    BGN = collections.namedtuple('BranchesGeneratorsNodes',
                                 'name branches generators nodes settings')

    name = f'{name_file_settings.name}_nonmergedcouplers'
    file_contents = name_file_settings.file
    settings = name_file_settings.settings
    if file_contents is None:
        return BGN(name, None, None, None, settings)

    branches, generators, nodes = read_grid(file_contents, settings)
    convert_couplers_to_lines(branches)
    merge_tie_lines(branches, nodes)
    remove_branches_with_loop_elements(branches, nodes)
    validate_topology(nodes, branches)

    return BGN(name, branches, generators, nodes, settings)
Пример #4
0
def test_open_file_and_read_grid_on_off_merge_couplers(merge_couplers, settings):
    settings.do_merge_couplers = merge_couplers

    try:
        file_contents = open_file(settings)
    except FileNotFoundError:
        print(f'\n{settings.input_file_name} not found, skipping test for that file.')
        return

    branches, gens, nodes = read_grid(file_contents, settings)
    assert len(branches) > 0
    assert isinstance(branches[0], Branch)
    assert len([b.name_branch for b in branches]) == len(
        set([b.name_branch for b in branches]))  # uniqueness

    assert len(gens) > 1
    assert isinstance(gens[0], GenerationUnit)
    assert len([g.name for g in gens]) == len(set([g.name for g in gens]))  # uniqueness

    assert len(nodes) > 0
    assert isinstance(nodes[0], Node)
    assert len([n.name for n in nodes]) == len(set([n.name for n in nodes]))