ubermag / help

Repository for raising issues and requesting help on Ubermag
BSD 2-Clause "Simplified" License
11 stars 3 forks source link

Visualization of 'z' component of magnetization over a circular region #268

Closed DebanjanPolley closed 11 months ago

DebanjanPolley commented 11 months ago

I am simulating a circular dot with out-of-plane magnetization and studying the effect of current pulse-induced magnetization dynamics. Initially, the magnetization is aligned out-of-plane (z direction). I am trying to plot 'Mz' as a scalar field on the surface of a circular region. On top of that, I also would like to plot the magnetization vector as an arrow. I am using the following code:

fig = plt.figure(figsize=(8,8))
ax1 = fig.add_subplot(1,1,1)
i=20
combined1[i].z.sel('z').mpl.scalar(ax=ax1,cmap='bwr', colorbar=False,clim=(-1e6, 1e6)) #scalar component

combined1[i].sel('z').resample((8,8)).mpl.vector(ax=ax1, cmap='ocean',colorbar=False,clim=(-1, 1)) #vector component

ax1.tick_params(direction='in', length=6, width=2, colors='k', grid_color='k',  labelsize= 20)
ax1.set_xlabel('X (nm)', fontsize=20)
ax1.set_ylabel('Y (nm)', fontsize=20)
plt.tight_layout()
plt.savefig(path+'test_{i}.jpg'.format(i=i),dpi=200)

I can understand the scalar 'Mz' component, as with the colormap I am using, it should show 'red' and 'blue' for two opposite orientations of the magnetization. However, I am confused with the vector component orientation. To my understanding, initially, as the magnetization is mostly out-of-plane, it should show a '.' or 'x' (i.e. the tip or tail of the arrow). However, as you can see in the attached figure, it looks like the magnetization is aligned along 'X' axis. Am I doing something wrong?

test_20

samjrholt commented 11 months ago

@DebanjanPolley As mpl is designed to deal with 2D visualisations, mpl.vector will only plot 2D arrows within the plane rather than three dimensional arrows pointing in the vector direction. Thus is you have a vector (vx, vy, vz) and plot the z plane the arrows will point in the (vx, vy) direction.

If you prefer 3D visualisations, the next release of discretisedfield will have support for more complex visualizations using pyvista.