Changeset 463eb76e in sasview for sansmodels/src


Ignore:
Timestamp:
Jul 25, 2011 3:43:34 PM (13 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:
bc7bc839
Parents:
38155f7
Message:

implementation of pearlneckclace model: need utest and doc

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

Legend:

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

    r38155f7 r463eb76e  
    4747         num_pearls      = 3.0  
    4848         sld_pearl       = 1e-006 [1/A^(2)] 
    49          sld_string      = 5e-006 [1/A^(2)] 
    50          sld_solv        = 5e-007 [1/A^(2)] 
     49         sld_string      = 1e-006 [1/A^(2)] 
     50         sld_solv        = 6.3e-006 [1/A^(2)] 
    5151         background      = 0.0  
    5252 
  • sansmodels/src/sans/models/c_extensions/libmultifunc/libfunc.c

    r8c8cb05 r463eb76e  
     1// by jcho 
    12#include <math.h> 
    23#include "libmultifunc/libfunc.h" 
     
    1920 
    2021// Used in pearl nec model 
    21 //integral of sin(x)/x up to namx term nmax>10 looks fine. 
    22 double Si(double x, int nmax ) 
     22// Sine integral function: approximated within 1%!!! 
     23// integral of sin(x)/x up to namx term nmax=6 looks the best. 
     24double Si(double x) 
    2325{ 
    2426        int i; 
     27        int nmax=6; 
    2528        double out; 
    2629        long double power; 
    27         if (x > 5.0){ 
    28                 double pi = 4.0*atan(1.0); 
    29                 return pi/2.0; 
     30        double pi = 4.0*atan(1.0); 
     31        if (x >= pi*6.2/4.0){ 
     32 
     33                double out_sin = 0.0; 
     34                double out_cos = 0.0; 
     35                out = pi/2.0; 
     36                for (i=0; i<nmax-2; i+=1){ 
     37                        out_cos += pow(-1.0, i) * (double)factorial(2*i) / pow(x, 2*i+1); 
     38                        out_sin += pow(-1.0, i) * (double)factorial(2*i+1) / pow(x, 2*i+2); 
     39                } 
     40                out -= cos(x) * out_cos; 
     41                out -= sin(x) * out_sin; 
     42                return out; 
    3043        } 
    3144        out = 0.0; 
     
    4356} 
    4457 
    45 double sin_x(double x) 
     58double sinc(double x) 
    4659{ 
    4760        if (x==0){ 
  • sansmodels/src/sans/models/c_extensions/libmultifunc/libfunc.h

    r8c8cb05 r463eb76e  
    44int factorial(int i); 
    55 
    6 double Si(double x, int nmax ); 
     6double Si(double x); 
    77 
    8 double sin_x(double x); 
     8double sinc(double x); 
    99 
    1010#endif 
  • sansmodels/src/sans/models/c_extensions/pearlnecklace.c

    r8c8cb05 r463eb76e  
    5353        // Note take only 20 terms in Si series: 10 terms may be enough though. 
    5454        double gamma; 
    55         gamma = Si(q* edge_separation, 6); 
     55        gamma = Si(q* edge_separation); 
    5656        gamma /= (q* edge_separation); 
    5757        double beta; 
    58         beta = Si(q * (edge_separation + radius), 6); 
    59         beta -= Si(q * radius, 6); 
     58        beta = Si(q * (edge_separation + radius)); 
     59        beta -= Si(q * radius); 
    6060        beta /= (q* edge_separation); 
    6161 
     
    6868 
    6969        // form factor for num_pearls 
    70         sss = 1.0 - pow(sin_x(q*A_s), (int)num_pearls ); 
    71         sss /= pow((1.0-sin_x(q*A_s)), 2); 
    72         sss *= sin_x(q*A_s); 
     70        sss = 1.0 - pow(sinc(q*A_s), num_pearls ); 
     71        sss /= pow((1.0-sinc(q*A_s)), 2); 
     72        sss *= -sinc(q*A_s); 
    7373        sss -= num_pearls/2.0; 
    74         sss += num_pearls/(1.0-sin_x(q*A_s)); 
     74        sss += num_pearls/(1.0-sinc(q*A_s)); 
    7575        sss *= 2.0 * pow((m_s*psi), 2); 
    7676 
    7777        // form factor for num_strings (like thin rods) 
    7878        double srr_1; 
    79         srr_1 = -pow(sin_x(q*edge_separation/2.0), 2); 
    80         //printf ("sss %g, %g, %g\n",sss, srr_1, gamma); 
     79        srr_1 = -pow(sinc(q*edge_separation/2.0), 2); 
     80 
    8181        srr_1 += 2.0 * gamma; 
    8282        srr_1 *= num_strings; 
    8383        double srr_2; 
    84         srr_2 = 2.0/(1.0-sin_x(q*A_s)); 
     84        srr_2 = 2.0/(1.0-sinc(q*A_s)); 
    8585        srr_2 *= num_strings; 
    8686        srr_2 *= pow(beta, 2); 
    8787        double srr_3; 
    88         srr_3 = 1.0 - pow(sin_x(q*A_s), (int)num_strings); 
    89         srr_3 /= pow((1.0-sin_x(q*A_s)), 2); 
     88        srr_3 = 1.0 - pow(sinc(q*A_s), num_strings); 
     89        srr_3 /= pow((1.0-sinc(q*A_s)), 2); 
    9090        srr_3 *= pow(beta, 2); 
    9191        srr_3 *= -2.0; 
     
    9696 
    9797        // form factor for correlations 
    98         srs = -1.0; 
    99         srs -= pow(sin_x(q*A_s), (int)num_strings); 
    100         srs /= pow((1.0-sin_x(q*A_s)), 2); 
    101         srs *= sin_x(q*A_s); 
    102         srs += (num_strings/(1.0-sin_x(q*A_s))); 
     98        srs = 1.0; 
     99        srs -= pow(sinc(q*A_s), num_strings); 
     100        srs /= pow((1.0-sinc(q*A_s)), 2); 
     101        srs *= -sinc(q*A_s); 
     102        srs += (num_strings/(1.0-sinc(q*A_s))); 
    103103        srs *= 4.0; 
    104104        srs *= (m_r * m_s * beta * psi); 
     
    111111        form_factor *= scale; 
    112112        form_factor += background; 
    113  
    114113    return (form_factor); 
    115114} 
  • sansmodels/src/sans/models/c_extensions/pearlnecklace.h

    r8c8cb05 r463eb76e  
    4444        double sld_pearl; 
    4545        ///     sld_string 
    46         //  [DEFAULT]=sld_string= 5.0e-06 [1/A^(2)] 
     46        //  [DEFAULT]=sld_string= 1.0e-06 [1/A^(2)] 
    4747        double sld_string; 
    4848        ///     sld_solv 
    49         //  [DEFAULT]=sld_solv= 0.5e-06 [1/A^(2)] 
     49        //  [DEFAULT]=sld_solv= 6.3e-06 [1/A^(2)] 
    5050        double sld_solv; 
    5151        /// Background 
  • sansmodels/src/sans/models/c_models/CPearlNecklaceModel.cpp

    r38155f7 r463eb76e  
    9393        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000)); 
    9494        PyDict_SetItemString(self->params,"thick_string",Py_BuildValue("d",2.500000000000)); 
    95         PyDict_SetItemString(self->params,"sld_string",Py_BuildValue("d",0.000005000000)); 
     95        PyDict_SetItemString(self->params,"sld_string",Py_BuildValue("d",0.000001000000)); 
    9696        PyDict_SetItemString(self->params,"edge_separation",Py_BuildValue("d",350.000000000000)); 
    9797        PyDict_SetItemString(self->params,"sld_pearl",Py_BuildValue("d",0.000001000000)); 
    9898        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",80.000000000000)); 
    9999        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000)); 
    100         PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000000500000)); 
     100        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000)); 
    101101        // Initialize dispersion / averaging parameter dict 
    102102        DispersionVisitor* visitor = new DispersionVisitor(); 
  • sansmodels/src/sans/models/c_models/pearlnecklace.cpp

    r8c8cb05 r463eb76e  
    2121        num_pearls.set_min(0.0); 
    2222        sld_pearl = Parameter(1.0e-06); 
    23         sld_string = Parameter(5.0e-06); 
    24         sld_solv = Parameter(0.5e-06); 
     23        sld_string = Parameter(1.0e-06); 
     24        sld_solv = Parameter(6.3e-06); 
    2525    background = Parameter(0.0); 
    2626 
Note: See TracChangeset for help on using the changeset viewer.