Three-phase transformer (including hysteresis effect) with rectifier. This is a model of a three-phase transformer and rectifier unit using the Transformer3PhaseYyWithHysteresis model. Use the following simulation settings:

within Modelica.Magnetic.FluxTubes.Examples.Hysteresis;
model ThreePhaseTransformerWithRectifier
  "Three-phase transformer (including hysteresis effect) with rectifier"
  extends Modelica.Icons.Example;

  Modelica.Electrical.Analog.Basic.Ground ground1
  Modelica.Electrical.Analog.Basic.Ground ground2
  Modelica.Electrical.Analog.Sources.SineVoltage vSource1(
    offset=0,
    f=50,
    V=50)
  Components.Transformer3PhaseYyWithHysteresis transformer(
    EddyCurrents=true,
    N1=200,
    N2=10,
    mat=FluxTubes.Material.HysteresisEverettParameter.M330_50A(),
    sigma=2.2e6,
    HFixed={true,true,true},
    MagRelFixed={true,true,false},
    I1Fixed={true,true,true},
    I2Fixed={true,false,false},
    useHeatPort=false,
    MagRelStart={-0.4,0.8,-0.4},
    l1=0.2,
    l2=0.15,
    a=0.04,
    b=0.04,
    t=0.0005)
  Modelica.Electrical.Analog.Sources.SineVoltage vSource2(
    offset=0,
    f=vSource1.f,
    V=50,
    phase=4.1887902047864)
  Modelica.Electrical.Analog.Sources.SineVoltage vSource3(
    offset=0,
    f=vSource1.f,
    V=50,
    phase=2.0943951023932)
  Modelica.Electrical.Analog.Basic.Resistor resistor1(R=0)
  Modelica.Electrical.Analog.Basic.Resistor resistor2(R=resistor1.R)
  Modelica.Electrical.Analog.Basic.Resistor resistor3(R=resistor1.R)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode1(Vknee=0.7)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode2(Vknee=0.7)
  Modelica.Electrical.Analog.Basic.Resistor resistorL(R=5)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode3(Vknee=0.7)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode4(Vknee=0.7)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode5(Vknee=0.7)
  Modelica.Electrical.Analog.Ideal.IdealDiode diode6(Vknee=0.7)
  Modelica.Electrical.Analog.Basic.Capacitor capacitor1(C=1e-6, v(fixed=
          true))
  Modelica.Electrical.Analog.Basic.Inductor inductor1(L=1e-3)
  Modelica.Electrical.Analog.Basic.Inductor inductor2(L=1e-3)
  Modelica.Electrical.Analog.Basic.Inductor inductor3(L=1e-3)
  Modelica.Electrical.Analog.Basic.Capacitor capacitor2(C=1e-6, v(fixed=
          true))
  Modelica.Blocks.Sources.RealExpression rExp1(y=transformer.LossPowerStat)
  Modelica.Blocks.Sources.RealExpression rExp2(y=transformer.LossPowerEddy)
  Modelica.Blocks.Sources.RealExpression rExp3(y=transformer.LossPowerWinding)
  Modelica.Blocks.Continuous.Filter pdissStatAvg(f_cut=10)
    "Approx. average static hysteresis losses"
  Modelica.Blocks.Continuous.Filter pdissEddyAvg(f_cut=10)
    "Approx. average eddy current losses"
  Modelica.Blocks.Continuous.Filter pdissCopAvg(f_cut=10)
    "Approx. average copper losses"
initial equation
  transformer.core1.derHstat = 0.0;
  transformer.core2.derHstat = 0.0;
  transformer.core3.derHstat = 0.0;
equation
  connect(vSource1.n, ground1.p)
  connect(vSource2.n, ground1.p)
  connect(vSource3.n, ground1.p)
  connect(resistor1.n, transformer.p1)
  connect(resistor1.p, vSource1.p)
  connect(resistor2.n, transformer.p2)
  connect(resistor2.p, vSource2.p)
  connect(vSource3.p, resistor3.p)
  connect(resistor3.n, transformer.p3)
  connect(diode2.n, diode1.p)
  connect(diode4.n, diode3.p)
  connect(diode6.n, diode5.p)
  connect(diode2.p, diode4.p)
  connect(diode4.p, diode6.p)
  connect(diode1.n, diode3.n)
  connect(diode3.n, diode5.n)
  connect(diode5.n, capacitor1.p)
  connect(resistorL.p, capacitor1.p)
  connect(transformer.n1, inductor1.p)
  connect(transformer.n2, inductor2.p)
  connect(inductor2.n, diode3.p)
  connect(inductor3.p, transformer.n3)
  connect(inductor3.n, diode6.n)
  connect(capacitor2.n, diode6.p)
  connect(capacitor2.p, capacitor1.n)
  connect(inductor1.n, diode1.p)
  connect(resistorL.n, capacitor2.n)
  connect(transformer.starPoint1, ground1.p)
  connect(transformer.starPoint2, ground2.p)
  connect(ground2.p, capacitor2.p)
  connect(rExp3.y,pdissCopAvg. u)
  connect(rExp2.y,pdissEddyAvg. u)
  connect(rExp1.y,pdissStatAvg. u)
end ThreePhaseTransformerWithRectifier;


Components to be used in examples

within Modelica.Magnetic.FluxTubes.Examples.Hysteresis;
package Components "Components to be used in examples"
  extends Modelica.Icons.Package;
end Components;


Single-phase transformer with ferromagnetic core and hysteresis. Simple model of a single-phase transformer with a primary and a secondary winding and a magnetic core. The core is modeled with GenericHystTellinenEverett flux tube elements. Thus, this element considers static and dynamic hysteresis.

within Modelica.Magnetic.FluxTubes.Examples.Hysteresis.Components;
model Transformer1PhaseWithHysteresis
  "Single-phase transformer with ferromagnetic core and hysteresis"

  Modelica.Electrical.Analog.Interfaces.NegativePin n1 "Negative pin of primary winding"
  Modelica.Electrical.Analog.Interfaces.PositivePin p1 "Positive pin of primary winding"
  Modelica.Electrical.Analog.Interfaces.NegativePin n2 "Negative pin of secondary winding"
  Modelica.Electrical.Analog.Interfaces.PositivePin p2 "Positive pin of secondary winding"

  Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature tempSource

  // Tab: Electrical //Group:Primary Winding
  parameter Integer N1=10 "Primary turns"
  parameter SI.Length L1(displayUnit="mm") = 1.2*2*(a+b)
    "Mean primary turn length"
  parameter SI.Length d1(displayUnit="mm") = 0.5e-3
    "Wire diameter of primary turns"
  parameter SI.Resistivity rho1 = 1.678e-8
    "Resistivity of primary winding (at 20degC)"
  parameter SI.LinearTemperatureCoefficient alpha1 = 0
    "Temperature coefficient of primary turns"

  // Tab: Electrical //Group:Secondary Winding
  parameter Integer N2=10 "Secondary turns"
  parameter SI.Length L2(displayUnit="mm") = L1
    "Mean secondary turn length"
  parameter SI.Length d2(displayUnit="mm") = d1
    "Wire diameter of secondary turns"
  parameter SI.Resistivity rho2 = rho1
    "Resistivity of secondary winding (at 20degC)"

  parameter SI.LinearTemperatureCoefficient alpha2 = alpha1
    "Temperature coefficient of secondary turns"

  parameter SI.Length l1(displayUnit="mm") = 40e-3
    "Mean Length l1 of core"
  parameter SI.Length l2(displayUnit="mm") = 60e-3
    "Mean Length l2 of core"
  parameter SI.Length a(displayUnit="mm") = 15e-3 "Height of core"
  parameter SI.Length b(displayUnit="mm") = 10e-3 "Width of core"

  //
  parameter FluxTubes.Material.HysteresisEverettParameter.BaseData mat=
      FluxTubes.Material.HysteresisEverettParameter.BaseData()
    "Parameter set of ferromagnetic Hysteresis"

  output SI.Voltage v1 "Primary voltage drop";
  output SI.Voltage v2 "Secondary voltage drop";

  output SI.Resistance R1 "Primary resistance of Winding";
  output SI.Resistance R2 "Secondary resistance of Winding";

  output SI.Current i1 "Primary current";
  output SI.Current i2 "Secondary current";

  output SI.MagneticFluxDensity B "Magnetic Flux Density of Core";
  output SI.MagneticFieldStrength Hstat
    "Ferromagnetic portion of magnetic field strength";
  output SI.MagneticFieldStrength Heddy
    "Eddy current portion of magnetic field strength";
  output SI.MagneticFieldStrength H
    "Total magnetic field strength of core";

  //output SI.Resistance R1

  parameter Real MagRelStart=0 "Initial magnetization of Core (-1..1)"
  parameter Boolean MagRelFixed = false "Fixed"

  parameter SI.MagneticFieldStrength HStart=0
    "Initial magnetic field strength of Core"
  parameter Boolean HFixed = false "Fixed"
  parameter SI.ElectricCurrent I1Start=0
    "Initial primary current through winding"
  parameter Boolean I1Fixed = false "Fixed"

  output SI.Power LossPowerWinding "Winding losses";
  output SI.Power LossPowerStat "Ferromagnetic hysteresis losses";
  output SI.Power LossPowerEddy "Eddy current losses";

  extends Interfaces.ConditionalHeatPort;
  parameter Boolean EddyCurrents = false "Enable eddy currents"
  parameter SI.Conductivity sigma = mat.sigma
    "Conductivity of core material"
  parameter SI.Length t(displayUnit="mm") = 0.5e-3
    "Thickness of lamination"
  parameter SI.Length L_l1=10e-3 "Length of leakage of primary Winding"
  parameter SI.Area A_l1=10e-6
    "Cross section of leakage of primary Winding"
  parameter Real mu_rel1=1
    "Constant relative permeability of primary leakage (>0 required)"
  parameter SI.Length L_l2=10e-3
    "Length of leakage of secondary Winding"
  parameter SI.Area A_l2=10e-6
    "Cross section of leakage of secondary Winding"
  parameter Real mu_rel2=1
    "Constant relative permeability of secondary leakage (>0 required)"

protected
  Basic.Ground ground
  Basic.ElectroMagneticConverterWithLeakageInductance winding1(
    N=N1,
    L=L_l1,
    A=A_l1,
    mu_rel=mu_rel1,
    i(start=I1Start, fixed=I1Fixed))
  Basic.ElectroMagneticConverterWithLeakageInductance winding2(
    N=N2,
    L=L_l2,
    mu_rel=mu_rel2,
    A=A_l2)

  Modelica.Electrical.Analog.Basic.Resistor resistor1(
    R=rho1*N1*L1/(pi/4*d1^2),
    useHeatPort=true,
    alpha=alpha1,
    T_ref=293.15)
  Modelica.Electrical.Analog.Basic.Resistor resistor2(
    R=rho2*N2*L2/(pi/4*d2^2),
    useHeatPort=true,
    alpha=alpha2,
    T_ref=293.15)

public
  Shapes.HysteresisAndMagnets.GenericHystTellinenEverett core(
    mat=mat,
    l=2*(l1 + l2),
    A=a*b,
    includeEddyCurrents=EddyCurrents,
    sigma=sigma,
    d=t,
    H(start=HStart, fixed=HFixed),
    MagRel(start=MagRelStart, fixed=MagRelFixed))
equation
  v1 =p1.v - n1.v;
  i1 =resistor1.i;
  R1 =resistor1.R_actual;

  v2 =p2.v - n2.v;
  i2 =resistor2.i;
  R2 =resistor2.R_actual;

  B =core.B;
  Hstat =core.Hstat;
  Heddy =core.Heddy;
  H =core.H;
  //der(MagRel)=0;

  tempSource.T = if useHeatPort then T_heatPort else T;

  LossPowerWinding =resistor1.LossPower + resistor2.LossPower;
                                                  //AvgWinding.y;
  LossPowerStat =core.LossPowerStat;
  LossPowerEddy =core.LossPowerEddy;
  LossPower = LossPowerWinding + LossPowerEddy + LossPowerStat;

  connect(winding1.port_n, ground.port)
  connect(resistor1.n, winding1.p)
  connect(resistor1.p, p1)
  connect(resistor2.n, p2)
  connect(winding1.n, n1)
  connect(tempSource.port, resistor1.heatPort)
  connect(resistor2.heatPort, tempSource.port)
  connect(winding2.port_n, ground.port)
  connect(winding2.n, resistor2.p)
  connect(n2, winding2.p)
  connect(core.port_p, winding1.port_p)
  connect(core.port_n, winding2.port_p)
end Transformer1PhaseWithHysteresis;


Three-phase transformer in Yy configuration. Simple model of a three-phase transformer with primary and a secondary windings and a magnetic E-I shaped core. The core is modeled with GenericHystTellinenEverett flux tube elements. Thus, this model considers static and dynamic hysteresis as well as initial flux.

within Modelica.Magnetic.FluxTubes.Examples.Hysteresis.Components;
model Transformer3PhaseYyWithHysteresis
  "Three-phase transformer in Yy configuration"

  Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature Temp

  // Tab: Electrical //Group:Primary Winding
  parameter Integer N1=10 "Primary turns"
  parameter SI.Length L1(displayUnit="mm") = 1.2*2*(a+b)
    "Mean primary turn length"
  parameter SI.Length d1(displayUnit="mm") = 0.5e-3
    "Wire diameter of primary turns"
  parameter SI.Resistivity rho1 = 1.678e-8
    "Resistivity of primary winding (at 20degC)"
  parameter SI.LinearTemperatureCoefficient alpha1 = 0
    "Temperature coefficient of primary turns"

  // Tab: Electrical //Group:Secondary Winding
  parameter Integer N2=10 "Secondary turns"
  parameter SI.Length L2(displayUnit="mm") = L1
    "Mean secondary turn length"
  parameter SI.Length d2(displayUnit="mm") = d1
    "Wire diameter of secondary turns"
  parameter SI.Resistivity rho2 = rho1
    "Resistivity of secondary winding (at 20degC)"

  parameter SI.LinearTemperatureCoefficient alpha2 = alpha1
    "Temperature coefficient of secondary turns"

  parameter SI.Length l1(displayUnit="mm") = 40e-3
    "Mean length l1 of core"
  parameter SI.Length l2(displayUnit="mm") = 60e-3
    "Mean length l2 of core"
  parameter SI.Length a(displayUnit="mm") = 15e-3 "Height of core"
  parameter SI.Length b(displayUnit="mm") = 10e-3 "Width of core"

  parameter FluxTubes.Material.HysteresisEverettParameter.BaseData mat=
      FluxTubes.Material.HysteresisEverettParameter.BaseData()
    "Core Material"

  output SI.Voltage v1[3] "Voltage drop of primary winding 1-3";
  output SI.Voltage v2[3] "Voltage drop of secondary winding 1-3";

  output SI.Resistance R1[3] "Resistance of primary winding 1-3";
  output SI.Resistance R2[3] "Resistance of secondary winding 1-3";

  output SI.Current i1[3] "Current in primary winding 1-3";
  output SI.Current i2[3] "Current in secondary winding 1-3";

  output SI.MagneticFluxDensity B[3]
    "Magnetic Flux Density in core portions 1-3";
  output SI.MagneticFlux Phi[3]
    "Magnetic Flux through core portions 1-3";

  output SI.MagneticFieldStrength Hstat[3]
    "Ferromagnetic portion of magnetic field strength";
  output SI.MagneticFieldStrength Heddy[3]
    "Eddy current portion of magnetic field strength";
  output SI.MagneticFieldStrength H[3]
    "Total magnetic field strength of core";

  //output SI.Resistance R1

  parameter Real MagRelStart[3]={0,0,0}
    "Initial magnetization of Core (-1..1)"
  parameter Boolean MagRelFixed[3] = {false,false,false} "Fixed"

  parameter SI.MagneticFieldStrength HStart[3]={0,0,0}
    "Initial magnetic field strength of Core"
  parameter Boolean HFixed[3] = {false,false,false} "Fixed"

  parameter SI.ElectricCurrent I1Start[3]={0,0,0}
    "Initial current of primary Windings"
  parameter Boolean I1Fixed[3] = {false,false,false} "Fixed"

  parameter SI.ElectricCurrent I2Start[3]={0,0,0}
    "Initial current of secondary Windings"
  parameter Boolean I2Fixed[3] = {false,false,false} "Fixed"

  output SI.Power LossPowerWinding "Winding losses";
  output SI.Power LossPowerStat "Ferromagnetic hysteresis losses";
  output SI.Power LossPowerEddy "Eddy current losses";

  extends Interfaces.ConditionalHeatPort;
  parameter Boolean EddyCurrents = false "Enable eddy currents"
  parameter SI.Conductivity sigma = mat.sigma
    "Conductivity of core material"
  parameter SI.Length t(displayUnit="mm") = 0.5e-3
    "Thickness of lamination"

  parameter SI.Length L_l1=10e-3 "Length of leakage of primary Winding"
  parameter SI.Area A_l1=10e-6
    "Cross section of leakage of primary Winding"
  parameter Real mu_rel1=1
    "Constant relative permeability of primary leakage (>0 required)"
  parameter SI.Length L_l2=10e-3
    "Cross section of leakage of secondary Winding"
  parameter SI.Area A_l2=10e-6 "Length of leakage of secondary Winding"
  parameter Real mu_rel2=1
    "Constant relative permeability of secondary leakage (>0 required)"

  Shapes.HysteresisAndMagnets.GenericHystTellinenEverett core1(
    mat=mat,
    A=a*b,
    sigma=sigma,
    d=t,
    useHeatPort=false,
    includeEddyCurrents=EddyCurrents,
    l=l1 + 2*l2,
    H(start=HStart[1], fixed=HFixed[1]),
    MagRel(start=MagRelStart[1], fixed=MagRelFixed[1]))
  Shapes.HysteresisAndMagnets.GenericHystTellinenEverett core2(
    mat=mat,
    A=a*b,
    sigma=sigma,
    d=t,
    useHeatPort=false,
    includeEddyCurrents=EddyCurrents,
    l=l2,
    H(start=HStart[2], fixed=HFixed[2]),
    MagRel(start=MagRelStart[2], fixed=MagRelFixed[2]))

  Shapes.HysteresisAndMagnets.GenericHystTellinenEverett core3(
    mat=mat,
    A=a*b,
    includeEddyCurrents=EddyCurrents,
    sigma=sigma,
    d=t,
    l=l1 + 2*l2,
    H(start=HStart[3], fixed=HFixed[3]),
    MagRel(start=MagRelStart[3], fixed=MagRelFixed[3]))

  Basic.Ground ground

  Basic.ElectroMagneticConverterWithLeakageInductance winding11(
    N=N1,
    L=L_l1,
    A=A_l1,
    mu_rel=mu_rel1,
    i(start=I1Start[1], fixed=I1Fixed[1]))

  Basic.ElectroMagneticConverterWithLeakageInductance winding12(
    L=L_l1,
    A=A_l1,
    mu_rel=mu_rel1,
    i(start=I1Start[2], fixed=I1Fixed[2]),
    final N=N1)

  Basic.ElectroMagneticConverterWithLeakageInductance winding13(
    N=N1,
    L=L_l1,
    A=A_l1,
    mu_rel=mu_rel1,
    i(start=I1Start[3], fixed=I1Fixed[3]))

   Basic.ElectroMagneticConverterWithLeakageInductance winding21(
    N=N2,
    L=L_l2,
    A=A_l2,
    mu_rel=mu_rel2,
    i(start=I2Start[1], fixed=I2Fixed[1]))

   Basic.ElectroMagneticConverterWithLeakageInductance winding22(
    N=N2,
    L=L_l2,
    A=A_l2,
    mu_rel=mu_rel2,
    i(start=I2Start[1], fixed=I2Fixed[1]))

  Basic.ElectroMagneticConverterWithLeakageInductance winding23(
    N=N2,
    L=L_l2,
    A=A_l2,
    mu_rel=mu_rel2,
    i(start=I2Start[1], fixed=I2Fixed[1]))

  Modelica.Electrical.Analog.Basic.Resistor resistor11(
    R=rho1*N1*L1/(pi/4*d1^2),
    useHeatPort=true,
    alpha=alpha1,
    T_ref=293.15)
  Modelica.Electrical.Analog.Basic.Resistor resistor21(
    R=rho2*N2*L2/(pi/4*d2^2),
    useHeatPort=true,
    alpha=alpha2,
    T_ref=293.15)

  Modelica.Electrical.Analog.Basic.Resistor resistor12(
    R=rho1*N1*L1/(pi/4*d1^2),
    useHeatPort=true,
    alpha=alpha1,
    T_ref=293.15)
  Modelica.Electrical.Analog.Basic.Resistor resistor22(
    R=rho2*N2*L2/(pi/4*d2^2),
    useHeatPort=true,
    alpha=alpha2,
    T_ref=293.15)

  Modelica.Electrical.Analog.Basic.Resistor resistor23(
    R=rho2*N2*L2/(pi/4*d2^2),
    useHeatPort=true,
    alpha=alpha2,
    T_ref=293.15)

  Modelica.Electrical.Analog.Basic.Resistor resistor13(
    R=rho1*N1*L1/(pi/4*d1^2),
    useHeatPort=true,
    alpha=alpha1,
    T_ref=293.15)
  Shapes.FixedShape.Cuboid leakage(
    nonLinearPermeability=false,
    mu_rConst=1,
    l=l2,
    a=a,
    b=b/1000)

  Modelica.Electrical.Analog.Interfaces.PositivePin p1 "Primary winding 1"
  Modelica.Electrical.Analog.Interfaces.PositivePin p2 "Primary winding 2"
  Modelica.Electrical.Analog.Interfaces.PositivePin p3 "Primary winding 3"
  Modelica.Electrical.Analog.Interfaces.NegativePin n1 "Secondary winding 1"
  Modelica.Electrical.Analog.Interfaces.NegativePin n2 "Secondary winding 2"
  Modelica.Electrical.Analog.Interfaces.NegativePin n3 "Secondary winding 3"
  Modelica.Electrical.Analog.Interfaces.NegativePin starPoint2 "Star point of secondary windings"
  Modelica.Electrical.Analog.Interfaces.NegativePin starPoint1 "Star point of primary windings"

equation
  v1[1] =resistor11.p.v - winding11.n.v;
  v1[2] =resistor12.p.v - winding12.n.v;
  v1[3] =resistor13.p.v - winding13.n.v;
  i1[1] =resistor11.i;
  i1[2] =resistor12.i;
  i1[3] =resistor13.i;
  R1[1] =resistor11.R_actual;
  R1[2] =resistor12.R_actual;
  R1[3] =resistor13.R_actual;

  v2[1] =resistor21.n.v - winding21.n.v;
  v2[2] =resistor21.n.v - winding21.n.v;
  v2[3] =resistor21.n.v - winding21.n.v;
  i2[1] =resistor21.i;
  i2[2] =resistor22.i;
  i2[3] =resistor23.i;
  R2[1] =resistor21.R_actual;
  R2[2] =resistor22.R_actual;
  R2[3] =resistor23.R_actual;

  B[1] =core1.B;
  B[2] =core2.B;
  B[3] =core3.B;

  Phi[1] =core1.Phi;
  Phi[2] =core2.Phi;
  Phi[3] =core3.Phi;

  Hstat[1] =core1.Hstat;
  Hstat[2] =core2.Hstat;
  Hstat[3] =core3.Hstat;
  Heddy[1] =core1.Heddy;
  Heddy[2] =core2.Heddy;
  Heddy[3] =core3.Heddy;
  H[1] =core1.H;
  H[2] =core2.H;
  H[3] =core3.H;

  Temp.T = if useHeatPort then T_heatPort else T;

  LossPowerWinding =resistor11.LossPower + resistor12.LossPower + resistor13.LossPower + resistor21.LossPower + resistor22.LossPower + resistor23.LossPower;
  LossPowerStat =core1.LossPowerStat  +core2.LossPowerStat  +core3.LossPowerStat;
  LossPowerEddy =core1.LossPowerEddy  +core2.LossPowerEddy  +core3.LossPowerEddy;
  LossPower = LossPowerWinding + LossPowerEddy + LossPowerStat;

  connect(winding11.port_n, winding21.port_p)
  connect(winding11.p, resistor11.n)
  connect(resistor11.p, p1)
  connect(winding12.p, resistor12.n)
  connect(winding13.p, resistor13.n)
  connect(winding12.port_p, core2.port_n)
  connect(winding12.port_n, winding22.port_p)
  connect(winding21.port_n, ground.port)
  connect(ground.port, winding22.port_n)
  connect(winding23.port_n, ground.port)
  connect(winding23.port_p, winding13.port_n)
  connect(winding13.port_p, core3.port_n)
  connect(p2, resistor12.p)
  connect(p3, resistor13.p)
  connect(Temp.port, resistor11.heatPort)
  connect(resistor12.heatPort, Temp.port)
  connect(resistor13.heatPort, Temp.port)
  connect(resistor23.heatPort, Temp.port)
  connect(resistor22.heatPort, Temp.port)
  connect(resistor21.heatPort, Temp.port)
  connect(resistor21.p, winding21.p)
  connect(resistor22.p, winding22.p)
  connect(resistor23.p, winding23.p)
  connect(resistor21.n, n1)
  connect(resistor22.n, n2)
  connect(resistor23.n, n3)
  connect(leakage.port_n, ground.port)
  connect(winding11.port_p, core1.port_n)
  connect(core1.port_p,core2. port_p)
  connect(core3.port_p,core1. port_p)
  connect(leakage.port_p,core3. port_p)

  connect(winding11.n, starPoint1)
  connect(starPoint1, winding13.n)
  connect(starPoint1, winding12.n)
  connect(winding21.n, starPoint2)
  connect(starPoint2, winding22.n)
  connect(winding23.n, starPoint2)
end Transformer3PhaseYyWithHysteresis;


Armature stroke of both moving coil actuator models after a voltage step at time t=0. Have a look at ConstantActuator and at PermeanceActuator
for an explanation of both actuator models.

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator;
model ArmatureStroke
  "Armature stroke of both moving coil actuator models after a voltage step at time t=0"

  extends Modelica.Icons.Example;
  constant Modelica.Units.SI.Current steadyStateCurrent = 1.5;
  Modelica.Electrical.Analog.Basic.Ground pmGround
  Modelica.Electrical.Analog.Sources.StepVoltage pmSource(startTime=0, V=
        pmActuator.R*steadyStateCurrent)
  FluxTubes.Examples.MovingCoilActuator.Components.PermeanceActuator pmActuator(
    material=Material.HardMagnetic.PlasticNdFeB(),
    x(start=pmActuator.x_min, fixed=true),
    armature(v(fixed=true)),
    coil(i(fixed=true)))
    "Moving coil actuator described with permeance model"

  Modelica.Mechanics.Translational.Components.Mass pmLoad(m=0.05)
    "Load to be moved in addition to the armature mass"
  Modelica.Electrical.Analog.Basic.Ground cGround
  Modelica.Electrical.Analog.Sources.StepVoltage cSource(startTime=0, V=
        cActuator.R*steadyStateCurrent)
  FluxTubes.Examples.MovingCoilActuator.Components.ConstantActuator cActuator(
    x(start=cActuator.x_min, fixed=true),
    armature(v(fixed=true)),
    l(i(start=0, fixed=true)))
    "Moving coil actuator described with converter constant"
  Modelica.Mechanics.Translational.Components.Mass cLoad(m=0.05)
    "Load to be moved in addition to the armature mass"
