Changeset 07646b6 in sasmodels for doc


Ignore:
Timestamp:
Oct 25, 2018 3:43:01 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
149eb53
Parents:
31fc4ad (diff), d5ce7fa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (10/25/18 14:41:48)
git-committer:
Paul Kienzle <pkienzle@…> (10/25/18 15:43:01)
Message:

Merge branch 'cuda-test' into beta_approx

Location:
doc/guide
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/gpu_setup.rst

    r63602b1 r8b31efa  
    9494Device Selection 
    9595================ 
     96**OpenCL drivers** 
     97 
    9698If you have multiple GPU devices you can tell the program which device to use. 
    9799By default, the program looks for one GPU and one CPU device from available 
     
    104106was used to run the model. 
    105107 
    106 **If you don't want to use OpenCL, you can set** *SAS_OPENCL=None* 
    107 **in your environment settings, and it will only use normal programs.** 
    108  
    109 If you want to use one of the other devices, you can run the following 
     108If you want to use a specific driver and devices, you can run the following 
    110109from the python console:: 
    111110 
     
    115114This will provide a menu of different OpenCL drivers available. 
    116115When one is selected, it will say "set PYOPENCL_CTX=..." 
    117 Use that value as the value of *SAS_OPENCL*. 
     116Use that value as the value of *SAS_OPENCL=driver:device*. 
     117 
     118To use the default OpenCL device (rather than CUDA or None), 
     119set *SAS_OPENCL=opencl*. 
     120 
     121In batch queues, you may need to set *XDG_CACHE_HOME=~/.cache*  
     122(Linux only) to a different directory, depending on how the filesystem  
     123is configured.  You should also set *SAS_DLL_PATH* for CPU-only modules. 
     124 
     125    -DSAS_MODELPATH=path sets directory containing custom models 
     126    -DSAS_OPENCL=vendor:device|cuda:device|none sets the target GPU device 
     127    -DXDG_CACHE_HOME=~/.cache sets the pyopencl cache root (linux only) 
     128    -DSAS_COMPILER=tinycc|msvc|mingw|unix sets the DLL compiler 
     129    -DSAS_OPENMP=1 turns on OpenMP for the DLLs 
     130    -DSAS_DLL_PATH=path sets the path to the compiled modules 
     131 
     132 
     133**CUDA drivers** 
     134 
     135If OpenCL drivers are not available on your system, but NVidia CUDA 
     136drivers are available, then set *SAS_OPENCL=cuda* or 
     137*SAS_OPENCL=cuda:n* for a particular device number *n*.  If no device 
     138number is specified, then the CUDA drivers looks for look for 
     139*CUDA_DEVICE=n* or a file ~/.cuda-device containing n for the device number. 
     140 
     141In batch queues, the SLURM command *sbatch --gres=gpu:1 ...* will set 
     142*CUDA_VISIBLE_DEVICES=n*, which ought to set the correct device 
     143number for *SAS_OPENCL=cuda*.  If not, then set 
     144*CUDA_DEVICE=$CUDA_VISIBLE_DEVICES* within the batch script.  You may 
     145need to set the CUDA cache directory to a folder accessible across the 
     146cluster with *PYCUDA_CACHE_DIR* (or *PYCUDA_DISABLE_CACHE* to disable 
     147caching), and you may need to set environment specific compiler flags 
     148with *PYCUDA_DEFAULT_NVCC_FLAGS*.  You should also set *SAS_DLL_PATH*  
     149for CPU-only modules. 
     150 
     151**No GPU support** 
     152 
     153If you don't want to use OpenCL or CUDA, you can set *SAS_OPENCL=None* 
     154in your environment settings, and it will only use normal programs. 
     155 
     156In batch queues, you may need to set *SAS_DLL_PATH* to a directory 
     157accessible on the compute node. 
     158 
    118159 
    119160Device Testing 
     
    154195*Document History* 
    155196 
    156 | 2017-09-27 Paul Kienzle 
     197| 2018-10-15 Paul Kienzle 
  • doc/guide/magnetism/magnetism.rst

    rbefe905 rdf87acf  
    8989 
    9090===========   ================================================================ 
    91  M0:sld       $D_M M_0$ 
    92  mtheta:sld   $\theta_M$ 
    93  mphi:sld     $\phi_M$ 
    94  up:angle     $\theta_\mathrm{up}$ 
    95  up:frac_i    $u_i$ = (spin up)/(spin up + spin down) *before* the sample 
    96  up:frac_f    $u_f$ = (spin up)/(spin up + spin down) *after* the sample 
     91 sld_M0       $D_M M_0$ 
     92 sld_mtheta   $\theta_M$ 
     93 sld_mphi     $\phi_M$ 
     94 up_frac_i    $u_i$ = (spin up)/(spin up + spin down) *before* the sample 
     95 up_frac_f    $u_f$ = (spin up)/(spin up + spin down) *after* the sample 
     96 up_angle     $\theta_\mathrm{up}$ 
    9797===========   ================================================================ 
    9898 
    9999.. note:: 
    100     The values of the 'up:frac_i' and 'up:frac_f' must be in the range 0 to 1. 
     100    The values of the 'up_frac_i' and 'up_frac_f' must be in the range 0 to 1. 
    101101 
    102102*Document History* 
  • doc/guide/plugin.rst

    r2015f02 r31fc4ad  
    291291 
    292292**Note: The order of the parameters in the definition will be the order of the 
    293 parameters in the user interface and the order of the parameters in Iq(), 
    294 Iqac(), Iqabc() and form_volume(). And** *scale* **and** *background* 
    295 **parameters are implicit to all models, so they do not need to be included 
    296 in the parameter table.** 
     293parameters in the user interface and the order of the parameters in Fq(), Iq(), 
     294Iqac(), Iqabc(), form_volume() and shell_volume(). 
     295And** *scale* **and** *background* **parameters are implicit to all models, 
     296so they do not need to be included in the parameter table.** 
    297297 
    298298- **"name"** is the name of the parameter shown on the FitPage. 
     
    363363    scattered intensity. 
    364364 
    365   - "volume" parameters are passed to Iq(), Iqac(), Iqabc() and form_volume(), 
    366     and have polydispersity loops generated automatically. 
     365  - "volume" parameters are passed to Fq(), Iq(), Iqac(), Iqabc(), form_volume() 
     366    and shell_volume(), and have polydispersity loops generated automatically. 
    367367 
    368368  - "orientation" parameters are not passed, but instead are combined with 
     
    428428        def random(): 
    429429        ... 
    430          
    431 This function provides a model-specific random parameter set which shows model  
    432 features in the USANS to SANS range.  For example, core-shell sphere sets the  
    433 outer radius of the sphere logarithmically in `[20, 20,000]`, which sets the Q  
    434 value for the transition from flat to falling.  It then uses a beta distribution  
    435 to set the percentage of the shape which is shell, giving a preference for very  
    436 thin or very thick shells (but never 0% or 100%).  Using `-sets=10` in sascomp  
    437 should show a reasonable variety of curves over the default sascomp q range.   
    438 The parameter set is returned as a dictionary of `{parameter: value, ...}`.   
    439 Any model parameters not included in the dictionary will default according to  
     430 
     431This function provides a model-specific random parameter set which shows model 
     432features in the USANS to SANS range.  For example, core-shell sphere sets the 
     433outer radius of the sphere logarithmically in `[20, 20,000]`, which sets the Q 
     434value for the transition from flat to falling.  It then uses a beta distribution 
     435to set the percentage of the shape which is shell, giving a preference for very 
     436thin or very thick shells (but never 0% or 100%).  Using `-sets=10` in sascomp 
     437should show a reasonable variety of curves over the default sascomp q range. 
     438The parameter set is returned as a dictionary of `{parameter: value, ...}`. 
     439Any model parameters not included in the dictionary will default according to 
    440440the code in the `_randomize_one()` function from sasmodels/compare.py. 
    441441 
     
    492492used. 
    493493 
     494Hollow shapes, where the volume fraction of particle corresponds to the 
     495material in the shell rather than the volume enclosed by the shape, must 
     496also define a *shell_volume(par1, par2, ...)* function.  The parameters 
     497are the same as for *form_volume*.  The *I(q)* calculation should use 
     498*shell_volume* squared as its scale factor for the volume normalization. 
     499The structure factor calculation needs *form_volume* in order to properly 
     500scale the volume fraction parameter, so both functions are required for 
     501hollow shapes. 
     502 
     503Note: Pure python models do not yet support direct computation of the 
     504average of $F(q)$ and $F^2(q)$. 
     505 
    494506Embedded C Models 
    495507................. 
     
    503515This expands into the equivalent C code:: 
    504516 
    505     #include <math.h> 
    506517    double Iq(double q, double par1, double par2, ...); 
    507518    double Iq(double q, double par1, double par2, ...) 
     
    512523*form_volume* defines the volume of the shape. As in python models, it 
    513524includes only the volume parameters. 
     525 
     526*form_volume* defines the volume of the shell for hollow shapes. As in 
     527python models, it includes only the volume parameters. 
    514528 
    515529**source=['fn.c', ...]** includes the listed C source files in the 
     
    548562The INVALID define can go into *Iq*, or *c_code*, or an external C file 
    549563listed in *source*. 
     564 
     565Structure Factors 
     566................. 
     567 
     568Structure factor calculations may need the underlying $<F(q)>$ and $<F^2(q)>$ 
     569rather than $I(q)$.  This is used to compute $\beta = <F(q)>^2/<F^2(q)>$ in 
     570the decoupling approximation to the structure factor. 
     571 
     572Instead of defining the *Iq* function, models can define *Fq* as 
     573something like:: 
     574 
     575    double Fq(double q, double *F1, double *F2, double par1, double par2, ...); 
     576    double Fq(double q, double *F1, double *F2, double par1, double par2, ...) 
     577    { 
     578        // Polar integration loop over all orientations. 
     579        ... 
     580        *F1 = 1e-2 * total_F1 * contrast * volume; 
     581        *F2 = 1e-4 * total_F2 * square(contrast * volume); 
     582        return I(q, par1, par2, ...); 
     583    } 
     584 
     585If the volume fraction scale factor is built into the model (as occurs for 
     586the vesicle model, for example), then scale *F1* by $\surd V_f$ so that 
     587$\beta$ is computed correctly. 
     588 
     589Structure factor calculations are not yet supported for oriented shapes. 
     590 
     591Note: only available as a separate C file listed in *source*, or within 
     592a *c_code* block within the python model definition file. 
    550593 
    551594Oriented Shapes 
Note: See TracChangeset for help on using the changeset viewer.