aUCBLogo Demos and Tests / nmr_carterspectra_f_borate
setCaseIgnored false
to nmr_carterspectra_f_borate
setUpdateGraph "false
hideTurtle
clearScreen
WindowMode
setpensize 0
; disableTextureFont
enablePolySmooth
ch=0
zzz
stop
forever
[
clearScreen
;pr repcount
catch "error [ignore runResult [zzz]]
err=Error
if :err != []
[ clearText
print :err.2
waitMS 200
]
updategraph
updateVars
dispatchMessages
waitMS 100
if ch==Char 27 [stop]
]
end
to zzz
ni=1000
x=rSeqFA -400 400 :ni
comment [
spectrum=readfile "../La2RuO5/56Mhz/0_700K_ausw.dat
specx=:spectrum.1
specy=:spectrum.2
specy=:specy/(max :specy)
specn=count specy
specy=:specy-rSeqFA 0.0 0.05 specn
specy=:specy*400-200
spectrum2=readfile "../La2RuO5/64Mhz/1K_2_ausw.dat
specx2=:spectrum2.1/64*56
specy2=:spectrum2.2
specy2=:specy2/(max :specy2)*400-200
]
intensity=FloatArray :ni
for [p 0 1 0.001]
[
I=3/2
MHz=1e6
Tesla=1
B=14.1*:Tesla
gamma=13.4*:MHz/:Tesla
markerx=56*:MHz
nu0=:B*:gamma
nuref=nu0
nuQ=2.56/2*:MHz
eta=0.688 ;0.21
expo=0.99
K1=0
K2=0
ntheta=200
nphi=400
I0=3
Inu0=:nu0
nnu=0.6*MHz ;3*:Tesla*:gamma
smoothwidth=0.005*:MHz
compwidth=1*:MHz
nmr
nu0=:B*:gamma
nuref=nu0
nuQ=0.52/2*:MHz
eta=0.51
K1=0
K2=0
ntheta=200
nphi=400
I0=1
Inu0=:nu0
nmr
I0=25
maxy=200
maxx=400
ticksx=12
tick=15
txtx=25
filename="nmr_carterspectrum_Li2B4O7.pdf
xmax=( :nnu/2);/:gamma
xmin=(-:nnu/2);/:gamma
w=:xmax-:xmin
wq=(:xmax-:xmin)*2^(int -0.5+(ln :w/(:xmax-:xmin))/ln 2)
markerx=:markerx ;/:gamma
draw
if ch==char 27 [break]
]
end
to nmr
intens=FloatArray :ni
intens=NMRCarterIntensity_MAS
:I :nu0 :nuQ :nuref
:eta :K1 :K2
:ntheta :nphi :Inu0 :nnu
:intens :expo
intensity=intensity+intens*I0
end
to draw
repeat 1
[
; computeIntensityRatios
;stop
; smoothedIntensity=:intensity
smoothedIntensity=GaussianSmooth
:nnu :smoothwidth :compwidth :intensity
mi=(max :smoothedIntensity)
if :mi != 0
[ intensityScaled=:smoothedIntensity/:mi*I0*400-maxy
]
hideTurtle
clearScreen
WindowMode
setpensize 0
penup
setXY -400 :intensityScaled.1
pendown
setXY :x :intensityScaled
comment [
specxsc=(:specx*:gamma+:xmax)/w*maxx*(-2)+maxx
setPC HSB 120 1 1
penup
setXY :specxsc.1 :specy.1
pendown
setXY :specxsc :specy
penup
setPC 0
specxsc2=(:specx2*:gamma+:xmax)/w*maxx*(-2)+maxx
setPC HSB 0 1 1
penup
setXY :specxsc2.1 :specy2.1
pendown
setXY :specxsc2 :specy2
penup
setPC 0
]
markerxsc=maxx-(:markerx+:xmax)/w*maxx*2
setPC HSB 240 1 1
penup
setXY :markerxsc -:maxy
pendown
setXY :markerxsc :maxy
penup
setPC 0
setY -:maxy
for [x -:ticksx 2*:ticksx]
[ hx=:wq*(:x/:ticksx-0.5)
hx=:hx+(remainder (:xmax+:xmin)/2 :wq/:ticksx)
rx=:hx-(:xmax+:xmin)/2
hx=:hx*:maxx*2/:w
if :hx > :maxx or2 :hx < -:maxx [continueLoop]
setX :hx
PenDown
setY -:maxy+:tick
setY -:maxy
PenUp
setY :maxy-:tick
PenDown
setY :maxy
PenUp
setY -:maxy-:txtx
seth 90
label :rx/1e6
setY -:maxy
]
setXY 0 -250
Label "f (MHz)
setXY 0 -280
; Label :p
updateGraph
if Key?
[ ch=readChar
if :ch==Char 27 [break]
if :ch=="s
[ penup
setpensize 0
; boundingbox
catch "error
[ saveScreenVector filename
]
err=error
if :err != []
[ print :err.2
]
]
]
(GC "true)
]
end
to computeIntensityRatios
r=(FloatArray 2*:I -:I+1/2)
j=1
ratios={{1}@0 {4 3}@0 {9 8 5}@0 {16 15 12 7}@0 {25 24 12 16 9}@0}
for [m -:I+1 :I]
[ j=Int :m-1/2
factor=:ratios.(Int :I+1/2).abs :j
intensity=FloatArray :ni
intensity=NMRCarterIntensity_m
:I :nu0 :nuQ :nuref
:eta :K1 :K2
:ntheta :nphi :Inu0 :nnu
:intensity :m
smoothedIntensity=GaussianSmooth :nnu :smoothwidth :intensity
mi=(max :smoothedIntensity)
if :mi != 0
[ intensityScaled=:smoothedIntensity/:mi*factor*40-200
]
penup
setpc HSB 180+180*:m/:I 1 1
setXY -400 :intensityScaled.1
pendown
setXY :x :intensityScaled
setitem :j :r 0+:intensity
]
; show :r
end
to readfile f
local [x y d]
x=[]
y=[]
openRead :f
setReader :f
while [not eof?]
[ d=readlist
x=fput :d.1 :x
y=fput :d.2 :y
]
setReader []
close :f
output list reverse FloatArray :x reverse FloatArray :y
end