Changeset 148 for sans/SASCalc
- Timestamp:
- Aug 15, 2007 2:33:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/SASCalc/trunk/SASCALC.ipf
r139 r148 10 10 // 19 MAR 2007 SRK - corrections added for projected BS diameter at anode plane 11 11 // 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 12 16 // 13 17 // calculate what q-values you get based on the instruments settings … … 89 93 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;" 90 94 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) 91 96 92 97 //tick labels for SDD slider … … 278 283 Slider SC_Slider_2,pos={394,21},size={47,65},proc=OffsetSliderProc,live=0,ticks=4 279 284 Slider SC_Slider_2,limits={0,25,1},variable= root:SAS:gOffset,thumbColor= (1,16019,65535) 280 CheckBox checkNG3,pos={20,1 6},size={36,14},proc=SelectInstrumentCheckProc,title="NG3"285 CheckBox checkNG3,pos={20,18},size={36,14},proc=SelectInstrumentCheckProc,title="NG3" 281 286 CheckBox checkNG3,value=1,mode=1 282 CheckBox checkNG7,pos={66,1 6},size={36,14},proc=SelectInstrumentCheckProc,title="NG7"287 CheckBox checkNG7,pos={66,18},size={36,14},proc=SelectInstrumentCheckProc,title="NG7" 283 288 CheckBox checkNG7,value=0,mode=1 284 289 CheckBox checkChamber,pos={172,48},size={57,14},proc=TableCheckProc,title="Chamber" … … 307 312 SetVariable setvar0_3,pos={140,94},size={110,15},title="Diam (mm)",disable=1 308 313 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 309 318 // set up a fake dependency to trigger recalculation 310 319 //root:SAS:gCalculate := ReCalculateInten(root:SAS:gTouched) … … 392 401 393 402 if(event %& 0x1) // bit 0, value set 403 if(sliderValue != 0) 404 LensCheckProc("",0) //make sure lenses are deselected 405 endif 394 406 sourceToSampleDist() //updates the SSD global and wave 395 407 //change the sourceAp popup, SDD range, etc … … 408 420 409 421 if(event %& 0x1) // bit 0, value set 422 if(sliderValue < 1300) 423 LensCheckProc("",0) //make sure lenses are deselected 424 endif 410 425 sampleToDetectorDist() //changes the SDD and wave (DetDist is the global) 411 426 ReCalculateInten(1) … … 471 486 ReCalculateInten(1) 472 487 End 488 489 490 //lenses (or prisms) in/out changes resolution 491 Function 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) 511 End 512 473 513 474 514 // change the source aperture … … 1075 1115 String results 1076 1116 results ="Failure" 1117 1118 NVAR usingLenses = root:SAS:gUsingLenses 1077 1119 1078 1120 //rename for working variables, these must be gotten from global … … 1103 1145 1104 1146 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 1106 1154 v_d = (DDet/2.3548)^2 + del_r^2/12.0 1107 1155 vz = vz_1 / lambda 1108 1156 yg = 0.5*g*L2*(L1+L2)/vz^2 1109 v_g = 2.0* yg^2*v_lambda1157 v_g = 2.0*(2.0*yg^2*v_lambda) //factor of 2 correction, B. Hammouda, 2007 1110 1158 1111 1159 r0 = L2*tan(2.0*asin(lambda*inQ/(4.0*Pi) )) … … 1212 1260 NVAR instrument = instrument 1213 1261 NVAR L2diff = L2diff 1262 NVAR lens = root:SAS:gUsingLenses 1214 1263 1215 1264 … … 1263 1312 sprintf temp,"Sample Aperture to Sample Position =\t%.2f cm\r", L2Diff 1264 1313 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 1265 1320 1266 1321 setDataFolder root: … … 1395 1450 1396 1451 //direction = one of "vertical;horizontal;maximum;" 1452 // all of this is bypassed if the lenses are in 1453 // 1397 1454 Function beamDiameter(direction) 1398 1455 String direction 1399 1456 1457 NVAR lens = root:SAS:gUsingLenses 1458 if(lens) 1459 return sourceApertureDiam() 1460 endif 1461 1400 1462 Variable l1 = sourceToSampleDist() 1401 1463 Variable l2 //= sampleAperToDetDist() … … 1436 1498 //on NG3 and NG7, allowable sizes are 1,2,3,4" diameter 1437 1499 //will return values larger than 4.0*2.54 if a larger beam is needed 1500 // 1501 // - in an approximate way, account for lenses 1438 1502 Function beamstopDiam() 1439 1503 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 1447 1518 //update the wave 1448 1519 WAVE rw=root:SAS:realsRead
Note: See TracChangeset
for help on using the changeset viewer.