# Need assistance PowerModelDistribution. jl

**URL:** <https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785>\
**Category:** Optimization (Mathematical)\
**Created:** [February 23, 2026, 9:35am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785 "2026-02-23T09:35:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis96](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Curtis96](https://discourse.julialang.org/u/Curtis96)\
**Post date:** [February 23, 2026, 9:35am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/1 "2026-02-23T09:35:58Z")

</div>

Hello everyone, I need your help. I am currently modelling a distribution network (13 buses) using Julia software via PowerModelDistribution with a MATHEMATICAL model. The problem I am encountering is that when calculating the power flow, the voltages do not vary and remain at 1.0 PU, except for those of the Slack Bus. I have tried everything and realise that my network is disconnected, even though the lines and other components of the network are well defined. For this reason, I would like to know if anyone has ever had this kind of problem and how I can solve it.  
I remain at your disposal for further information on the problem.  
Thank you.

---

<div class="post-metadata">

**Author:** ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Post date:** [February 23, 2026, 10:07am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/2 "2026-02-23T10:07:47Z")

</div>

Hello and welcome to the forum.

Please start here:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

For the average person (I mean not domain experts) to be able to help, we would need to first see some code.

---

<div class="post-metadata">

**Author:** ![Curtis96](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Curtis96](https://discourse.julialang.org/u/Curtis96)\
**Post date:** [February 23, 2026, 10:23am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/3 "2026-02-23T10:23:10Z")

</div>

```Julia
###### Here is my main code where I connect the network and perform the calculations. 
using PowerModelsDistribution
using Ipopt
using Printf
const PMD = PowerModelsDistribution
cd(@ __DIR__ )
bus_dict = include(joinpath(@ __DIR__ ,"Bus.jl"))
load_dict = include(joinpath(@ __DIR__ ,"Lasten.jl"))
line_dict = include(joinpath(@ __DIR__ , "Linien.jl"))

math_data = Dict{String, Any}(

   "bus" => bus_dict["bus"],
   "load" => load_dict["load"],
   "branch" => line_dict["branch"],  

    "source" => Dict{String, Any}(
        "1" => Dict{String, Any}("connections" => [1, 2, 3],
           "bus" => "632",
           "index" => 1, 
           "status" => 1, 
           "vm" => [1.0210, 1.0420, 1.0174], 
           "va" => [-2.49*(pi/180), -121.72*(pi/180), 117.83*(pi/180)]
           )
    ),
    "gen" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "connections" => [1, 2, 3],
            "gen_bus" => "632", "index" => 1,
            "gen_status" => 1,
            "gen_type" => 3,
            #"vm" => [1.0210, 1.0420, 1.0174],
            #"va" => [-2.49*(pi /180), -121.72*(pi /180), 117.83*(pi /180)], #radiant winckel
           "status" =>1,
            #"index" =>1,
            "pg" => [5.0, 5.0, 5.0], 
            "qg" => [0.1, 0.1, 0.1],
            "pmax" => [10.0, 10.0, 10.0],
            "pmin" => [0.0, 0.0, 0.0],
            "qmax" => [10.0, 10.0, 10.0],
            "qmin" => [-10.0, -10.0, -10.0]
        )
    ),
    "switch" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "692",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "state" => 1,
            "status" => 1,
            "index" => 1,
            "rs" => [0.001, 0.001, 0.001],
            "xs" => [0.0, 0.0, 0.0],
            "angmin" => [-1.0, -1.0, -1.0], "argmax"=>[1.0,1.0,1.0]
        )
    ),
    "transformer" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "633",
            "t_bus" => "634",
            "f_connections" => [1, 2, 3], 
            "t_connections" => [1, 2, 3],
            "configuration" => PMD.WYE,
            "tm_nom" => 1.0,
            "tm_set" => [1.0, 1.0, 1.0],
            "polarity" => 1,
            "vbase" => [4.16, 0.48],
            "xsc" => [0.8, 0.8, 0.8],
            "rw" => [0.1, 0.1, 0.1],
            "index" => 1,
            "status" => 1,
            "tm_status" => 1
        )   
    ),
    "settings" => Dict{String, Any}("sbase" => 1.0, "vbase" => 4.16),
    "per_unit" => true, "data_model" => PMD.MATHEMATICAL
)

###############################################################################
println("Nombre de bus chargés : ", length(math_data["bus"]))
println("Nombre de branches chargées : ", length(math_data["branch"]))
println("Nombre de charges chargées : ", length(math_data["load"]))
println("Nombre de générateurs chargés : ", length(get(math_data, "gen", Dict())))
println("Nombre de transformateur chargés : ", length(get(math_data, "transformer", Dict())))
println("Nombre de Breacker chargés : ", length(get(math_data, "switch", Dict())))
id_tr = first(keys(math_data["transformer"]))
println("Transformateur reliant le bus $(math_data["transformer"][id_tr]["f_bus"]) au bus $(math_data["transformer"][id_tr]["t_bus"])")
println("Branches reconnues par PMD : ", length(math_data["branch"]))
println("Charges reconnues par PMD : ", length(math_data["load"]))
###
opt = optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6, "print_level"=>0)
resultat_pf = PMD.solve_mc_pf(math_data, PMD.ACPUPowerModel, opt)

# Vérifie immédiatement si la branche 1 existe dans la solution
if haskey(resultat_pf["solution"], "branch") && haskey(resultat_pf["solution"]["branch"], "1")
    flux = resultat_pf["solution"]["branch"]["1"]["pf"]
    println(">>> Flux de puissance sur la branche 1 (632-633) : ", flux)
else
    println(">>> ALERTE : La branche 1 est INEXISTANTE dans la solution finale !")
end
# 3. AFFICHAGE ET CALCUL DES INJECTIONS
if resultat_pf["termination_status"] in [PMD.LOCALLY_SOLVED, PMD.ALMOST_LOCALLY_SOLVED]
    # On récupèration des données de sol
    ma_sol = resultat_pf["solution"]
    sbase_kw = get(math_data["settings"], "sbase", 1.0) * 1000.0

    println("\n" * "═"^95)
    println(" RAPPORT DE FLUX DE PUISSANCE : ÉTAT DES BUS")
    println("═"^95)
    @printf("%-5s | %-5s | %-10s | %-10s | %-15s | %-15s\n", 
            "BUS", "Ph", "V (pu)", "Angle (°)", "P_net (kW)", "Q_net (kVAR)")
    println("-"^95)

    # Tri des bus par ordre numérique
    bus_ids = sort(collect(keys(ma_sol["bus"])), by=x->parse(Int, x))

    for b_id in bus_ids
        # Données de tension du bus
        b_sol = ma_sol["bus"][b_id]
        vm = b_sol["vm"]
        va = rad2deg.(b_sol["va"])
        
        #CALCUL DES INJECTIONS NETTES PAR PHASE...
        p_net = zeros(length(vm))
        q_net = zeros(length(vm))

        # production des Générateurs
        for (g_id, g_res) in get(ma_sol, "gen", Dict())
            if string(math_data["gen"][g_id]["gen_bus"]) == b_id
                pg_vals = g_res["pg"]
                qg_vals = g_res["qg"]
                for i in 1:min(length(p_net), length(pg_vals))
                    p_net[i] += pg_vals[i]
                    q_net[i] += qg_vals[i]
                end
            end
        end

        # 2. Soustraire la consommation (Charges)
        for (l_id, l_info) in get(math_data, "load", Dict())
            if string(l_info["load_bus"]) == b_id
                pd_vals = l_info["pd"]
                qd_vals = l_info["qd"]
                for i in 1:min(length(p_net), length(pd_vals))
                    p_net[i] -= pd_vals[i]
                    q_net[i] -= qd_vals[i]
                end
            end
        end

        # Conversion finale en unités physiques (kW)
        p_final = p_net .* sbase_kw
        q_final = q_net .* sbase_kw
        

        # Affichage de chaque phase pour le bus
        for i in 1:length(vm)
            @printf("%-5s | %d | %12f | %9.2f | %12.2f | %12.2f\n", 
                    b_id, i, vm[i], va[i], p_final[i], q_final[i])
        end
        println("-"^95)
    end
    println("═"^95)
else
    println(" Le solveur n'a pas convergé. Statut : ", resultat_pf["termination_status"])
end

```

---

<div class="post-metadata">

**Author:** ![Curtis96](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Curtis96](https://discourse.julialang.org/u/Curtis96)\
**Post date:** [February 23, 2026, 10:27am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/4 "2026-02-23T10:27:11Z")

</div>

```Julia
############# Here I have defined the different branches of the network. 
#Erstellung der Linien
# 09 branch

using LinearAlgebra
# Constantes de conversion
mi2Km = 1.60934
ft2km = 0.0003048
ms2F = 1/2/pi/60*1e-6
# Per unit umrechnen: Z_base = (V_base)^2/S_base
V_base = 4.16
Z_base = (V_base)^2 /1.0

# Configuration 601 (Triphasée - Standard)
R_601 = [0.3465 0.1560 0.1580; 0.1560 0.3375 0.1535; 0.1580 0.1535 0.3414]./Z_base
X_601 = [1.0179 0.5017 0.4236; 0.5017 1.0478 0.3849; 0.4236 0.3849 1.0348] ./Z_base
B_601 = [6.2998 -1.9958 -1.2595; -1.9958 5.9597 -0.7417; -1.2595 -0.7417 5.6386].*Z_base 

# Convert for SPS
R_601_sps = R_601/mi2Km
L_601_sps = X_601/mi2Km/2/pi/60
C_601_sps = B_601/mi2Km*ms2F

# Configuration 602 (Triphasée)
R_602 = [0.7526 0.1580 0.1560; 0.1580 0.7475 0.1535; 0.1560 0.1535 0.7436]./Z_base
X_602 = [1.1814 0.4236 0.5017; 0.4236 1.1983 0.3849; 0.5017 0.3849 1.2112]./Z_base
B_602 = [5.6990 -1.0817 -1.6905; -1.0817 5.1795 -0.6588; -1.6905 -0.6588 5.4246].*Z_base 

# Convert for SPS
R_602_sps = R_602/mi2Km
L_602_sps = X_602/mi2Km/2/pi/60
C_602_sps = B_602/mi2Km*ms2F

# Configuration 603 
R_603 = [0 0 0 ; 0 1.3294 0.2066; 0 0.2066 1.3238]./Z_base
X_603 = [0 0 0; 0 1.3471 0.4591; 0 0.4591 1.3569] ./Z_base
B_603 = [0 0 0; 0 4.7097 -0.8999;0 -0.8999 4.6658].*Z_base 

# Convert for SPS
R_603_sps = R_603/mi2Km
L_603_sps = X_603/mi2Km/2/pi/60
C_603_sps = B_603/mi2Km*ms2F

# Configuration 604 
R_604 = [1.3238 0 0.2066;0 0 0; 0.2066 0 1.3294]./Z_base
X_604 = [1.3569 0 0.4591;0 0 0; 0.4591 0 1.3471]./Z_base
B_604 = [4.6658 0 -0.8999;0 0 0; -0.8999 0 4.7097].*Z_base

# Convert for SPS
R_604_sps = R_604/mi2Km
L_604_sps = X_604/mi2Km/2/pi/60
C_604_sps = B_604/mi2Km*ms2F

#Configuration 605 
R_605 = [0 0 0;0 0 0;0 0 1.3292]./Z_base
X_605 = [0 0 0;0 0 0;0 0 1.3475]./Z_base
B_605 = [0 0 0;0 0 0;0 0 4.5193].*Z_base

# Convert for SPS
R_605_sps = R_605/mi2Km
L_605_sps = X_605/mi2Km/2/pi/60
C_605_sps = B_605/mi2Km*ms2F

# Configuration 606 
R_606 = [0.7982 0.3192 0.2849; 0.3192 0.7891 0.3192; 0.2849 0.3192 0.7982]./Z_base 
X_606 = [0.4463 0.0328 0.0143; 0.0328 0.4041 0.0328; 0.0143 0.0328 0.4463]./Z_base 
B_606 = [96.8897 -1e-6 -1e-6; -1e-6 96.8897 -1e-6; -1e-6 -1e-6 96.8897].*Z_base

# Convert for SPS
R_606_sps = R_606/mi2Km
L_606_sps = X_606/mi2Km/2/pi/60
C_606_sps = B_606/mi2Km*ms2F

# Configuration 607
R_607 = [1.3425 0 0;0 0 0;0 0 0]./Z_base
X_607 = [0.5124 0 0;0 0 0;0 0 0]./Z_base
B_607= [88.9912 0 0;0 0 0;0 0 0].*Z_base

# Convert for SPS
R_607_sps = R_607/mi2Km
L_607_sps = X_607/mi2Km/2/pi/60
C_607_sps = B_607/mi2Km*ms2F

# --- DÉFINITION DES LIGNES ---

Dict(
  "branch" => Dict{String, Any}(
        "1" => Dict{String, Any}( #632_633
            "f_bus" => "632",
            "t_bus" => "633",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_602_sps.*500*ft2km,
            "br_x" => X_602.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_602.*500*ft2km/2, "b_to" => B_602.*500*ft2km/2, 
            "br_status" => 1, "index" => 1,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

        "2" => Dict{String, Any}( #632_645
            "f_bus" => "632",
            "t_bus" => "645",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*500*ft2km,
            "br_x" => X_603[2:3,2:3].*500*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_603[2:3,2:3].*500*ft2km./2, "b_to" => B_603[2:3,2:3].*500*ft2km./2, 
            "br_status" => 1, "index" => 2,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "3" => Dict{String, Any}( #645_646
            "f_bus" => "645",
            "t_bus" => "646",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*300*ft2km,
            "br_x" => X_603[2:3,2:3].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_603[2:3,2:3].*300*ft2km./2, "b_to" => B_603[2:3,2:3].*300*ft2km./2, 
            "br_status" => 1, "index" => 3,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "4" => Dict{String, Any}( #632_671
            "f_bus" => "632",
            "t_bus" => "671",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*2000*ft2km,
            "br_x" => X_601.*2000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_601.*2000*ft2km/2, "b_to" => B_601.*2000*ft2km/2, 
            "br_status" => 1, "index" => 4,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "5" => Dict{String, Any}( #692_675
            "f_bus" => "692",
            "t_bus" => "675",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_606_sps.*500*ft2km,
            "br_x" => X_606.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_606.*500*ft2km/2, "b_to" => B_606.*500*ft2km/2, 
            "br_status" => 1, "index" => 5,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "6" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "680",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*1000*ft2km,
            "br_x" => X_601.*1000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_601.*1000*ft2km/2, "b_to" => B_601.*1000*ft2km/2, 
            "br_status" => 1, "index" => 6,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),
     
        "7" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "684",
            "f_connections" => [1, 3],
            "t_connections" => [1, 3],
            "br_r" => R_604_sps[[1, 3], [1, 3]].*300*ft2km,
            "br_x" => X_604[[1, 3], [1, 3]].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_604[[1, 3], [1, 3]].*300*ft2km ./ 2, "b_to" => B_604[[1, 3], [1, 3]].*300*ft2km./ 2, 
            "br_status" => 1, "index" => 7,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

         "8" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "652",
            "f_connection" => [1],
            "t_connection" => [1],
            "br_r" => R_604_sps[1: 1, 1: 1].*800*ft2km,
            "br_x" => X_604[1: 1, 1: 1].*800*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1), 
            "b_fr" => B_604[1: 1, 1: 1].*800*ft2km ./ 2, "b_to" => B_604[1: 1, 1: 1].*800*ft2km ./ 2, 
            "br_status" => 1, "index" => 8,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

         "9" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "611",
            "f_connection" => [3],
            "t_connection" => [3],
            "br_r" => R_605_sps[3: 3, 3: 3].*300*ft2km,
            "br_x" => X_605[3: 3, 3: 3].*300*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1), 
            "b_fr" => B_605[3: 3, 3: 3].*300*ft2km ./ 2, "b_to" => B_605[3: 3, 3: 3].*300*ft2km ./ 2, 
            "br_status" => 1, "index" => 9,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

   )
)

```

---

<div class="post-metadata">

**Author:** ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Post date:** [February 23, 2026, 10:50am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/5 "2026-02-23T10:50:35Z")

</div>

please format your code correctly, this is also explained in [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

You don’t have to make a new post, just edit the original one.

---

<div class="post-metadata">

**Author:** ![Curtis96](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Curtis96](https://discourse.julialang.org/u/Curtis96)\
**Post date:** [February 23, 2026, 11:27am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/6 "2026-02-23T11:27:32Z")

</div>

My code is structured into four main parts: one for buses, lines, loads, and the main code.

```Julia
using PowerModelsDistribution
using Ipopt
using Printf
const PMD = PowerModelsDistribution
cd(@ __DIR__ )
bus_dict = include(joinpath(@ __DIR__ ,"Bus.jl"))
load_dict = include(joinpath(@ __DIR__ ,"Lasten.jl"))
line_dict = include(joinpath(@ __DIR__ , "Linien.jl"))

math_data = Dict{String, Any}(

   "bus" => bus_dict["bus"],
   "load" => load_dict["load"],
   "branch" => line_dict["branch"],  

    "source" => Dict{String, Any}(
        "1" => Dict{String, Any}("connections" => [1, 2, 3],
           "bus" => "632",
           "index" => 1, 
           "status" => 1, 
           "vm" => [1.0210, 1.0420, 1.0174], 
           "va" => [-2.49*(pi/180), -121.72*(pi/180), 117.83*(pi/180)]
           )
    ),
    "gen" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "connections" => [1, 2, 3],
            "gen_bus" => "632", "index" => 1,
            "gen_status" => 1,
            "gen_type" => 3,
            #"vm" => [1.0210, 1.0420, 1.0174],
            #"va" => [-2.49*(pi /180), -121.72*(pi /180), 117.83*(pi /180)], #radiant winckel
           "status" =>1,
            #"index" =>1,
            "pg" => [5.0, 5.0, 5.0], 
            "qg" => [0.1, 0.1, 0.1],
            "pmax" => [10.0, 10.0, 10.0],
            "pmin" => [0.0, 0.0, 0.0],
            "qmax" => [10.0, 10.0, 10.0],
            "qmin" => [-10.0, -10.0, -10.0]
        )
    ),
    "switch" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "692",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "state" => 1,
            "status" => 1,
            "index" => 1,
            "rs" => [0.001, 0.001, 0.001],
            "xs" => [0.0, 0.0, 0.0],
            "angmin" => [-1.0, -1.0, -1.0], "argmax"=>[1.0,1.0,1.0]
        )
    ),
    "transformer" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "633",
            "t_bus" => "634",
            "f_connections" => [1, 2, 3], 
            "t_connections" => [1, 2, 3],
            "configuration" => PMD.WYE,
            "tm_nom" => 1.0,
            "tm_set" => [1.0, 1.0, 1.0],
            "polarity" => 1,
            "vbase" => [4.16, 0.48],
            "xsc" => [0.8, 0.8, 0.8],
            "rw" => [0.1, 0.1, 0.1],
            "index" => 1,
            "status" => 1,
            "tm_status" => 1
        )   
    ),
    "settings" => Dict{String, Any}("sbase" => 1.0, "vbase" => 4.16),
    "per_unit" => true, "data_model" => PMD.MATHEMATICAL
)

###############################################################################
println("Nombre de bus chargés : ", length(math_data["bus"]))
println("Nombre de branches chargées : ", length(math_data["branch"]))
println("Nombre de charges chargées : ", length(math_data["load"]))
println("Nombre de générateurs chargés : ", length(get(math_data, "gen", Dict())))
println("Nombre de transformateur chargés : ", length(get(math_data, "transformer", Dict())))
println("Nombre de Breacker chargés : ", length(get(math_data, "switch", Dict())))
id_tr = first(keys(math_data["transformer"]))
println("Transformateur reliant le bus $(math_data["transformer"][id_tr]["f_bus"]) au bus $(math_data["transformer"][id_tr]["t_bus"])")
println("Branches reconnues par PMD : ", length(math_data["branch"]))
println("Charges reconnues par PMD : ", length(math_data["load"]))
###
opt = optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6, "print_level"=>0)
resultat_pf = PMD.solve_mc_pf(math_data, PMD.ACPUPowerModel, opt)

# Verification de la branche 1
if haskey(resultat_pf["solution"], "branch") && haskey(resultat_pf["solution"]["branch"], "1")
    flux = resultat_pf["solution"]["branch"]["1"]["pf"]
    println(">>> Flux de puissance sur la branche 1 (632-633) : ", flux)
else
    println(">>> ALERTE : La branche 1 est INEXISTANTE dans la solution finale !")
end
# 3. AFFICHAGE ET CALCUL DES INJECTIONS
if resultat_pf["termination_status"] in [PMD.LOCALLY_SOLVED, PMD.ALMOST_LOCALLY_SOLVED]
    # On récupèration des données de sol
    ma_sol = resultat_pf["solution"]
    sbase_kw = get(math_data["settings"], "sbase", 1.0) * 1000.0

    println("\n" * "═"^95)
    println(" RAPPORT DE FLUX DE PUISSANCE : ÉTAT DES BUS")
    println("═"^95)
    @printf("%-5s | %-5s | %-10s | %-10s | %-15s | %-15s\n", 
            "BUS", "Ph", "V (pu)", "Angle (°)", "P_net (kW)", "Q_net (kVAR)")
    println("-"^95)

    # Tri des bus par ordre numérique
    bus_ids = sort(collect(keys(ma_sol["bus"])), by=x->parse(Int, x))

    for b_id in bus_ids
        # Données de tension du bus
        b_sol = ma_sol["bus"][b_id]
        vm = b_sol["vm"]
        va = rad2deg.(b_sol["va"])
        
        #CALCUL DES INJECTIONS NETTES PAR PHASE...
        p_net = zeros(length(vm))
        q_net = zeros(length(vm))

        # production des Générateurs
        for (g_id, g_res) in get(ma_sol, "gen", Dict())
            if string(math_data["gen"][g_id]["gen_bus"]) == b_id
                pg_vals = g_res["pg"]
                qg_vals = g_res["qg"]
                for i in 1:min(length(p_net), length(pg_vals))
                    p_net[i] += pg_vals[i]
                    q_net[i] += qg_vals[i]
                end
            end
        end

        # 2. Soustraire la consommation (Charges)
        for (l_id, l_info) in get(math_data, "load", Dict())
            if string(l_info["load_bus"]) == b_id
                pd_vals = l_info["pd"]
                qd_vals = l_info["qd"]
                for i in 1:min(length(p_net), length(pd_vals))
                    p_net[i] -= pd_vals[i]
                    q_net[i] -= qd_vals[i]
                end
            end
        end

        # Conversion finale en unités physiques (kW)
        p_final = p_net .* sbase_kw
        q_final = q_net .* sbase_kw
        

        # Affichage de chaque phase pour le bus
        for i in 1:length(vm)
            @printf("%-5s | %d | %12f | %9.2f | %12.2f | %12.2f\n", 
                    b_id, i, vm[i], va[i], p_final[i], q_final[i])
        end
        println("-"^95)
    end
    println("═"^95)
else
    println("❌ Le solveur n'a pas convergé. Statut : ", resultat_pf["termination_status"])
end

#Erstellung der Lasten / Load
# 15 Lasten

using LinearAlgebra
# Constantes de conversion
mi2Km = 1.60934
ft2km = 0.0003048
ms2F = 1/2/pi/60*1e-6
# Per unit umrechnen: Z_base = (V_base)^2/S_base
V_base = 4.16
Z_base = (V_base)^2 /1.0

# Configuration 601 (Triphasée - Standard)
R_601 = [0.3465 0.1560 0.1580; 0.1560 0.3375 0.1535; 0.1580 0.1535 0.3414]./Z_base
X_601 = [1.0179 0.5017 0.4236; 0.5017 1.0478 0.3849; 0.4236 0.3849 1.0348] ./Z_base
B_601 = [6.2998 -1.9958 -1.2595; -1.9958 5.9597 -0.7417; -1.2595 -0.7417 5.6386].*Z_base 

# Convert for SPS
R_601_sps = R_601/mi2Km
L_601_sps = X_601/mi2Km/2/pi/60
C_601_sps = B_601/mi2Km*ms2F

# Configuration 602 (Triphasée)
R_602 = [0.7526 0.1580 0.1560; 0.1580 0.7475 0.1535; 0.1560 0.1535 0.7436]./Z_base
X_602 = [1.1814 0.4236 0.5017; 0.4236 1.1983 0.3849; 0.5017 0.3849 1.2112]./Z_base
B_602 = [5.6990 -1.0817 -1.6905; -1.0817 5.1795 -0.6588; -1.6905 -0.6588 5.4246].*Z_base 

# Convert for SPS
R_602_sps = R_602/mi2Km
L_602_sps = X_602/mi2Km/2/pi/60
C_602_sps = B_602/mi2Km*ms2F

# Configuration 603 
R_603 = [0 0 0 ; 0 1.3294 0.2066; 0 0.2066 1.3238]./Z_base
X_603 = [0 0 0; 0 1.3471 0.4591; 0 0.4591 1.3569] ./Z_base
B_603 = [0 0 0; 0 4.7097 -0.8999;0 -0.8999 4.6658].*Z_base 

# Convert for SPS
R_603_sps = R_603/mi2Km
L_603_sps = X_603/mi2Km/2/pi/60
C_603_sps = B_603/mi2Km*ms2F

# Configuration 604 
R_604 = [1.3238 0 0.2066;0 0 0; 0.2066 0 1.3294]./Z_base
X_604 = [1.3569 0 0.4591;0 0 0; 0.4591 0 1.3471]./Z_base
B_604 = [4.6658 0 -0.8999;0 0 0; -0.8999 0 4.7097].*Z_base

# Convert for SPS
R_604_sps = R_604/mi2Km
L_604_sps = X_604/mi2Km/2/pi/60
C_604_sps = B_604/mi2Km*ms2F

#Configuration 605 
R_605 = [0 0 0;0 0 0;0 0 1.3292]./Z_base
X_605 = [0 0 0;0 0 0;0 0 1.3475]./Z_base
B_605 = [0 0 0;0 0 0;0 0 4.5193].*Z_base

# Convert for SPS
R_605_sps = R_605/mi2Km
L_605_sps = X_605/mi2Km/2/pi/60
C_605_sps = B_605/mi2Km*ms2F

# Configuration 606 
R_606 = [0.7982 0.3192 0.2849; 0.3192 0.7891 0.3192; 0.2849 0.3192 0.7982]./Z_base 
X_606 = [0.4463 0.0328 0.0143; 0.0328 0.4041 0.0328; 0.0143 0.0328 0.4463]./Z_base 
B_606 = [96.8897 -1e-6 -1e-6; -1e-6 96.8897 -1e-6; -1e-6 -1e-6 96.8897].*Z_base

# Convert for SPS
R_606_sps = R_606/mi2Km
L_606_sps = X_606/mi2Km/2/pi/60
C_606_sps = B_606/mi2Km*ms2F

# Configuration 607
R_607 = [1.3425 0 0;0 0 0;0 0 0]./Z_base
X_607 = [0.5124 0 0;0 0 0;0 0 0]./Z_base
B_607= [88.9912 0 0;0 0 0;0 0 0].*Z_base

# Convert for SPS
R_607_sps = R_607/mi2Km
L_607_sps = X_607/mi2Km/2/pi/60
C_607_sps = B_607/mi2Km*ms2F

# --- DÉFINITION DES LIGNES ---

Dict(
  "branch" => Dict{String, Any}(
        "1" => Dict{String, Any}( #632_633
            "f_bus" => "632",
            "t_bus" => "633",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_602_sps.*500*ft2km,
            "br_x" => X_602.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_602.*500*ft2km/2, "b_to" => B_602.*500*ft2km/2, 
            "br_status" => 1, "index" => 1,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

        "2" => Dict{String, Any}( #632_645
            "f_bus" => "632",
            "t_bus" => "645",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*500*ft2km,
            "br_x" => X_603[2:3,2:3].*500*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_603[2:3,2:3].*500*ft2km./2, "b_to" => B_603[2:3,2:3].*500*ft2km./2, 
            "br_status" => 1, "index" => 2,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "3" => Dict{String, Any}( #645_646
            "f_bus" => "645",
            "t_bus" => "646",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*300*ft2km,
            "br_x" => X_603[2:3,2:3].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_603[2:3,2:3].*300*ft2km./2, "b_to" => B_603[2:3,2:3].*300*ft2km./2, 
            "br_status" => 1, "index" => 3,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "4" => Dict{String, Any}( #632_671
            "f_bus" => "632",
            "t_bus" => "671",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*2000*ft2km,
            "br_x" => X_601.*2000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_601.*2000*ft2km/2, "b_to" => B_601.*2000*ft2km/2, 
            "br_status" => 1, "index" => 4,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "5" => Dict{String, Any}( #692_675
            "f_bus" => "692",
            "t_bus" => "675",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_606_sps.*500*ft2km,
            "br_x" => X_606.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_606.*500*ft2km/2, "b_to" => B_606.*500*ft2km/2, 
            "br_status" => 1, "index" => 5,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "6" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "680",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*1000*ft2km,
            "br_x" => X_601.*1000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3), 
            "b_fr" => B_601.*1000*ft2km/2, "b_to" => B_601.*1000*ft2km/2, 
            "br_status" => 1, "index" => 6,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),
     
        "7" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "684",
            "f_connections" => [1, 3],
            "t_connections" => [1, 3],
            "br_r" => R_604_sps[[1, 3], [1, 3]].*300*ft2km,
            "br_x" => X_604[[1, 3], [1, 3]].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2), 
            "b_fr" => B_604[[1, 3], [1, 3]].*300*ft2km ./ 2, "b_to" => B_604[[1, 3], [1, 3]].*300*ft2km./ 2, 
            "br_status" => 1, "index" => 7,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

         "8" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "652",
            "f_connection" => [1],
            "t_connection" => [1],
            "br_r" => R_604_sps[1: 1, 1: 1].*800*ft2km,
            "br_x" => X_604[1: 1, 1: 1].*800*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1), 
            "b_fr" => B_604[1: 1, 1: 1].*800*ft2km ./ 2, "b_to" => B_604[1: 1, 1: 1].*800*ft2km ./ 2, 
            "br_status" => 1, "index" => 8,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

         "9" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "611",
            "f_connection" => [3],
            "t_connection" => [3],
            "br_r" => R_605_sps[3: 3, 3: 3].*300*ft2km,
            "br_x" => X_605[3: 3, 3: 3].*300*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1), 
            "b_fr" => B_605[3: 3, 3: 3].*300*ft2km ./ 2, "b_to" => B_605[3: 3, 3: 3].*300*ft2km ./ 2, 
            "br_status" => 1, "index" => 9,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

   )
)

#Erstellung der Lasten / Load
# 15 Lasten
# Dien Leistungen sind in kWatt und durch sbase = 1000 haben wir dies Per Unit
Dict(
  "load"=> Dict{String,Any}(

    "1" =>Dict{String, Any}( #632_Yq_PQ
        "load_bus"=> "632",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [17, 66, 117]./2000.0,
        "qd" => [10, 38, 68]./2000.0,
        "status" => 1,
        "index" => 1
    ),

    "2" =>Dict{String, Any}( #634_Yg_PQ
        "load_bus"=>"634",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [160, 120, 120]./1000.0,
        "qd" => [110, 90, 90]./1000.0,
        "status" => 1,
        "index" => 2
    ),
    "3" =>Dict{String, Any}( #645_PQ
        "load_bus"=> "645",
        "connections" =>[2],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        #"pd" => [0.0, 170, 0.0]./1000.0,
        #"qd" => [0.0, 125, 0.0]./1000.0,
        "pd" => [170]/1000.0,
        "qd" => [125]/1000.0,
        "status" => 1,
        "index" => 3
    ),
    "4" =>Dict{String, Any}( # a verifier completement #646_Z
        "load_bus"=> "646",
        "connections" =>[2,3],
        "configuration" => PMD.DELTA, #DELTA weil sie zwichen 2 phasen ist
        "model" => PMD.IMPEDANCE,
        #"pd" => [0.0, 230, 0.0]./1000.0, #1 und 2 dann 2 und 3 danach 3 und 1 wiwr haben nur 2 und 3 andere sind 0 
        #"qd" => [0.0, 132, 0.0]./1000.0,
        "pd" => [230, 0.0]./1000.0, #1 und 2 dann 2 und 3 danach 3 und 1 wiwr haben nur 2 und 3 andere sind 0 
        "qd" => [132, 0.0]./1000.0,
        "status" => 1,
        "index" => 4
    ),
    "5" =>Dict{String, Any}( #671_Yq_PQ
        "load_bus"=> "671",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [17, 66, 117]./2000.0,
        "qd" => [10, 38, 68]./2000.0,
        "status" => 1,
        "index" => 5
    ),
    "6" =>Dict{String, Any}( #671_D_PQ
        "load_bus"=> "671",
        "connections" =>[1,2,3],
        "configuration" => PMD.DELTA,
        "model" => PMD.POWER,
        "pd" => [385, 385, 385]./1000.0,
        "qd" => [220, 220, 220]./1000.0,
        "status" => 1,
        "index" => 6
    ),
    "7" =>Dict{String, Any}( #675_Yg_Z
        "load_bus"=> "675",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [0.0, 0.0, 0.0],
        "qd" => [-200, -200, -200]./1000.0,
        "status" => 1,
        "index" => 7
    ),
    "8" =>Dict{String, Any}( #675_Yg_PQ
        "load_bus"=> "675",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [485, 68, 290]./1000.0, #en Watt
        "qd" => [190, 60, 212]./1000.0,
        "status" => 1,
        "index" => 8
    ),
    "9" =>Dict{String, Any}( #692_D_I
        "load_bus"=> "692",
        "connections" =>[1,2,3],
        "configuration" => PMD.DELTA,
        "model" => PMD.CURRENT,
        "pd" => [1e-6, 1e-3, 170]./1000.0, # en watt
        "qd" => [0.0, 0.0, 151]./1000.0, # en Var
        "status" => 1,
        "index" => 9
    ),
    "10" =>Dict{String, Any}( #652_Z
        "load_bus"=> "652",
        "connection" =>[1],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [128]/1000.0,
        "qd" => [86]/1000.0,
        "status" => 1,
        "index" => 10
    ),
    "11" =>Dict{String, Any}( #611_Z
        "load_bus"=> "611",
        "connection" =>[3],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [0.0],
        "qd" => [-100]/1000.0,
        "status" => 1,
        "index" => 11
    ),
    "12" =>Dict{String, Any}( #611_I
        "load_bus"=> "611",
        "connection" =>[3],
        "configuration" => PMD.WYE,
        "model" => PMD.CURRENT,
        "pd" => [170]/1000.0,
        "qd" => [80]/1000.0,
        "status" => 1,
        "index" => 12
    ),
  )

)

#Erstellung der Knoten / Bussen
# 13 Bussen
Dict(
  "bus" => Dict{String, Any}(
        "632" => Dict{String,Any}(
            "bus_type" => 3,
            "vbase" => 4.160/sqrt(3), #kV
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [true, true,true],
            "index" => 1,
            "vmin" => [0.1, 0.1, 0.1],
            "vmax" => [1.1, 1.1, 1.1],
            "vm" => [1.0210, 1.0420, 1.0174],
            "va" => [-2.49*(pi/180), -121.72*(pi/180), 117.83*(pi/180)]
        ),

        "633" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 2,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "634" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 0.480/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 3,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "645" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [2,3],
            #"terminals" => [1,2,3],
            "grounded" => [false,false],
            "index" => 4,
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
            #"vmin" => [0.0, 0.0, 0.0],
            #"vmax" => [1.5, 1.5, 1.5]
        ),
        "646" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [2,3],
            "grounded" => [false,false],
            "index" => 5,
            #"vmin" => [0.0, 0.0, 0.0],
            #"vmax" => [1.5, 1.5, 1.5]
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
        ),
        "671" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 6,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "675" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 7,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "692" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 8,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "680" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 9,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "684" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,3],
            "grounded" => [false,false],
            "index" => 10,
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
        ),
        "652" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1],
            "grounded" => [false],
            "index" => 11,
            "vmin" => [0.0],
            "vmax" => [1.5]
        ),
        "611" => Dict{String,Any}(#Erstellung der Knoten / Bussen
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [3],
            "grounded" => [false],
            "index" => 12,
            "vmin" => [0.0],
            "vmax" => [1.5]
        )

    )
)

```

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [February 23, 2026, 1:34pm UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/7 "2026-02-23T13:34:02Z")

</div>

> [@Curtis96](#):
>
> I have tried everything and realise that my network is disconnected, even though the lines and other components of the network are well defined. For this reason, I would like to know if anyone has ever had this kind of problem and how I can solve it.

Hi,

A 13-bus distribution network is a small case. I think it’s a good starting point to use a toy example like that model, if you are relatively inexperienced. Since it’s small, you can directly draw that network as a graph on a paper so you can check whether it is a proper network. And after solution you can analyze the power flows…

From my personal experience about numeric computation (especially optimization), the data can generally be generated via random number in proper ranges. Therefore all datasets are not mandatory for me. I would borrow only the graph structure (i.e. the branch-node connection pattern) from the standard cases. And if the existing graph structure is not standard (e.g. there are isolated nodes, or there are redundant parallel branches), I would manually modify it so it can serve as a proper numeric test case that I can write algorithms on.

---

<div class="post-metadata">

**Author:** ![Curtis96](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Curtis96](https://discourse.julialang.org/u/Curtis96)\
**Post date:** [February 23, 2026, 10:52pm UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/8 "2026-02-23T22:52:09Z")

</div>

Thank you very much.  
I did that, but the problem persists.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 24, 2026, 1:40am UTC](https://discourse.julialang.org/t/need-assistance-powermodeldistribution-jl/135785/9 "2026-02-24T01:40:04Z")

</div>

Hi @Curtis96, welcome to the forum 😄

I’ve edited your previous posts to format them correctly.

You needed triple back-ticks, like this:

````julia-auto
```julia
1 + 1
```

````

Unfortunately I don’t know if I have the domain expertise the understand your problem. You’ve probably chosen the wrong combination of `solve_mc_pf` and the `ACPUPowerModel`.

@ccoffrin may be able to point us in the direction of someone who can help.

Here’s a reproducible example for future reference

```Julia
using PowerModelsDistribution
using Ipopt
using Printf
const PMD = PowerModelsDistribution

using LinearAlgebra
# Constantes de conversion
mi2Km = 1.60934
ft2km = 0.0003048
ms2F = 1/2/pi/60*1e-6
# Per unit umrechnen: Z_base = (V_base)^2/S_base
V_base = 4.16
Z_base = (V_base)^2 /1.0

# Configuration 601 (Triphasée - Standard)
R_601 = [0.3465 0.1560 0.1580; 0.1560 0.3375 0.1535; 0.1580 0.1535 0.3414]./Z_base
X_601 = [1.0179 0.5017 0.4236; 0.5017 1.0478 0.3849; 0.4236 0.3849 1.0348] ./Z_base
B_601 = [6.2998 -1.9958 -1.2595; -1.9958 5.9597 -0.7417; -1.2595 -0.7417 5.6386].*Z_base

# Convert for SPS
R_601_sps = R_601/mi2Km
L_601_sps = X_601/mi2Km/2/pi/60
C_601_sps = B_601/mi2Km*ms2F

# Configuration 602 (Triphasée)
R_602 = [0.7526 0.1580 0.1560; 0.1580 0.7475 0.1535; 0.1560 0.1535 0.7436]./Z_base
X_602 = [1.1814 0.4236 0.5017; 0.4236 1.1983 0.3849; 0.5017 0.3849 1.2112]./Z_base
B_602 = [5.6990 -1.0817 -1.6905; -1.0817 5.1795 -0.6588; -1.6905 -0.6588 5.4246].*Z_base

# Convert for SPS
R_602_sps = R_602/mi2Km
L_602_sps = X_602/mi2Km/2/pi/60
C_602_sps = B_602/mi2Km*ms2F

# Configuration 603
R_603 = [0 0 0 ; 0 1.3294 0.2066; 0 0.2066 1.3238]./Z_base
X_603 = [0 0 0; 0 1.3471 0.4591; 0 0.4591 1.3569] ./Z_base
B_603 = [0 0 0; 0 4.7097 -0.8999;0 -0.8999 4.6658].*Z_base

# Convert for SPS
R_603_sps = R_603/mi2Km
L_603_sps = X_603/mi2Km/2/pi/60
C_603_sps = B_603/mi2Km*ms2F

# Configuration 604
R_604 = [1.3238 0 0.2066;0 0 0; 0.2066 0 1.3294]./Z_base
X_604 = [1.3569 0 0.4591;0 0 0; 0.4591 0 1.3471]./Z_base
B_604 = [4.6658 0 -0.8999;0 0 0; -0.8999 0 4.7097].*Z_base

# Convert for SPS
R_604_sps = R_604/mi2Km
L_604_sps = X_604/mi2Km/2/pi/60
C_604_sps = B_604/mi2Km*ms2F

#Configuration 605
R_605 = [0 0 0;0 0 0;0 0 1.3292]./Z_base
X_605 = [0 0 0;0 0 0;0 0 1.3475]./Z_base
B_605 = [0 0 0;0 0 0;0 0 4.5193].*Z_base

# Convert for SPS
R_605_sps = R_605/mi2Km
L_605_sps = X_605/mi2Km/2/pi/60
C_605_sps = B_605/mi2Km*ms2F

# Configuration 606
R_606 = [0.7982 0.3192 0.2849; 0.3192 0.7891 0.3192; 0.2849 0.3192 0.7982]./Z_base
X_606 = [0.4463 0.0328 0.0143; 0.0328 0.4041 0.0328; 0.0143 0.0328 0.4463]./Z_base
B_606 = [96.8897 -1e-6 -1e-6; -1e-6 96.8897 -1e-6; -1e-6 -1e-6 96.8897].*Z_base

# Convert for SPS
R_606_sps = R_606/mi2Km
L_606_sps = X_606/mi2Km/2/pi/60
C_606_sps = B_606/mi2Km*ms2F

# Configuration 607
R_607 = [1.3425 0 0;0 0 0;0 0 0]./Z_base
X_607 = [0.5124 0 0;0 0 0;0 0 0]./Z_base
B_607= [88.9912 0 0;0 0 0;0 0 0].*Z_base

# Convert for SPS
R_607_sps = R_607/mi2Km
L_607_sps = X_607/mi2Km/2/pi/60
C_607_sps = B_607/mi2Km*ms2F

line_dict = Dict(
  "branch" => Dict{String, Any}(
        "1" => Dict{String, Any}( #632_633
            "f_bus" => "632",
            "t_bus" => "633",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_602_sps.*500*ft2km,
            "br_x" => X_602.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3),
            "b_fr" => B_602.*500*ft2km/2, "b_to" => B_602.*500*ft2km/2,
            "br_status" => 1, "index" => 1,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

        "2" => Dict{String, Any}( #632_645
            "f_bus" => "632",
            "t_bus" => "645",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*500*ft2km,
            "br_x" => X_603[2:3,2:3].*500*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2),
            "b_fr" => B_603[2:3,2:3].*500*ft2km./2, "b_to" => B_603[2:3,2:3].*500*ft2km./2,
            "br_status" => 1, "index" => 2,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "3" => Dict{String, Any}( #645_646
            "f_bus" => "645",
            "t_bus" => "646",
            "f_connections" => [2, 3],
            "t_connections" => [2, 3],
            "br_r" => R_603_sps[2:3,2:3].*300*ft2km,
            "br_x" => X_603[2:3,2:3].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2),
            "b_fr" => B_603[2:3,2:3].*300*ft2km./2, "b_to" => B_603[2:3,2:3].*300*ft2km./2,
            "br_status" => 1, "index" => 3,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

        "4" => Dict{String, Any}( #632_671
            "f_bus" => "632",
            "t_bus" => "671",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*2000*ft2km,
            "br_x" => X_601.*2000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3),
            "b_fr" => B_601.*2000*ft2km/2, "b_to" => B_601.*2000*ft2km/2,
            "br_status" => 1, "index" => 4,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "5" => Dict{String, Any}( #692_675
            "f_bus" => "692",
            "t_bus" => "675",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_606_sps.*500*ft2km,
            "br_x" => X_606.*500*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3),
            "b_fr" => B_606.*500*ft2km/2, "b_to" => B_606.*500*ft2km/2,
            "br_status" => 1, "index" => 5,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

         "6" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "680",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "br_r" => R_601_sps.*1000*ft2km,
            "br_x" => X_601.*1000*ft2km,
            "g_fr" => zeros(3,3), "g_to" => zeros(3,3),
            "b_fr" => B_601.*1000*ft2km/2, "b_to" => B_601.*1000*ft2km/2,
            "br_status" => 1, "index" => 6,
            "angmin" => [-3.14, -3.14, -3.14], "angmax" => [3.14, 3.14, 3.14]
        ),

        "7" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "684",
            "f_connections" => [1, 3],
            "t_connections" => [1, 3],
            "br_r" => R_604_sps[[1, 3], [1, 3]].*300*ft2km,
            "br_x" => X_604[[1, 3], [1, 3]].*300*ft2km,
            "g_fr" => zeros(2,2), "g_to" => zeros(2,2),
            "b_fr" => B_604[[1, 3], [1, 3]].*300*ft2km ./ 2, "b_to" => B_604[[1, 3], [1, 3]].*300*ft2km./ 2,
            "br_status" => 1, "index" => 7,
            "angmin" => [-3.14, -3.14], "angmax" => [3.14, 3.14]
        ),

         "8" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "652",
            "f_connection" => [1],
            "t_connection" => [1],
            "br_r" => R_604_sps[1: 1, 1: 1].*800*ft2km,
            "br_x" => X_604[1: 1, 1: 1].*800*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1),
            "b_fr" => B_604[1: 1, 1: 1].*800*ft2km ./ 2, "b_to" => B_604[1: 1, 1: 1].*800*ft2km ./ 2,
            "br_status" => 1, "index" => 8,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

         "9" => Dict{String, Any}(
            "f_bus" => "684",
            "t_bus" => "611",
            "f_connection" => [3],
            "t_connection" => [3],
            "br_r" => R_605_sps[3: 3, 3: 3].*300*ft2km,
            "br_x" => X_605[3: 3, 3: 3].*300*ft2km,
            "g_fr" => zeros(1,1), "g_to" => zeros(1,1),
            "b_fr" => B_605[3: 3, 3: 3].*300*ft2km ./ 2, "b_to" => B_605[3: 3, 3: 3].*300*ft2km ./ 2,
            "br_status" => 1, "index" => 9,
            "angmin" => [-3.14], "angmax" => [3.14]
        ),

   )
)

#Erstellung der Lasten / Load
# 15 Lasten
# Dien Leistungen sind in kWatt und durch sbase = 1000 haben wir dies Per Unit
load_dict = Dict(
  "load"=> Dict{String,Any}(

    "1" =>Dict{String, Any}( #632_Yq_PQ
        "load_bus"=> "632",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [17, 66, 117]./2000.0,
        "qd" => [10, 38, 68]./2000.0,
        "status" => 1,
        "index" => 1
    ),

    "2" =>Dict{String, Any}( #634_Yg_PQ
        "load_bus"=>"634",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [160, 120, 120]./1000.0,
        "qd" => [110, 90, 90]./1000.0,
        "status" => 1,
        "index" => 2
    ),
    "3" =>Dict{String, Any}( #645_PQ
        "load_bus"=> "645",
        "connections" =>[2],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        #"pd" => [0.0, 170, 0.0]./1000.0,
        #"qd" => [0.0, 125, 0.0]./1000.0,
        "pd" => [170]/1000.0,
        "qd" => [125]/1000.0,
        "status" => 1,
        "index" => 3
    ),
    "4" =>Dict{String, Any}( # a verifier completement #646_Z
        "load_bus"=> "646",
        "connections" =>[2,3],
        "configuration" => PMD.DELTA, #DELTA weil sie zwichen 2 phasen ist
        "model" => PMD.IMPEDANCE,
        #"pd" => [0.0, 230, 0.0]./1000.0, #1 und 2 dann 2 und 3 danach 3 und 1 wiwr haben nur 2 und 3 andere sind 0
        #"qd" => [0.0, 132, 0.0]./1000.0,
        "pd" => [230, 0.0]./1000.0, #1 und 2 dann 2 und 3 danach 3 und 1 wiwr haben nur 2 und 3 andere sind 0
        "qd" => [132, 0.0]./1000.0,
        "status" => 1,
        "index" => 4
    ),
    "5" =>Dict{String, Any}( #671_Yq_PQ
        "load_bus"=> "671",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [17, 66, 117]./2000.0,
        "qd" => [10, 38, 68]./2000.0,
        "status" => 1,
        "index" => 5
    ),
    "6" =>Dict{String, Any}( #671_D_PQ
        "load_bus"=> "671",
        "connections" =>[1,2,3],
        "configuration" => PMD.DELTA,
        "model" => PMD.POWER,
        "pd" => [385, 385, 385]./1000.0,
        "qd" => [220, 220, 220]./1000.0,
        "status" => 1,
        "index" => 6
    ),
    "7" =>Dict{String, Any}( #675_Yg_Z
        "load_bus"=> "675",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [0.0, 0.0, 0.0],
        "qd" => [-200, -200, -200]./1000.0,
        "status" => 1,
        "index" => 7
    ),
    "8" =>Dict{String, Any}( #675_Yg_PQ
        "load_bus"=> "675",
        "connections" =>[1,2,3],
        "configuration" => PMD.WYE,
        "model" => PMD.POWER,
        "pd" => [485, 68, 290]./1000.0, #en Watt
        "qd" => [190, 60, 212]./1000.0,
        "status" => 1,
        "index" => 8
    ),
    "9" =>Dict{String, Any}( #692_D_I
        "load_bus"=> "692",
        "connections" =>[1,2,3],
        "configuration" => PMD.DELTA,
        "model" => PMD.CURRENT,
        "pd" => [1e-6, 1e-3, 170]./1000.0, # en watt
        "qd" => [0.0, 0.0, 151]./1000.0, # en Var
        "status" => 1,
        "index" => 9
    ),
    "10" =>Dict{String, Any}( #652_Z
        "load_bus"=> "652",
        "connection" =>[1],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [128]/1000.0,
        "qd" => [86]/1000.0,
        "status" => 1,
        "index" => 10
    ),
    "11" =>Dict{String, Any}( #611_Z
        "load_bus"=> "611",
        "connection" =>[3],
        "configuration" => PMD.WYE,
        "model" => PMD.IMPEDANCE,
        "pd" => [0.0],
        "qd" => [-100]/1000.0,
        "status" => 1,
        "index" => 11
    ),
    "12" =>Dict{String, Any}( #611_I
        "load_bus"=> "611",
        "connection" =>[3],
        "configuration" => PMD.WYE,
        "model" => PMD.CURRENT,
        "pd" => [170]/1000.0,
        "qd" => [80]/1000.0,
        "status" => 1,
        "index" => 12
    ),
  )

)

#Erstellung der Knoten / Bussen
# 13 Bussen
bus_dict = Dict(
  "bus" => Dict{String, Any}(
        "632" => Dict{String,Any}(
            "bus_type" => 3,
            "vbase" => 4.160/sqrt(3), #kV
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [true, true,true],
            "index" => 1,
            "vmin" => [0.1, 0.1, 0.1],
            "vmax" => [1.1, 1.1, 1.1],
            "vm" => [1.0210, 1.0420, 1.0174],
            "va" => [-2.49*(pi/180), -121.72*(pi/180), 117.83*(pi/180)]
        ),

        "633" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 2,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "634" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 0.480/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 3,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "645" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [2,3],
            #"terminals" => [1,2,3],
            "grounded" => [false,false],
            "index" => 4,
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
            #"vmin" => [0.0, 0.0, 0.0],
            #"vmax" => [1.5, 1.5, 1.5]
        ),
        "646" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [2,3],
            "grounded" => [false,false],
            "index" => 5,
            #"vmin" => [0.0, 0.0, 0.0],
            #"vmax" => [1.5, 1.5, 1.5]
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
        ),
        "671" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 6,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "675" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 7,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "692" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 8,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "680" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,2,3],
            "grounded" => [false, false,false],
            "index" => 9,
            "vmin" => [0.0, 0.0, 0.0],
            "vmax" => [1.5, 1.5, 1.5]
        ),
        "684" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1,3],
            "grounded" => [false,false],
            "index" => 10,
            "vmin" => [0.0, 0.0],
            "vmax" => [1.5, 1.5]
        ),
        "652" => Dict{String,Any}(
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [1],
            "grounded" => [false],
            "index" => 11,
            "vmin" => [0.0],
            "vmax" => [1.5]
        ),
        "611" => Dict{String,Any}(#Erstellung der Knoten / Bussen
            "bus_type" => 1,
            "vbase" => 4.160/sqrt(3),
            "vnom_kv" => 4.16 / sqrt(3),
            "terminals" => [3],
            "grounded" => [false],
            "index" => 12,
            "vmin" => [0.0],
            "vmax" => [1.5]
        )

    )
)

math_data = Dict{String, Any}(

   "bus" => bus_dict["bus"],
   "load" => load_dict["load"],
   "branch" => line_dict["branch"],

    "source" => Dict{String, Any}(
        "1" => Dict{String, Any}("connections" => [1, 2, 3],
           "bus" => "632",
           "index" => 1,
           "status" => 1,
           "vm" => [1.0210, 1.0420, 1.0174],
           "va" => [-2.49*(pi/180), -121.72*(pi/180), 117.83*(pi/180)]
           )
    ),
    "gen" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "connections" => [1, 2, 3],
            "gen_bus" => "632", "index" => 1,
            "gen_status" => 1,
            "gen_type" => 3,
            #"vm" => [1.0210, 1.0420, 1.0174],
            #"va" => [-2.49*(pi /180), -121.72*(pi /180), 117.83*(pi /180)], #radiant winckel
           "status" =>1,
            #"index" =>1,
            "pg" => [5.0, 5.0, 5.0],
            "qg" => [0.1, 0.1, 0.1],
            "pmax" => [10.0, 10.0, 10.0],
            "pmin" => [0.0, 0.0, 0.0],
            "qmax" => [10.0, 10.0, 10.0],
            "qmin" => [-10.0, -10.0, -10.0]
        )
    ),
    "switch" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "671",
            "t_bus" => "692",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "state" => 1,
            "status" => 1,
            "index" => 1,
            "rs" => [0.001, 0.001, 0.001],
            "xs" => [0.0, 0.0, 0.0],
            "angmin" => [-1.0, -1.0, -1.0], "argmax"=>[1.0,1.0,1.0]
        )
    ),
    "transformer" => Dict{String, Any}(
        "1" => Dict{String, Any}(
            "f_bus" => "633",
            "t_bus" => "634",
            "f_connections" => [1, 2, 3],
            "t_connections" => [1, 2, 3],
            "configuration" => PMD.WYE,
            "tm_nom" => 1.0,
            "tm_set" => [1.0, 1.0, 1.0],
            "polarity" => 1,
            "vbase" => [4.16, 0.48],
            "xsc" => [0.8, 0.8, 0.8],
            "rw" => [0.1, 0.1, 0.1],
            "index" => 1,
            "status" => 1,
            "tm_status" => 1
        )
    ),
    "settings" => Dict{String, Any}("sbase" => 1.0, "vbase" => 4.16),
    "per_unit" => true, "data_model" => PMD.MATHEMATICAL
)
opt = optimizer_with_attributes(Ipopt.Optimizer, "tol"=>1e-6)
resultat_pf = PMD.solve_mc_pf(math_data, PMD.ACPUPowerModel, opt)

```
