Changeset 148 for sans/SASCalc


Ignore:
Timestamp:
Aug 15, 2007 2:33:02 PM (16 years ago)
Author:
srkline
Message:

Tried, in at least an approximate way to account for lenses using SASCALC

  • added the correct resolution calculation as in the reduction macros

--

  • flux is not really correct as the lens transmission has not been included
  • the lenses can be 'used' in unphysical cases, may need to be more stringent
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/SASCalc/trunk/SASCALC.ipf

    r139 r148  
    1010// 19 MAR 2007 SRK - corrections added for projected BS diameter at anode plane 
    1111// 11 APR 2007 SRK - default aperture offset of 5 cm added to match VAX implementation 
     12// nn AUG 2007 SRK - added defulat sample aperture size 
     13//                                               added option of lenses, approximated beamDiam=sourceDiam, BSdiam=1" 
     14//                                               Lens flux, trans is not corrected for lens/prism transmission 
     15//                                               Lenses can still be inserted in incorrect cases, and are not automatically taken out 
    1216// 
    1317// calculate what q-values you get based on the instruments settings 
     
    8993        String/G root:SAS:gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;" 
    9094        Variable/G root:SAS:gSamApOther = 10            //non-standard aperture diameter, in mm 
     95        Variable/G root:SAS:gUsingLenses = 0            //0=no lenses, 1=lenses(or prisms) 
    9196         
    9297        //tick labels for SDD slider 
     
    278283        Slider SC_Slider_2,pos={394,21},size={47,65},proc=OffsetSliderProc,live=0,ticks=4 
    279284        Slider SC_Slider_2,limits={0,25,1},variable= root:SAS:gOffset,thumbColor= (1,16019,65535) 
    280         CheckBox checkNG3,pos={20,16},size={36,14},proc=SelectInstrumentCheckProc,title="NG3" 
     285        CheckBox checkNG3,pos={20,18},size={36,14},proc=SelectInstrumentCheckProc,title="NG3" 
    281286        CheckBox checkNG3,value=1,mode=1 
    282         CheckBox checkNG7,pos={66,16},size={36,14},proc=SelectInstrumentCheckProc,title="NG7" 
     287        CheckBox checkNG7,pos={66,18},size={36,14},proc=SelectInstrumentCheckProc,title="NG7" 
    283288        CheckBox checkNG7,value=0,mode=1 
    284289        CheckBox checkChamber,pos={172,48},size={57,14},proc=TableCheckProc,title="Chamber" 
     
    307312        SetVariable setvar0_3,pos={140,94},size={110,15},title="Diam (mm)",disable=1 
    308313        SetVariable setvar0_3,limits={0,100,0.1},value= root:SAS:gSamApOther,proc=SourceApOtherSetVarProc 
     314         
     315        CheckBox checkLens,pos={6,155},size={44,14},proc=LensCheckProc,title="Lenses?" 
     316        CheckBox checkLens,value=root:SAS:gUsingLenses 
     317         
    309318        // set up a fake dependency to trigger recalculation 
    310319        //root:SAS:gCalculate := ReCalculateInten(root:SAS:gTouched) 
     
    392401         
    393402        if(event %& 0x1)        // bit 0, value set 
     403                if(sliderValue != 0) 
     404                        LensCheckProc("",0)             //make sure lenses are deselected 
     405                endif 
    394406                sourceToSampleDist()            //updates the SSD global and wave 
    395407                //change the sourceAp popup, SDD range, etc 
     
    408420 
    409421        if(event %& 0x1)        // bit 0, value set 
     422                if(sliderValue < 1300) 
     423                        LensCheckProc("",0)             //make sure lenses are deselected 
     424                endif 
    410425                sampleToDetectorDist()          //changes the SDD and wave (DetDist is the global) 
    411426                ReCalculateInten(1) 
     
    471486        ReCalculateInten(1) 
    472487End 
     488 
     489 
     490//lenses (or prisms) in/out changes resolution 
     491Function LensCheckProc(ctrlName,checked) : CheckBoxControl 
     492        String ctrlName 
     493        Variable checked 
     494 
     495        // don't let the box get checked if the conditions are wrong 
     496        // lambda != 8.09,8.4,17.2 
     497        // Ng != 0 
     498        NVAR lens = root:SAS:gUsingLenses 
     499        NVAR ng = root:SAS:gNg 
     500        NVAR lam = root:SAS:gLambda 
     501        NVAR dist = root:SAS:gDetDist 
     502         
     503        if( (Ng != 0) || (lam < 8) || (dist < 1300) ) 
     504                lens = 0 
     505                CheckBox checkLens,value=0 
     506                return(0) 
     507        endif 
     508        lens = checked 
     509         
     510        ReCalculateInten(1) 
     511End 
     512 
    473513 
    474514// change the source aperture 
     
    10751115        String results 
    10761116        results ="Failure" 
     1117         
     1118        NVAR usingLenses = root:SAS:gUsingLenses 
    10771119 
    10781120        //rename for working variables,  these must be gotten from global 
     
    11031145 
    11041146        v_lambda = lambdaWidth^2/6.0 
    1105         v_b = 0.25*(S1*L2/L1)^2 +0.25*(S2*L2/lp)^2 
     1147         
     1148        if(usingLenses==1)                      //SRK 2007 
     1149                v_b = 0.25*(S1*L2/L1)^2 +0.25*(2/3)*(lambdaWidth/lambda)^2*(S2*L2/lp)^2         //correction to 2nd term 
     1150        else 
     1151                v_b = 0.25*(S1*L2/L1)^2 +0.25*(S2*L2/lp)^2              //original form 
     1152        endif 
     1153         
    11061154        v_d = (DDet/2.3548)^2 + del_r^2/12.0 
    11071155        vz = vz_1 / lambda 
    11081156        yg = 0.5*g*L2*(L1+L2)/vz^2 
    1109         v_g = 2.0*yg^2*v_lambda 
     1157        v_g = 2.0*(2.0*yg^2*v_lambda)                                   //factor of 2 correction, B. Hammouda, 2007 
    11101158 
    11111159        r0 = L2*tan(2.0*asin(lambda*inQ/(4.0*Pi) )) 
     
    12121260        NVAR instrument = instrument 
    12131261        NVAR L2diff = L2diff 
     1262        NVAR lens = root:SAS:gUsingLenses 
    12141263         
    12151264         
     
    12631312        sprintf temp,"Sample Aperture to Sample Position =\t%.2f cm\r", L2Diff 
    12641313        str += temp 
     1314        if(lens==1) 
     1315                sprintf temp,"Lenses are IN\r" 
     1316        else 
     1317                sprintf temp,"Lenses are OUT\r" 
     1318        endif 
     1319        str += temp  
    12651320         
    12661321   setDataFolder root: 
     
    13951450 
    13961451//direction = one of "vertical;horizontal;maximum;" 
     1452// all of this is bypassed if the lenses are in 
     1453// 
    13971454Function beamDiameter(direction) 
    13981455        String direction 
    13991456 
     1457        NVAR lens = root:SAS:gUsingLenses 
     1458        if(lens) 
     1459                return sourceApertureDiam() 
     1460        endif 
     1461         
    14001462    Variable l1 = sourceToSampleDist() 
    14011463    Variable l2 //= sampleAperToDetDist() 
     
    14361498//on NG3 and NG7, allowable sizes are 1,2,3,4" diameter 
    14371499//will return values larger than 4.0*2.54 if a larger beam is needed 
     1500// 
     1501// - in an approximate way, account for lenses 
    14381502Function beamstopDiam() 
    14391503 
    1440     Variable bm = beamDiameter("maximum") 
    1441     Variable bs=0.0 
    1442      
    1443     do 
    1444         bs += 1 
    1445     while ( (bs*2.54 < bm) || (bs > 30.0))                      //30 = ridiculous limit to avoid inf loop 
    1446   
     1504        NVAR yesLens = root:SAS:gUsingLenses 
     1505        Variable bm=0 
     1506        Variable bs=0.0 
     1507    
     1508        if(yesLens) 
     1509                //bm = sourceApertureDiam()             //ideal result, not needed 
     1510                bs = 1                                                          //force the diameter to 1" 
     1511        else 
     1512                bm = beamDiameter("maximum") 
     1513                do 
     1514                bs += 1 
     1515           while ( (bs*2.54 < bm) || (bs > 30.0))                       //30 = ridiculous limit to avoid inf loop 
     1516        endif 
     1517 
    14471518        //update the wave 
    14481519        WAVE rw=root:SAS:realsRead 
Note: See TracChangeset for help on using the changeset viewer.