Conversation
update for magnetfield
| %x1,y1,z1 - reference corner of magnet | ||
| %x2,y2,z2 - opposite corner of magnet, defining direction of coordinate | ||
| % system and dimension of magnet | ||
| % x_m = [x1,x2] ... |
There was a problem hiding this comment.
For consistency with other approaches, I think the inputs into this function should be x_c,y_c,z_c for the magnet centre with d_x,d_y,d_z for the cuboid widths. Or similar. Could even be two 3x1 vectors instead.
|
|
||
| %theta - CCW angle from the +x-axis to the polarisation vector | ||
| % (XY-plane // about Z) | ||
| %phi - CW angle from the +z-axis to the polarisation vector |
There was a problem hiding this comment.
Is it possible to rewrite the equations around having a magnetization vector such as Mx,My,Mz so that theta & phi don’t need to be figured out?
| H = cat(3,Hx,Hy,Hz); | ||
|
|
||
| %magnetic flux density | ||
| B = u0.*H; |
There was a problem hiding this comment.
M0 could be removed from the Hx,Hy,Hz equations above and moved down to here.
| zeta = sqrt((x-x_m(i)+eps).^2+(y-y_m(j)+eps).^2+(z-z_m(k)+eps).^2); | ||
| zeta(isnan(zeta))=0; | ||
|
|
||
| %calculate magnetic field strength |
There was a problem hiding this comment.
Does Ravaud provide the singular cases so we can get rid of the eps terms? It’s a bit ugly to hack around them like this and doesn’t entirely eliminate the problem (not out of the realm of possibility that a user would provide a displacement of eps, say.)
A few things I’d change before pulling it into the main repo...