MagneticFluxSensor

model MagneticFluxSensor "Sensor to measure magnetic flux"
    extends FluxTubes.Interfaces.PartialTwoPortsElementary;
    extends Modelica.Icons.RotationalSensor;

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

    annotation (
        defaultComponentName = "magFluxSensor",
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {0, -100}, 
                    {0, -70}}), 
                Line(
                    points = {
                        {-70, 0}, 
                        {-90, 0}},
                    color = {255, 128, 0}), 
                Line(
                    points = {
                        {70, 0}, 
                        {90, 0}},
                    color = {255, 128, 0}), 
                Text(
                    extent = {
                        {-29, -11}, 
                        {30, -70}},
                    textString = "Phi"), 
                Text(
                    extent = {
                        {-150, 120}, 
                        {150, 80}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(points = {
                    {0, -90}, 
                    {0, -70}})}));
end MagneticFluxSensor;