Ignore:
Timestamp:
Feb 6, 2012 12:19:28 PM (11 years ago)
Author:
srkline
Message:

moving the Polarization routines to a temporary "beta" menu location on the macros menu, numbering the panels.

Created a loader for the polarization routines that will load the SANS reduction if needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2006/SchulzSpheres_v40.ipf

    r570 r835  
    66// at low polydispersity (< 0.2), it is very similar to the Gaussian distribution 
    77// at larger polydispersities, it is more skewed and similar to log-normal 
     8// 
     9// 
     10// JAN 2012  
     11//-- added the functions to calculate the Beta factor for the decoupling approximation to 
     12// modify the S(q) calculation. A separate Sq_Beta.ipf file was created to hold all of the new P*S' combinations 
    813// 
    914 
     
    384389//End 
    385390// 
     391 
     392//AAO version, uses XOP if available 
     393// simply calls the original single point calculation with 
     394// a wave assignment (this will behave nicely if given point ranges) 
     395Function SchulzSpheresBeta(cw,yw,xw) : FitFunc 
     396        Wave cw,yw,xw 
     397         
     398#if exists("SchulzSpheresBetaX") 
     399        yw = SchulzSpheresBetaX(cw,xw) 
     400#else 
     401        yw = fSchulzSpheresBeta(cw,xw) 
     402#endif 
     403        return(0) 
     404End 
     405 
     406//use the analytic formula from Kotlarchyk & Chen, JCP 79 (1983) 2461 
     407//equations 26 + 23-30 
     408// 
     409// need to calculate in terms of logarithms to avoid numerical errors 
     410// this returns the Beta factor 
     411// 
     412Function fSchulzSpheresBeta(w,x) : FitFunc 
     413        Wave w 
     414        Variable x 
     415 
     416        Variable scale,ravg,pd,delrho,bkg,zz,rho,rhos,vpoly 
     417        scale = w[0] 
     418        ravg = w[1] 
     419        pd = w[2] 
     420        rho = w[3] 
     421        rhos = w[4] 
     422        bkg = w[5] 
     423         
     424        delrho=rho-rhos 
     425        zz = (1/pd)^2-1 
     426 
     427        Variable zp1,zp2,zp3,zp4,zp5,zp6,zp7 
     428        Variable aa,b1,b2,b3,at1,at2,rt1,rt2,rt3,t1,t2,t3 
     429        Variable v1,v2,v3,g1,g11,gd,pq,g2,g22,fBETA 
     430         
     431        ZP1 = zz + 1 
     432        ZP2 = zz + 2 
     433        ZP3 = zz + 3 
     434        ZP4 = zz + 4 
     435        ZP5 = zz + 5 
     436        ZP6 = zz + 6 
     437        ZP7 = zz + 7 
     438         
     439//      //small QR limit - use Guinier approx 
     440//      Variable i_zero,Rg2,zp8 
     441//      zp8 = zz+8 
     442//      if(x*ravg < 0.1) 
     443//              i_zero = scale*delrho*delrho*1e8*4*Pi/3*ravg^3 
     444//              i_zero *= zp6*zp5*zp4/zp1/zp1/zp1               //6th moment / 3rd moment 
     445//              Rg2 = 3*zp8*zp7/5/(zp1^2)*ravg*ravg 
     446//              pq = i_zero*exp(-x*x*Rg2/3) 
     447//              pq += bkg 
     448//              return(pq) 
     449//      endif 
     450// 
     451        aa = (zz+1)/x/Ravg 
     452 
     453        AT1 = atan(1/aa) 
     454        AT2 = atan(2/aa) 
     455// 
     456//  CALCULATIONS ARE PERFORMED TO AVOID  LARGE # ERRORS 
     457// - trick is to propogate the a^(z+7) term through the G1 
     458//  
     459        T1 = ZP7*log(aa) - zp1/2*log(aa*aa+4) 
     460        T2 = ZP7*log(aa) - zp3/2*log(aa*aa+4) 
     461        T3 = ZP7*log(aa) - zp2/2*log(aa*aa+4) 
     462//      Print T1,T2,T3 
     463        RT1 = alog(T1) 
     464        RT2 = alog(T2) 
     465        RT3 = alog(T3) 
     466        V1 = aa^6 - RT1*cos(zp1*at2) 
     467        V2 = ZP1*ZP2*( aa^4 + RT2*cos(zp3*at2) ) 
     468        V3 = -2*ZP1*RT3*SIN(zp2*at2) 
     469        G1 = (V1+V2+V3) 
     470         
     471        Pq = log(G1) - 6*log(ZP1) + 6*log(Ravg) 
     472        Pq = alog(Pq)*8*PI*PI*delrho*delrho 
     473         
     474// 
     475// beta factor is not used here, but could be for the  
     476// decoupling approximation 
     477//  
     478        G11 = G1 
     479        GD = -ZP7*log(aa) 
     480        G1 = log(G11) + GD 
     481                        
     482        T1 = ZP1*at1 
     483        T2 = ZP2*at1 
     484        G2 = SIN( T1 ) - ZP1/SQRT(aa*aa+1)*COS( T2 ) 
     485        G22 = G2*G2 
     486        fBETA = ZP1*log(aa) - ZP1*log(aa*aa+1) - G1 + log(G22)  
     487        fBETA = 2*alog(fBETA) 
     488         
     489        return(fBETA) 
     490         
     491//re-normalize by the average volume 
     492//      vpoly = 4*Pi/3*zp3*zp2/zp1/zp1*(ravg)^3 
     493//      Pq /= vpoly 
     494//scale, convert to cm^-1 
     495//      Pq *= scale * 1e8 
     496// add in the background 
     497//      Pq += bkg 
     498         
     499        //return (g1) 
     500//      Return (Pq) 
     501End 
Note: See TracChangeset for help on using the changeset viewer.