equation
  connect(pmLoad.flange_a, pmActuator.flange)
  connect(cGround.p, cSource.n)
  connect(cLoad.flange_a, cActuator.flange)
  connect(cSource.p, cActuator.p)
  connect(cSource.n, cActuator.n)
  connect(pmSource.n, pmGround.p)
  connect(pmSource.n, pmActuator.n)
  connect(pmSource.p, pmActuator.p)
end ArmatureStroke;


Comparison of the force-current characteristics of both converter models with armature blocked at mid-position. Have a look at ConstantActuator and at PermeanceActuator for an explanation of both converter models.

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator;
model ForceCurrentBehaviour
  "Comparison of the force-current characteristics of both converter models with armature blocked at mid-position"

  extends Modelica.Icons.Example;

  Modelica.Electrical.Analog.Basic.Ground pmGround
  FluxTubes.Examples.MovingCoilActuator.Components.PermeanceActuator pmActuator(x(start=0),
      material=Material.HardMagnetic.PlasticNdFeB())
    "Moving coil actuator described with permeance model"
  Modelica.Mechanics.Translational.Components.Fixed pmFixedPos(s0=0)
    "Fixed armature position"
  Modelica.Electrical.Analog.Sources.RampCurrent pmRampCurrent(
    I=-6,
    duration=6,
    offset=3) "Ideal current source"
  Modelica.Electrical.Analog.Basic.Ground cGround
  Modelica.Mechanics.Translational.Components.Fixed cFixedPos(s0=0)
    "Fixed armature position"
  Modelica.Electrical.Analog.Sources.RampCurrent cRampCurrent(
    I=-6,
    duration=6,
    offset=3) "Ideal current source"
  FluxTubes.Examples.MovingCoilActuator.Components.ConstantActuator cActuator
    "Moving coil actuator described with converter constant"
  Modelica.Blocks.Tables.CombiTable1Ds comparisonWithFEA(table=[-3, -9.65653;
        -2.5, -8.28587; -2, -6.82002; -1.5, -5.25898; -1, -3.60274; -0.5,
        -1.85131; 0, -0.00468; 0.5, 1.93714; 1, 3.97415; 1.5, 6.10636; 2,
        8.33376; 2.5, 10.65636; 3, 13.07415])
    "Column 1: current, col. 2: force; mu_rFe=const.=1000 in FEA model"
  Modelica.Electrical.Analog.Sensors.CurrentSensor iSensor
    "Input value for look-up table with FEA results"
equation
  connect(pmFixedPos.flange, pmActuator.flange)
  connect(pmRampCurrent.p, pmActuator.p)
  connect(pmActuator.n, pmRampCurrent.n)
  connect(pmGround.p, pmRampCurrent.n)
  connect(cGround.p, cRampCurrent.n)
  connect(cActuator.flange, cFixedPos.flange)
  connect(cRampCurrent.n, cActuator.n)
  connect(cRampCurrent.p, iSensor.p)
  connect(cActuator.p, iSensor.n)
  connect(iSensor.i, comparisonWithFEA.u)
end ForceCurrentBehaviour;


Force-stroke characteristic of the permeance model at constant current. Have a look at ConstantActuator and at PermeanceActuator for an explanation of both converter models.

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator;
model ForceStrokeBehaviour
  "Force-stroke characteristic of the permeance model at constant current"

  extends Modelica.Icons.Example;

  Modelica.Electrical.Analog.Basic.Ground ground
  FluxTubes.Examples.MovingCoilActuator.Components.PermeanceActuator actuator(x(start=0),
      material=Material.HardMagnetic.PlasticNdFeB())
  Modelica.Electrical.Analog.Sources.ConstantCurrent source(I=3)
  Modelica.Blocks.Sources.Ramp sweepX(
    height=7.99e-3,
    duration=8,
    offset=-3.995e-3,
    startTime=-4)
  Modelica.Mechanics.Translational.Sources.Position feedX(exact=true)
  Modelica.Blocks.Tables.CombiTable1Ds comparisonWithFEA(table=[-0.004, -8.8729,
        -9.07503, 0.00332; -0.0035, -9.05239, -9.25042, 0.00352; -0.003,
        -9.1915, -9.38558, 0.00371; -0.0025, -9.28247, -9.47266, 0.0039;
        -0.002, -9.3587, -9.54503, 0.00409; -0.0015, -9.41568, -9.59782,
        0.00429; -0.001, -9.45496, -9.6331, 0.00448; -0.0005, -9.47427, -9.64839,
        0.00467; 0, -9.48639, -9.65616, 0.00486; 0.0005, -9.48623, -9.65174,
        0.00505; 0.001, -9.4732, -9.63435, 0.00524; 0.0015, -9.44143, -9.59825,
        0.00543; 0.002, -9.39915, -9.55226, 0.00562; 0.0025, -9.33166, -9.47988,
        0.00581; 0.003, -9.23707, -9.38112, 0.006; 0.0035, -9.09497, -9.23417,
        0.00619; 0.004, -8.91839, -9.05337, 0.00638])
    "Column 1: position, col.2: force with non-linear stator iron, col.3: force with mu_rFe=const.=1000, col.4: inductance with mu_rFe=const.=1000"
equation
  connect(ground.p, source.n)
  connect(source.n, actuator.n)
  connect(source.p, actuator.p)
  connect(sweepX.y, feedX.s_ref)
  connect(feedX.flange, actuator.flange)
  connect(feedX.s_ref, comparisonWithFEA.u)
end ForceStrokeBehaviour;


within Modelica.Magnetic.FluxTubes.Examples;
package MovingCoilActuator "Two translatory electrodynamic actuator models of different modelling depth and their comparison"
  extends Modelica.Icons.ExamplesPackage;
end MovingCoilActuator;


Simple behavioural actuator model for system simulation. Similar to rotational DC-Motors, the electro-mechanical energy conversion of translatory electrodynamic actuators and generators of moving coil and moving magnet type can be described with the following two converter equations:

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator.Components;
model ConstantActuator
  "Simple behavioural actuator model for system simulation"

  parameter SI.ElectricalForceConstant k=3.88 "Converter constant";
  parameter SI.Resistance R=2.86 "Coil resistance";
  parameter SI.Inductance L=0.0051 "Coil inductance at mid-stroke";
  parameter SI.Mass m_a=0.012 "Armature mass"
  parameter SI.TranslationalSpringConstant c=1e11
    "Spring stiffness between impact partners"
  parameter SI.TranslationalDampingConstant d=400
    "Damping coefficient between impact partners"
  parameter SI.Position x_min=-4e-3 "Minimum armature position"
  parameter SI.Position x_max=4e-3 "Maximum armature position"

  SI.Position x(start=x_min, stateSelect=StateSelect.prefer)
    "Armature position, alias for flange position";

  Modelica.Electrical.Analog.Basic.Resistor r(final R=R)
    "Coil resistance"
  FluxTubes.Examples.Utilities.TranslatoryArmatureAndStopper armature(
    final m=m_a,
    final x_max=x_max,
    final x_min=x_min,
    final L=0,
    final c=c,
    final d=d,
    n=2) "Armature inertia with stoppers at end of stroke range"

  Modelica.Electrical.Analog.Basic.Inductor l(final L=L)
    "Coil inductance"
  Modelica.Electrical.Analog.Basic.TranslationalEMF
    electroTranslationalConverter(final k=k)
  Modelica.Electrical.Analog.Interfaces.PositivePin p
    "Electrical connector"
  Modelica.Electrical.Analog.Interfaces.NegativePin n
    "Electrical connector"
  Modelica.Mechanics.Translational.Interfaces.Flange_b flange
    "Flange of component"
equation
  flange.s = x;

  connect(r.p, p)
  connect(l.p, r.n)
  connect(armature.flange_b, flange)
  connect(l.n, electroTranslationalConverter.p)
  connect(n, electroTranslationalConverter.n)
  connect(electroTranslationalConverter.flange, armature.flange_a)
end ConstantActuator;


Components to be used in examples

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator;
package Components "Components to be used in examples"
  extends Modelica.Icons.Package;
end Components;


Detailed actuator model for rough magnetic design of actuator and system simulation. In the ConstantActuator model the force F is strictly proportional to the current i as indicated by the converter constant c. However, there is an additional non-linear force component in such an actuator that is due to the dependency of the coil inductance L on the armature position x. The inductance increases as the armature moves into the stator. The total force is

within Modelica.Magnetic.FluxTubes.Examples.MovingCoilActuator.Components;
model PermeanceActuator
  "Detailed actuator model for rough magnetic design of actuator and system simulation"

  parameter Real N=140 "Number of turns"
  parameter SI.Resistance R=2.86 "Coil resistance";

  parameter SI.Radius r_core=12.5e-3
    "Radius of ferromagnetic stator core";

  parameter SI.Length l_PM=3.5e-3
    "Radial thickness of permanent magnet ring";
  parameter SI.Length t=0.02
    "Axial length of permanent magnet ring and air gap respectively";

  parameter SI.Length l_air=3e-3
    "Total radial length of armature air gap";

  parameter SI.Length l_FeOut=4e-3
    "Radial thickness of outer back iron (for estimation of leakage permeance)";

  parameter FluxTubes.Material.HardMagnetic.BaseData material=
      Material.HardMagnetic.BaseData()
    "Ferromagnetic material characteristics"

  parameter SI.Mass m_a=0.012 "Mass of armature"

  parameter SI.TranslationalSpringConstant c=1e11
    "Spring stiffness between impact partners"
  parameter SI.TranslationalDampingConstant d=400
    "Damping coefficient between impact partners"
  parameter SI.Position x_min=-4e-3
    "Position of stopper at minimum armature position"
  parameter SI.Position x_max=4e-3
    "Position of stopper at maximum armature position"

  SI.Position x(start=x_min, stateSelect=StateSelect.prefer)
    "Armature position, alias for flange position";

  SI.Inductance L "Coil inductance";

  FluxTubes.Sources.ConstantMagneticPotentialDifference mmf_PM(final V_m=
       material.H_cB*l_PM) "Permanent magnet's magnetomotive force"

  FluxTubes.Examples.Utilities.TranslatoryArmatureAndStopper armature(
    final L=0,
    final m=m_a,
    final c=c,
    final d=d,
    n=2,
    final x_max=x_max,
    final x_min=x_min)
    "Inertia of moving coil + coil carrier; stoppers at end of stroke range"
  Modelica.Electrical.Analog.Basic.Resistor r(final R=R)

  Basic.Ground ground
  FluxTubes.Basic.ElectroMagneticConverter coil(final N=N)
  FluxTubes.Shapes.Force.HollowCylinderRadialFlux g_ma(
    final dlBydx=1,
    final l=t/2 + x,
    final r_i=r_core,
    final r_o=r_core + l_air + l_PM,
    final mu_r=1.05,
    final useSupport=false)
  FluxTubes.Shapes.Force.HollowCylinderRadialFlux g_mb(
    final r_i=r_core,
    final r_o=r_core + l_air + l_PM,
    final dlBydx=-1,
    final l=t/2 - x,
    final mu_r=1.05,
    final useSupport=false)
  FluxTubes.Shapes.Leakage.CoaxCylindersEndFaces g_mLeak1(
    final r_1=r_core + l_air + l_PM,
    final r_2=r_core + l_air + l_PM + l_FeOut,
    final r_0=r_core)
    "Leakage between coaxial end planes of ferromagnetic stator core and outer back iron"
  FluxTubes.Shapes.Leakage.HalfCylinder g_mLeak2(final l=2*pi*(r_core +
        (l_air + l_PM)/2))
    "Leakage between edges of ferromagnetic stator core and outer back iron"

  Modelica.Electrical.Analog.Interfaces.PositivePin p
    "Electrical connector"
  Modelica.Electrical.Analog.Interfaces.NegativePin n
    "Electrical connector"
  Modelica.Mechanics.Translational.Interfaces.Flange_b flange
    "Flange of component"
equation
  x = flange.s;
  L = coil.N^2*(g_ma.G_m + g_mLeak1.G_m + g_mLeak2.G_m);

  connect(armature.flange_b, flange)
  connect(r.p, p)
  connect(armature.flange_a, g_mb.flange)
  connect(g_mb.flange, g_ma.flange)
  connect(g_mLeak1.port_n, g_ma.port_n)
  connect(g_mLeak2.port_n, g_ma.port_n)
  connect(g_ma.port_n, coil.port_p)
  connect(coil.port_n, g_mb.port_n)
  connect(g_mb.port_n, mmf_PM.port_p)
  connect(mmf_PM.port_p, g_mLeak2.port_p)
  connect(mmf_PM.port_p, g_mLeak1.port_p)
  connect(g_ma.port_p, mmf_PM.port_n)
  connect(mmf_PM.port_n, g_mb.port_p)
  connect(r.n, coil.p)
  connect(coil.n, n)
  connect(ground.port, g_mb.port_n)
end PermeanceActuator;


Pull-in stroke of both solenoid models after a voltage step at time t=0. Have a look at SolenoidActuator for general comments and at SimpleSolenoid and AdvancedSolenoid for a detailed description of both magnetic network models.


Slow forced armature motion of both solenoid models so that electromagnetic field and current are quasi-static. Have a look at SolenoidActuator for general comments and at SimpleSolenoid and AdvancedSolenoid for a detailed description of both magnetic network models.

within Modelica.Magnetic.FluxTubes.Examples.SolenoidActuator;
model ComparisonQuasiStatic
  "Slow forced armature motion of both solenoid models so that electromagnetic field and current are quasi-static"

  extends Modelica.Icons.Example;

  parameter SI.Voltage v_step=12 "Applied voltage";

  Modelica.Blocks.Sources.Ramp x_set(
    duration=10,
    height=-(advancedSolenoid.x_max - advancedSolenoid.x_min),
    offset=advancedSolenoid.x_max)
    "Prescribed armature position, slow enforced motion from x_max to x_min"
  Modelica.Electrical.Analog.Basic.Ground advancedGround
  Modelica.Electrical.Analog.Sources.StepVoltage advancedSource(V=v_step)
  FluxTubes.Examples.SolenoidActuator.Components.AdvancedSolenoid advancedSolenoid
  Modelica.Mechanics.Translational.Sources.Position advancedFeed_x(f_crit=
       1000, exact=false)
  Modelica.Electrical.Analog.Basic.Ground simpleGround
  Modelica.Electrical.Analog.Sources.StepVoltage simpleSource(V=v_step)
  FluxTubes.Examples.SolenoidActuator.Components.SimpleSolenoid simpleSolenoid
  Modelica.Mechanics.Translational.Sources.Position simpleFeed_x(f_crit=
        1000, exact=false)
  Modelica.Blocks.Tables.CombiTable1Ds comparisonWithFEA(table=[0.00025,
        -85.8619, 0.00014821, 0.11954; 0.0005, -59.9662, 0.00013931,
        0.11004; 0.00075, -41.0806, 0.0001277, 0.098942; 0.001, -28.88,
        0.00011587, 0.088425; 0.00125, -21.4113, 0.00010643, 0.08015;
        0.0015, -16.8003, 9.9406e-005, 0.073992; 0.00175, -13.6942,
        9.3416e-005, 0.068792; 0.002, -11.1188, 8.8564e-005, 0.064492;
        0.00225, -9.6603, 8.4505e-005, 0.060917; 0.0025, -8.4835,
        8.1215e-005, 0.058017; 0.00275, -7.4658, 7.7881e-005, 0.055125;
        0.003, -6.5591, 7.5197e-005, 0.052733; 0.00325, -5.9706,
        7.2447e-005, 0.05035; 0.0035, -5.5013, 7.0342e-005, 0.048525;
        0.00375, -5.0469, 6.8527e-005, 0.046867; 0.004, -4.6573,
        6.6526e-005, 0.045158; 0.00425, -4.2977, 6.4425e-005, 0.043442;
        0.0045, -4.0912, 6.2747e-005, 0.04205; 0.00475, -3.7456,
        6.1231e-005, 0.040733; 0.005, -3.5869, 5.9691e-005, 0.039467])
    "Valid for u_source=12V only; column 1: position, col.2: force, col.3: armature flux, col.4: inductance"
equation
  connect(advancedGround.p, advancedSource.n)
  connect(x_set.y, advancedFeed_x.s_ref)
  connect(simpleSolenoid.p, simpleSource.p)
  connect(simpleSolenoid.n, simpleSource.n)
  connect(simpleSolenoid.flange, simpleFeed_x.flange)
  connect(advancedSolenoid.n, advancedSource.n)
  connect(simpleFeed_x.s_ref, x_set.y)
  connect(x_set.y, comparisonWithFEA.u)
  connect(advancedFeed_x.flange, advancedSolenoid.flange)
  connect(advancedSource.p, advancedSolenoid.p)
  connect(simpleGround.p, simpleSource.n)
end ComparisonQuasiStatic;


within Modelica.Magnetic.FluxTubes.Examples;
package SolenoidActuator "Two models of a reluctance actuator of different modelling depth and their comparison and usage"
  extends Modelica.Icons.ExamplesPackage;
end SolenoidActuator;


Advanced network model of a lifting magnet with planar armature end face, split magnetomotive force. Please have a look at SimpleSolenoid for a general description of this actuator. Unlike in that simple magnetic network model, the coil is split into two lumped elements here. This enables for more realistic modelling of the radial leakage flux between armature and yoke (leakage permeance G_mLeakRad). Especially for large air gaps, the influence of this leakage flux on the actuator's inductance and its electromagnetic force is rather strong. Please have a look at ComparisonQuasiStatic for a comparison of both models with FEA-based results included as reference.

within Modelica.Magnetic.FluxTubes.Examples.SolenoidActuator.Components;
model AdvancedSolenoid
  "Advanced network model of a lifting magnet with planar armature end face, split magnetomotive force"

  parameter Real N=957 "Number of turns"
  parameter SI.Resistance R=5 "Coil resistance";
  parameter SI.Resistance R_par=1e5
    "Resistance parallel to the coil, in series to C_par";
  parameter SI.Capacitance C_par=1e-9
    "Capacitance parallel to the coil, in series to R_par";

  //yoke
  parameter SI.Radius r_yokeOut=15e-3 "Outer yoke radius";
  parameter SI.Radius r_yokeIn=13.5e-3 "Inner yoke radius";
  parameter SI.Length l_yoke=35e-3 "Axial yoke length";
  parameter SI.Length t_yokeBot=3.5e-3 "Axial thickness of yoke bottom";

  //pole
  parameter SI.Length l_pole=6.5e-3 "Axial length of pole";
  parameter SI.Length t_poleBot=3.5e-3
    "Axial thickness of bottom at pole side";

  parameter SI.Length t_airPar=0.65e-3
    "Radial thickness of parasitic air gap due to slide guiding";

  parameter FluxTubes.Material.SoftMagnetic.BaseData material=
      Material.SoftMagnetic.Steel.Steel_9SMnPb28()
    "Ferromagnetic material characteristics"

  //armature
  parameter SI.Radius r_arm=5e-3 "Armature radius = pole radius"
  parameter SI.Length l_arm=26e-3 "Armature length"
  parameter SI.TranslationalSpringConstant c=1e11
    "Spring stiffness between impact partners"
  parameter SI.TranslationalDampingConstant d=400
    "Damping coefficient between impact partners"
  parameter SI.Position x_min=0.25e-3
    "Stopper at minimum armature position"
  parameter SI.Position x_max=5e-3
    "Stopper at maximum armature position"

  SI.Position x(start=x_max, stateSelect=StateSelect.prefer)
    "Armature position";

  SI.MagneticFlux Psi_tot "Total flux linkage for information only";
  SI.Inductance L_statTot
    "Total static inductance for information only";

protected
  parameter SI.Density rho_steel=7853
    "Density for calculation of armature mass from geometry";

public
  FluxTubes.Basic.Ground ground
  FluxTubes.Basic.ElectroMagneticConverter coil1(final N=N/2, i(fixed=true))
    "Electromagnetic conversion in first half of coil"
  Modelica.Electrical.Analog.Basic.Resistor r_1(final R=R)
    "Resistance of first half of coil"
  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFeYokeSide1(
    final l=l_yoke/2 - t_poleBot/2,
    final r_i=r_yokeIn,
    final r_o=r_yokeOut,
    final nonLinearPermeability=true,
    final material=material)
    "Permeance of first half of yoke's hollow cylindric section"

  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFeArm(
    final r_i=0,
    final l=l_yoke - (t_yokeBot + t_poleBot)/2 - l_pole - (x_max +
        x_min)/2,
    final r_o=r_arm,
    final nonLinearPermeability=true,
    final material=material) "Permeance of ferromagnetic armature"

  FluxTubes.Shapes.Force.HollowCylinderAxialFlux g_mAirWork(
    final r_o=r_arm,
    final useSupport=false,
    final mu_r=1,
    final dlBydx=1,
    final r_i=0,
    final l=flange.s)
    "Permeance of working air gap (between armature and pole end faces)"
  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mFeYokeBot(
    final l=t_yokeBot,
    final r_i=r_arm + t_airPar,
    final r_o=r_yokeIn,
    final nonLinearPermeability=true,
    final material=material)
    "Permeance of bottom side of ferromagnetic yoke"

  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mAirPar(
    final l=t_yokeBot,
    final r_i=r_arm,
    final r_o=r_arm + t_airPar,
    final nonLinearPermeability=false,
    final mu_rConst=1)
    "Permeance of parasitic radial air gap due to slide guiding"
  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mFePoleBot(
    final l=t_poleBot,
    final r_i=r_arm,
    final r_o=r_yokeIn,
    final nonLinearPermeability=true,
    final material=material) "Permeance of bottom side of pole"

  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFePole(
    final l=l_pole,
    final r_o=r_arm,
    final nonLinearPermeability=true,
    final material=material,
    r_i=0) "Permeance of ferromagnetic pole"

  FluxTubes.Examples.Utilities.TranslatoryArmatureAndStopper armature(
    final x_max=x_max,
    final x_min=x_min,
    final m=rho_steel*l_arm*pi*r_arm^2,
    final L=0,
    final c=c,
    final d=d,
    n=2,
    v(fixed=true))
    "Inertia of armature and stoppers at end of stroke range"
  FluxTubes.Shapes.Leakage.QuarterCylinder g_mLeak1(final l=2*pi*(r_arm +
        t_airPar/2))
    "Leakage permeance between inner edge of yoke bore and armature side face"
  FluxTubes.Shapes.Leakage.QuarterHollowCylinder g_mLeak2(final ratio=8,
      final l=2*pi*r_arm)
    "Leakage permeance between inner side of yoke bottom and armature side (r_i = t_airPar)"
  FluxTubes.Basic.ElectroMagneticConverter coil2(final N=N/2, i(fixed=true))
    "Electromagnetic conversion in first half of coil"
  Modelica.Electrical.Analog.Basic.Capacitor c_par1(final C=C_par, v(
        start=0, fixed=true))
    "Parasitic capacitance assigned to first half of coil"
  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux G_mLeakRad(
    final mu_rConst=1,
    final r_i=r_arm,
    final r_o=r_yokeIn,
    final l=l_yoke/4,
    final nonLinearPermeability=false)
    "Permeance of radial leakage flux tube between armature side and yoke side"
  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFeYokeSide2(
    final l=l_yoke/2 - t_yokeBot/2,
    final r_i=r_yokeIn,
    r_o=r_yokeOut,
    final nonLinearPermeability=true,
    final material=material)
    "Permeance of second half of yoke's hollow cylindric section"

  Modelica.Electrical.Analog.Basic.Capacitor c_par2(final C=C_par, v(
        start=0, fixed=true))
    "Parasitic capacitance assigned to second half of coil"
  Modelica.Electrical.Analog.Basic.Resistor r_par1(final R=R_par)
    "Parasitic resistance assigned to first half of coil"
  Modelica.Electrical.Analog.Basic.Resistor r_par2(final R=R_par)
    "Parasitic resistance assigned to second half of coil"
  Modelica.Electrical.Analog.Basic.Resistor r_2(final R=R)
    "Resistance of second half of coil"
  FluxTubes.Shapes.Leakage.QuarterCylinder g_mLeak3(final l=2*pi*(r_arm +
        t_airPar/2))
    "Leakage permeance between outer edge of yoke bore and armature side face"
  FluxTubes.Shapes.Force.LeakageAroundPoles g_mLeakWork(
    final w=2*pi*(r_arm + 0.0015),
    final r=0.003,
    final useSupport=false,
    final mu_r=1,
    final dlBydx=1,
    final l=flange.s)
    "Permeance of leakage air gap around working air gap (between armature and pole side faces)"
  Modelica.Electrical.Analog.Interfaces.PositivePin p
    "Electrical connector"
  Modelica.Electrical.Analog.Interfaces.NegativePin n
    "Electrical connector"
  Modelica.Mechanics.Translational.Interfaces.Flange_b flange
    "Flange of component"
equation
  x = flange.s;
  Psi_tot = coil1.Psi + coil2.Psi;
  L_statTot = coil1.L_stat + coil2.L_stat;
  connect(armature.flange_b, flange)
  connect(r_par1.n, c_par1.p)
  connect(r_par1.p, r_1.p)
  connect(c_par2.p, r_par2.n)
  connect(r_par2.p, r_2.p)
  connect(r_1.p, p)
  connect(g_mLeakWork.flange, g_mAirWork.flange)
  connect(g_mAirWork.flange, armature.flange_a)
  connect(n, c_par2.n)
  connect(coil2.port_p, g_mFeArm.port_p)
  connect(G_mLeakRad.port_p, g_mFeArm.port_n)
  connect(g_mAirWork.port_p, g_mFeArm.port_n)
  connect(coil1.port_n, g_mAirWork.port_n)
  connect(g_mAirWork.port_n, g_mLeakWork.port_n)
  connect(g_mLeakWork.port_p, g_mAirWork.port_p)
  connect(coil1.port_p, g_mFePole.port_p)
  connect(g_mFePole.port_n, g_mFePoleBot.port_p)
  connect(g_mFePoleBot.port_n, g_mFeYokeSide1.port_p)
  connect(g_mFeYokeSide1.port_n, G_mLeakRad.port_n)
  connect(g_mFeYokeSide1.port_n, g_mFeYokeSide2.port_p)
  connect(g_mFeYokeSide2.port_n, g_mFeYokeBot.port_n)
  connect(coil2.port_n, g_mLeak2.port_p)
  connect(g_mLeak2.port_p, g_mLeak1.port_p)
  connect(g_mLeak1.port_p, g_mAirPar.port_p)
  connect(g_mAirPar.port_p, g_mLeak3.port_p)
  connect(g_mLeak2.port_n, g_mLeak1.port_n)
  connect(g_mLeak1.port_n, g_mAirPar.port_n)
  connect(g_mAirPar.port_n, g_mLeak3.port_n)
  connect(g_mFeYokeBot.port_p, g_mAirPar.port_n)
  connect(coil2.p, r_2.n)
  connect(coil2.n, c_par2.n)
  connect(coil1.n, c_par1.n)
  connect(coil1.n, r_2.p)
  connect(r_1.n, coil1.p)
  connect(ground.port, g_mLeak2.port_p)
end AdvancedSolenoid;


Components to be used in examples

within Modelica.Magnetic.FluxTubes.Examples.SolenoidActuator;
package Components "Components to be used in examples"
  extends Modelica.Icons.Package;
end Components;


Simple network model of a lifting magnet with planar armature end face. Please refer to the Parameters section for a schematic drawing of this axis-symmetric lifting magnet.
In the half-section below, the flux tube elements of the actuator's magnetic circuit are superimposed on a field plot obtained with FEA. The magnetomotive force imposed by the coil is modelled as one lumped element. As a result, the radial leakage flux between armature and yoke that occurs especially at large working air gaps can not be considered properly. This leads to a a higher total reluctance and lower inductance respectively compared to FEA for large working air gaps (i.e., armature close to x_max). Please have a look at the comments associated with the individual model components for a short explanation of their purpose in the model.

