Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Calculate magnetic field inside a uniformly magnetized sphere #406

Open
simgt opened this issue Jul 26, 2017 · 4 comments
Open

Calculate magnetic field inside a uniformly magnetized sphere #406

simgt opened this issue Jul 26, 2017 · 4 comments

Comments

@simgt
Copy link

simgt commented Jul 26, 2017

Hi,

In order to reproduce the test data of this article, I am trying to compute the B-field of a uniformly magnetized sphere. I'm expecting something like the following:

capture d ecran 2017-07-26 a 09 18 11

Here's the code I'm using, a slightly modified version of one of the example:

radius = 1
model = [
    mesher.Sphere(x=0, y=0, z=0, radius=radius,
                  props={'magnetization': utils.ang2vec(1, inc=0, dec=90)})
]

# Create a regular grid at a constant height
shape = (20, 20)
area = [-2, 2, -2, 2]
x, y, z = gridder.regular(area, shape, z=0)

field = np.array([sphere.bx(x, y, z, model),
                  sphere.by(x, y, z, model),
                  sphere.bz(x, y, z, model)])

I am getting the following vector field (after a non-linear normalization for aesthetic purpose):

intensity = np.linalg.norm(field, axis=0)
field = field / intensity * np.power(intensity, 1/7) 

fig, ax = plt.subplots(figsize=(6, 6))
ax.quiver(x, y, field[0], field[1], scale=80)

circle = plt.Circle((0, 0), radius, facecolor=(0, 0, 0, 0.1), edgecolor='black', linestyle='solid')
ax.add_artist(circle)

index

Disclaimer: I'm a programmer, not a physicist ;)

Is my understanding of what "uniformly magnetized" means inaccurate ? Any idea how the first plot could be reproduced using Fatiando ?

Thanks in advance !

@leouieda leouieda added the bug label Jul 26, 2017
@leouieda
Copy link
Member

Hi @notsimon thanks for reporting this and taking the time to write such a detailed issue! We really appreciate it.

I've never tested that part of the code inside the sphere (as you can see from the tests). It's good to know that it doesn't currently work.

The equations we use are the same as those for a single dipole because outside of the sphere their fields are equivalent. But inside we would have to change the equations appropriately. I don't know exactly where to find the equations.

@birocoles do you have any thoughts on this?

@simgt
Copy link
Author

simgt commented Jul 27, 2017

Hi @leouieda, thanks for your explanation !
I guess that's more an enhancement than a bug to fix then, as the field inside the magnetized object may not be used very often.

Thanks for this awesome library !

@leouieda leouieda added enhancement and removed bug labels Jul 27, 2017
@leouieda leouieda changed the title Uniformly magnetized sphere Calculate magnetic field inside a uniformly magnetized sphere Jul 27, 2017
@leouieda
Copy link
Member

@notsimon that's true. I updated your title to reflect this so that we can keep track of our todo.

Would you be interested in contributing this if we find the equations?

@simgt
Copy link
Author

simgt commented Aug 2, 2017

Hi @leouieda, sorry for the late reply.
Turns out I can manage to do what I need without what's happening inside the sphere.
If I find some time to contribute, I will probably use it to add Cuda support instead ! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants