#pragma rtGlobals=1 // Use modern global access method. #pragma IgorVersion=6.0 // // // BCC paracrystal, powder average // // VERY slow, since the function is so ill-behaved and needs LOTS of quadrature // points. Adaptive methods were even slower and troublesom to converge, // although in theory they should be a better choice than blindly increasing the number of points. // // 150 points seems to give reasonable reproduction of the peak heights in the paper. // peak locations are correct // 76 points of quadrature for the smearing is only a guess, it's not been tested yet. // // Original implementation - Danilo Pozzo // modified and modernized for more efficient integration SRK Nov 2008 // //REFERENCE //Hideki Matsuoka etal. Physical Review B, Vol 36 Num 3, p1754 1987 ORIGINAL PAPER //Hideki Matsuoka etal. Physical Review B, Vol 41 Num 6, p3854 1990 CORRECTIONS TO PAPER // //////////////////////////////////////////////////// Proc PlotBCC_ParaCrystal(num,qmin,qmax) Variable num=100, qmin=0.001, qmax=0.7 Prompt num "Enter number of data points for model: " Prompt qmin "Enter minimum q-value (^-1) for model: " Prompt qmax "Enter maximum q-value (^-1) for model: " // Make/O/D/n=(num) xwave_BCC_ParaCrystal, ywave_BCC_ParaCrystal xwave_BCC_ParaCrystal = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) Make/O/D coef_BCC_ParaCrystal = {1,220,0.06,40,3e-6,6.3e-6,0.0} make/o/t parameters_BCC_ParaCrystal = {"scale","Nearest Neighbor (A)","distortion, g","Sphere Radius (A)","SLD Sphere (A-2)","SLD Solvent (A-2)", "Background (cm-1)"} Edit parameters_BCC_ParaCrystal, coef_BCC_ParaCrystal Variable/G root:gNordBCC=150 Variable/G root:g_BCC_ParaCrystal g_BCC_ParaCrystal := BCC_ParaCrystal(coef_BCC_ParaCrystal, ywave_BCC_ParaCrystal, xwave_BCC_ParaCrystal) Display ywave_BCC_ParaCrystal vs xwave_BCC_ParaCrystal ModifyGraph marker=29, msize=2, mode=4 ModifyGraph grid=1,mirror=2 ModifyGraph log=0 Label bottom "q (\\S-1\\M) " Label left "I(q) (cm\\S-1\\M)" AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) AddModelToStrings("BCC_ParaCrystal","coef_BCC_ParaCrystal","parameters_BCC_ParaCrystal","BCC_ParaCrystal") // End // //this macro sets up all the necessary parameters and waves that are //needed to calculate the smeared model function. // //no input parameters are necessary, it MUST use the experimental q-values // from the experimental data read in from an AVE/QSIG data file //////////////////////////////////////////////////// // - sets up a dependency to a wrapper, not the actual SmearedModelFunction Proc PlotSmearedBCC_ParaCrystal(str) String str Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) // if any of the resolution waves are missing => abort if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) Abort endif SetDataFolder $("root:"+str) // Setup parameter table for model function Make/O/D smear_coef_BCC_ParaCrystal = {1,220,0.06,40,3e-6,6.3e-6,0.0} make/o/t smear_param_BCC_ParaCrystal = {"scale","Nearest Neighbor (A)","distortion, g","Sphere Radius (A)","SLD Sphere (A-2)","SLD Solvent (A-2)", "Background (cm-1)"} Edit smear_param_BCC_ParaCrystal,smear_coef_BCC_ParaCrystal //display parameters in a table // output smeared intensity wave, dimensions are identical to experimental QSIG values // make extra copy of experimental q-values for easy plotting Duplicate/O $(str+"_q") smeared_BCC_ParaCrystal,smeared_qvals SetScale d,0,0,"1/cm",smeared_BCC_ParaCrystal Variable/G gNordBCC = 150 Variable/G gs_BCC_ParaCrystal=0 gs_BCC_ParaCrystal := fSmearedBCC_ParaCrystal(smear_coef_BCC_ParaCrystal,smeared_BCC_ParaCrystal,smeared_qvals) //this wrapper fills the STRUCT Display smeared_BCC_ParaCrystal vs smeared_qvals ModifyGraph marker=29,msize=2,mode=4 ModifyGraph log=0 Label bottom "q (\\S-1\\M)" Label left "I(q) (cm\\S-1\\M)" AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) SetDataFolder root: AddModelToStrings("SmearedBCC_ParaCrystal","smear_coef_BCC_ParaCrystal","smear_param_BCC_ParaCrystal","BCC_ParaCrystal") End // Threaded version // Threaded XOP = 2.4 s // non-threaded, non-XOP = 46.8 s // = x 19.5 speedup ! // Function BCC_ParaCrystal(cw,yw,xw) : FitFunc Wave cw,yw,xw /////// NO threading ///////// //#if exists("BCC_ParaCrystalX") // yw = BCC_ParaCrystalX(cw,xw) //#else // yw = fBCC_ParaCrystal(cw,xw) //#endif /// THREADING /////// // Variable t1=StopMSTimer(-2) #if exists("BCC_ParaCrystalX") Variable npt=numpnts(yw) Variable i,nthreads= ThreadProcessorCount variable mt= ThreadGroupCreate(nthreads) for(i=0;i