within Modelica.Magnetic.FluxTubes.Examples.SolenoidActuator.Components;
model SimpleSolenoid
  "Simple network model of a lifting magnet with planar armature end face"

  parameter SI.Resistance R=10 "Armature coil resistance";
  parameter Real N=957 "Number of turns";

  //yoke
  parameter SI.Radius r_yokeOut=15e-3 "Outer yoke radius"
  parameter SI.Radius r_yokeIn=13.5e-3 "Inner yoke radius";
  parameter SI.Length l_yoke=35e-3 "Axial yoke length";
  parameter SI.Length t_yokeBot=3.5e-3 "Axial thickness of yoke bottom";

  //pole
  parameter SI.Length l_pole=6.5e-3 "Axial length of pole";
  parameter SI.Length t_poleBot=3.5e-3
    "Axial thickness of bottom at pole side";

  parameter SI.Length t_airPar=0.65e-3
    "Radial thickness of parasitic air gap due to slide guiding";

  parameter FluxTubes.Material.SoftMagnetic.BaseData material=
      Material.SoftMagnetic.Steel.Steel_9SMnPb28()
    "Ferromagnetic material characteristics"

  //armature
  parameter SI.Radius r_arm=5e-3 "Armature radius = pole radius"
  parameter SI.Length l_arm=26e-3 "Armature length"
  parameter SI.TranslationalSpringConstant c=1e11
    "Spring stiffness between impact partners"
  parameter SI.TranslationalDampingConstant d=400
    "Damping coefficient between impact partners"
  parameter SI.Position x_min=0.25e-3
    "Stopper at minimum armature position"
  parameter SI.Position x_max=5e-3
    "Stopper at maximum armature position"

  SI.Position x(start=x_max, stateSelect=StateSelect.prefer)
    "Armature position, alias for flange position (identical with length of working air gap)";

protected
  parameter SI.Density rho_steel=7853
    "Density for calculation of armature mass from geometry";

public
  FluxTubes.Basic.Ground ground
  FluxTubes.Basic.ElectroMagneticConverter coil(final N=N, i(fixed=true))
    "Electromagnetic converter"
  Modelica.Electrical.Analog.Basic.Resistor r(final R=R)
    "Coil resistance"
  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFeYokeSide(
    final nonLinearPermeability=true,
    final material=material,
    final l=l_yoke - (t_poleBot + t_yokeBot)/2,
    final r_i=r_yokeIn,
    final r_o=r_yokeOut)
    "Permeance of hollow cylindric section of ferromagnetic yoke"

  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFeArm(
    final nonLinearPermeability=true,
    final material=material,
    final l=l_yoke - (t_yokeBot + t_poleBot)/2 - l_pole - (x_max +
        x_min)/2,
    final r_i=0,
    final r_o=r_arm) "Permeance of ferromagnetic armature"

  FluxTubes.Shapes.Force.HollowCylinderAxialFlux g_mAirWork(
    final mu_r=1,
    final dlBydx=1,
    final r_i=0,
    final r_o=r_arm,
    final useSupport=false,
    final l=flange.s)
    "Permeance of working air gap (between armature and pole end faces)"
  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mFeYokeBot(
    final nonLinearPermeability=true,
    final material=material,
    final l=t_yokeBot,
    final r_i=r_arm + t_airPar,
    final r_o=r_yokeIn)
    "Permeance of bottom side of ferromagnetic yoke"

  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mAirPar(
    final nonLinearPermeability=false,
    final mu_rConst=1,
    final l=t_yokeBot,
    final r_i=r_arm,
    final r_o=r_arm + t_airPar)
    "Permeance of parasitic radial air gap due to slide guiding"
  FluxTubes.Shapes.FixedShape.HollowCylinderRadialFlux g_mFePoleBot(
    final l=t_poleBot,
    final r_i=r_arm,
    final r_o=r_yokeIn,
    final nonLinearPermeability=true,
    final material=material) "Permeance of bottom side of pole"

  FluxTubes.Shapes.FixedShape.HollowCylinderAxialFlux g_mFePole(
    final nonLinearPermeability=true,
    final material=material,
    final l=l_pole,
    final r_i=0,
    final r_o=r_arm) "Permeance of ferromagnetic pole"

  FluxTubes.Examples.Utilities.TranslatoryArmatureAndStopper armature(
    final m=rho_steel*l_arm*pi*r_arm^2,
    final x_max=x_max,
    final x_min=x_min,
    final L=0,
    final c=c,
    final d=d,
    n=2,
    v(fixed=true))
    "Inertia of armature and stoppers at end of stroke range"
  FluxTubes.Shapes.Leakage.QuarterCylinder g_mLeak1(l=2*pi*(r_arm +
        t_airPar/2))
    "Leakage permeance between inner edge of yoke bore and armature side face"
  FluxTubes.Shapes.Leakage.QuarterHollowCylinder g_mLeak2(final l=2*pi*
        r_arm, final ratio=8)
    "Leakage permeance between inner side of yoke bottom and armature side (r_i = t_airPar)"
  FluxTubes.Shapes.Force.LeakageAroundPoles g_mLeakWork(
    final mu_r=1,
    final dlBydx=1,
    final w=2*pi*(r_arm + 0.0015),
    final r=0.003,
    final l=flange.s,
    final useSupport=false)
    "Permeance of leakage air gap around working air gap (between armature and pole side faces)"
  Modelica.Electrical.Analog.Interfaces.PositivePin p
    "Electrical connector"
  Modelica.Electrical.Analog.Interfaces.NegativePin n
    "Electrical connector"
  Modelica.Mechanics.Translational.Interfaces.Flange_b flange
    "Flange of component"
equation
  x = flange.s;
  connect(r.p, p)
  connect(armature.flange_b, flange)
  connect(armature.flange_a, g_mAirWork.flange)
  connect(g_mAirWork.flange, g_mLeakWork.flange)
  connect(r.n, coil.p)
  connect(coil.n, n)
  connect(coil.port_p, g_mAirWork.port_p)
  connect(g_mAirWork.port_p, g_mLeakWork.port_p)
  connect(g_mAirWork.port_n, g_mLeakWork.port_n)
  connect(g_mFePole.port_p, g_mAirWork.port_n)
  connect(g_mFePoleBot.port_p, g_mFePole.port_n)
  connect(g_mFePoleBot.port_n, g_mFeYokeSide.port_p)
  connect(g_mFeYokeSide.port_n, g_mFeYokeBot.port_n)
  connect(g_mFeYokeBot.port_p, g_mAirPar.port_n)
  connect(g_mFeArm.port_p, g_mLeak2.port_p)
  connect(g_mLeak2.port_p, g_mLeak1.port_p)
  connect(g_mLeak1.port_p, g_mAirPar.port_p)
  connect(g_mLeak2.port_n, g_mLeak1.port_n)
  connect(g_mLeak1.port_n, g_mAirPar.port_n)
  connect(g_mFeArm.port_n, coil.port_n)
  connect(ground.port, g_mLeak1.port_p)
end SimpleSolenoid;


Calculation of winding parameters (wire diameter, number of turns et al.) and recalculation with optionally chosen parameters; to be adapted to particular design tasks. This model example shows dimensioning of a winding (wire diameter, number of turns) based on desired operating conditions (voltage, temperature, current density, conductor filling factor) for a given cross-section area of the winding. It can be modified according to the parameters given and sought after for a particular design project.

within Modelica.Magnetic.FluxTubes.Examples.Utilities;
record CoilDesign
  "Calculation of winding parameters (wire diameter, number of turns et al.) and recalculation with optionally chosen parameters; to be adapted to particular design tasks"
  extends Modelica.Icons.Record;

  parameter SI.Resistivity rho_20=0.0178e-6
    "Resistivity of conductor material at 20 degC (default: Copper)";
  parameter SI.LinearTemperatureCoefficient alpha_20=0.0039
    "Temperature coefficient of conductor material's resistivity at 20 degC (default: Copper)";
  parameter SI.Temperature T_op=293.15 "Operating temperature of winding";

  final parameter SI.Resistivity rho=rho_20*(1 + alpha_20*(T_op - (20 -
      Modelica.Constants.T_zero))) "Resistivity at operating temperature";

  parameter SI.Length h_w "Height of winding cross-section";
  parameter SI.Length b_w "Width of winding cross-section";

  final parameter SI.Area A_w=h_w*b_w "Cross-section area of winding";

  parameter SI.Length l_avg "Average length of one turn";

  parameter SI.Voltage V_op
    "Operating voltage (nominal/ minimum/ maximum voltage depending on design objective)";

  parameter SI.CurrentDensity J_desired=4e6
    "DESIRED current density at operating temperature and voltage resp.";

  parameter Real c_condFillChosen=0.6
    "CHOSEN conductor filling factor = total conductor area without insulation/ total winding area";

  final parameter Real N_calculated=V_op/(rho*l_avg*J_desired)
    "CALCULATED number of turns";

  final parameter SI.Diameter d_wireCalculated=sqrt(4*A_w*
      c_condFillChosen/(pi*N_calculated))
    "CALCULATED wire diameter (without insulation)";

  final parameter SI.Area A_wireCalculated=pi*d_wireCalculated^2/4
    "Calculated wire cross-section area";

  final parameter SI.Resistance R_calculated=rho*N_calculated*l_avg/
      A_wireCalculated
    "Winding resistance at operating temperature and voltage resp. with CALCULATED number of turns and wire diameter";

  final parameter SI.Power P_calculated=V_op^2/R_calculated
    "Winding's ohmic losses at operating temperature and voltage resp. with CALCULATED number of turns and wire diameter";

  parameter SI.Diameter d_wireChosen=d_wireCalculated
    "CHOSEN available wire diameter (without insulation)"

  parameter Real N_chosen=N_calculated "CHOSEN number of turns"

  final parameter SI.Area A_wireChosen=pi*d_wireChosen^2/4
    "Wire cross-section area resulting from CHOSEN wire diameter";

  final parameter SI.Resistance R_actual=rho*N_chosen*l_avg/A_wireChosen
    "Winding resistance at operating temperature and voltage resp. resulting from CHOSEN number of turns and wire diameter";

  final parameter SI.Power P_actual=V_op^2/R_actual
    "Winding's ohmic losses at operating temperature and voltage resp. resulting from CHOSEN number of turns and wire diameter";

  final parameter SI.CurrentDensity J_actual=V_op*4/(R_actual*pi*
      d_wireChosen^2)
    "Current density at operating temperature and voltage resp. resulting from CHOSEN number of turns and wire diameter";

  final parameter Real c_condFillActual=N_chosen*pi*d_wireChosen^2/(4*A_w)
    "Conductor filling factor resulting from CHOSEN number of turns and wire diameter";

end CoilDesign;


Utilities to be used in examples

within Modelica.Magnetic.FluxTubes.Examples;
package Utilities "Utilities to be used in examples"
  extends Modelica.Icons.UtilitiesPackage;
end Utilities;


Mass with free travel between two stoppers. In translatory actuators with limited stroke, the armature with its inertia can travel between two stoppers.

within Modelica.Magnetic.FluxTubes.Examples.Utilities;
model TranslatoryArmatureAndStopper
  "Mass with free travel between two stoppers"

  parameter SI.Length L(start=0)
    "Length of component from left flange to right flange (= flange_b.s - flange_a.s)";
  parameter SI.Mass m(start=1) "Armature mass";

  parameter SI.TranslationalSpringConstant c(start=1e11)
    "Spring stiffness between impact partners";
  parameter SI.TranslationalDampingConstant d(start=2e7)
    "Damping coefficient between impact partners";
  parameter Real n(final min=1) = 2
    "Exponent of spring forces (f_c = c*|s_rel|^n)"

  parameter SI.Position x_max(start=10e-3)
    "Position of stopper at maximum armature position";
  parameter SI.Position x_min(start=0)
    "Position of stopper at minimum armature position";
  SI.Position s(start=0)
    "Absolute position of center of component (= flange_a.s + L/2)";
  SI.Velocity v(start=0)
    "Absolute velocity of components (= der(s))";
  SI.Acceleration a(start=0)
    "Absolute acceleration of components (= der(v))";
  Modelica.Mechanics.Translational.Components.Mass mass(final L=L, final
      m=m)
  Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a
  Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b
  Modelica.Mechanics.Translational.Components.Fixed limit_xMin(s0=x_min)
  Modelica.Mechanics.Translational.Components.Fixed limit_xMax(s0=x_max)
  Modelica.Mechanics.Translational.Components.ElastoGap stopper_xMax(
    final c=c,
    final d=d,
    final n=n,
    final s_rel0=0)
  Modelica.Mechanics.Translational.Components.ElastoGap stopper_xMin(
    final c=c,
    final d=d,
    final n=n,
    final s_rel0=0)

equation
  mass.s = s;
  mass.v = v;
  mass.a = a;
  connect(mass.flange_a, stopper_xMin.flange_b)
  connect(limit_xMax.flange, stopper_xMax.flange_b)
  connect(stopper_xMax.flange_a, mass.flange_b)
  connect(mass.flange_a, flange_a)
  connect(limit_xMin.flange, stopper_xMin.flange_a)
  connect(flange_b, mass.flange_b)
end TranslatoryArmatureAndStopper;


Icon for cuboid.

within Modelica.Magnetic.FluxTubes.Icons;
partial model Cuboid "Icon for cuboid"
end Cuboid;


Icon for cylinder with axial flux.

within Modelica.Magnetic.FluxTubes.Icons;
partial model HollowCylinderAxialFlux "Icon for cylinder with axial flux"
end HollowCylinderAxialFlux;


Icon for cylinder with circumferential flux.

within Modelica.Magnetic.FluxTubes.Icons;
partial model HollowCylinderCircumferentialFlux
  "Icon for cylinder with circumferential flux"
