Trouble Flipping Magnetization of Object #570
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
hi @leahkong02 Thanks for reaching out. There are two problems
Both together lead to confusion that is however easily solved ! import magpylib as magpy
inner_r = 60
outer_r = 35
h = 10
mag = [0, 0, 1000]
nmag = [0, 0,-1000]
distance = 70
dim = (outer_r, inner_r, h, 0, 360)
a = magpy.magnet.CylinderSegment( mag, dim, [0, 0, distance])
b = magpy.magnet.CylinderSegment(nmag, dim, [0, 0, -distance])
c = magpy.magnet.CylinderSegment( mag, dim, [0, distance, 0])
d = magpy.magnet.CylinderSegment(nmag, dim, [0, -distance, 0])
e = magpy.magnet.CylinderSegment( mag, dim, [ distance, 0, 0])
f = magpy.magnet.CylinderSegment(nmag, dim, [-distance, 0, 0])
c.rotate_from_angax(-90, 'x')
d.rotate_from_angax(-90, 'x')
e.rotate_from_angax(90, 'y')
f.rotate_from_angax(90, 'y')
for x in [a,b,c,d,e,f]:
print(x.getB((0,0,0)))
magpy.show(a,b,c,d,e,f, backend='plotly') The output should be [ 0. 0. 10.17666237] which shows that the field computation is good, and the graphic Here the graphic output is created with the optional Plotly packge. Matplotlib will still give a bad output - this will be fixed with the next update. does this answer your question ? |
Beta Was this translation helpful? Give feedback.
-
Hi @leahkong02, thanks for your feedback about the library ;)
|
Beta Was this translation helpful? Give feedback.
-
Hi @leahkong02, we have released a patch version that also fixes the wrong display of magnetization arrows like in this case. you can upgrade your version with pip install -U magpylib or by giving the explicit version number pip install magpylib==4.1.2 or if you use conda: conda install -c conda-forge magpylib=4.1.2 :-) |
Beta Was this translation helpful? Give feedback.
hi @leahkong02
Thanks for reaching out. There are two problems
Both together lead to confusion that is however easily solved !
Your correct code should be like this: