@testset "control comparison" begin
    original_network = "data/nordic_fault/base/fault_4032_4044.m"
    # We choose to put the new network data in the same folder because
    # we also want to use some data that is already there. Each upgrade
    # gets its own folder.
    new_data_directory = "results/inputs/nordic_fault/"
    standard_frequency = 50.0
    lfac_branch_upgrades = [27,33]

    VariableFrequencyOPF.upgrade_branches(
        original_network,
        new_data_directory,
        standard_frequency,
        indices=lfac_branch_upgrades
    )

    # Minimize generation in areas 2 and 3 with plots including
    # the power flow between areas 1 and 2
    objective = "areagen"
    gen_areas = [2,3]
    area_transfer = [1,2]
    # We want to plot the results of all branch upgrades,
    # so we set `enum_branch` to true
    enum_branches = true

    VariableFrequencyOPF.control_comparison(
        new_data_directory,
        "results/nordic_fault/",
        objective,
        gen_areas=gen_areas,
        area_transfer=area_transfer,
        enum_branches=true,
        results_folders=[],
        start_vals=Dict("sn"=>Dict(2=>50))
    )

    results = JSON.parsefile("results/nordic_fault/results_dict_allplots.json")
    results_dict = results[1]

    subnet1 = findall(results_dict["subnet"]["br27"].==1)[1]
    subnet2 = 3-subnet1

    @test results_dict["status"]["br27"] == "LOCALLY_SOLVED"
    @test results_dict["status"]["br33"] == "LOCALLY_SOLVED"
    @test isapprox(results_dict["cost"]["br27"][subnet1], 4.4015e6; rtol = 1e-2)
    @test isapprox(results_dict["cost"]["br27"][subnet2], 0.0; rtol = 1e-2)
    @test isapprox(results_dict["frequency (Hz)"]["br27"][subnet1], 50.0; atol = 1e0)
    # @test isapprox(results_dict["frequency (Hz)"]["br27"][subnet2], 20.92; atol = 1e0)
    @test isapprox(results_dict["cost"]["br33"][subnet1], 4.3645e6; rtol = 1e-2)
    @test isapprox(results_dict["cost"]["br33"][subnet2], 0.0; rtol = 1e-2)
    @test isapprox(results_dict["frequency (Hz)"]["br33"][subnet1], 50.0; atol = 1e0)
    # @test isapprox(results_dict["frequency (Hz)"]["br33"][subnet2], 22.43; atol = 1e0)

    @test isfile("results/nordic_fault/plots/total/total generation.pdf")
    @test isfile("results/nordic_fault/plots/subnet1/subnet 1 line loss.pdf")
    @test isfile("results/nordic_fault/plots/subnet2/subnet 2 frequency (Hz).pdf")

    try
        rm("results",force=true,recursive=true)
    catch IOError
        println("Unable to delete the results files generated by this test.")
    end
end

@testset "hvdc comparison" begin
    original_network = "data/nordic_fault/base/fault_4032_4044.m"
    # We choose to put the new network data in the same folder because
    # we also want to use some data that is already there. Each upgrade
    # gets its own folder.
    new_data_directory = "results/inputs/nordic_fault/"
    standard_frequency = 50.0
    lfac_branch_upgrades = [27,33]

    VariableFrequencyOPF.upgrade_branches(
        original_network,
        new_data_directory,
        standard_frequency,
        indices=lfac_branch_upgrades,
        noloss=true
    )

    # Minimize generation in areas 2 and 3 with plots including
    # the power flow between areas 1 and 2
    objective = "areagen"
    gen_areas = [2,3]
    area_transfer = [1,2]
    # We want to plot the results of all branch upgrades,
    # so we set `enum_branch` to true
    enum_branches = true

    VariableFrequencyOPF.hvdc_comparison(
        new_data_directory,
        "results/nordic_fault/",
        objective,
        gen_areas=gen_areas,
        area_transfer=area_transfer,
        enum_branches=true,
        series_labels=[
           "LFAC",
           "k_cond=1,k_ins=sqrt(2)",
           "k_cond=2_3,k_ins=sqrt(2)",
           "k_cond=1,k_ins=1",
           "k_cond=2_3,k_ins=1"
           ],
        k_cond=[1,2/3,1,2/3],
        k_ins=[sqrt(2),sqrt(2),1,1],
        dc_subnet=-1,
    )

    results = JSON.parsefile("results/nordic_fault/results_dict_allplots.json")
    results_dict = results[2]

    subnet1 = findall(results_dict["subnet"]["br27"].==1)[1]
    subnet2 = 3-subnet1

    @test results_dict["status"]["br27"] == "LOCALLY_SOLVED"
    @test results_dict["status"]["br33"] == "LOCALLY_SOLVED"
    @test isapprox(results_dict["cost"]["br27"][subnet1], 4.3564e6; rtol = 1e-2)
    @test isapprox(results_dict["cost"]["br27"][subnet2], 0.0; rtol = 1e-2)
    @test isapprox(results_dict["frequency (Hz)"]["br27"][subnet1], 50.0; atol = 1e0)
    @test isapprox(results_dict["frequency (Hz)"]["br27"][subnet2], 0.0; atol = 1e0)
    @test isapprox(results_dict["cost"]["br33"][subnet1], 4.3105e6; rtol = 1e-2)
    @test isapprox(results_dict["cost"]["br33"][subnet2], 0.0; rtol = 1e-2)
    @test isapprox(results_dict["frequency (Hz)"]["br33"][subnet1], 50.0; atol = 1e0)
    @test isapprox(results_dict["frequency (Hz)"]["br33"][subnet2], 0.0; atol = 1e0)

    @test isfile("results/nordic_fault/plots/total/total generation.pdf")
    @test isfile("results/nordic_fault/plots/subnet1/subnet 1 line loss.pdf")
    @test isfile("results/nordic_fault/plots/subnet2/subnet 2 frequency (Hz).pdf")

    try
        rm("results",force=true,recursive=true)
    catch IOError
        println("Unable to delete the results files generated by this test.")
    end
end