end HollowCylinderCircumferentialFlux;


Icon for cylinder with radial flux.

within Modelica.Magnetic.FluxTubes.Icons;
partial model HollowCylinderRadialFlux "Icon for cylinder with radial flux"
end HollowCylinderRadialFlux;


Icons for FluxTubes components

within Modelica.Magnetic.FluxTubes;
package Icons "Icons for FluxTubes components"
  extends Modelica.Icons.IconsPackage;
end Icons;


Icon for reluctance / permeance components.

within Modelica.Magnetic.FluxTubes.Icons;
partial model Reluctance "Icon for reluctance / permeance components"
end Reluctance;


Icon for toroid.

within Modelica.Magnetic.FluxTubes.Icons;
partial model Toroid "Icon for toroid"
end Toroid;


Partial model to include a conditional HeatPort in order to describe the power loss via a thermal network. This partial model provides a conditional heating port for the connection to a thermal network.

within Modelica.Magnetic.FluxTubes.Interfaces;
partial model ConditionalHeatPort
  "Partial model to include a conditional HeatPort in order to describe the power loss via a thermal network"

  parameter Boolean useHeatPort = false "= true, if HeatPort is enabled"
  parameter SI.Temperature T=293.15
    "Fixed device temperature if useHeatPort = false"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort(final T=T_heatPort, final Q_flow=-LossPower) if useHeatPort
  SI.Power LossPower
    "Loss power leaving component via HeatPort";
  SI.Temperature T_heatPort "Temperature of HeatPort";
equation
  if not useHeatPort then
     T_heatPort = T;
  end if;
end ConditionalHeatPort;


within Modelica.Magnetic.FluxTubes;
package Interfaces "Interfaces of magnetic network components"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Interface component including flux balance equation. It is assumed that the magnetic flux flowing into port_p is identical to the flux flowing out of port_n.
This magnetic flux is provided explicitly as flux Phi.

within Modelica.Magnetic.FluxTubes.Interfaces;
partial model TwoPort "Interface component including flux balance equation"

  extends TwoPortExtended;

equation
  0 = port_p.Phi + port_n.Phi;
end TwoPort;


Interface component with two magnetic ports for textual programming. Partial model of a flux tube component with two magnetic ports:
the positive port connector port_p, and the negative port
connector port_n.

within Modelica.Magnetic.FluxTubes.Interfaces;
partial model TwoPortElementary "Interface component with two magnetic ports for textual programming"

  FluxTubes.Interfaces.PositiveMagneticPort port_p "Positive magnetic port"
  FluxTubes.Interfaces.NegativeMagneticPort port_n "Negative magnetic port"
end TwoPortElementary;


Extended TwoPort interface model with alias variables for magnetic voltage and flux. It is assumed that the magnetic flux flowing into port_p is identical to the flux flowing out of port_n.
This magnetic flux is provided explicitly as flux Phi.

within Modelica.Magnetic.FluxTubes.Interfaces;
partial model TwoPortExtended "Extended TwoPort interface model with alias variables for magnetic voltage and flux"

  extends TwoPortElementary;
  SI.MagneticPotentialDifference V_m "Magnetic potential difference of ports";
  SI.MagneticFlux Phi(start=0) "Magnetic flux from port_p to port_n";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
end TwoPortExtended;


within Modelica.Magnetic.FluxTubes;
package Material "Magnetisation characteristics of common soft magnetic and hard magnetic materials"
  extends Modelica.Icons.MaterialPropertiesPackage;
end Material;


within Modelica.Magnetic.FluxTubes.Material;
package HardMagnetic "Characteristics of common permanent magnetic materials (temperature dependence considered)"
  extends Modelica.Icons.MaterialPropertiesPackage;
end HardMagnetic;


within Modelica.Magnetic.FluxTubes.Material;
package HysteresisEverettParameter "Parameter sets for an analytical description of the Everett function"
  extends Modelica.Icons.MaterialPropertiesPackage;
end HysteresisEverettParameter;


Material table data for the <a href=\

within Modelica.Magnetic.FluxTubes.Material;
package HysteresisTableData
  extends Modelica.Icons.MaterialPropertiesPackage;
end HysteresisTableData;


within Modelica.Magnetic.FluxTubes.Material;
package SoftMagnetic "Characteristics mu_r(B) of common soft magnetic materials; hysteresis neglected"
  extends Modelica.Icons.MaterialPropertiesPackage;
end SoftMagnetic;


Cobalt iron

within Modelica.Magnetic.FluxTubes.Material.SoftMagnetic;
package CobaltIron "Cobalt iron"
  extends Modelica.Icons.MaterialPropertiesPackage;

end CobaltIron;


Various electric sheets

within Modelica.Magnetic.FluxTubes.Material.SoftMagnetic;
package ElectricSheet "Various electric sheets"
  extends Modelica.Icons.MaterialPropertiesPackage;
end ElectricSheet;


Nickel iron

within Modelica.Magnetic.FluxTubes.Material.SoftMagnetic;
package NickelIron "Nickel iron"
  extends Modelica.Icons.MaterialPropertiesPackage;
end NickelIron;


Pure iron

within Modelica.Magnetic.FluxTubes.Material.SoftMagnetic;
package PureIron "Pure iron"
  extends Modelica.Icons.MaterialPropertiesPackage;
end PureIron;


Various ferromagnetic steels

within Modelica.Magnetic.FluxTubes.Material.SoftMagnetic;
package Steel "Various ferromagnetic steels"
  extends Modelica.Icons.MaterialPropertiesPackage;
end Steel;


Sensor to measure magnetic flux.

within Modelica.Magnetic.FluxTubes.Sensors;
model MagneticFluxSensor "Sensor to measure magnetic flux"
  extends Interfaces.TwoPortElementary;
  extends Modelica.Icons.RoundSensor;

  Modelica.Blocks.Interfaces.RealOutput Phi(final quantity="MagneticFlux",
      final unit="Wb")
    "Magnetic flux from port p to port n as output signal"
equation
  port_p.V_m = port_n.V_m;
  Phi = port_p.Phi;
  0 = port_p.Phi + port_n.Phi;
end MagneticFluxSensor;


Sensor to measure magnetic potential difference.

within Modelica.Magnetic.FluxTubes.Sensors;
model MagneticPotentialDifferenceSensor
  "Sensor to measure magnetic potential difference"
  extends Modelica.Icons.RoundSensor;
  extends Interfaces.TwoPortElementary;

  Modelica.Blocks.Interfaces.RealOutput V_m(final quantity=
        "MagneticPotential", final unit="A")
    "Magnetic potential difference between ports p and n as output signal"
  SI.MagneticFlux Phi "Magnetic flux from port_p to port_n";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
  Phi = 0;
  0 = port_p.Phi + port_n.Phi;
end MagneticPotentialDifferenceSensor;


within Modelica.Magnetic.FluxTubes;
package Sensors "Sensors to measure variables in magnetic networks"
  extends Modelica.Icons.SensorsPackage;
end Sensors;


within Modelica.Magnetic.FluxTubes;
package Shapes "Reluctance and permeance elements respectively based on geometric shapes"
  extends Modelica.Icons.Package;
end Shapes;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model Cuboid
  "Flux tube with rectangular cross-section; fixed shape; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.Cuboid;

  parameter SI.Length l=0.01 "Length in direction of flux"
  parameter SI.Length a=0.01 "Width of rectangular cross-section"
  parameter SI.Length b=0.01 "Height of rectangular cross-section"

equation
  A = a*b;
  G_m = mu_0*mu_r*A/l;
end Cuboid;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model GenericFluxTube
  "Flux tube with fixed cross-section and length; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.Reluctance;

  parameter SI.Length l=0.01 "Length in direction of flux"
  parameter SI.CrossSection area=0.0001 "Area of cross section"
equation
  A = area;
  G_m = mu_0*mu_r*A/l;
end GenericFluxTube;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model HollowCylinderAxialFlux
  "(Hollow) cylinder with axial flux; fixed shape; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.HollowCylinderAxialFlux;

  parameter SI.Length l=0.01 "Axial length (in direction of flux)"
  parameter SI.Radius r_i=0
    "Inner radius of hollow cylinder (zero for cylinder)"
  parameter SI.Radius r_o=0.01 "Outer radius of (hollow) cylinder"
  parameter SI.Angle alpha=2*pi "Central angle"
equation
  A = (r_o^2 - r_i^2)*alpha/2;
  G_m = mu_0*mu_r*A/l;
end HollowCylinderAxialFlux;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model HollowCylinderCircumferentialFlux
  "Hollow cylinder with circumferential flux; fixed shape; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.HollowCylinderCircumferentialFlux;
  import Modelica.Constants.pi;
  parameter SI.Length l=0.02 "Width (orthogonal to flux direction)"
  parameter SI.Radius r_i=0.01 "Inner radius of hollow cylinder"
  parameter SI.Radius r_o=0.02 "Outer radius of hollow cylinder"
  parameter SI.Angle alpha=pi/2 "Angle of cylinder section"
equation
  A = (r_o - r_i)*l;
  G_m = mu_0*mu_r*A/((r_o + r_i)/2*alpha);
end HollowCylinderCircumferentialFlux;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model HollowCylinderRadialFlux
  "Hollow cylinder with radial flux; fixed shape; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.HollowCylinderRadialFlux;

  parameter SI.Length l=0.01 "Width (orthogonal to flux direction)"
  parameter SI.Radius r_i=0.01 "Inner radius of hollow cylinder"
  parameter SI.Radius r_o=0.02 "Outer radius of hollow cylinder"
  parameter SI.Angle alpha=2*pi "Central angle"
equation
  A = l*alpha*(r_o + r_i)/2;
  // Area at arithmetic mean radius for calculation of average flux density
  G_m = mu_0*mu_r*alpha*l/Modelica.Math.log(r_o/r_i);
end HollowCylinderRadialFlux;


within Modelica.Magnetic.FluxTubes.Shapes;
package FixedShape "Flux tubes with fixed shape during simulation and linear or non-linear material characteristics"
  extends Modelica.Icons.VariantsPackage;
end FixedShape;


within Modelica.Magnetic.FluxTubes.Shapes.FixedShape;
model Toroid
  "Toroid with circular cross section; fixed shape; linear or non-linear material characteristics"

  extends BaseClasses.FixedShape;
  extends Modelica.Magnetic.FluxTubes.Icons.Toroid;
  import Modelica.Constants.pi;
  parameter SI.Radius r=0.1 "Radius of toroid (middle)"
  parameter SI.Radius d=0.01 "Diameter of cylindrical core"
  parameter SI.Angle alpha=pi/2 "Angle of toroid section"
equation
  A = d^2*pi/4 "Area at arithmetic mean radius for calculation of average flux density";
  G_m = mu_0*mu_r*A/(r*alpha);
end Toroid;


within Modelica.Magnetic.FluxTubes.Shapes.Force;
model CuboidOrthogonalFlux
  "Cuboid with flux orthogonal to direction of motion; constant permeability"

  extends BaseClasses.Force;

  SI.Length l=s "Length in direction of motion (orthogonal to flux)"
  parameter SI.Length a=0.01 "Width of rectangular cross-section";
  parameter SI.Length b=0.01
    "Height of rectangular cross-section (in flux direction)";

  SI.MagneticFluxDensity B "Homogeneous flux density";

protected
  SI.Area A "Cross-sectional area orthogonal to direction of flux";

equation
  A = a*l;
  G_m = mu_0*mu_r*A/b;

  dGmBydx = mu_0*mu_r*a/b*dlBydx;

  B = Phi/A;
end CuboidOrthogonalFlux;


within Modelica.Magnetic.FluxTubes.Shapes.Force;
model CuboidParallelFlux
  "Cuboid with flux in direction of motion, e.g., air gap with rectangular cross-section; constant permeability"

  extends BaseClasses.Force;

  SI.Length l=s "Axial length (in direction of flux)"
  parameter SI.Length a=0.01 "Width of rectangular cross-section";
  parameter SI.Length b=0.01 "Height of rectangular cross-section";

  SI.MagneticFluxDensity B "Homogeneous flux density";

protected
  parameter SI.Area A=a*b
    "Cross-sectional area orthogonal to direction of flux";

equation
  G_m = mu_0*mu_r*A/l;

  dGmBydx = -1*mu_0*mu_r*A/l^2*dlBydx;

  B = Phi/A;
end CuboidParallelFlux;


within Modelica.Magnetic.FluxTubes.Shapes.Force;
model HollowCylinderAxialFlux
  "(Hollow) cylinder with axial flux; constant permeability"

  extends BaseClasses.Force;

  SI.Length l=s "Axial length (in direction of flux)"
  parameter SI.Radius r_i=0 "Inner radius of (hollow) cylinder";
  parameter SI.Radius r_o=0.01 "Outer radius of (hollow) cylinder";

  SI.MagneticFluxDensity B "Homogeneous flux density";

protected
  parameter SI.Area A=pi*(r_o^2 - r_i^2)
    "Cross-sectional area orthogonal to direction of flux";

equation
  G_m = mu_0*mu_r*A/l;

  dGmBydx = -1*mu_0*mu_r*A/l^2*dlBydx;

  B = Phi/A;
end HollowCylinderAxialFlux;


within Modelica.Magnetic.FluxTubes.Shapes.Force;
model HollowCylinderRadialFlux
  "Hollow cylinder with radial flux; constant permeability"

  extends BaseClasses.Force;

  SI.Length l=s "Axial length (orthogonal to direction of flux)"
  parameter SI.Radius r_i=0.01 "Inner radius of hollow cylinder";
  parameter SI.Radius r_o=0.015 "Outer radius of hollow cylinder";

  SI.MagneticFluxDensity B_avg
    "Average flux density (at arithmetic mean radius)";

protected
  SI.Area A_avg
    "Average cross-sectional area orthogonal to direction of flux (at arithmetic mean radius)";

equation
  G_m = mu_0*mu_r*2*pi*l/Modelica.Math.log(r_o/r_i);

  dGmBydx = mu_0*mu_r*2*pi/Modelica.Math.log(r_o/r_i)*dlBydx;

  A_avg = pi*(r_i + r_o)*l;
  B_avg = Phi/A_avg;
end HollowCylinderRadialFlux;


Leakage flux tube around cylindrical or prismatic poles. Please refer to the description of  the enclosing sub-package Force for a description of all elements of this package.

within Modelica.Magnetic.FluxTubes.Shapes.Force;
model LeakageAroundPoles
  "Leakage flux tube around cylindrical or prismatic poles"

  extends BaseClasses.Force;
  SI.Length l=s "Axial length (in direction of flux)"
  parameter SI.Length w=0.1
    "Width orthogonal to flux; mean circumference of flux tube in case of cylindrical poles";
  parameter SI.Radius r=0.01 "Radius of leakage field";

equation
  //adapted from [Ka08], but corrected
  //(in [Ka08] equation accidentally swapped with that of a similar element)
  G_m = mu_0*w/pi*Modelica.Math.log(1 + pi*r/l);

  //derivative at full length:
  //  dGmBydx = mu_0 * w /pi * 1/(1 + pi * r/l) * (-1)*pi*r/l^2  * dlBydx;
  //simplified:
  dGmBydx = -mu_0*w*r*dlBydx/(l^2*(1 + pi*r/l));
end LeakageAroundPoles;


within Modelica.Magnetic.FluxTubes.Shapes;
package Force "Flux tubes with reluctance force generation; constant permeability"
  extends Modelica.Icons.VariantsPackage;
end Force;


Generic flux tube with ferromagnetic hysteresis based on the Preisach model and the Everett function [Ya89]). Flux tube element for modeling magnetic materials with ferromagnetic and dynamic hysteresis (eddy currents). The ferromagnetic hysteresis behavior is defined by the
Preisach hysteresis model. The Shape of the limiting ferromagnetic hysteresis loop is specified by an analytical description of the Everett function. A library of predefined parameter sets can be found in FluxTubes.Material.HysteresisEverettParameter.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystPreisachEverett
  "Generic flux tube with ferromagnetic hysteresis based on the Preisach model and the Everett function [Ya89])"
  import Modelica.Constants.pi;

  parameter FluxTubes.Material.HysteresisEverettParameter.BaseData mat=
      FluxTubes.Material.HysteresisEverettParameter.BaseData()
    "Preisach Parameters"

  parameter Integer Count=100 "Length of history array"
  parameter SI.MagneticFieldStrength eps=1e-5
    "Tolerance in Preisach history"
  parameter SI.Time t1=1e-6 "Initialization time"

  extends BaseClasses.GenericHysteresis(sigma=mat.sigma);

protected
  final parameter Real mu0=mat.K*Modelica.Constants.mu_0;

  SI.MagneticFluxDensity J "Polarisation";
  SI.MagneticFieldStrength hmax(start=0, min=0) "Maximum value of h";

  SI.MagneticFieldStrength alpha
    "Current alpha coordinate of Everett-Function everett(alpha,beta)";
  SI.MagneticFieldStrength beta
    "Current beta coordinate of Everett-Function everett(alpha,beta)";

  Boolean asc(start=true, fixed=true) "=asc without chatter";
  Boolean asc2 "Hstat is ascending der(Hstat)>0";
  Boolean delAsc(start=false)
    "Wipeout history vertex at ascending Hstat";
  Boolean delDesc(start=false)
    "Wipeout history vertex at descending Hstat";
  Boolean del(start=false) "delAsc or delDesc";
  Boolean init(start=false, fixed=true)
    "If init=1 then J runs on the initial magnetization curve";
  Boolean evInit(start=false) "Event init=0 -> init=1";
  Boolean evAsc(start=false) "Event asc=0 -> asc=1";
  Boolean evDesc(start=false) "Event asc=1 -> asc=0";

  SI.MagneticFieldStrength aSav[Count]
    "1xCount array of alpha history (vertices on Preisach Plane)";
  SI.MagneticFieldStrength bSav[Count]
    "1xCount array of beta history (vertices on Preisach Plane)";

  SI.MagneticFluxDensity E "Everett function";
  SI.MagneticFieldStrength H1 "Term for computing the Everett function";
  SI.MagneticFieldStrength H2 "Term for computing the Everett function";
  SI.MagneticFieldStrength H3 "Term for computing the Everett function";
  SI.MagneticFieldStrength H4 "Term for computing the Everett function";
  constant SI.MagneticFluxDensity unitT=1;

  Real v(start=0,  fixed=true, final unit="1");

  Boolean init2(start=false, fixed=true);
  Boolean init3;
  SI.MagneticFieldStrength x(start=0)
    "Variable for initialization of the Preisach model";
  discrete Real aSavI(start=0, fixed=true);
  discrete Real bSavI(start=0, fixed=true);
  discrete Real bI(start=0, fixed=true);
  discrete Real hmaxI(start=0, fixed=true);

initial equation
  J = 0.5*(FluxTubes.Utilities.everett(
          H,
          -mat.Hsat,
          mat,
          false)*(1 - MagRel) - FluxTubes.Utilities.everett(
          mat.Hsat,
          H,
          mat,
          false)*(1 + MagRel) + FluxTubes.Utilities.everett(
          mat.Hsat,
          -mat.Hsat,
          mat,
          false)*MagRel);
  J = FluxTubes.Utilities.initPreisach(
          x,
          H,
          mat);
  aSav=fill( mat.Hsat,Count);
  bSav=fill(-mat.Hsat,Count);
  beta=alpha;
  hmax=mat.Hsat;

equation
  init2 = time >= 1.5*t1;
  init3 = edge(init2);

  der(x) = 0;
  when init2 then
    hmaxI = abs(Hstat)+abs(x);
    if hmax<eps then
      aSavI = mat.Hsat;
      bSavI = -mat.Hsat;
    elseif asc and x<0 then
      aSavI = mat.Hsat;
      bSavI = -hmax;
    elseif asc and x>0 then
      aSavI = hmax;
      bSavI = alpha;
    elseif not asc and x<0 then
      aSavI = alpha;
      bSavI = -hmax;
    else
      aSavI = hmax;
      bSavI = -mat.Hsat;
    end if;
    bI = if asc then bSav[1] else aSav[1];
  end when;

  alpha = if Hstat<=-mat.Hsat then -mat.Hsat elseif Hstat>=mat.Hsat then mat.Hsat else Hstat;

  asc2 = der(Hstat)>0;
  der(v)= if (asc2 and v<1) then 0.5/t1 elseif (not asc2 and v>0) then -0.5/t1 else 0;
  asc = v>0.5;

  evAsc = (not pre(asc)) and asc;
  evDesc = pre(asc) and (not asc);

  der(beta) = if init then -der(alpha) else 0;

  delAsc = (alpha > pre(aSav[1]));
  delDesc = (alpha < pre(bSav[1]));
  del = delAsc or delDesc or evInit;

  init = (abs(alpha) >= pre(hmax)) and time>=2*t1;

  evInit = init and not pre(init);

  when init3 or (change(asc) and pre(init)) then
    hmax = if init3 then hmaxI else abs(Hstat);
  end when;

  //##### bSav #####
  when {init3, evAsc, del} then
    if init3 then
      bSav=cat(1,{bSavI},fill(-mat.Hsat,Count-1));
    elseif evAsc then
      bSav = if (alpha-eps)>pre(bSav[1]) then cat(1,{alpha},pre(bSav[1:end-1])) else pre(bSav);
    elseif del then
      bSav = cat(1,pre(bSav[2:end]),{-mat.Hsat});
    else
      bSav = pre(bSav);
    end if;
  end when;

  //##### REINIT aSav #####
  when {init3, evDesc, del} then
    if init3 then
      aSav=cat(1,{aSavI},fill(mat.Hsat,Count-1));
    elseif evDesc then
      aSav = if (alpha+eps)<pre(aSav[1]) then cat(1,{alpha},pre(aSav[1:end-1])) else pre(aSav);
    elseif del then
      aSav = cat(1,pre(aSav[2:end]),{mat.Hsat});
    else
      aSav = pre(aSav);
    end if;
  end when;

  // #### beta ####
  when {init3, change(asc), evInit, del} then
    reinit(beta, if init3 then bI elseif change(asc) then alpha elseif evInit then -alpha elseif asc then bSav[1] else aSav[1]);
  end when;

  H1= -beta-mat.Hc;
  H2= alpha-mat.Hc;
  H3= -alpha-mat.Hc;
  H4= beta-mat.Hc;

  E = unitT*
      ((mat.M*mat.r*(2/pi*atan(mat.q*H1)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H1)+exp(-mat.p2*H1))))*
      (mat.M*mat.r*(2/pi*atan(mat.q*H2)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H2)+exp(-mat.p2*H2))))-
      (mat.M*mat.r*(2/pi*atan(mat.q*H3)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H3)+exp(-mat.p2*H3))))*
      (mat.M*mat.r*(2/pi*atan(mat.q*H4)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H4)+exp(-mat.p2*H4)))));

  der(J) = (if init then 0.5 else 1) * der(E);
  B = J + mu0 * Hstat;
end GenericHystPreisachEverett;


Generic flux tube with ferromagnetic hysteresis based on the Tellinen model and the Everett function [Ya89]). Flux tube element for modeling soft magnetic materials with ferromagnetic and dynamic hysteresis (eddy currents). The ferromagnetic hysteresis behavior is defined by the Tellinen hysteresis model. The Shape of the limiting ferromagnetic hysteresis loop is specified by an analytical description of the Everett function, which is also used to parameterize the GenericHystPreisachEverett model. A library of predefined parameter sets can be found in FluxTubes.Material.HysteresisEverettParameter.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystTellinenEverett
  "Generic flux tube with ferromagnetic hysteresis based on the Tellinen model and the Everett function [Ya89])"

  parameter FluxTubes.Material.HysteresisEverettParameter.BaseData mat=
      FluxTubes.Material.HysteresisEverettParameter.BaseData()
    "Material properties"
  extends BaseClasses.GenericHysteresisTellinen(      mu0=mat.K*mu_0, sigma=mat.sigma);

protected
  parameter SI.MagneticFluxDensity Js = 0.5 * FluxTubes.Utilities.everett(
                                                     mat.Hsat,-mat.Hsat, mat, false)
    "Saturation polarization";
  //final parameter Real mu0 = mat.K * mu_0;
  parameter SI.MagneticFluxDensity eps=mat.M/1000;
  parameter Real P1 = (mat.M*mat.r*(2/pi*atan(mat.q*(mat.Hsat-mat.Hc))+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*(mat.Hsat-mat.Hc))+exp(-mat.p2*(mat.Hsat-mat.Hc)))));
  parameter Real P4 = (mat.M*mat.r*(2/pi*atan(mat.q*(-mat.Hsat-mat.Hc))+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*(-mat.Hsat-mat.Hc))+exp(-mat.p2*(-mat.Hsat-mat.Hc)))));

  SI.MagneticFieldStrength H2;
  SI.MagneticFieldStrength H3;
  Real P2;
  Real P3;
  Real H_lim;
  constant SI.MagneticFluxDensity unitT = 1;

equation
  H_lim = if Hstat<-mat.Hsat then -mat.Hsat elseif Hstat>mat.Hsat then mat.Hsat else Hstat;
  H2 = H_lim-mat.Hc;
  H3 = -H_lim-mat.Hc;

  P2 = (mat.M*mat.r*(2/pi*atan(mat.q*H2)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H2)+exp(-mat.p2*H2))));
  P3 = (mat.M*mat.r*(2/pi*atan(mat.q*H3)+1)+(2*mat.M*(1-mat.r))/(1+1/2*(exp(-mat.p1*H3)+exp(-mat.p2*H3))));

  hystR = -Js + unitT*(P1*P2-P3*P4) + mu0*Hstat - eps/2;
  hystF =  Js + unitT*(P4*P2-P3*P1) + mu0*Hstat + eps/2;
end GenericHystTellinenEverett;


Generic flux tube with hard magnetic hysteresis based on the Tellinen model and simple tanh()-functions. Flux tube element for modeling the ferromagnetic (static) hysteresis of hard magnetic materials. The ferromagnetic hysteresis behavior is defined by the Tellinen hysteresis model. The shape of the limiting hysteresis loop is described by simple hyperbolic tangent functions with 4 parameters.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystTellinenHard
  "Generic flux tube with hard magnetic hysteresis based on the Tellinen model and simple tanh()-functions"

  extends BaseClasses.GenericHysteresisTellinen(      mu0=K*mu_0);

  //Hysteresis parameter
  parameter SI.MagneticFluxDensity Br=1.2 "Remanence"
  parameter SI.MagneticFieldStrength Hc=5e5 "Coercitivity"
  parameter Real M(final unit="m/A") = 10/Hc "Slope of tanh()-function"
  parameter Real K=1 "Slope of hysteresis in the saturation region (K*mu_0)"

protected
  final parameter SI.MagneticFluxDensity eps = Br/1000;
  //final parameter Real mu0(final unit="N/A2") = K*mu_0;
  final parameter Real H0= 0.5*log((1+mu0*Hc/Br)/(1-mu0*Hc/Br)) + M*Hc;
  constant SI.MagneticFieldStrength unitH = 1;

  Real tanhR;
  Real tanhF;

equation
  tanhR = tanh(M*H - H0);
  tanhF = tanh(M*H + H0);
  hystR = Br*tanhR + mu0*H - eps/2;
  hystF = Br*tanhF + mu0*H + eps/2;
end GenericHystTellinenHard;


