Last active
October 31, 2024 17:23
-
-
Save mducle/bb6a4f5a999061389cf66231f3df5707 to your computer and use it in GitHub Desktop.
New spinw syntax proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ase import Atom | |
from spinw import Lattice, Interaction | |
import numpy as np | |
import matplotlib.pyplot as plt | |
""" | |
% Matlab code | |
linipo = spinw; | |
linipo.genlattice('lat_const', [10.02 5.86 4.68],'sym','P n m a'); | |
linipo.addatom('r',[1/4 1/4 0],'S',1,'label','MNi2','color','b') | |
linipo.genmagstr('mode','direct','S',[0 0 0 0; 0 0 0 0; 1 -1 -1 1]) | |
""" | |
#mn = Atom('Mn', position=[1/4, 1/4, 0], magmom=1) | |
#spins = Lattice(lat_const=[10.02, 5.86, 4.68], sym='P n m a', atoms=[mn]) | |
#spins.genmagstr(mode='direct', basis=[[0,0,1], [0,0,-1], [0,0,-1], [0,0,1]]) | |
#mn1 = Atom('Mn', position=[1/4, 1/4, 0], magmom=[0,0,1]) | |
#mn2 = Atom('Mn', position=[3/4, 1/4, 1/2], magmom=[0,0,-1]) | |
#mn3 = Atom('Mn', position=[1/4, 3/4, 1/2], magmom=[0,0,-1]) | |
#mn4 = Atom('Mn', position=[1/4, 3/4, 0], magmom=[0,0,1]) | |
#spins = Lattice(lat_const=[10.02, 5.86, 4.68], atoms=[mn1, mn2, mn3, mn4]) | |
#magnetic_structure = MagStruct(basis=[mn1, mn2, mn3, mn4], propagation_vector=[0,0,0]) | |
mn = Atom('Mn', position=[1/4, 1/4, 0], magmom=1, anisotropy=np.diag([0.1969, 0.9097, 0])) | |
atoms = GenerateFromSymmetry(lat_const=[10.02, 5.84, 4.68], sym='P n m a', unique_atoms=[mn]) | |
# atoms = [Atom('Mn', position=[0.25, 0.25, 0]), Atom('Mn', position=[0.75, 0.25, 0]) ...] | |
atoms[0].magmom = [0,0,-1] | |
k1 = Component(atoms, propagation_vector=[0,0,0]) | |
k2 = Component(atoms, propagation_vector=[0,0,0.5], magmom=[[...]]) | |
magstruct = MagneticStructure([k1, k2]) | |
#magnetic_structure = MagStruct(atoms, propagation_vector=[[0,0,0],[0,0,0.5]]) | |
#atoms = GenerateFromSymmetry(lat_const=[10.02, 5.84, 4.68], sym='P n m a', unique_atoms=[mn], | |
# irrep='GM') # Look up in Bilbao Crystallographic Server - maybe? | |
""" | |
linipo.gencoupling() | |
linipo.addmatrix('label','Jbc','value', 1.036); linipo.addcoupling('mat','Jbc','bond',1) | |
linipo.addmatrix('label','Jb', 'value', 0.6701); linipo.addcoupling('mat','Jc' ,'bond',2) | |
linipo.addmatrix('label','Jc', 'value', -0.0469); linipo.addcoupling('mat','Jb' ,'bond',7) | |
linipo.addmatrix('label','Jab','value', 0.2977); linipo.addcoupling('mat','Jab','bond',[5 6]) | |
linipo.addmatrix('label','Jac','value', -0.1121); linipo.addcoupling('mat','Jac','bond',[3 4]) | |
linipo.addmatrix('label','D', 'value', np.diag([0.1969, 0.9097, 0])) | |
linipo.addaniso('D') | |
""" | |
Jbc = Interaction(label='Jbc', value=1.036, bond_index=0) | |
Jb = Interaction(label='Jb', value=0.6701, bond_index=1) | |
Jc = Interaction(label='Jc', value=-0.0469, bond_index=6) | |
Jab = Interaction(label='Jab', value=0.2977, bond_index=[4, 5]) | |
Jac = Interaction(label='Jac', value=-0.1121, bond_index=[2, 3]) | |
Aa = AtomTerm(anisotopty = aaa, g=2.1??) | |
Ab = AtomTerm(anisotopty = aaa, g=default None) | |
Ab ... | |
mymodel = SpinModel(structure=magstruct, interactions=[Jbc, Jb, Jc, Jab, Jac], g=None) | |
""" | |
linipoSpec = linipo.spinwave({[0 1 0] [2 1 0]}); | |
linipoSpec = sw_egrid(linipoSpec); | |
linipoSpec = sw_omegasum(linipoSpec,'zeroint',1e-3); | |
figure | |
subplot(3,1,1) | |
sw_plotspec(linipoSpec,'mode','disp','axLim',[0 8],'colormap',[0 0 0],'colorbar',false) | |
subplot(3,1,2) | |
sw_plotspec(linipoSpec,'mode','int','axLim',[0 15],'colormap',[0 0 0],'colorbar',false) | |
subplot(3,1,3) | |
sw_plotspec(linipoSpec,'mode','color') | |
""" | |
spec = spins.spinwave(([0,1,0], [2,1,0])) | |
spec.egrid().omegasum(zeroint=1e-3) | |
fig, ax = plt.subplots(3, 1, subplot_kw={'projection':'spinw'}) | |
ax[0].plot(spec) | |
ax[0].set_ylim([0, 8]) | |
ax[1].plot(spec.intensity()) | |
ax[1].set_ylim([0, 15]) | |
ax[2].pcolormesh(spec) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment