#pragma rtGlobals=1 // Use modern global access method. #pragma IgorVersion = 4.0 #pragma version = 1.0 #include "CromerLieberman", version>=1.0 //#include "Elements", version>=1.0 //Menu "Analysis" // Submenu "X-ray" // "X-ray atomic structure factor",GetfoXray("",NaN) // End //End Function GetfoXray(symb,K) // compute fo(Q) String symb // name of atom desired Variable K // 2*pi/d (1/Angstroms) if (exists("root:Packages:Xray:focoefs")!=1) XrayDataInitPackage() endif symb = LowerStr(symb) symb[0,0] = UpperStr(symb[0]) if (strlen(symb)<1 || numtype(K) || K<0) K = numtype(K) ? 0 : abs(K) SVAR symbs=root:Packages:Xray:symbs Prompt K, "Length of Q, 2pi/d (1/Angstrom)" Prompt symb, "symbol of atom", popup, symbs DoPrompt "pick atom and K", symb,K if (V_flag) return 1 endif endif Variable fo = foXray(symb,K) if (numtype(fo)) printf " fo(%s, K=%g) = Unknown symbol\r",symb,K else printf " fo(%s, K=%g) = %g (electrons)\r",symb,K, fo endif return fo End Function foXray(symb,K) // compute fo(Q) String symb // name of atom desired Variable K // 2*pi/d (1/Angstroms) SVAR symbs=root:Packages:Xray:symbs Wave focoefs=root:Packages:Xray:focoefs if (!WaveExists(focoefs) || !SVAR_Exists(symbs)) print "you forgot to init this package, do a 'XrayDataInitPackage()'" Abort "you forgot to init this package, do a 'XrayDataInitPackage()'" endif symb = LowerStr(symb) symb[0,0] = UpperStr(symb[0]) Variable m = WhichListItem(symb,symbs) // index into symbs if (m<0) return NaN // bad symbol endif Wave foLast=root:Packages:Xray:foLast Wave KLast=root:Packages:Xray:KLast Wave/T symbLast=root:Packages:Xray:symbLast NVAR nlast=root:Packages:Xray:nlast Variable Nbuf=numpnts(root:Packages:Xray:foLast), i,j for (i=0;i