Repository navigation
|
Dear all, Thank you all for your help. |
Answered by
lamoreel
Mar 30, 2026
Replies: 1 comment 3 replies
|
Hi! This is definitely possible! You could do this in two different ways:
import numpy as np
Bext = np.zeros(magnet.bias_magnetic_field.shape)
Bext[0, :, :, :] = 1 # x-comp is 1 everywhere
Bext[1, :, :, :nx//2] = 1 # y-comp is 1 in left half
Bext[1, :, :, nx//2:] = -1 # y-comp is -1 in right half
magnet.bias_magnetic_field = Bext
def my_Bext(x,y,z):
return (x*y, 1, 2*z)
magnet.bias_magnetic_field = my_BextThis is also explained in this tutorial for the case of magnetization setting. The methodology is the same, apart from the fact that the magnetization gets normalized behind the scenes. Hope this helps! |
3 replies
Answer selected by
ilateur
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
This is definitely possible! You could do this in two different ways:
numpyarrays of shape (3, nz, ny, nx). For exampleThis is also explained in this tutorial for the case of magnetization setting. The methodology is the same, apart f…