Changeset c5607fa in sasview for sansmodels/src


Ignore:
Timestamp:
Dec 1, 2009 10:39:26 AM (15 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
437a9f0
Parents:
ef9ed58
Message:

Trick applied to the formula of Schulz func to fix having many singularities near small sigmas

Location:
sansmodels/src/sans/models
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/Schulz.py

    r27972c1d rc5607fa  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\schulz.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/schulz.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class Schulz(CSchulz, BaseComponent): 
    2929    """ Class that evaluates a Schulz model.  
    30         This file was auto-generated from ..\c_extensions\schulz.h. 
     30        This file was auto-generated from ../c_extensions/schulz.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
  • sansmodels/src/sans/models/c_extensions/schulz.c

    reba9885 rc5607fa  
    1212 * Function to evaluate 1D Schulz function. 
    1313 * The function is normalized to the 'scale' parameter. 
    14  *  
     14 * 
    1515 * f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)* 
    1616 *                                      math.exp(-R*(z+1))/(center*gamma(z+1) 
     
    2222 */ 
    2323double schulz_analytical_1D(SchulzParameters *pars, double x) { 
    24         double z = pow(pars->center/ pars->sigma, 2)-1;  
     24        double z = pow(pars->center/ pars->sigma, 2)-1; 
    2525        double R= x/pars->center; 
    2626        double zz= z+1; 
    27         return pars->scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((pars->center) * tgamma(zz)) ; 
     27        double expo; 
     28        expo = log(pars->scale)+zz*log(zz)+z*log(R)-R*zz-log(pars->center)-lgamma(zz); 
     29 
     30        return exp(expo);//pars->scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((pars->center) * tgamma(zz)) ; 
    2831} 
    2932 
     
    3134 * Function to evaluate 2D schulz function 
    3235 * The function is normalized to the 'scale' parameter. 
    33  *  
     36 * 
    3437 * f(x,y) = Schulz(x) * Schulz(y) 
    35  *  
     38 * 
    3639 * where both Shulzs share the same parameters. 
    37  *  
     40 * 
    3841 * @param pars: parameters of the schulz 
    3942 * @param x: x-value 
     
    4346double schulz_analytical_2DXY(SchulzParameters *pars, double x, double y) { 
    4447    return schulz_analytical_1D(pars, x) * schulz_analytical_1D(pars, y); 
    45 }  
     48} 
    4649 
    4750/** 
    4851 * Function to evaluate 2D Schulz  function 
    4952 * The function is normalized to the 'scale' parameter. 
    50  *  
     53 * 
    5154 * f(x,y) = Schulz(x) * Schulz(y) 
    52  *  
     55 * 
    5356 * where both Gaussians share the same parameters. 
    54  *  
     57 * 
    5558 * @param pars: parameters of the gaussian 
    5659 * @param length: length of the (x,y) vector 
     
    6063double schulz_analytical_2D(SchulzParameters *pars, double length, double phi) { 
    6164    return schulz_analytical_2DXY(pars, length*cos(phi), length*sin(phi)); 
    62 }  
     65} 
  • sansmodels/src/sans/models/c_models/parameters.cpp

    reba9885 rc5607fa  
    156156 
    157157double lognormal_weight(double mean, double sigma, double x) { 
    158          
    159         double sigma2 = pow(sigma, 2);   
     158 
     159        double sigma2 = pow(sigma, 2); 
    160160        return 1/(x*sigma2) * exp( -pow((log(x) -mean), 2) / (2*sigma2)); 
    161   
     161 
    162162} 
    163163 
     
    217217double schulz_weight(double mean, double sigma, double x) { 
    218218        double vary, expo_value; 
    219     double z = pow(mean/ sigma, 2)-1;    
     219    double z = pow(mean/ sigma, 2)-1; 
    220220        double R= x/mean; 
    221221        double zz= z+1; 
    222         return  pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((mean) * tgamma(zz)) ; 
     222        double expo; 
     223        expo = zz*log(zz)+z*log(R)-R*zz-log(mean)-lgamma(zz); 
     224        return  exp(expo); 
    223225} 
    224226 
Note: See TracChangeset for help on using the changeset viewer.