Engee documentation
Notebook

Simulation of an inductor with hysteresis.

This example shows how changing the coefficients of the Giles-Atherton magnetic hysteresis equation affects the resulting B-H curve. The simulation parameters are configured to perform four complete alternating current cycles with the initial field strength (H) and magnetic flux density (B) set to zero.

Model diagram:

inductor_with_hysteresis--1732692062795.png

Defining the function to load and run the model:

In [ ]:
function start_model_engee()
    try
        engee.close("inductor_with_hysteresis", force=true) # closing the model
        catch err # if there is no model to close and engee.close() is not executed, it will be loaded after catch.
            m = engee.load("$(@__DIR__)/inductor_with_hysteresis.engee") # loading the model
        end;

    try
        engee.run(m) # launching the model
        catch err # if the model is not loaded and engee.run() is not executed, the bottom two lines after catch will be executed.
            m = engee.load("$(@__DIR__)/inductor_with_hysteresis.engee") # loading the model
            engee.run(m) # launching the model
        end
end
Out[0]:
start_model_engee (generic function with 1 method)

Launching the model:

In [ ]:
try
    start_model_engee() # running the simulation using the special function implemented above
    catch err
    end;

Output of simulation results from the simout variable:

In [ ]:
res = collect(simout)
Out[0]:
10-element Vector{WorkspaceArray}:
 WorkspaceArray{Float64}("inductor_with_hysteresis/SysOutput_1")
 WorkspaceArray{Float64}("Nonlinear Inductor.v")
 WorkspaceArray{Float64}("Nonlinear Inductor.i")
 WorkspaceArray{Float64}("Nonlinear Inductor.H")
 WorkspaceArray{Float64}("Nonlinear Inductor.B")
 WorkspaceArray{Float64}("Nonlinear Inductor.n.v")
 WorkspaceArray{Float64}("Nonlinear Inductor.p.v")
 WorkspaceArray{Float64}("Nonlinear Inductor.M")
 WorkspaceArray{Float64}("Nonlinear Inductor.Phi")
 WorkspaceArray{Float64}("Nonlinear Inductor.power_dissipated")

Writing results to variables:

In [ ]:
H = collect(res[4]) # field strength
B = collect(res[5]) # magnetic flux density
Out[0]:
651×2 DataFrame
626 rows omitted
Rowtimevalue
Float64Float64
10.00.0
20.00010.00734923
30.00020.0234542
40.00030.046533
50.00040.076265
60.00050.112378
70.00060.154527
80.00070.202262
90.00080.255024
100.00090.312132
110.0010.37279
120.00110.436089
130.00120.501028
6400.0639-1.24976
6410.064-1.24918
6420.0641-1.24853
6430.0642-1.24783
6440.0643-1.24705
6450.0644-1.24619
6460.0645-1.24525
6470.0646-1.24421
6480.0647-1.24307
6490.0648-1.24181
6500.0649-1.24042
6510.065-1.23889
In [ ]:
using Plots
plot(H[100:end,2], B[100:end,2], linewidth=3, xlabel= "H, Vehicle", ylabel= "B, T", legend=:bottomright)
Out[0]:

Determination of a new reverse magnetization coefficient:

Output of the Nonlinear Inductor block parameters:

In [ ]:
engee.get_param("inductor_with_hysteresis/Nonlinear Inductor")
Out[0]:
Dict{String, Any} with 27 entries:
  "A_effective"          => Dict{String, Any}("unit"=>"m^2", "value"=>"1.6e-05")
  "H_anhysteretic"       => Dict{String, Any}("unit"=>"A/m", "value"=>"1000")
  "effective_gap"        => Dict{String, Any}("unit"=>"m", "value"=>"0.032")
  "c"                    => "0.1"
  "B_vector"             => Dict{String, Any}("unit"=>"T", "value"=>"[0, .81, 1…
  "L"                    => Dict{String, Any}("unit"=>"H", "value"=>"2e-4")
  "parameterization"     => "Magnetic flux density versus magnetic field streng…
  "BlockName"            => "Nonlinear Inductor"
  "start_option"         => "Current"
  "N"                    => "10"
  "dB_dH_0"              => Dict{String, Any}("unit"=>"T*m/A", "value"=>"0.005")
  "interpolation_option" => "Linear"
  "B_start"              => Dict{String, Any}("unit"=>"T", "value"=>"0")
  "H_start"              => Dict{String, Any}("unit"=>"A/m", "value"=>"0")
  "g"                    => Dict{String, Any}("unit"=>"1/Ohm", "value"=>"1e-9")
  "Phi_start"            => Dict{String, Any}("unit"=>"Wb", "value"=>"0")
  "BlockPath"            => "/Physical Modeling/Electrical/Passive/Nonlinear In…
  "Phi_sat"              => Dict{String, Any}("unit"=>"Wb", "value"=>"1.3e-05")
  "alpha"                => "0.0001"
  "i_L_start"            => Dict{String, Any}("unit"=>"A", "value"=>"0")
  "i_vector"             => Dict{String, Any}("unit"=>"A", "value"=>"[0, .64, 1…
  "L_sat"                => Dict{String, Any}("unit"=>"H", "value"=>"1e-4")
  "H_vector"             => Dict{String, Any}("unit"=>"A/m", "value"=>"[0, 200,…
  "BlockType"            => "AcausalElectricPowerSystems.Passive.NonlinearInduc…
  "Phi_vector"           => Dict{String, Any}("unit"=>"Wb", "value"=>"[0, 1.29,…
  ⋮                      => ⋮

We redefine the values of the coefficients of the magnetic hysteresis equation using the function set_param! Hidden under a mask:

In [ ]:
engee.load("$(@__DIR__)/inductor_with_hysteresis.engee")
# @markdown Reversible magnetization coefficient:
c = 0.2 # @param {type:"slider", min:0, max:1, step:0.1}
# @markdown Volume ratio:
K = 200.0 # @param {type:"slider", min:0, max:1000, step:1}
# @markdown Cross-domain coupling coefficient:
alpha = 0.0001 # @param {type:"slider", min:0, max:0.001, step:0.0001}
engee.set_param!("inductor_with_hysteresis/Nonlinear Inductor", "c" => c)
engee.set_param!("inductor_with_hysteresis/Nonlinear Inductor", "K" => K)
engee.set_param!("inductor_with_hysteresis/Nonlinear Inductor", "alpha" => alpha)
engee.run("inductor_with_hysteresis")
res1 = collect(simout)
H1 = collect(res1[7])
B1 = collect(res1[9])
engee.close("inductor_with_hysteresis", force = true)
plot(H[100:end,2], B[100:end,2], label = "Initial parameters of the model", xlabel= "H, Vehicle", ylabel= "B, T", linewidth=3)
plot!(H1[100:end,2], B1[100:end,2], label = "Changed model parameters", legend=:bottomright, linewidth=3)
Out[0]:

Conclusions:

In this example, a simulation of an inductor model with hysteresis was performed using software control. The graphs show how the individual coefficients of the Giles-Atherton equations affect the hysteresis curve.