Skip to content

Instantly share code, notes, and snippets.

@mducle
Created March 2, 2026 19:55
Show Gist options
  • Select an option

  • Save mducle/72ba28fd46010def8e8eb3b9f4012dab to your computer and use it in GitHub Desktop.

Select an option

Save mducle/72ba28fd46010def8e8eb3b9f4012dab to your computer and use it in GitHub Desktop.
close all
%%
AFMchain = spinw;
AFMchain.genlattice('lat_const',[8 3 8],'angled',[90 90 90],'spgr',0);
AFMchain.addatom('r',[0 0 0],'S',1,'label','MCu1','color','blue');
AFMchain.gencoupling('maxDistance',7)
AFMchain.addmatrix('label','Ja','value',1,'color','red');
AFMchain.addcoupling('mat','Ja','bond',1);
%AFMchain.genmagstr('mode','direct','k',[1/2 0 0],'n',[1 0 0],'S',[0; 1 ;0],'nExt');
AFMchain.genmagstr('mode','direct','nExt',[2 1 1],'S',[0 0; 1 -1; 0 0]);
afcSpec = AFMchain.spinwave({[0 0 0] [1 0 0] 523}, 'hermit',true);
figure; subplot(2,1,1)
sw_plotspec(afcSpec,'mode',4,'dE',0.2,'axLim',[0 3])
afcSpec = sw_egrid(sw_neutron(afcSpec),'Evect',linspace(0,6.5,500),'component','Sperp');
afcSpec = sw_omegasum(afcSpec,'zeroint',1e-6);
subplot(2,1,2)
sw_plotspec(afcSpec,'mode',2,'log',true,'axLim',[-4 10])
%print -dpdf mat01.pdf
%%
afc = spinw;
afc.genlattice('lat_const',[4 6 6])
afc.addatom('r',[ 0 0 0],'S',1)
afc.addatom('r',[1/2 0 0],'S',1)
afc.addmatrix('label','J','value',1)
afc.gencoupling
afc.addcoupling('mat','J','bond',1)
afc.addmatrix('label','A','value',diag([0 0 -0.1]))
afc.addaniso('A')
afc.genmagstr('mode','direct','S',[0 0; 0 0; 1 -1]);
afc.field([0 0 7])
afcSpec = afc.spinwave({[0 0 0] [2 0 0] 101}, 'hermit',true);
figure; subplot(2,1,1)
sw_plotspec(afcSpec,'mode',4,'dE',0.2,'axLim',[0 3])
afcSpec = sw_egrid(sw_neutron(afcSpec),'Evect',linspace(0,6.5,500),'component','Sperp');
afcSpec = sw_omegasum(afcSpec,'zeroint',1e-6);
subplot(2,1,2)
sw_plotspec(afcSpec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat02.pdf
%%
FMchain = spinw;
FMchain.genlattice('lat_const',[3 8 8],'angled',[90 90 90])
FMchain.addatom('r', [0 0 0],'S', 1,'label','MCu1','color','blue')
FMchain.gencoupling('maxDistance',7)
FMchain.addmatrix('value',-eye(3),'label','Ja','color','green')
FMchain.addcoupling('mat','Ja','bond',1);
FMchain.genmagstr('mode','direct', 'k',[0 0 0],'n',[1 0 0],'S',[0; 1; 0]);
FMspec = FMchain.spinwave({[0 0 0] [1 0 0]},'hermit',false);
figure; subplot(2,1,1)
sw_plotspec(FMspec,'mode',4,'dE',0.2,'axLim',[0 3])
FMspec = sw_egrid(sw_neutron(FMspec),'Evect',linspace(0,6.5,500),'component','Sperp');
FMspec = sw_omegasum(FMspec,'zeroint',1e-6);
subplot(2,1,2)
sw_plotspec(FMspec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat03.pdf
%%
AFkagome = spinw;
AFkagome.genlattice('lat_const',[6 6 10],'angled',[90 90 120],'spgr','P -3')
AFkagome.addatom('r',[1/2 0 0],'S', 1,'label','MCu1','color','r')
AFkagome.gencoupling('maxDistance',7)
AFkagome.addmatrix('label','J1','value',1.00,'color','r')
AFkagome.addmatrix('label','J2','value',0.11,'color','g')
AFkagome.addcoupling('mat','J1','bond',1)
AFkagome.addcoupling('mat','J2','bond',2)
S0 = [1 -2 1; 2 -1 -1; 0 0 0];
AFkagome.genmagstr('mode','direct','k',[0 0 0],'n',[0 0 1],'unit','lu','S',S0);
afkSpec = AFkagome.spinwave({[-1/2 0 0] [0 0 0] [1/2 1/2 0] 100},'hermit',true);
figure; subplot(211)
sw_plotspec(afkSpec,'mode',1,'colorbar',false,'colormap',[0 0 0],'dashed',true,'axLim',[0 3])
afkSpec = sw_egrid(sw_neutron(afkSpec),'Evect',linspace(0,6.5,500),'component','Sperp');
afkSpec = sw_omegasum(afkSpec,'zeroint',1e-6);
subplot(212); sw_plotspec(afkSpec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat04.pdf
%%
FMkagome = spinw;
FMkagome.genlattice('lat_const',[6 6 5],'angled',[90 90 120],'spgr','P -3')
FMkagome.addatom('r', [1/2 0 0], 'S', 1, 'label','MCu1','color','r')
FMkagome.gencoupling('maxDistance',4)
FMkagome.addmatrix('label','J1','value',-1,'color','orange');
FMkagome.addcoupling('mat','J1','bond',1);
FMkagome.genmagstr('mode','helical','k',[0 0 0],'n',[0 1 0],'S',[0 1 0]')
fmkSpec = FMkagome.spinwave({[-1/2 0 0] [0 0 0] [1/2 1/2 0] 100},'hermit',false);
%fmkSpec = sw_egrid(sw_neutron(fmkSpec), 'Evect',linspace(0,6.5,100),'component','Sperp');
%figure; sw_plotspec(fmkSpec,'mode',1,'colorbar',false,'axLim',[0 8])
%fmkPow = FMkagome.powspec(linspace(0,2.5,100),'Evect',linspace(0,7,250),'nRand',1000,'hermit',false);
%figure; sw_plotspec(fmkPow,'colorbar',true,'axLim',[0 0.05])
figure; subplot(211)
sw_plotspec(fmkSpec,'mode',1,'colorbar',false,'colormap',[0 0 0],'dashed',true,'axLim',[0 8])
fmkSpec = sw_egrid(sw_neutron(fmkSpec),'Evect',linspace(0,6.5,500),'component','Sperp');
fmkSpec = sw_omegasum(fmkSpec,'zeroint',1e-6);
subplot(212); sw_plotspec(fmkSpec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat05.pdf
%%
AF33kagome = spinw;
AF33kagome.genlattice('lat_const',[6 6 40],'angled',[90 90 120],'spgr','P -3')
AF33kagome.addatom('r',[1/2 0 0],'S', 1,'label','MCu1','color','r')
AF33kagome.gencoupling('maxDistance',7)
AF33kagome.addmatrix('label','J1','value',1.00,'color','g')
AF33kagome.addcoupling('mat','J1','bond',1)
S0 = [0 0 -1;
1 1 -1;
0 0 0];
AF33kagome.genmagstr('mode','helical','k',[-1/3 -1/3 0],...
'n',[0 0 1],'unit','lu','S',S0,'nExt',0.1);
kag33Spec = AF33kagome.spinwave({[-1/2 0 0] [0 0 0] [1/2 1/2 0] 250},'hermit',false);
figure; subplot(211)
sw_plotspec(kag33Spec,'mode',1,'colorbar',false,'colormap',[0 0 0],'dashed',true,'axLim',[0 3])
kag33Spec = sw_egrid(sw_neutron(kag33Spec),'Evect',linspace(0,6.5,500),'component','Sperp');
kag33Spec = sw_omegasum(kag33Spec,'zeroint',1e-6);
subplot(212); sw_plotspec(kag33Spec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat06.pdf
%%
tri = spinw;
tri.genlattice('lat_const',[3 3 4],'angled',[90 90 120])
tri.addatom('r',[0 0 0],'S',3/2,'label','MCr3','color','orange')
tri.gencoupling()
tri.addmatrix('value',1,'label','J','color','SteelBlue')
tri.addcoupling('mat','J','bond',1)
tri.addmatrix('value',diag([0 0 0.2]),'label','D','color','r')
tri.addaniso('D')
tri.genmagstr('mode','helical','S',[0; 1; 0],'k',[1/3 1/3 0],'n', [0 0 1],'nExt',0.1);
triSpec = sw_neutron(tri.spinwave({[0 0 0] [1 1 0] 500}));
figure; subplot(211)
sw_plotspec(triSpec,'mode','disp','axLim',[0 7],'colormap',[0 0 0],'colorbar',false)
triSpec = sw_egrid(triSpec,'Evect',linspace(0,6.5,500),'component','Sperp');
triSpec = sw_omegasum(triSpec,'zeroint',1e-6);
subplot(212); sw_plotspec(triSpec,'mode',2,'log',false,'axLim',[0 3])
%print -dpdf mat07.pdf
%%
[J, Jp, Jpp, Jc] = deal(138.3, 2, 2, 38);
lacuo = sw_model('squareAF',[J-Jc/2 Jp-Jc/4 Jpp]/2,0);
lacuo.unit_cell.S = 1/2;
lacuoSpec = lacuo.spinwave({[3/4 1/4 0] [1/2 1/2 0] [1/2 0 0] [3/4 1/4 0] [1 0 0] [1/2 0 0] 100},'hermit',false);
lacuoSpec = sw_neutron(lacuoSpec);
lacuoSpec = sw_egrid(lacuoSpec,'component','Sperp');
figure
subplot(2,1,1)
sw_plotspec(lacuoSpec,'mode','disp','axLim',[0 350],'dE',35,'dashed',true)
subplot(2,1,2)
lacuoSpec = sw_omegasum(lacuoSpec,'zeroint',1e-5,'tol',1e-3);
sw_plotspec(lacuoSpec,'mode',2,'axLim',[0 20],'dashed',true,'colormap',[0 0 0])
lacuo.table('bond', 1:4)
%print -dpdf mat08.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment