#pragma rtGlobals=1 // Use modern global access method. #pragma ModuleName=StereoGraphicProjection #pragma version = 2.4 #include "LatticeSym", version>=3.1 Menu "Analysis" "Stereographic Projection", MakeStereo(NaN,NaN,NaN,NaN,NaN) End Function MakeStereo(Hz,Kz,Lz,hklmax,fntSize,[Qmax]) Variable Hz,Kz,Lz // hkl of the pole Variable hklmax Variable fntSize Variable Qmax // maximum Q (1/nm) Variable Qpassed = !ParamIsDefault(Qmax) // a Qmax was passed Qmax = Qpassed ? Qmax : Inf // if not passed, do not limit the Q (it is limited by hklmax) if (!(fntSize>0) || !(hklmax>0) || numtype(Hz+Kz+Lz)) Hz = numtype(Hz) ? 3 : Hz Kz = numtype(Kz) ? -1 : Kz Lz = numtype(Lz) ? 7 : Lz fntSize = fntSize>0 ? fntSize : 9 hklmax = hklmax>0 ? hklmax : 6 String hklStr sprintf hklStr,"%g %g %g",Hz,Kz,Lz Prompt hklStr,"(hkl) of the pole" Prompt fntSize,"size of font for hkl" Prompt hklmax,"maximum hkl to accept" Prompt Qmax,"maximum Q to show (a redundant limit) (1/nm)" DoPrompt "hkl max & font size",hklStr,hklmax,Qmax,fntSize if (V_flag) return 1 endif sscanf hklStr, "%g %g %g",Hz,Kz,Lz Qmax = numtype(Qmax) ? Inf : Qmax if (numtype(Qmax)!=1) printf "MakeStereo(%g,%g,%g, %g,%g, Qmax=%g)\r",Hz,Kz,Lz,hklmax,fntSize,Qmax else printf "MakeStereo(%g,%g,%g, %g,%g)\r",Hz,Kz,Lz,hklmax,fntSize endif endif if (!(fntSize>0) || !(hklmax>0) || numtype(Hz+Kz+Lz)) return 1 endif if (setLattice()) return 1 endif STRUCT crystalStructure xtal if (FillCrystalStructDefault(xtal)) //fill the lattice structure with current values DoAlert 0, "No Lattice, please set one" return 1 endif Variable maxWaveLen=9000 Make/N=(maxWaveLen)/O longs_MakeStereo,lats_MakeStereo Make/N=(maxWaveLen,3)/W/O hkls_MakeStereo Wave hkls=hkls_MakeStereo Wave longs=longs_MakeStereo, lats=lats_MakeStereo longs=NaN lats=NaN Make/N=3/O/D qhat_MakeStereo Wave qhat = qhat_MakeStereo Variable qmag // magnitude of qvector Variable hmax, kmax, lmax // get separate limits on h,k, & l based on hklmax and Qmax qmag = sqrt(xtal.as0^2 + xtal.as1^2 + xtal.as2^2) hmax = min(ceil(Qmax/qmag),hklmax) qmag = sqrt(xtal.bs0^2 + xtal.bs1^2 + xtal.bs2^2) kmax = min(ceil(Qmax/qmag),hklmax) qmag = sqrt(xtal.cs0^2 + xtal.cs1^2 + xtal.cs2^2) lmax = min(ceil(Qmax/qmag),hklmax) Variable H,K,L Variable N=0, lat, long String str // Variable timer = startMSTimer for (L=0;L<=lmax;L=signedAdvance(L)) for (K=0;K<=kmax;K=signedAdvance(K)) for (H=0;H<=hmax;H=signedAdvance(H)) if (H==0 && K==0 && L==0) // skip the (000) continue endif if (magsqr(Fstruct(xtal,h,k,l)) < 0.001) continue endif qhat[0] = H*xtal.as0+K*xtal.bs0+L*xtal.cs0 // qmag*qhat = recip x hkl qhat[1] = H*xtal.as1+K*xtal.bs1+L*xtal.cs1 qhat[2] = H*xtal.as2+K*xtal.bs2+L*xtal.cs2 qmag = normalize(qhat) if (qmag > Qmax) continue endif hkl2LongLat(Hz,Kz,Lz,qhat,long,lat,xtal) if (lat>=-0.01 && N=0;i-=1) for (j=0;j= 2) return 1 // (100) type elseif (zeros==1 && (h==k || h==l || k==l)) return 1 // (110) type elseif (h==k && h==l) return 1 // (111) type endif return 0 // not a low order reflection End //Function ALLOW_All(h,k,l) // allow all hkl, always returns 1 // Variable h,k,l // return 1 //End //// //Static Function ALLOW_FC(h,k,l) // for face-centered, hkl must be all even or all odd // Variable h,k,l // return !mod(h+k,2) && !mod(k+l,2) //End //// //Static Function ALLOW_BC(h,k,l) // for body-centered, !mod(round(h+k+l),2) // Variable h,k,l // return !mod(round(h+k+l),2) //End //// //Static Function ALLOW_CC(h,k,l) // for C-centered, !mod(round(h+k),2) // Variable h,k,l // return !mod(round(h+k),2) //End //// //Static Function ALLOW_AC(h,k,l) // for A-centered, !mod(round(k+l),2) // Variable h,k,l // return !mod(round(k+l),2) //End //// //Static Function ALLOW_RHOM_HEX(h,k,l) // for rhombohedral hexagonal, allowed are -H+K+L=3n or H-K+L=3n // Variable h,k,l // return !mod(-h+k+l,3) || !mod(h-k+l,3) //End //// //Static Function ALLOW_HEXAGONAL(h,k,l) // for hexagonal, // forbidden are: H+2K=3N with L odd // Variable h,k,l // return mod(h+2*k,3) || !mod(l,2) //End Function InitStereoGraphicPackage() InitLatticeSymPackage() // used to initialize this package End