Permanent magnet based on the Tellinen hysteresis model. Flux tube element for modeling the hard magnetic hysteresis of permanent magnets. The model is similar to GenericHystTellinenHard but has an initial magnetization preset of -100% and an adapted icon for better readability of the diagram.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystTellinenPermanentMagnet
  "Permanent magnet based on the Tellinen hysteresis model"

  extends BaseClasses.GenericHysteresisTellinen(                mu0=K*
        Modelica.Constants.mu_0, MagRel(start=-1, fixed=true));

  parameter SI.MagneticFluxDensity Br=1.2 "Remanence"
  parameter SI.MagneticFieldStrength Hc=5e5 "Coercitivity"
  parameter Real M(final unit="m/A") = 10/Hc
    "Slope of tanh()-function"
  parameter Real K(final unit="1")=1 "mu_0 multiplier"

protected
  constant SI.MagneticFieldStrength unitH = 1;
  parameter SI.MagneticFluxDensity eps= Br/1000;
  parameter Real H0(final unit="1")= 0.5*log((1+mu0*Hc/Br)/(1-mu0*Hc/Br)) + M*Hc;

equation
  hystR = Br*tanh((M*H - H0)) + mu0*H - eps/2;
  hystF = Br*tanh((M*H + H0)) + mu0*H + eps/2;
end GenericHystTellinenPermanentMagnet;


Generic flux tube with soft magnetic hysteresis based on the Tellinen model and simple tanh()-functions. Flux tube element for modeling soft magnetic materials with ferromagnetic and dynamic hysteresis (eddy currents). The ferromagnetic hysteresis behavior is defined by the Tellinen hysteresis model. The shape of the limiting hysteresis loop (see Fig. 1) is described by simple hyperbolic tangent functions with 4 parameters. Therefore, the hysteresis shape variety is limited but the parameterization of the model is very simple and the model is relatively fast and robust. The rising (hystR) and falling (hystF) branches of the limiting hysteresis loop are defined by the following equations.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystTellinenSoft
  "Generic flux tube with soft magnetic hysteresis based on the Tellinen model and simple tanh()-functions"
  // Dialog Group Hysteresis
  parameter SI.MagneticFluxDensity Js = 1.8 "Saturation polarization"
  parameter SI.MagneticFluxDensity Br=0.9 "Remanence"
  parameter SI.MagneticFieldStrength Hc=120 "Coercitivity"
  parameter Real K=1 "Slope of hysteresis in the saturation region (K*mu_0)"

  extends BaseClasses.GenericHysteresisTellinen(      mu0=K*mu_0);

protected
  parameter SI.MagneticFluxDensity eps=Js/1000;
  //parameter Real mu0(final unit="N/A2")=K*mu_0;
  parameter Real H0=0.5*Modelica.Math.log((1 + Br/Js)/(1 - Br/Js));
  parameter Real M=H0/Hc;
  constant SI.MagneticFieldStrength unitH = 1;

equation
  hystR = Js*tanh(M*Hstat - H0) + mu0*Hstat - eps/2;
  hystF = Js*tanh(M*Hstat + H0) + mu0*Hstat + eps/2;
end GenericHystTellinenSoft;


Generic flux tube with ferromagnetic hysteresis based on the Tellinen model and table data. Flux tube element for modeling magnetic materials with ferromagnetic and dynamic hysteresis (eddy currents). The ferromagnetic hysteresis behavior is defined by the Tellinen hysteresis model. The rising and falling branch of the limiting ferromagnetic hysteresis loop are specified by table data. Therefore, almost any hysteresis shapes are possible. A library with predefined tables can be found at FluxTubes.Material.HysteresisTableData.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericHystTellinenTable
  "Generic flux tube with ferromagnetic hysteresis based on the Tellinen model and table data"

  parameter FluxTubes.Material.HysteresisTableData.BaseData mat=
    FluxTubes.Material.HysteresisTableData.BaseData() "Material properties"
  parameter Real K = 1
    "Slope of hysteresis in the saturation region (K*mu_0)"

  extends BaseClasses.GenericHysteresisTellinen(      mu0=mu_0*K, sigma=mat.sigma);

protected
  constant SI.MagneticFluxDensity unitT=1;
  parameter SI.MagneticFluxDensity eps = unitT*mat.tabris[size(mat.tabris,1),2]/1000;

  Modelica.Blocks.Tables.CombiTable1Dv tabris(
    table=mat.tabris,
    smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative);

  Modelica.Blocks.Tables.CombiTable1Dv tabfal(
    table=mat.tabfal,
    smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative);

equation
  tabris.u[1]=Hstat;
  tabfal.u[1]=Hstat;

  hystR = unitT*tabris.y[1]+mu0*Hstat-eps;
  hystF = unitT*tabfal.y[1]+mu0*Hstat+eps;
end GenericHystTellinenTable;


Permanent Magnet with linear characteristic. Simple model of a linear permanent Magnet. Typical characteristics of common permanent magnetic materials can be found at FluxTubes.Material.HardMagnetic.

within Modelica.Magnetic.FluxTubes.Shapes.HysteresisAndMagnets;
model GenericLinearPermanentMagnet
  "Permanent Magnet with linear characteristic"
  extends BaseClasses.Generic;

  parameter Material.HardMagnetic.BaseData mat=
      Material.HardMagnetic.BaseData() "Material"

  output SI.MagneticFieldStrength H;
  output SI.MagneticFluxDensity B;

equation
  V_m = H*l;
  Phi = B*A;
  B = -mat.B_r+mu_0*mat.mu_r*H;
end GenericLinearPermanentMagnet;


within Modelica.Magnetic.FluxTubes.Shapes;
package HysteresisAndMagnets "Flux tube elements for modelling ferromagnetic hysteresis, eddy currents and permanent magnets"
  extends Modelica.Icons.VariantsPackage;
end HysteresisAndMagnets;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model CoaxCylindersEndFaces
  "Leakage flux between the end planes of a inner solid cylinder and a coaxial outer hollow cylinder"

  extends BaseClasses.Leakage;

  parameter SI.Radius r_0=10e-3 "Radius of inner solid cylinder"
  parameter SI.Radius r_1=17e-3 "Inner radius of outer hollow cylinder";
  parameter SI.Radius r_2=20e-3 "Outer radius of outer hollow cylinder";

  final parameter SI.Distance l_g=r_1 - r_0
    "Radial gap length between both cylinders";
  final parameter SI.Length t=r_2 - r_1
    "Radial thickness of outer hollow cylinder";

equation
  // [Ro41], p. 139, Eq. (22)
  G_m = if t <= r_0 then 2*mu_0*(r_0 + l_g/2)*Modelica.Math.log(1 + 2*t/
    l_g) else 2*mu_0*(r_0 + l_g/2)*Modelica.Math.log(1 + 2*r_0/l_g);
end CoaxCylindersEndFaces;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model EighthOfHollowSphere
  "Leakage flux through one edge and the opposite plane of an eighth of a hollow sphere"

  extends BaseClasses.Leakage;

  parameter SI.Length t(start=0.01) "Thickness of spherical shell"

equation
  G_m = mu_0*0.5*t;
end EighthOfHollowSphere;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model EighthOfSphere
  "Leakage flux through one edge and the opposite plane of an eighth of a sphere"

  extends BaseClasses.Leakage;

  parameter SI.Radius r=0.01 "Radius of eighth of sphere"

equation
  G_m = mu_0*0.308*r;
end EighthOfSphere;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model HalfCylinder "Leakage flux through the edges of a half cylinder"

  extends BaseClasses.Leakage;

  parameter SI.Length l=0.1
    "Axial length orthogonal to flux (=2*pi*r for cylindrical pole and r>>distance between edges)"

equation
  G_m = mu_0*0.26*l;
end HalfCylinder;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model HalfHollowCylinder
  "Leakage flux in circumferential direction through a half hollow cylinder"

  extends BaseClasses.Leakage;

  parameter SI.Length l=0.1
    "Axial length orthogonal to flux (=2*pi*r for cylindrical pole and r>>r_i)"
  parameter Real ratio(start=1) "Constant ratio t/r_i";

equation
  G_m = mu_0*l*Modelica.Math.log(1 + ratio)/pi;
end HalfHollowCylinder;


within Modelica.Magnetic.FluxTubes.Shapes;
package Leakage "Leakage flux tubes with position-independent permeance and hence no force generation; mu_r=1"
  extends Modelica.Icons.VariantsPackage;
end Leakage;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model QuarterCylinder
  "Leakage flux from one edge to the opposite plane through a quarter cylinder"

  extends BaseClasses.Leakage;

  parameter SI.Length l=0.1
    "Axial length orthogonal to flux (=2*pi*r for cylindrical pole and r>>distance between edge and plane)"
equation
  G_m = mu_0*0.52*l;
end QuarterCylinder;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model QuarterHollowCylinder
  "Leakage flux in circumferential direction through a quarter hollow cylinder"

  extends BaseClasses.Leakage;

  parameter SI.Length l=0.1
    "Axial length orthogonal to flux (=2*pi*r for cylindrical pole and r>>r_i)"
  parameter Real ratio(start=1) "Constant ratio t/r_i";

equation
  G_m = 2*mu_0*l*Modelica.Math.log(1 + ratio)/pi;
end QuarterHollowCylinder;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model QuarterHollowSphere
  "Leakage flux through the edges of a quarter hollow sphere"

  extends BaseClasses.Leakage;

  parameter SI.Length t(start=0.01) "Thickness of spherical shell"

equation
  G_m = mu_0*0.25*t;
end QuarterHollowSphere;


within Modelica.Magnetic.FluxTubes.Shapes.Leakage;
model QuarterSphere
  "Leakage flux through the corners of a quarter sphere"

  extends BaseClasses.Leakage;

  parameter SI.Radius r=0.005 "Radius of quarter sphere"

equation
  G_m = mu_0*0.077*2*r;
end QuarterSphere;


Source of constant magnetic flux. Sources of a constant magnetic flux are useful for modelling of permanent magnets with Norton's magnetic equivalent circuit.

within Modelica.Magnetic.FluxTubes.Sources;
model ConstantMagneticFlux "Source of constant magnetic flux"

  extends Interfaces.TwoPortElementary;
  parameter SI.MagneticFlux Phi=1 "Magnetic flux";
  SI.MagneticPotentialDifference V_m
    "Magnetic potential difference between both ports";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
  0 = port_p.Phi + port_n.Phi;
end ConstantMagneticFlux;


Constant magnetomotive force. Magnetic circuits under steady-state conditions, i.e., with stationary magnetic fields (change of magnetic flux  dΦ/dt = 0) can be described with constant sources of a magnetic potential difference or magnetomotive force (mmf). Constant magnetic potential differences are imposed by

within Modelica.Magnetic.FluxTubes.Sources;
model ConstantMagneticPotentialDifference "Constant magnetomotive force"

  extends Interfaces.TwoPortElementary;
  parameter SI.MagneticPotentialDifference V_m
    "Magnetic potential difference";
  SI.MagneticFlux Phi "Magnetic flux from port_p to port_n";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
  0 = port_p.Phi + port_n.Phi;
end ConstantMagneticPotentialDifference;


within Modelica.Magnetic.FluxTubes;
package Sources "Sources of different complexity of magnetomotive force and magnetic flux"
  extends Modelica.Icons.SourcesPackage;
end Sources;


Signal-controlled magnetic flux source. This source of a magnetic flux is intended for test purposes, e.g., for simulation and subsequent plotting of a softmagnetic material's magnetisation characteristics if used together with a non-linear reluctance element.

within Modelica.Magnetic.FluxTubes.Sources;
model SignalMagneticFlux "Signal-controlled magnetic flux source"

  extends Interfaces.TwoPortElementary;
  Modelica.Blocks.Interfaces.RealInput Phi(unit="Wb") "Magnetic flux"
  SI.MagneticPotentialDifference V_m
    "Magnetic potential difference between both ports";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
  0 = port_p.Phi + port_n.Phi;
end SignalMagneticFlux;


Signal-controlled magnetomotive force. In electromagnetic devices, a change of a coil's magnetic flux linkage Ψ reacts on the electrical subsystem in that a voltage v is induced due to Faraday's law:

within Modelica.Magnetic.FluxTubes.Sources;
model SignalMagneticPotentialDifference
  "Signal-controlled magnetomotive force"

  extends Interfaces.TwoPortElementary;
  Modelica.Blocks.Interfaces.RealInput V_m(unit="A")
    "Magnetic potential difference"
  SI.MagneticFlux Phi "Magnetic flux from port_p to port_n";

equation
  V_m = port_p.V_m - port_n.V_m;
  Phi = port_p.Phi;
  0 = port_p.Phi + port_n.Phi;
end SignalMagneticPotentialDifference;


Function used for the initialization of the Preisach hysteresis model GenericHystPreisachEverett.

within Modelica.Magnetic.FluxTubes.Utilities;
function initPreisach
  "Function used for the initialization of the Preisach hysteresis model GenericHystPreisachEverett"
  extends Modelica.Icons.Function;

  input SI.MagneticFieldStrength x;
  input SI.MagneticFieldStrength H;
  input FluxTubes.Material.HysteresisEverettParameter.BaseData p;
  output SI.MagneticFluxDensity B;

protected
  SI.MagneticFieldStrength hmax;
  SI.MagneticFieldStrength H_l;

algorithm
  H_l :=if H <= -p.Hsat then -p.Hsat elseif H >= p.Hsat then p.Hsat else H;
  hmax :=abs(H) + abs(x);
  B := if x < 0
  then
     -0.5*everett(hmax,-hmax,p,false)
     + everett(H_l, -hmax, p, false)
     + p.K*mu_0*H
  else
    0.5*everett(hmax, -hmax, p, false)
     - everett(hmax, H_l, p, false) + p.K*mu_0*H;

end initPreisach;


Package with utility functions

within Modelica.Magnetic.FluxTubes;
package Utilities "Package with utility functions"
  extends Modelica.Icons.FunctionsPackage;
end Utilities;


within Modelica.Magnetic;
package FundamentalWave "Library for magnetic fundamental wave effects in electric machines"
  extends Modelica.Icons.Package;
end FundamentalWave;