MagneticPotentialDifferenceSensor

model MagneticPotentialDifferenceSensor "Sensor to measure magnetic potential difference"
    extends Modelica.Icons.RotationalSensor;
    extends FluxTubes.Interfaces.PartialTwoPortsElementary;

    Modelica.Blocks.Interfaces.RealOutput V_m(final quantity = "MagneticPotential", final unit = "A") "Magnetic potential difference between ports p and n as output signal"
        annotation (Placement(transformation(
            origin = {0, -100},
            extent = {
                {10, -10}, 
                {-10, 10}},
            rotation = 90)));
    SI.MagneticFlux Phi "Magnetic flux from port_p to port_n";
equation
    0 = port_p.Phi + port_n.Phi;
    Phi = 0;
    Phi = port_p.Phi;
    V_m = port_p.V_m - port_n.V_m;

    annotation (
        defaultComponentName = "magVoltageSensor",
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-52, 1}, 
                        {48, -57}},
                    textString = "V_m"), 
                Line(
                    points = {
                        {-70, 0}, 
                        {-90, 0}},
                    color = {255, 128, 0}), 
                Line(
                    points = {
                        {70, 0}, 
                        {90, 0}},
                    color = {255, 128, 0}), 
                Line(points = {
                    {0, -90}, 
                    {0, -70}}), 
                Text(
                    extent = {
                        {-150, 120}, 
                        {150, 80}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-70, 0}, 
                        {-100, 0}},
                    color = {255, 128, 0}), 
                Line(
                    points = {
                        {70, 0}, 
                        {100, 0}},
                    color = {255, 128, 0}), 
                Line(points = {
                    {0, -100}, 
                    {0, -70}})}));
end MagneticPotentialDifferenceSensor;