Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spin wave dispersion analysis #287

Open
jmiasif opened this issue Jul 16, 2024 · 0 comments
Open

Spin wave dispersion analysis #287

jmiasif opened this issue Jul 16, 2024 · 0 comments

Comments

@jmiasif
Copy link

jmiasif commented Jul 16, 2024

dear ubermag team
i had simulated the below code for dispersion relation in mumax after obtain magnetization Now, for post-processing, I am using ubermag
mumax code

//mumax 3.10 [windows_amd64 go1.11.6(gc) CUDA-11.0]
//GPU info: NVIDIA GeForce GTX 1080(8191MB), CUDA Driver 12.2, cc=6.1, using cc=61 PTX
//(c) Arne Vansteenkiste, Dynamat LAB, Ghent University, Belgium
//This is free software without any warranty. See license.txt
//********************************************************************//
//  If you use mumax in any work or publication,                      //
//  we kindly ask you to cite the references in references.bib        //
//********************************************************************//
//output directory: swd.out/
setgridsize(384, 384, 1)
setcellsize(3.125e-9, 3.125e-9, 20e-9)
setPBC(4, 4, 0)
//resizing...
Aex = 13e-12
alpha = 0.01
Msat = 800e3
waveguide := square(1200e-9)
antenna := rect(1200e-9, 20e-9)
Py_waveguide := waveguide.add(antenna)
setgeom(Py_waveguide)
DefRegion(1, waveguide)
DefRegion(2, antenna)
save(regions)
m = randomMag()
B_ext = vector(0.08, 0, 0)
relax()
minimize()
save(m)
saveas(m, "final_static_Py_film")
snapshotas(m, "final_static_conf_PY_waveguide.jpg")
f0 := 2 * pi * 30e9
t0 := 5e-9
B0 := 0.01
B_ext.setRegion(2, vector(0.08, B0*sinc(f0*(t-t0)), 0))
autosave(m, 10e-12)
tableadd(B_ext)
tableautosave(10e-12)
run(15e-9)
saveas(m, "m_final")
snapshotas(m, "m_final.jpg")
//********************************************************************//
//Please cite the following references, relevant for your simulation. //
//See bibtex file in output folder for justification.                 //
//********************************************************************//
//   * Vansteenkiste et al., AIP Adv. 4, 107133 (2014).
//   * Exl et al., J. Appl. Phys. 115, 17D118 (2014).

for dispersion relations, i only use my magnetisation in this

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Constants and dimensions
time_steps = 1500
nx = 2048
ny = 2048
nz = 1
dx = 1200e-9 / nx
dt = 10e-12
fmax = 30e9
kc = (2 * np.pi) / (2 * dx)

# Load the data for 't' and 'my' using pandas
t = np.loadtxt('C:/Users/HP/t.csv')
my_data = pd.read_csv('C:/Users/HP/my.csv', header=None)

# Convert to numpy array
my = my_data.to_numpy()

# Inspect the shape of the loaded data
print(f"Shape of t: {t.shape}")
print(f"Shape of my: {my.shape}")

# Verify the expected size
expected_size_my = time_steps * nx * ny * nz
actual_size_my = my.size
actual_size_t = t.size

if actual_size_my == expected_size_my and actual_size_t == time_steps:
    # Reshape 'my' data
    my = my.reshape((time_steps, nx, ny, nz))
    print("Reshape successful!")
else:
    raise ValueError(f"Expected size for 'my': {expected_size_my}, but got actual size: {actual_size_my}. "
                     f"Expected size for 't': {time_steps}, but got actual size: {actual_size_t}")

# Select the slice at y = ny//2 (midpoint)
y_index = ny // 2

# Initialize an array to store the slice data
y_slice = np.zeros((time_steps, nx))

# Extract the slice data
for t_idx in range(time_steps):
    for x_idx in range(nx):
        y_slice[t_idx, x_idx] = my[t_idx, x_idx, y_index, 0]

# Perform 2D FFT
my_fft = np.fft.fft2(y_slice)
my_fft_shifted = np.fft.fftshift(my_fft)

# Calculate frequency and wave vector ranges
freqs = np.fft.fftfreq(time_steps, d=dt)
k_space = np.fft.fftfreq(nx, d=dx)

# Shift zero frequency component to the center
freqs_shifted = np.fft.fftshift(freqs)
k_space_shifted = np.fft.fftshift(k_space)

# Plot the results
plt.figure(figsize=(10, 4))
extent = [k_space_shifted[0], k_space_shifted[-1], freqs_shifted[0], freqs_shifted[-1]]
plt.imshow(np.abs(my_fft_shifted)**2, extent=extent, aspect='auto', origin='lower', cmap='bwr')
plt.xlim([-kc, kc])
plt.ylim([0, fmax])
plt.xlabel('Wave Vector $k$ (1/m)')
plt.ylabel('Frequency $f$ (Hz)')
plt.title('Spin Wave Dispersion')
plt.colorbar(label='Intensity')
plt.show()

while i run this code in jupyter lab i gives following error

ValueError                                Traceback (most recent call last)
Cell In[13], line 36
     34     print("Reshape successful!")
     35 else:
---> 36     raise ValueError(f"Expected size for 'my': {expected_size_my}, but got actual size: {actual_size_my}. "
     37                      f"Expected size for 't': {time_steps}, but got actual size: {actual_size_t}")
     39 # Select the slice at y = ny//2 (midpoint)
     40 y_index = ny // 2

ValueError: Expected size for 'my': 6291456000, but got actual size: 1500. Expected size for 't': 1500, but got actual size: 1500

please help me out

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

No branches or pull requests

1 participant