Open Shobhn opened 2 years ago
Hi ,
I am sorry for the urgency, but please could anyone help me through above issue . Thanks
Hi @Shobhn, thank you for your message and apologies for the wait. The majority of the team is at the conference.
Could you please send us the file?
yes sure! And thank you very much for the urgent reply :) Large_area_00000_arrows.txt
Hi @Shobhn, as you do not have magnetisation values for every single point in the region I have written a short example about how you might convert this to a Field
object.
import numpy as np
import discretisedfield as df
txt_file = np.loadtxt('Large_area_00000_arrows.txt', skiprows=2)
coords = txt_file[:, :3]
mag = txt_file[:, 3:]
cell = (1, 1, 1)
p1 = np.min(coords, axis=0) - np.divide(cell, 2)
p2 = 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)
m_field = df.Field(mesh=mesh, dim=3, value=val_fun)
Please remember that the mfm
function expects SI units for the mesh and the magnetisation values.
Hi @samjrholt ,
Thank you, and the team, very much for the quick response and for this answer, I really appreciate your help.
The code above helped me lot. Thanks again! :)
Hi team,
Thanks again for your help earlier ! :)
I have one more query regarding this issue, so I have more data files with different positions and spins, I wanted to ask that what should be the approach while defining the cell and the mesh so that the region can be discretised correctly with all spins at the centre of each cell. I want to learn how should we go about thinking while defining the cell for particular sets of positions. Since I tried various cell dimension for my other files but I was not able to discretised the region correctly.
I have attached a file here for example : [DL_sat_0.txt](https://github.com/ubermag/help/files/9038689/DL_sat_0.txt)
It would be great if some one can help me through this.
Thanks Again! Best.
Hello, I have encountered a similar problem. I have attached an 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.
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()
Hi,
So I have 6 column data file in format of (x,y,z,Sx,Sy,Sz) representing each spin positions and directions in a lattice. I want to create a MFM image simulation for this artificial spin ice lattice. Could anybody please explain me how to read these positions and spin directions to define a system in Ubermag. I am confused about how to put spins in these specific positions after defining the region.
Any Help is really appreciated. Thanks