-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Magpylib version
4.x (Latest)
What happened?
It looks like the B and H field values along the side flank are wrong, showing zero everywhere.
Code example
Note that I chose to use an almost closed cylinder because when using the object oriented interface. The calculation falls back to the cylinder core function when using a closed cylinder segment
import magpylib as magpy
import numpy as np
cs = magpy.magnet.CylinderSegment(
magnetization=(0, 0, 1),
dimension=(0, 0.5, 1, 0, 359),
)
pos = np.array([(x, 0.0, 0.2) for x in np.linspace(-0.5, 0.5)])
sens = magpy.Sensor(position=pos)
with magpy.show_context(cs, sens):
magpy.show(col=1)
magpy.show(col=2, output=["Bx", "By", "Bz"], style_opacity=0.5)
magpy.show(col=3, output=["Hx", "Hy", "Hz"], style_opacity=0.5)

Additional context
I stumbled upon it when reworking the core functions for v5 and noticed that a cylinder segment showed a different result when compared to a cylinder of equal dimensions. There was also another issue with the cylinder field values but this is addressed in #703.
field = "H"
obs = np.array([(0,0,0)])
pols = np.array([(0, 0, 1)] * len(obs))
d,h = 1,1
dims = np.array([(d, h)]*len(obs))
dims_cs = np.array([(0, d/2, h, 0, 360)]*len(obs))
Bc = magpy.core.magnet_cylinder_field(
field=field,
observers=obs,
dimension=dims,
magnetization=pols,
)
Bcs = magpy.core.magnet_cylinder_segment_field(
field=field,
observers=obs,
dimension=dims_cs,
magnetization=pols,
)
print("B, Cylinder: ", Bc.round(2))
print("B, CylinderSegment: ", Bcs.round(2))
# -> output:
# B, Cylinder: [[ 0. 0. -0.23]]
# B, CylinderSegment: [[0. 0. 0.]]
@fslanovc Could do please have a look at this, thanks
Metadata
Metadata
Assignees
Labels
bugneeds attentionneeds attention