Open DebanjanPolley opened 7 months ago
Hi @DebanjanPolley , Ubermag (i.e. discretisedfield) does not have any functionality to directly create an initial state from an image. Two suggestions:
particle
function for multiple particles you could probably introduce a for-loop over all (x0, y0, r)
tuples to avoid some code duplication.Hello, I tried a solution as provided in some other thread. I have attached a simplified image and the corresponding data file (including the position and magnetization vector ). However, I fail to achieve the required spin configuration using a similar code. The idea is that the white portion of the image should have a large magnetization, and the black portion should have zero magnetization.
My code looks like this:
import numpy as np
import discretisedfield as df
import micromagneticmodel as mm
import oommfc as oc
import matplotlib.pyplot as plt
from PIL import Image
system = mm.System(name='testpos1')
Data = np.genfromtxt("example.txt", delimiter='\t', skip_header = 2, skip_footer=1)
coords = Data[:, :3]
mag = Data[:, 3:]
cell = (5, 5, 1)
p1 = (0,0,0) # np.min(coords, axis=0) - np.divide(cell, 2)
p2 = (300, 270, 1) # np.max(coords, axis=0) + np.divide(cell, 2)
mesh = df.Mesh(p1=p1, p2=p2, cell=cell)
def val_fun(pos):
arr = np.all(np.isclose(coords, pos), axis=1)
if np.any(arr):
return mag[arr].squeeze()
else:
return (0, 0, 0)
system.m = df.Field(mesh=mesh, nvdim=3, value=val_fun)
mesh.mpl()
system.m.sel('z').mpl()
Hello, I am trying to simulate a 3-dimensional magnetic disk (dot and or anti-dot type structure) lattice structure using Ubermag. I am mainly interested in stray field distribution. If it is a single magnetic disk, I can easily use:
However, this process gets cumbersome if I have multiple such disks or if I try to simulate a real SEM image of such an artificial lattice structure. Is it possible to write a code in such a way that Ubermag takes the initial magnetization configuration after reading an image file (.png,. jpeg or .bmp)?
I have attached a sample image here. The black/white part should be read as 'zero/Ms' magnetization, where Ms is the predefined magnetization value.
Thanks, Debanjan