Ignore:
Timestamp:
Feb 17, 2012 12:04:13 PM (11 years ago)
Author:
srkline
Message:

changes to FFT routines to clean things up for a beta release at the next startup. No functionality changes, just cleaning up the operation, interface, and menu items.

Some important changes to the polarization routines. New equations for calculating the coefficient matrix. Now appears to be correct. Also, proper proportions are used when adding multiple files together to the matrix.

Change to the Model Docs is an updated reference.

WorkFileUtils? was broken when I changed to use linear_data exclusively. This has now been fixed and it operates as expected.

PackageLoader? now has menu items (under Macros) for the Polarization routines. These may later be moved to the SANS menu.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_ConcentratedSpheres.ipf

    r798 r836  
    22 
    33 
    4  
     4// in this procedure file there are a few testing proceudres that are good  
     5// examples of how to script the calcualtions to automatically fill, calculate 
     6// and rename output for later inspection. Very useful to survey a series of  
     7// conditions or for very lengthy calculations 
     8// 
     9// there is also a loop to run through all of the calculation methods to  
     10// get relatice timing information. 
     11// 
    512 
    613Proc concSphereLoop() 
     
    127134// will try forever to fill a sphere, but there was always that possibility before. 
    128135// 
     136// 
     137// nSph = number of LARGE spheres to add (not the voxel size) 
     138// rad = mean radius of these large spheres 
     139// pd = polydispersity (0,1) 
     140// nPass = number of repeat averaging passes 
     141// tagStr = extension string for the output name = "iBin"+tagStr 
    129142// 
    130143Function TestConcSpheres(nSph,rad,pd,nPass,tagStr) 
     
    275288// for testing of the timing 
    276289// type is 0 | 2 | 3 
    277 // 
     290// 0 = FFT 
     291// 2 = binned, single SLD 
     292// 3 = Binned, multiple SLD (3 in this example) 
    278293Proc Timing_Method(type) 
    279294        Variable type           // type of calculation, not used right now 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Cubes_Includes.ipf

    r828 r836  
    3030                "Davg_to_Np" 
    3131        end 
    32         Submenu "Matrix Moving" 
    33                 "ParseMatrix 3D to XYZ" 
    34                 "Plot XYZ" 
    35                 "Animated Slices" 
    36                 "Show Full Matrix" 
    37         end 
    38         Submenu "3D testing" 
     32        Submenu "3D Examples" 
     33                "Polydisperse Spheres" 
    3934                "Connect Dots 3D" 
    4035                "Put Random Cylinders at Points" 
     
    4237                "Put X-axis Cylinders Square Grid",PutXAxisCylindersSquare() 
    4338                "Put X-axis Cylinders Hexagonal Grid",PutXAxisCylindersHexagonal() 
    44                 "Hexagonal Cylinders" 
    45                 "Conc Sphere Loop" 
    46                 "-" 
    47                 "Overnight" 
     39                "Core-shell Cylinders Hex Grid",PutXAxisCoreShellCyl_HexGrid() 
    4840        end 
    49         Submenu "2D testing" 
    50                 "Test 2D" 
    51                 "Connect Dots 2D" 
    52                 "Erase 2D" 
     41        Submenu "Matrix Viewing" 
     42//              "ParseMatrix 3D to XYZ" 
     43//              "Plot XYZ"                      //replaced by Gizmo 
     44                "Animated Slices" 
     45//              "Show Full Matrix" 
    5346        end 
    54         "-" 
    55         "Include FFT Fit Functions" 
     47        Submenu "Automation Examples" 
     48//              "Hexagonal Cylinders" 
     49//              "Conc Sphere Loop" 
     50//              "-" 
     51//              "Overnight" 
     52        end 
     53//      Submenu "2D testing" 
     54//              "Test 2D" 
     55//              "Connect Dots 2D" 
     56//              "Erase 2D" 
     57//      end 
     58//      "-" 
     59//      "Include FFT Fit Functions"             //automatically loaded now... 
    5660End 
    5761 
     
    6266        Execute/P "COMPILEPROCEDURES " 
    6367end 
     68 
     69 
     70////// examples of different structures, shapes and techniques for generating structures 
     71// other examples that could be added are: 
     72// -- a tetrahedron w/ 4 different colors (rotation, transformation) 
     73// -- core-shell spheres 
     74// -- binary (touching) spheres of different SLD (would make a simple fit function too) 
     75// -- ? other 
     76// -- orientation-dependent structures vs. 2D analytic 
     77// -- simple automation examples 
     78 
     79 
     80Proc PolydisperseSpheres(nSph,rad,pd,nPass,tagStr) 
     81        Variable nSph=505,rad=20,pd=0.25,nPass=10 
     82        String tagStr="_Poly" 
     83// nSph = number of LARGE spheres to add (not the voxel size) 
     84// rad = mean radius of these large spheres 
     85// pd = polydispersity (0,1) 
     86// nPass = number of repeat averaging passes 
     87// tagStr = extension string for the output name = "iBin"+tagStr 
     88        TestConcSpheres(nSph,rad,pd,nPass,tagStr) 
     89        Display $("iBin"+tagStr) vs $("qBin"+tagStr) 
     90        ModifyGraph grid=1,mirror=2,log=1 
     91        ModifyGraph mode=4,marker=2,msize=2 
     92        Legend 
     93End 
     94 
     95Proc PutXAxisCoreShellCyl_HexGrid(w,rad,len,sep) 
     96        String w="mat" 
     97        Variable rad=30,len=300,sep=100 
     98        Prompt w,"matrix" 
     99        prompt rad,"radius of cylinders" 
     100        prompt len,"length of cylinders" 
     101        prompt sep,"center-to-center separation of cylinders" 
     102         
     103        $w=0 
     104        X_CoreShellCylinderHexGrid($w,rad,len,sep) 
     105         
     106        NumberOfPoints() 
     107end 
     108 
     109Function X_CoreShellCylinderHexGrid(mat,rad,len,sep) 
     110        Wave mat 
     111        variable rad,len                //length of cylinders 
     112        Variable sep                    // EDGE separation, in same units as cylinder 
     113         
     114         
     115        NVAR grid=root:FFT_T 
     116        Variable np,spacing 
     117        np = DimSize(mat,0)                     // assumes that all dimensions are the same 
     118         
     119        // fill a 2D plane with points 
     120        Make/O/B/N=(np,np) plane 
     121        plane = 0 
     122 
     123        spacing = round(sep/grid)               // so it's an integer 
     124        FillPlaneHexagonal(plane,spacing) 
     125         
     126        // put it in the proper plane of the matrix 
     127        mat[np/2][][] = plane[q][r]                     // in the YZ plane 
     128         
     129        ParseMatrix3D_rho(mat) 
     130        Wave x3d=x3d 
     131        Wave y3d=y3d 
     132        Wave z3d=z3d 
     133         
     134        Variable ii=0,num 
     135        num = numpnts(x3d)       
     136         
     137        for(ii=0;ii<num;ii+=1) 
     138                FillXCylinder(mat,grid,rad,x3d[ii],y3d[ii],z3d[ii],len,1)               //cylinder 1 
     139        endfor 
     140 
     141// makes a crude core-shell cylinder     
     142        for(ii=0;ii<num;ii+=1) 
     143                FillXCylinder(mat,grid,rad-20,x3d[ii],y3d[ii],z3d[ii],len,3)            //cylinder 1 
     144        endfor 
     145         
     146        return(0) 
     147End 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Cylinder_Fills.ipf

    r800 r836  
    55// most is still being worked out and verified in 2D 
    66// 
     7/// search for "crude core-shell cylinder" for an example of how this can be done 
     8// -- maybe the same filling, but no mat=0 (ask) 
    79 
    810 
     
    1113//process of calculating a series of configurations. 
    1214 
    13  
    14  
    15 Proc ConnectDots3D(maxNumConn) 
    16         Variable maxNumConn=1 
     15         
     16Proc ConnectDots3D(w,np,maxNumConn,sobol) 
     17        String w="mat" 
     18        Variable np=100,maxNumConn=2,sobol=1 
     19        Prompt w,"matrix" 
     20        Prompt np,"number of points" 
     21        prompt maxNumConn,"number of connections per point" 
     22        Prompt sobol,"1=Sobol, 0=random" 
     23         
     24        $w=0 
     25 
     26        if(sobol) 
     27                SobolFill3DMat($w,np) 
     28        else 
     29                RandomFill3DMat($w,np) 
     30        endif 
     31         
     32        ParseMatrix3DToXYZ(w) 
    1733         
    1834        Variable num=numpnts(x3d) 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Debye_Spheres.ipf

    r816 r836  
    22 
    33 
     4// all three methods are coded here 
     5//      - simple Debye 
     6// - binned distances (1 SLD) 
     7// - binned distances and multiple SLDs 
     8// 
     9// 
    410// with the Debye Sphere method -- as of Jan 2011 
    511// the discretization seems to work now, and is significantly faster than the old double sum 
    612// 
    7 // now I need to XOP-it (done) 
    8  
    913 
    1014// routines to calculate I(q) and p(r) from the 3d arrangement of spheres 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_FillMatrixShapes.ipf

    r798 r836  
    55// also contains routines to convert matrix to XYZ values for export to the calculations 
    66// 
    7 // to add - more specialized visualization using CreateSlicer 
     7// random point fills are also here, either random or Sobol 
    88// 
    99 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Panel.ipf

    r798 r836  
    8484        Button FFTButton_2,pos={14,187},size={100,20},proc=FFTDrawSphereButtonProc,title="Draw Sphere" 
    8585        Button FFTButton_3,pos={14,265},size={70,20},proc=DoTheFFT_ButtonProc,title="Do FFT" 
    86         Button FFTButton_4,pos={191,264},size={110,20},proc=FFT_PlotResultsButtonProc,title="Plot 1D Results" 
     86        Button FFTButton_4,pos={180,264},size={130,20},proc=FFT_PlotResultsButtonProc,title="Plot FFT Results" 
    8787        Button FFTButton_5,pos={13,218},size={120,20},proc=FFTDrawZCylinderButtonProc,title="Draw Cylinder" 
    8888        Button FFTButton_6,pos={134,79},size={90,20},proc=FFTEraseMatrixButtonProc,title="Erase Matrix" 
    8989        Button FFTButton_7,pos={13,329},size={130,20},proc=FFT_BinnedSpheresButtonProc,title="Do Binned Debye" 
     90        Button FFTButton_7a,pos={180,329},size={130,20},proc=FFT_PlotResultsButtonProc,title="Plot Binned Results" 
     91 
    9092        Button FFTButton_8,pos={13,297},size={130,20},proc=FFT_AltiSpheresButtonProc,title="Do Debye Spheres" 
     93        Button FFTButton_8a,pos={180,297},size={130,20},proc=FFT_PlotResultsButtonProc,title="Plot Debye Results" 
     94 
    9195        Button FFTButton_14,pos={13,360},size={130,20},proc=FFT_BinnedSLDButtonProc,title="Do Binned SLD" 
     96        Button FFTButton_14a,pos={180,360},size={130,20},proc=FFT_PlotResultsButtonProc,title="Plot SLD Results" 
     97 
    9298        SetVariable FFTSetVar_4,pos={201,4},size={100,15},title="FFT time(s)" 
    9399        SetVariable FFTSetVar_4,limits={0,0,0},value= FFT_estTime,noedit= 1,live= 1,format="%d" 
    94         Button FFTButton_9,pos={200,295},size={100,20},proc=FFT_Get2DSlice,title="Get Slice" 
     100        Button FFTButton_9,pos={200,400},size={100,20},proc=FFT_Get2DSlice,title="Get 2D Slice" 
    95101        Button FFTButton_10,pos={169,156},size={130,20},proc=FFT_TransposeMat,title="Transpose Matrix" 
    96102        Button FFTButton_11,pos={169,189},size={130,20},proc=FFT_RotateMat,title="Rotate Matrix" 
    97103        Button FFTButton_12,pos={168,219},size={130,20},proc=FFT_AddRotatedObject,title="Add Rotated Obj" 
     104        Button FFTButton_12,disable=2           // hide this button 
    98105        Button FFTButton_13,pos={14,109},size={120,20},proc=FFTFillSolventMatrixProc,title="Solvent Matrix" 
    99         SetVariable FFTSetVar_5,pos={155,111},size={100,15},title="Solvent SLD" 
     106        SetVariable FFTSetVar_5,pos={155,111},size={150,15},title="Solvent SLD (10^-6)" 
    100107        SetVariable FFTSetVar_5,limits={-99,99,1},value= FFT_SolventSLD,live= 1 
    101         Button FFTButton_15,pos={209,327},size={90,20},proc=Interp2DSliceButton,title="Interp 2D" 
     108        Button FFTButton_15,pos={209,430},size={90,20},proc=Interp2DSliceButton,title="Interp 2D" 
     109        Button FFTButton_16,pos={14,460},size={70,20},proc=FFTHelpButton,title="Help" 
    102110EndMacro 
     111 
     112Function FFTHelpButton(ba) : ButtonControl 
     113        STRUCT WMButtonAction &ba 
     114         
     115        String win = ba.win 
     116 
     117        switch (ba.eventCode) 
     118                case 2: 
     119                        // click code here 
     120                        DisplayHelpTopic/Z/K=1 "Real-Space Modeling" 
     121                        if(V_flag !=0) 
     122                                DoAlert 0,"The Real-Space Modeling Help file could not be found" 
     123                        endif 
     124                        break 
     125        endswitch 
     126 
     127        return 0 
     128End 
     129 
    103130 
    104131Function Interp2DSliceButton(ba) : ButtonControl 
     
    424451        String ctrlName 
    425452 
     453        Variable first=0 
    426454        DoWindow/F FFT_IQ 
    427455        if(V_flag==0) 
    428                 Execute "FFT_IQ()" 
     456                first = 1 
     457                Display /W=(295,44,627,302) 
     458                DoWindow/C FFT_IQ 
    429459        Endif 
    430 End 
    431  
     460         
     461        // append the desired data, if it's not already there 
     462        // FFTButton_4 = FFT            = iBin 
     463        // FFTButton_7a = binned = _XOP 
     464        // FFTButton_8a = Debye = _full 
     465        // FFTButton_14a = SLD = _SLD 
     466        strswitch(ctrlName)      
     467                case "FFTButton_4": 
     468                        if(!isTraceOnGraph("iBin","FFT_IQ") && exists("iBin")==1)               //only append if it's not already there 
     469                                AppendToGraph /W=FFT_IQ iBin vs qBin 
     470                                ModifyGraph mode=4,marker=19,msize=2,rgb(iBin)=(65535,0,0) 
     471                        endif 
     472                        break 
     473                case "FFTButton_7a": 
     474                        if(!isTraceOnGraph("ival_XOP","FFT_IQ") && exists("ival_XOP")==1)               //only append if it's not already there 
     475                                AppendToGraph /W=FFT_IQ ival_XOP vs qval_XOP 
     476                                ModifyGraph mode=4,marker=19,msize=2,rgb(ival_XOP)=(1,12815,52428) 
     477                        endif            
     478                        break 
     479                case "FFTButton_8a": 
     480                        if(!isTraceOnGraph("ival_full","FFT_IQ") && exists("ival_full")==1)             //only append if it's not already there 
     481                                AppendToGraph /W=FFT_IQ ival_full vs qval_full 
     482                                ModifyGraph mode=4,marker=19,msize=2,rgb(ival_full)=(0,0,0) 
     483                        endif            
     484                        break 
     485                case "FFTButton_14a": 
     486                        if(!isTraceOnGraph("ival_SLD","FFT_IQ") && exists("ival_SLD")==1)               //only append if it's not already there 
     487                                AppendToGraph /W=FFT_IQ ival_SLD vs qval_SLD 
     488                                ModifyGraph mode=4,marker=19,msize=2,rgb(ival_SLD)=(2,39321,1) 
     489                        endif            
     490                        break 
     491        endswitch 
     492         
     493        if(first) 
     494                ModifyGraph mode=4 
     495                ModifyGraph marker=19 
     496                ModifyGraph msize=2 
     497                ModifyGraph gaps=0 
     498                ModifyGraph grid=1 
     499                ModifyGraph log=1 
     500                ModifyGraph mirror=2 
     501                Legend 
     502        endif 
     503         
     504        return(0) 
     505End 
     506 
     507Function isTraceOnGraph(traceStr,winStr) 
     508        String traceStr,winStr 
     509         
     510        Variable isOn=0 
     511        String str 
     512        str = TraceNameList("winStr",";",1)             //only normal traces 
     513        isOn = stringmatch(str,traceStr)                //must be an exact match 
     514 
     515        return(isOn) 
     516End 
    432517 
    433518Function FFTEraseMatrixButtonProc(ctrlName) : ButtonControl 
     
    466551End 
    467552 
    468  
    469 Proc FFT_IQ() : Graph 
    470         PauseUpdate; Silent 1           // building window... 
    471         Display /W=(295,44,627,302) iBin vs qBin 
    472         DoWindow/C FFT_IQ 
    473         ModifyGraph mode=4 
    474         ModifyGraph marker=19 
    475         ModifyGraph msize=2 
    476         ModifyGraph gaps=0 
    477         ModifyGraph grid=1 
    478         ModifyGraph log=1 
    479         ModifyGraph mirror=2 
    480         Legend/N=text0/J "\\s(iBin) iBin" 
    481 EndMacro 
    482553 
    483554 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Plane_Fills.ipf

    r798 r836  
    11#pragma rtGlobals=1             // Use modern global access method. 
    22 
    3  
     3// some very, very simple fills for lines and planes. 
     4// not of much use right now, but a good example of how to 
     5// index and access lines and planes in the 3D space 
     6// 
    47 
    58Function GridOfLines(m) 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_VoxelDisplay.ipf

    r798 r836  
    7575End 
    7676 
     77//// superceded by Gizmo 
     78//Proc ShowFullMatrix() 
     79// 
     80// 
     81//      CreateSurfer 
     82//       
     83//      //get the maximum dimensions - assumes input matrix "mat" 
     84//      Variable xm,ym,zm 
     85//      xm=DimSize(mat,0) 
     86//      ym=DimSize(mat,1) 
     87//      zm=DimSize(mat,2) 
     88//       
     89//      ModifySurfer  xmin=0,ymin=0,zmin=0 
     90//      ModifySurfer  xmax=xm,ymax=ym,zmax=zm 
     91// 
     92//End 
    7793 
    78 Proc ShowFullMatrix() 
    79          
    80         //get the maximum dimensions - assumes input matrix "mat" 
    81         Variable xm,ym,zm 
    82         xm=DimSize(mat,0) 
    83         ym=DimSize(mat,1) 
    84         zm=DimSize(mat,2) 
    85          
    86         ModifySurfer  xmin=0,ymin=0,zmin=0 
    87         ModifySurfer  xmax=xm,ymax=ym,zmax=zm 
     94//// superceded by Gizmo 
     95////plots each point in 3D space, does NOT autoscale to the input data 
     96//// 
     97//Proc PlotXYZ(xStr,yStr,zStr) 
     98//      String xStr="x3d",yStr="y3d",zStr="z3d" 
     99//       
     100//      //get the maximum dimensions - assumes input matrix "mat" 
     101//      Variable xm,ym,zm 
     102//      xm=DimSize(mat,0) 
     103//      ym=DimSize(mat,1) 
     104//      zm=DimSize(mat,2) 
     105//       
     106//      CreateSurfer 
     107//      MoveWindow 4,44,517,382  
     108//      ModifySurfer  FactoryDefaults, Update=0 
     109//      ModifySurfer/N=Surface0 
     110//      ModifySurfer srcWave=($xStr,$yStr,$zStr) 
     111//      ModifySurfer  srcType=4,plotType=5 
     112//      ModifySurfer  setControlView=3 
     113//      ModifySurfer  zScale=1,  xStep=1,  yStep=1 
     114//      ModifySurfer  frame=895,  drawFrame=1 
     115//      ModifySurfer  xmin=0,ymin=0,zmin=0 
     116//      ModifySurfer  xmax=xm,ymax=ym,zmax=zm 
     117//      ModifySurfer  drawBox=1 
     118//      ModifySurfer  drawTicks=5 
     119//      ModifySurfer backRGB={65535,65535,65535} 
     120//      ModifySurfer palette=Grays 
     121//      ModifySurfer markerRGB={65535,0,0} 
     122//      ModifySurfer  grids=1 
     123//      ModifySurfer  marker=19,  markerSize=2 
     124//      ModifySurfer  scatterDepthCue=1 
     125////    ModifySurfer  autoscale=1 
     126//      ModifySurfer  Update=1 
     127//       
     128//End 
    88129 
    89 End 
    90  
    91 //plots each point in 3D space, does NOT autoscale to the input data 
    92 // 
    93 Proc PlotXYZ(xStr,yStr,zStr) 
    94         String xStr="x3d",yStr="y3d",zStr="z3d" 
    95          
    96         //get the maximum dimensions - assumes input matrix "mat" 
    97         Variable xm,ym,zm 
    98         xm=DimSize(mat,0) 
    99         ym=DimSize(mat,1) 
    100         zm=DimSize(mat,2) 
    101          
    102         CreateSurfer 
    103         MoveWindow 4,44,517,382  
    104         ModifySurfer  FactoryDefaults, Update=0 
    105         ModifySurfer/N=Surface0 
    106         ModifySurfer srcWave=($xStr,$yStr,$zStr) 
    107         ModifySurfer  srcType=4,plotType=5 
    108         ModifySurfer  setControlView=3 
    109         ModifySurfer  zScale=1,  xStep=1,  yStep=1 
    110         ModifySurfer  frame=895,  drawFrame=1 
    111         ModifySurfer  xmin=0,ymin=0,zmin=0 
    112         ModifySurfer  xmax=xm,ymax=ym,zmax=zm 
    113         ModifySurfer  drawBox=1 
    114         ModifySurfer  drawTicks=5 
    115         ModifySurfer backRGB={65535,65535,65535} 
    116         ModifySurfer palette=Grays 
    117         ModifySurfer markerRGB={65535,0,0} 
    118         ModifySurfer  grids=1 
    119         ModifySurfer  marker=19,  markerSize=2 
    120         ModifySurfer  scatterDepthCue=1 
    121 //      ModifySurfer  autoscale=1 
    122         ModifySurfer  Update=1 
    123          
    124 End 
    125  
Note: See TracChangeset for help on using the changeset viewer.