Changeset 8e91f01 in sasview for sansmodels/src


Ignore:
Timestamp:
Aug 4, 2009 1:31:21 PM (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:
b4679de
Parents:
42f193a
Message:

set smear = 0 in LamellaPS instead of using arbitrary constant 0.025

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/libigor/libCylinder.c

    r34c3020 r8e91f01  
    2525        double uplim,lolim;             //upper and lower integration limits 
    2626        double summ,zi,yyy,answer,vcyl;                 //running tally of integration 
    27          
     27 
    2828        Pi = 4.0*atan(1.0); 
    2929        lolim = 0; 
    3030        uplim = Pi/2.0; 
    31          
     31 
    3232        summ = 0.0;                     //initialize intergral 
    33          
     33 
    3434        scale = dp[0];                  //make local copies in case memory moves 
    3535        radius = dp[1]; 
     
    4343                summ += yyy; 
    4444        } 
    45          
     45 
    4646        answer = (uplim-lolim)/2.0*summ; 
    4747        // Multiply by contrast^2 
     
    5757        // add in the background 
    5858        answer += bkg; 
    59          
     59 
    6060        return answer; 
    6161} 
     
    8181        double summ,zi,yyy,answer,vell;                 //running tally of integration 
    8282        double summj,vaj,vbj,zij,arg;                   //for the inner integration 
    83          
     83 
    8484        Pi = 4.0*atan(1.0); 
    8585        va = 0; 
     
    8787        vaj=0; 
    8888        vbj=Pi;         //endpoints of inner integral 
    89          
     89 
    9090        summ = 0.0;                     //initialize intergral 
    91          
     91 
    9292        scale = dp[0];                  //make local copies in case memory moves 
    9393        ra = dp[1]; 
     
    111111                //divide integral by Pi 
    112112                answer /=Pi; 
    113                  
     113 
    114114                //now calculate outer integral 
    115115                arg = q*length*zi/2; 
     
    130130        // add in the background 
    131131        answer += bkg; 
    132          
     132 
    133133        return answer; 
    134134} 
     
    156156        double summ,zi,yyy,answer,vell;                 //running tally of integration 
    157157        double summj,vaj,vbj,zij,arg;                   //for the inner integration 
    158          
     158 
    159159        Pi = 4.0*atan(1.0); 
    160160        va = 0; 
     
    162162        vaj=0; 
    163163        vbj=Pi;         //endpoints of inner integral 
    164          
     164 
    165165        summ = 0.0;                     //initialize intergral 
    166          
     166 
    167167        scale = dp[0];                  //make local copies in case memory moves 
    168168        ra = dp[1]; 
     
    186186                //divide integral by Pi 
    187187                answer /=Pi; 
    188                  
     188 
    189189                //now calculate outer integral 
    190190                arg = q*length*zi/2; 
     
    192192                summ += yyy; 
    193193        } 
    194          
     194 
    195195        answer = (vb-va)/2.0*summ; 
    196196        // Multiply by contrast^2 
     
    205205        answer *= scale; 
    206206        // add in the background 
    207         answer += bkg;   
    208          
     207        answer += bkg; 
     208 
    209209        return answer; 
    210210} 
     
    231231        double summ,zi,yyy,answer;                      //running tally of integration 
    232232        double summj,vaj,vbj,zij;                       //for the inner integration 
    233          
     233 
    234234        Pi = 4.0*atan(1.0); 
    235235        va = 0; 
     
    237237        vaj = 0; 
    238238        vbj = 1;                //endpoints of inner integral 
    239          
     239 
    240240        summ = 0.0;                     //initialize intergral 
    241          
     241 
    242242        scale = dp[0];                  //make local copies in case memory moves 
    243243        aa = dp[1]; 
     
    258258                //now calculate the value of the inner integral 
    259259                answer = (vbj-vaj)/2.0*summj; 
    260                  
     260 
    261261                //now calculate outer integral 
    262262                yyy = Gauss76Wt[i] * answer; 
    263263                summ += yyy; 
    264264        }               //final scaling is done at the end of the function, after the NT_FP64 case 
    265          
     265 
    266266        answer = (vb-va)/2.0*summ; 
    267267        // Multiply by contrast^2 
     
    275275        // add in the background 
    276276        answer += bkg; 
    277          
     277 
    278278        return answer; 
    279279} 
     
    301301        double summj,vaj,vbj;                   //for the inner integration 
    302302        double mu,mudum,arg,sigma,uu,vol; 
    303          
    304          
     303 
     304 
    305305        //      Pi = 4.0*atan(1.0); 
    306306        va = 0; 
     
    308308        vaj = 0; 
    309309        vbj = 1;                //endpoints of inner integral 
    310          
     310 
    311311        summ = 0.0;                     //initialize intergral 
    312          
     312 
    313313        scale = dp[0];                  //make local copies in case memory moves 
    314314        aa = dp[1]; 
     
    317317        delrho = dp[4]; 
    318318        bkg = dp[5]; 
    319          
     319 
    320320        mu = q*bb; 
    321321        vol = aa*bb*cc; 
     
    323323        aa = aa/bb; 
    324324        cc = cc/bb; 
    325          
     325 
    326326        for(i=0;i<nordi;i++) { 
    327327                //setup inner integral over the ellipsoidal cross-section 
    328328                summj=0; 
    329329                sigma = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;          //the outer dummy 
    330                  
     330 
    331331                for(j=0;j<nordj;j++) { 
    332332                        //76 gauss points for the inner integral 
     
    338338                //now calculate the value of the inner integral 
    339339                answer = (vbj-vaj)/2.0*summj; 
    340                  
     340 
    341341                arg = mu*cc*sigma/2; 
    342342                if ( arg == 0 ) { 
     
    345345                        answer *= sin(arg)*sin(arg)/arg/arg; 
    346346                } 
    347                  
     347 
    348348                //now sum up the outer integral 
    349349                yyy = Gauss76Wt[i] * answer; 
    350350                summ += yyy; 
    351351        }               //final scaling is done at the end of the function, after the NT_FP64 case 
    352          
     352 
    353353        answer = (vb-va)/2.0*summ; 
    354354        // Multiply by contrast^2 
     
    362362        // add in the background 
    363363        answer += bkg; 
    364          
     364 
    365365        return answer; 
    366366} 
     
    385385        double va,vb,zi;                //upper and lower integration limits 
    386386        double summ,answer,pi;                  //running tally of integration 
    387          
     387 
    388388        pi = 4.0*atan(1.0); 
    389389        va = 0; 
    390390        vb = 1;         //limits of numerical integral 
    391          
     391 
    392392        summ = 0.0;                     //initialize intergral 
    393          
     393 
    394394        scale = dp[0];          //make local copies in case memory moves 
    395395        rcore = dp[1]; 
     
    398398        delrho = dp[4]; 
    399399        bkg = dp[5]; 
    400          
     400 
    401401        for(i=0;i<nord;i++) { 
    402402                zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0; 
    403403                summ += Gauss76Wt[i] * HolCylKernel(q, rcore, rshell, length, zi); 
    404404        } 
    405          
     405 
    406406        answer = (vb-va)/2.0*summ; 
    407407        // Multiply by contrast^2 
     
    415415        // add in the background 
    416416        answer += bkg; 
    417          
     417 
    418418        return answer; 
    419419} 
     
    438438        double va,vb,zi;                //upper and lower integration limits 
    439439        double summ,answer,pi;                  //running tally of integration 
    440          
     440 
    441441        pi = 4.0*atan(1.0); 
    442442        va = 0; 
    443443        vb = 1;         //limits of numerical integral 
    444          
     444 
    445445        summ = 0.0;                     //initialize intergral 
    446          
     446 
    447447        scale = dp[0];                  //make local copies in case memory moves 
    448448        nua = dp[1]; 
     
    450450        delrho = dp[3]; 
    451451        bkg = dp[4]; 
    452          
     452 
    453453        for(i=0;i<nord;i++) { 
    454454                zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0; 
    455455                summ += Gauss76Wt[i] * EllipsoidKernel(q, a, nua, zi); 
    456456        } 
    457          
     457 
    458458        answer = (vb-va)/2.0*summ; 
    459459        // Multiply by contrast^2 
     
    467467        // add in the background 
    468468        answer += bkg; 
    469          
     469 
    470470        return answer; 
    471471} 
     
    485485        double summ,zi,yyy,answer,Vpoly;                        //running tally of integration 
    486486        double range,zz,Pi; 
    487          
     487 
    488488        Pi = 4.0*atan(1.0); 
    489489        range = 3.4; 
    490          
     490 
    491491        summ = 0.0;                     //initialize intergral 
    492          
     492 
    493493        scale = dp[0];                  //make local copies in case memory moves 
    494494        radius = dp[1]; 
     
    497497        delrho = dp[4]; 
    498498        bkg = dp[5]; 
    499          
     499 
    500500        zz = (1.0/pd)*(1.0/pd) - 1.0; 
    501          
     501 
    502502        lolim = radius*(1.0-range*pd);          //set the upper/lower limits to cover the distribution 
    503503        if(lolim<0) { 
     
    508508        } 
    509509        uplim = radius*(1.0+range*pd); 
    510          
     510 
    511511        for(i=0;i<nord;i++) { 
    512512                zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    514514                summ += yyy; 
    515515        } 
    516          
     516 
    517517        answer = (uplim-lolim)/2.0*summ; 
    518518        //normalize by average cylinder volume 
     
    526526        // add in the background 
    527527        answer += bkg; 
    528          
     528 
    529529        return answer; 
    530530} 
     
    543543        double summ,zi,yyy,answer,Vpoly;                        //running tally of integration 
    544544        double range,zz,Pi; 
    545          
    546          
     545 
     546 
    547547        Pi = 4.0*atan(1.0); 
    548548        range = 3.4; 
    549          
     549 
    550550        summ = 0.0;                     //initialize intergral 
    551          
     551 
    552552        scale = dp[0];                  //make local copies in case memory moves 
    553553        radius = dp[1]; 
     
    556556        delrho = dp[4]; 
    557557        bkg = dp[5]; 
    558          
     558 
    559559        zz = (1.0/pd)*(1.0/pd) - 1.0; 
    560          
     560 
    561561        lolim = length*(1.0-range*pd);          //set the upper/lower limits to cover the distribution 
    562562        if(lolim<0) { 
     
    567567        } 
    568568        uplim = length*(1.0+range*pd); 
    569          
     569 
    570570        for(i=0;i<nord;i++) { 
    571571                zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    573573                summ += yyy; 
    574574        } 
    575          
     575 
    576576        answer = (uplim-lolim)/2.0*summ; 
    577577        //normalize by average cylinder volume (first moment) 
     
    585585        // add in the background 
    586586        answer += bkg; 
    587          
     587 
    588588        return answer; 
    589589} 
     
    603603        double summ,zi,yyy,answer,Vcyl;                 //running tally of integration 
    604604        double Pi; 
    605          
    606         Pi = 4.0*atan(1.0); 
    607          
     605 
     606        Pi = 4.0*atan(1.0); 
     607 
    608608        lolim = 0.0; 
    609609        uplim = Pi/2.0; 
    610          
     610 
    611611        summ = 0.0;                     //initialize intergral 
    612          
     612 
    613613        scale = dp[0];          //make local copies in case memory moves 
    614614        rcore = dp[1]; 
     
    619619        rhosolv = dp[6]; 
    620620        bkg = dp[7]; 
    621          
     621 
    622622        halfheight = length/2.0; 
    623          
     623 
    624624        for(i=0;i<nord;i++) { 
    625625                zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    627627                summ += yyy; 
    628628        } 
    629          
     629 
    630630        answer = (uplim-lolim)/2.0*summ; 
    631         // length is the total core length  
     631        // length is the total core length 
    632632        Vcyl=Pi*(rcore+thick)*(rcore+thick)*(length+2.0*thick); 
    633633        answer /= Vcyl; 
     
    638638        // add in the background 
    639639        answer += bkg; 
    640          
     640 
    641641        return answer; 
    642642} 
     
    657657        double summ,yyy,answer,Vpoly;                   //running tally of integration 
    658658        double Pi,AR,Rsqrsumm,Rsqryyy,Rsqr; 
    659          
    660         Pi = 4.0*atan(1.0); 
    661          
     659 
     660        Pi = 4.0*atan(1.0); 
     661 
    662662        summ = 0.0;                     //initialize intergral 
    663663        Rsqrsumm = 0.0; 
    664          
     664 
    665665        scale = dp[0]; 
    666666        radius = dp[1]; 
     
    673673        rhosolv = dp[8]; 
    674674        bkg = dp[9]; 
    675          
     675 
    676676        lolim = exp(log(radius)-(4.*sigma)); 
    677677        if (lolim<0) { 
     
    679679        } 
    680680        uplim = exp(log(radius)+(4.*sigma)); 
    681          
     681 
    682682        for(i=0;i<nord;i++) { 
    683683                rad = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    688688                Rsqrsumm += Rsqryyy; 
    689689        } 
    690          
     690 
    691691        answer = (uplim-lolim)/2.0*summ; 
    692692        Rsqr = (uplim-lolim)/2.0*Rsqrsumm; 
     
    700700        // add in the background 
    701701        answer += bkg; 
    702          
     702 
    703703        return answer; 
    704704} 
     
    717717        double summ,zi,yyy,answer,oblatevol;                    //running tally of integration 
    718718        double Pi; 
    719          
    720         Pi = 4.0*atan(1.0); 
    721          
     719 
     720        Pi = 4.0*atan(1.0); 
     721 
    722722        lolim = 0.0; 
    723723        uplim = 1.0; 
    724          
     724 
    725725        summ = 0.0;                     //initialize intergral 
    726          
    727          
     726 
     727 
    728728        scale = dp[0];          //make local copies in case memory moves 
    729729        crmaj = dp[1]; 
     
    733733        delpc = dp[5]; 
    734734        delps = dp[6]; 
    735         bkg = dp[7];                         
    736          
     735        bkg = dp[7]; 
     736 
    737737        for(i=0;i<nord;i++) { 
    738738                zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    740740                summ += yyy; 
    741741        } 
    742          
     742 
    743743        answer = (uplim-lolim)/2.0*summ; 
    744744        // normalize by particle volume 
    745745        oblatevol = 4*Pi/3*trmaj*trmaj*trmin; 
    746746        answer /= oblatevol; 
    747          
     747 
    748748        //convert to [cm-1] 
    749749        answer *= 1.0e8; 
     
    752752        // add in the background 
    753753        answer += bkg; 
    754          
     754 
    755755        return answer; 
    756756} 
     
    769769        double summ,zi,yyy,answer,prolatevol;                   //running tally of integration 
    770770        double Pi; 
    771          
    772         Pi = 4.0*atan(1.0); 
    773          
     771 
     772        Pi = 4.0*atan(1.0); 
     773 
    774774        lolim = 0.0; 
    775775        uplim = 1.0; 
    776          
     776 
    777777        summ = 0.0;                     //initialize intergral 
    778          
     778 
    779779        scale = dp[0];          //make local copies in case memory moves 
    780780        crmaj = dp[1]; 
     
    784784        delpc = dp[5]; 
    785785        delps = dp[6]; 
    786         bkg = dp[7];                         
    787          
     786        bkg = dp[7]; 
     787 
    788788        for(i=0;i<nord;i++) { 
    789789                zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    791791                summ += yyy; 
    792792        } 
    793          
     793 
    794794        answer = (uplim-lolim)/2.0*summ; 
    795795        // normalize by particle volume 
    796796        prolatevol = 4*Pi/3*trmaj*trmin*trmin; 
    797797        answer /= prolatevol; 
    798          
     798 
    799799        //convert to [cm-1] 
    800800        answer *= 1.0e8; 
     
    803803        // add in the background 
    804804        answer += bkg; 
    805          
     805 
    806806        return answer; 
    807807} 
     
    820820        int nord=76;                    //order of integration 
    821821        double Pi; 
    822          
    823          
    824         Pi = 4.0*atan(1.0); 
    825          
     822 
     823 
     824        Pi = 4.0*atan(1.0); 
     825 
    826826        va = 0.0; 
    827827        vb = Pi/2.0; 
    828          
     828 
    829829        summ = 0.0;                     //initialize intergral 
    830          
     830 
    831831        scale = dp[0]; 
    832832        rcore = dp[1]; 
     
    839839        gsd = dp[8]; 
    840840        bkg = dp[9]; 
    841          
     841 
    842842        d=2.0*thick+length; 
    843843        halfheight = length/2.0; 
    844          
     844 
    845845        for(i=0;i<nord;i++) { 
    846846                zi = ( Gauss76Z[i]*(vb-va) + vb + va )/2.0; 
     
    848848                summ += yyy; 
    849849        } 
    850          
     850 
    851851        answer = (vb-va)/2.0*summ; 
    852         // length is the total core length  
     852        // length is the total core length 
    853853        vcyl=Pi*rcore*rcore*(2.0*thick+length)*N; 
    854854        answer /= vcyl; 
     
    859859        // add in the background 
    860860        answer += bkg; 
    861          
     861 
    862862        return answer; 
    863863} 
     
    873873        double inten, qval,Pq; 
    874874        double Pi; 
    875          
    876          
     875 
     876 
    877877        Pi = 4.0*atan(1.0); 
    878878        scale = dp[0]; 
     
    882882        bkg = dp[4]; 
    883883        qval = q; 
    884          
     884 
    885885        Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)*exp(-0.5*qval*qval*sig*sig)); 
    886          
     886 
    887887        inten = 2.0*Pi*scale*Pq/(qval*qval);            //this is now dimensionless... 
    888          
     888 
    889889        inten /= del;                   //normalize by the thickness (in A) 
    890          
     890 
    891891        inten *= 1.0e8;         // 1/A to 1/cm 
    892          
     892 
    893893        return(inten+bkg); 
    894894} 
     
    906906        double Pi,Euler,dQDefault,fii; 
    907907        int ii,NNint; 
    908          
     908 
    909909        Euler = 0.5772156649;           // Euler's constant 
    910         dQDefault = 0.0025;             //[=] 1/A, q-resolution, default value 
     910        dQDefault = 0.0;//0.0025;               //[=] 1/A, q-resolution, default value 
    911911        dQ = dQDefault; 
    912          
     912 
    913913        Pi = 4.0*atan(1.0); 
    914914        qval = q; 
    915          
     915 
    916916        scale = dp[0]; 
    917917        dd = dp[1]; 
     
    922922        Cp = dp[6]; 
    923923        bkg = dp[7]; 
    924          
     924 
    925925        Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)*exp(-0.5*qval*qval*sig*sig)); 
    926          
     926 
    927927        NNint = (int)NN;                //cast to an integer for the loop 
    928928        ii=0; 
    929929        Sq = 0.0; 
    930930        for(ii=1;ii<(NNint-1);ii+=1) { 
    931          
     931 
    932932                fii = (double)ii;               //do I really need to do this? 
    933                  
     933 
    934934                temp = 0.0; 
    935935                alpha = Cp/4.0/Pi/Pi*(log(Pi*ii) + Euler); 
     
    937937                t2 = 2.0*qval*qval*dd*dd*alpha; 
    938938                t3 = dQ*dQ*dd*dd*ii*ii; 
    939                  
     939 
    940940                temp = 1.0-ii/NN; 
    941941                temp *= cos(dd*qval*ii/(1.0+t1)); 
    942942                temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) ); 
    943943                temp /= sqrt(1.0+t1); 
    944                  
     944 
    945945                Sq += temp; 
    946946        } 
    947          
     947 
    948948        Sq *= 2.0; 
    949949        Sq += 1.0; 
    950          
     950 
    951951        inten = 2.0*Pi*scale*Pq*Sq/(dd*qval*qval); 
    952          
     952 
    953953        inten *= 1.0e8;         // 1/A to 1/cm 
    954          
     954 
    955955    return(inten+bkg); 
    956956} 
     
    969969        double Pi,Euler,dQDefault,fii; 
    970970        int ii,NNint; 
    971          
    972          
     971 
     972 
    973973        Euler = 0.5772156649;           // Euler's constant 
    974974        dQDefault = 0.0025;             //[=] 1/A, q-resolution, default value 
    975975        dQ = dQDefault; 
    976          
     976 
    977977        Pi = 4.0*atan(1.0); 
    978978        qval= q; 
    979          
     979 
    980980        scale = dp[0]; 
    981981        dd = dp[1]; 
     
    988988        Cp = dp[8]; 
    989989        bkg = dp[9]; 
    990          
    991          
     990 
     991 
    992992        drh = SLD_H - SLD_S; 
    993993        drt = SLD_T - SLD_S;    //correction 13FEB06 by L.Porcar 
    994          
     994 
    995995        Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT); 
    996996        Pq *= Pq; 
    997997        Pq *= 4.0/(qval*qval); 
    998          
     998 
    999999        NNint = (int)NN;                //cast to an integer for the loop 
    10001000        ii=0; 
    10011001        Sq = 0.0; 
    10021002        for(ii=1;ii<(NNint-1);ii+=1) { 
    1003          
     1003 
    10041004                fii = (double)ii;               //do I really need to do this? 
    1005                  
     1005 
    10061006                temp = 0.0; 
    10071007                alpha = Cp/4.0/Pi/Pi*(log(Pi*ii) + Euler); 
     
    10091009                t2 = 2.0*qval*qval*dd*dd*alpha; 
    10101010                t3 = dQ*dQ*dd*dd*ii*ii; 
    1011                  
     1011 
    10121012                temp = 1.0-ii/NN; 
    10131013                temp *= cos(dd*qval*ii/(1.0+t1)); 
    10141014                temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) ); 
    10151015                temp /= sqrt(1.0+t1); 
    1016                  
     1016 
    10171017                Sq += temp; 
    10181018        } 
    1019          
     1019 
    10201020        Sq *= 2.0; 
    10211021        Sq += 1.0; 
    1022          
     1022 
    10231023        inten = 2.0*Pi*scale*Pq*Sq/(dd*qval*qval); 
    1024          
     1024 
    10251025        inten *= 1.0e8;         // 1/A to 1/cm 
    1026          
     1026 
    10271027        return(inten+bkg); 
    10281028} 
     
    10381038        double inten, qval,Pq,drh,drt; 
    10391039        double Pi; 
    1040          
    1041          
     1040 
     1041 
    10421042        Pi = 4.0*atan(1.0); 
    10431043        qval= q; 
     
    10491049        slds = dp[5]; 
    10501050        bkg = dp[6]; 
    1051          
    1052          
     1051 
     1052 
    10531053        drh = sldh - slds; 
    10541054        drt = sldt - slds;              //correction 13FEB06 by L.Porcar 
    1055          
     1055 
    10561056        Pq = drh*(sin(qval*(delH+delT))-sin(qval*delT)) + drt*sin(qval*delT); 
    10571057        Pq *= Pq; 
    10581058        Pq *= 4.0/(qval*qval); 
    1059          
     1059 
    10601060        inten = 2.0*Pi*scale*Pq/(qval*qval);            //dimensionless... 
    1061          
     1061 
    10621062        inten /= 2.0*(delT+delH);                       //normalize by the bilayer thickness 
    1063          
     1063 
    10641064        inten *= 1.0e8;         // 1/A to 1/cm 
    1065          
     1065 
    10661066        return(inten+bkg); 
    10671067} 
     
    10761076        double scale,L,B,bkg,rad,qr,cont; 
    10771077        double Pi,flex,crossSect,answer; 
    1078          
    1079          
    1080         Pi = 4.0*atan(1.0); 
    1081          
     1078 
     1079 
     1080        Pi = 4.0*atan(1.0); 
     1081 
    10821082        scale = dp[0];          //make local copies in case memory moves 
    10831083        L = dp[1]; 
     
    10861086        cont = dp[4]; 
    10871087        bkg = dp[5]; 
    1088          
    1089      
     1088 
     1089 
    10901090        qr = q*rad; 
    1091          
     1091 
    10921092        flex = Sk_WR(q,L,B); 
    1093          
     1093 
    10941094        crossSect = (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 
    10951095        flex *= crossSect; 
     
    10981098        flex *= 1.0e8; 
    10991099        answer = scale*flex + bkg; 
    1100          
     1100 
    11011101        return answer; 
    11021102} 
     
    11111111        double scale,L,B,bkg,rad,qr,cont,ellRatio; 
    11121112        double Pi,flex,crossSect,answer; 
    1113          
    1114          
     1113 
     1114 
    11151115        Pi = 4.0*atan(1.0); 
    11161116        scale = dp[0];          //make local copies in case memory moves 
     
    11211121        cont = dp[5]; 
    11221122        bkg = dp[6]; 
    1123          
     1123 
    11241124        qr = q*rad; 
    1125          
     1125 
    11261126        flex = Sk_WR(q,L,B); 
    1127          
     1127 
    11281128        crossSect = EllipticalCross_fn(q,rad,(rad*ellRatio)); 
    11291129        flex *= crossSect; 
     
    11321132        flex *= 1.0e8; 
    11331133        answer = scale*flex + bkg; 
    1134          
     1134 
    11351135        return answer; 
    11361136} 
     
    11411141    double uplim,lolim,Pi,summ,arg,zi,yyy,answer; 
    11421142    int i,nord=76; 
    1143      
     1143 
    11441144    Pi = 4.0*atan(1.0); 
    11451145    lolim=0.0; 
    11461146    uplim=Pi/2.0; 
    11471147    summ=0.0; 
    1148      
     1148 
    11491149    for(i=0;i<nord;i++) { 
    11501150                zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    11571157    answer *= 2.0/Pi; 
    11581158    return(answer); 
    1159          
     1159 
    11601160} 
    11611161/*      FlexCyl_PolyLenX  :  calculates the form factor of a flecible cylinder at the given x-value p->x 
     
    11721172        double summ,zi,yyy,answer,Vpoly;                        //running tally of integration 
    11731173        double range,zz,Pi; 
    1174          
     1174 
    11751175        Pi = 4.0*atan(1.0); 
    11761176        range = 3.4; 
    1177          
     1177 
    11781178        summ = 0.0;                     //initialize intergral 
    11791179        scale = dp[0];                  //make local copies in case memory moves 
     
    11841184        delrho = dp[5]; 
    11851185        bkg = dp[6]; 
    1186          
     1186 
    11871187        zz = (1.0/pd)*(1.0/pd) - 1.0; 
    1188          
     1188 
    11891189        lolim = length*(1.0-range*pd);          //set the upper/lower limits to cover the distribution 
    11901190        if(lolim<0) { 
     
    11951195        } 
    11961196        uplim = length*(1.0+range*pd); 
    1197          
     1197 
    11981198        for(i=0;i<nord;i++) { 
    11991199                zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    12011201                summ += yyy; 
    12021202        } 
    1203          
     1203 
    12041204        answer = (uplim-lolim)/2.0*summ; 
    12051205        //normalize by average cylinder volume (first moment), using the average length 
    12061206        Vpoly=Pi*radius*radius*length; 
    12071207        answer /= Vpoly; 
    1208          
     1208 
    12091209        answer *=delrho*delrho; 
    1210          
     1210 
    12111211        //convert to [cm-1] 
    12121212        answer *= 1.0e8; 
     
    12151215        // add in the background 
    12161216        answer += bkg; 
    1217          
     1217 
    12181218        return answer; 
    12191219} 
     
    12321232        double summ,zi,yyy,answer,Vpoly;                        //running tally of integration 
    12331233        double range,zz,Pi; 
    1234          
    1235          
     1234 
     1235 
    12361236        Pi = 4.0*atan(1.0); 
    12371237        range = 3.4; 
    1238          
     1238 
    12391239        summ = 0.0;                     //initialize intergral 
    1240          
     1240 
    12411241        scale = dp[0];                  //make local copies in case memory moves 
    12421242        length = dp[1];                 //radius 
     
    12461246        delrho = dp[5]; 
    12471247        bkg = dp[6]; 
    1248          
     1248 
    12491249        zz = (1.0/pd)*(1.0/pd) - 1.0; 
    1250          
     1250 
    12511251        lolim = radius*(1.0-range*pd);          //set the upper/lower limits to cover the distribution 
    12521252        if(lolim<0) { 
     
    12571257        } 
    12581258        uplim = radius*(1.0+range*pd); 
    1259          
     1259 
    12601260        for(i=0;i<nord;i++) { 
    12611261                //zi = ( Gauss20Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
     
    12651265                summ += yyy; 
    12661266        } 
    1267          
     1267 
    12681268        answer = (uplim-lolim)/2.0*summ; 
    12691269        //normalize by average cylinder volume (second moment), using the average radius 
    12701270        Vpoly = Pi*radius*radius*length*(zz+2.0)/(zz+1.0); 
    12711271        answer /= Vpoly; 
    1272          
     1272 
    12731273        answer *=delrho*delrho; 
    1274          
     1274 
    12751275        //convert to [cm-1] 
    12761276        answer *= 1.0e8; 
     
    12791279        // add in the background 
    12801280        answer += bkg; 
    1281          
     1281 
    12821282        return answer; 
    12831283} 
     
    12901290        double p1,p2,p1short,p2short,q0,qconnect; 
    12911291        double C,epsilon,ans,q0short,Sexvmodify,pi; 
    1292          
     1292 
    12931293        pi = 4.0*atan(1.0); 
    1294          
     1294 
    12951295        p1 = 4.12; 
    12961296        p2 = 4.42; 
     
    12991299        q0 = 3.1; 
    13001300        qconnect = q0/b; 
    1301         //       
     1301        // 
    13021302        q0short = fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0); 
    1303          
     1303 
    13041304        // 
    13051305        if(L/b > 10.0) { 
     
    13111311        } 
    13121312        // 
    1313          
     1313 
    13141314        if( L > 4*b ) { // Longer Chains 
    13151315                if (q*b <= 3.1) {               //Modified by Yun on Oct. 15, 
     
    13181318                } else { //q(i)*b > 3.1 
    13191319                        ans = a1long(q, L, b, p1, p2, q0)/(pow((q*b),p1)) + a2long(q, L, b, p1, p2, q0)/(pow((q*b),p2)) + pi/(q*L); 
    1320                 }  
     1320                } 
    13211321        } else { //L <= 4*b Shorter Chains 
    13221322                if (q*b <= fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0) ) { 
     
    13301330                } 
    13311331        } 
    1332          
     1332 
    13331333        return(ans); 
    13341334        //return(a2long(q, L, b, p1, p2, q0)); 
     
    13411341    double yy; 
    13421342    yy = 0.5*(1 + tanh((x - 1.523)/0.1477)); 
    1343          
     1343 
    13441344    return (yy); 
    13451345} 
     
    13501350{ 
    13511351    double yy; 
    1352          
     1352 
    13531353    yy = Rgsquareshort(q,L,b)*q*q; 
    1354      
     1354 
    13551355    return (yy); 
    13561356} 
     
    13701370static double 
    13711371Rgsquarezero(double q, double L, double b) 
    1372 {     
     1372{ 
    13731373    double yy; 
    13741374    yy = (L*b/6.0) * (1.0 - 1.5*(b/L) + 1.5*pow((b/L),2) - 0.75*pow((b/L),3)*(1.0 - exp(-2.0*(L/b)))); 
    1375      
     1375 
    13761376    return (yy); 
    13771377} 
     
    13801380static double 
    13811381Rgsquareshort(double q, double L, double b) 
    1382 {     
     1382{ 
    13831383    double yy; 
    13841384    yy = AlphaSquare(L/b) * Rgsquarezero(q,L,b); 
    1385      
     1385 
    13861386    return (yy); 
    13871387} 
     
    13931393    double yy; 
    13941394    yy = AlphaSquare(L/b)*L*b/6.0; 
    1395      
     1395 
    13961396    return (yy); 
    13971397} 
     
    14001400static double 
    14011401AlphaSquare(double x) 
    1402 {     
     1402{ 
    14031403    double yy; 
    14041404    yy = pow( (1.0 + (x/3.12)*(x/3.12) + (x/8.67)*(x/8.67)*(x/8.67)),(0.176/3.0) ); 
    1405          
     1405 
    14061406    return (yy); 
    14071407} 
     
    14101410static double 
    14111411miu(double x) 
    1412 {     
     1412{ 
    14131413    double yy; 
    14141414    yy = (1.0/8.0)*(9.0*x - 2.0 + 2.0*log(1.0 + x)/x)*exp(1.0/2.565*(1.0/x + (1.0 - 1.0/(x*x))*log(1.0 + x))); 
    1415      
     1415 
    14161416    return (yy); 
    14171417} 
     
    14201420static double 
    14211421Sdebye(double q, double L, double b) 
    1422 {     
     1422{ 
    14231423    double yy; 
    14241424    yy = 2.0*(exp(-u_WR(q,L,b)) + u_WR(q,L,b) -1.0)/(pow((u_WR(q,L,b)),2)); 
    1425          
     1425 
    14261426    return (yy); 
    14271427} 
     
    14301430static double 
    14311431Sdebye1(double q, double L, double b) 
    1432 {     
     1432{ 
    14331433    double yy; 
    14341434    yy = 2.0*(exp(-u1(q,L,b)) + u1(q,L,b) -1.0)/( pow((u1(q,L,b)),2.0) ); 
    1435      
     1435 
    14361436    return (yy); 
    14371437} 
     
    14401440static double 
    14411441Sexv(double q, double L, double b) 
    1442 {     
     1442{ 
    14431443    double yy,C1,C2,C3,miu,Rg2; 
    14441444    C1=1.22; 
     
    14461446    C3=-1.651; 
    14471447    miu = 0.585; 
    1448          
     1448 
    14491449    Rg2 = Rgsquare(q,L,b); 
    1450      
     1450 
    14511451    yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) +  C2*pow((q*sqrt(Rg2)),(-2.0/miu)) +    C3*pow((q*sqrt(Rg2)),(-3.0/miu))); 
    1452      
     1452 
    14531453    return (yy); 
    14541454} 
     
    14571457static double 
    14581458Sexvnew(double q, double L, double b) 
    1459 {     
     1459{ 
    14601460    double yy,C1,C2,C3,miu; 
    14611461    double del=1.05,C_star2,Rg2; 
    1462      
     1462 
    14631463    C1=1.22; 
    14641464    C2=0.4288; 
    14651465    C3=-1.651; 
    14661466    miu = 0.585; 
    1467          
     1467 
    14681468    //calculating the derivative to decide on the corection (cutoff) term? 
    14691469    // I have modified this from WRs original code 
    1470      
     1470 
    14711471    if( (Sexv(q*del,L,b)-Sexv(q,L,b))/(q*del - q) >= 0.0 ) { 
    14721472        C_star2 = 0.0; 
     
    14741474        C_star2 = 1.0; 
    14751475    } 
    1476          
     1476 
    14771477    Rg2 = Rgsquare(q,L,b); 
    1478      
     1478 
    14791479        yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + C_star2*w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) + C2*pow((q*sqrt(Rg2)),(-2.0/miu)) + C3*pow((q*sqrt(Rg2)),(-3.0/miu))); 
    1480          
     1480 
    14811481    return (yy); 
    14821482} 
     
    14851485static double 
    14861486a2short(double q, double L, double b, double p1short, double p2short, double q0) 
    1487 {     
     1487{ 
    14881488    double yy,Rg2_sh; 
    14891489    double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p; 
    14901490    double pi; 
    1491          
     1491 
    14921492    E = 2.718281828459045091; 
    14931493        pi = 4.0*atan(1.0); 
     
    14961496    t1 = ((q0*q0*Rg2_sh)/(b*b)); 
    14971497    Et1 = pow(E,t1); 
    1498     Emt1 =pow(E,-t1);  
     1498    Emt1 =pow(E,-t1); 
    14991499    q02 = q0*q0; 
    15001500    q0p = pow(q0,(-4.0 + p2short) ); 
    1501      
     1501 
    15021502    //E is the number e 
    15031503    yy = ((-(1.0/(L*((p1short - p2short))*Rg2_sh2)*((b*Emt1*q0p*((8.0*b*b*b*L - 8.0*b*b*b*Et1*L - 2.0*b*b*b*L*p1short + 2.0*b*b*b*Et1*L*p1short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 2.0*b*Et1*L*p1short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + Et1*p1short*pi*q02*q0*Rg2_sh2))))))); 
    1504          
     1504 
    15051505    return (yy); 
    15061506} 
     
    15091509static double 
    15101510a1short(double q, double L, double b, double p1short, double p2short, double q0) 
    1511 {     
     1511{ 
    15121512    double yy,Rg2_sh; 
    15131513    double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p,b3; 
    15141514        double pi; 
    1515      
     1515 
    15161516    E = 2.718281828459045091; 
    15171517        pi = 4.0*atan(1.0); 
     
    15211521    t1 = ((q0*q0*Rg2_sh)/(b*b)); 
    15221522    Et1 = pow(E,t1); 
    1523     Emt1 =pow(E,-t1);  
     1523    Emt1 =pow(E,-t1); 
    15241524    q02 = q0*q0; 
    15251525    q0p = pow(q0,(-4.0 + p1short) ); 
    1526      
    1527     yy = ((1.0/(L*((p1short - p2short))*Rg2_sh2)*((b*Emt1*q0p*((8.0*b3*L - 8.0*b3*Et1*L - 2.0*b3*L*p2short + 2.0*b3*Et1*L*p2short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 2.0*b*Et1*L*p2short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + Et1*p2short*pi*q02*q0*Rg2_sh2))))));  
    1528          
     1526 
     1527    yy = ((1.0/(L*((p1short - p2short))*Rg2_sh2)*((b*Emt1*q0p*((8.0*b3*L - 8.0*b3*Et1*L - 2.0*b3*L*p2short + 2.0*b3*Et1*L*p2short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 2.0*b*Et1*L*p2short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + Et1*p2short*pi*q02*q0*Rg2_sh2)))))); 
     1528 
    15291529    return(yy); 
    15301530} 
     
    15371537    double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,pi; 
    15381538    double E,b2,b3,b4,q02,q03,q04,q05,Rg22; 
    1539      
     1539 
    15401540    pi = 4.0*atan(1.0); 
    15411541    E = 2.718281828459045091; 
     
    15451545        C = 1.0; 
    15461546    } 
    1547          
     1547 
    15481548    C1 = 1.22; 
    15491549    C2 = 0.4288; 
     
    15521552    C5 = 0.1477; 
    15531553    miu = 0.585; 
    1554          
     1554 
    15551555    Rg2 = Rgsquare(q,L,b); 
    15561556    Rg22 = Rg2*Rg2; 
     
    15621562    q04 = q03*q0; 
    15631563    q05 = q04*q0; 
    1564      
     1564 
    15651565    t1 = (1.0/(b* p1*pow(q0,((-1.0) - p1 - p2)) - b*p2*pow(q0,((-1.0) - p1 - p2)) )); 
    1566      
     1566 
    15671567    t2 = (b*C*(((-1.0*((14.0*b3)/(15.0*q03*Rg2))) + (14*b3*pow(E,(-((q02*Rg2)/b2))))/(15*q03*Rg2) + (2*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + (7*b2)/(15*q02*Rg2)))*Rg2)/b)))/L; 
    1568      
     1568 
    15691569    t3 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2))/(2*C5); 
    1570      
     1570 
    15711571    t4 = (b4*sqrt(Rg2)*(((-1) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2))/(C5*q04*Rg22); 
    1572      
     1572 
    15731573    t5 = (2*b4*(((2*q0*Rg2)/b - (2*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))*((1 + 1.0/2.0*(((-1) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22); 
    1574      
     1574 
    15751575    t6 = (8*b4*b*(((-1) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1 + 1.0/2.0*(((-1) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q05*Rg22); 
    1576      
     1576 
    15771577    t7 = (((-((3*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1) - 3/miu)))/miu)) - (2*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1) - 2/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1) - 1/miu)))/miu)); 
    1578      
     1578 
    15791579    t8 = ((1 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 
    1580      
     1580 
    15811581    t9 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7*b2)/(15*q02*Rg2))) + (7*b2)/(15*q02*Rg2))))/L; 
    1582      
     1582 
    15831583    t10 = (2*b4*(((-1) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1 + 1.0/2.0*(((-1) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22); 
    1584          
    1585      
     1584 
     1585 
    15861586    yy = ((-1*(t1* ((-pow(q0,-p1)*(((b2*pi)/(L*q02) + t2 + t3 - t4 + t5 - t6 + 1.0/2.0*t7*t8)) - b*p1*pow(q0,((-1) - p1))*(((-((b*pi)/(L*q0))) + t9 + t10 + 1.0/2.0*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1)/miu))))*((1 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))))))); 
    1587          
     1587 
    15881588    return (yy); 
    15891589} 
     
    15921592static double 
    15931593sech_WR(double x) 
    1594 {        
     1594{ 
    15951595        return(1/cosh(x)); 
    15961596} 
     
    15991599static double 
    16001600a1long(double q, double L, double b, double p1, double p2, double q0) 
    1601 {     
     1601{ 
    16021602    double yy,C,C1,C2,C3,C4,C5,miu,Rg2; 
    16031603    double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15; 
    16041604    double E,pi; 
    16051605    double b2,b3,b4,q02,q03,q04,q05,Rg22; 
    1606          
     1606 
    16071607    pi = 4.0*atan(1.0); 
    16081608    E = 2.718281828459045091; 
    1609      
     1609 
    16101610    if( L/b > 10.0) { 
    16111611        C = 3.06/pow((L/b),0.44); 
     
    16131613        C = 1.0; 
    16141614    } 
    1615          
     1615 
    16161616    C1 = 1.22; 
    16171617    C2 = 0.4288; 
     
    16201620    C5 = 0.1477; 
    16211621    miu = 0.585; 
    1622          
     1622 
    16231623    Rg2 = Rgsquare(q,L,b); 
    16241624    Rg22 = Rg2*Rg2; 
     
    16301630    q04 = q03*q0; 
    16311631    q05 = q04*q0; 
    1632      
     1632 
    16331633    t1 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7.0*b2)/(15.0*q02*Rg2))) + (7.0*b2)/(15.0*q02*Rg2)))); 
    1634      
     1634 
    16351635    t2 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 
    1636      
     1636 
    16371637    t3 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu)))); 
    1638      
     1638 
    16391639    t4 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 
    1640          
     1640 
    16411641    t5 = (1.0/(b*p1*pow(q0,((-1.0) - p1 - p2)) - b*p2*pow(q0,((-1.0) - p1 - p2)))); 
    1642      
     1642 
    16431643    t6 = (b*C*(((-((14.0*b3)/(15.0*q03*Rg2))) + (14.0*b3*pow(E,(-((q02*Rg2)/b2))))/(15.0*q03*Rg2) + (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + (7.0*b2)/(15.0*q02*Rg2)))*Rg2)/b))); 
    1644      
     1644 
    16451645    t7 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2)); 
    1646      
     1646 
    16471647    t8 = (b4*sqrt(Rg2)*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2)); 
    1648      
     1648 
    16491649    t9 = (2.0*b4*(((2.0*q0*Rg2)/b - (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 
    1650      
     1650 
    16511651    t10 = (8.0*b4*b*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 
    1652      
     1652 
    16531653    t11 = (((-((3.0*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 3.0/miu)))/miu)) - (2.0*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 2.0/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 1.0/miu)))/miu)); 
    1654      
     1654 
    16551655    t12 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 
    1656      
     1656 
    16571657    t13 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + (7.0*b2)/(15.0*q02* Rg2))) + (7.0*b2)/(15.0*q02*Rg2)))); 
    1658      
     1658 
    16591659    t14 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 
    1660      
     1660 
    16611661    t15 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu)))); 
    1662          
    1663      
     1662 
     1663 
    16641664    yy = (pow(q0,p1)*(((-((b*pi)/(L*q0))) +t1/L +t2/(q04*Rg22) + 1.0/2.0*t3*t4)) + (t5*((pow(q0,(p1 - p2))*(((-pow(q0,(-p1)))*(((b2*pi)/(L*q02) +t6/L +t7/(2.0*C5) -t8/(C5*q04*Rg22) +t9/(q04*Rg22) -t10/(q05*Rg22) + 1.0/2.0*t11*t12)) - b*p1*pow(q0,((-1.0) - p1))*(((-((b*pi)/(L*q0))) +t13/L +t14/(q04*Rg22) + 1.0/2.0*t15*((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))))))))))); 
    1665          
     1665 
    16661666    return (yy); 
    16671667} 
     
    16731673// 
    16741674//     FUNCTION gfn2:    CONTAINS F(Q,A,B,mu)**2  AS GIVEN 
    1675 //                       BY (53) AND (56,57) IN CHEN AND  
     1675//                       BY (53) AND (56,57) IN CHEN AND 
    16761676//                       KOTLARCHYK REFERENCE 
    16771677// 
     
    16831683        // local variables 
    16841684        double aa,bb,u2,ut2,uq,ut,vc,vt,gfnc,gfnt,gfn2,pi43,gfn,Pi; 
    1685          
    1686         Pi = 4.0*atan(1.0); 
    1687          
     1685 
     1686        Pi = 4.0*atan(1.0); 
     1687 
    16881688        pi43=4.0/3.0*Pi; 
    16891689        aa = crmaj; 
     
    16991699        gfn = gfnc+gfnt; 
    17001700        gfn2 = gfn*gfn; 
    1701          
     1701 
    17021702        return (gfn2); 
    17031703} 
     
    17091709// 
    17101710//       <OBLATE ELLIPSOID> 
    1711 // function gfn4 for oblate ellipsoids  
     1711// function gfn4 for oblate ellipsoids 
    17121712double 
    17131713gfn4(double xx, double crmaj, double crmin, double trmaj, double trmin, double delpc, double delps, double qq) 
     
    17151715        // local variables 
    17161716        double aa,bb,u2,ut2,uq,ut,vc,vt,gfnc,gfnt,tgfn,gfn4,pi43,Pi; 
    1717          
     1717 
    17181718        Pi = 4.0*atan(1.0); 
    17191719        pi43=4.0/3.0*Pi; 
     
    17301730        tgfn = gfnc+gfnt; 
    17311731        gfn4 = tgfn*tgfn; 
    1732          
     1732 
    17331733        return (gfn4); 
    17341734} 
     
    17391739    double Pq,vcyl,dl; 
    17401740    double Pi,qr; 
    1741      
     1741 
    17421742    Pi = 4.0*atan(1.0); 
    17431743    qr = q*radius; 
    1744      
     1744 
    17451745    Pq = Sk_WR(q,zi,lb);                //does not have cross section term 
    17461746    Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 
    1747      
     1747 
    17481748    vcyl=Pi*radius*radius*zi; 
    17491749    Pq *= vcyl*vcyl; 
    1750      
     1750 
    17511751    dl = SchulzPoint_cpr(zi,length,zz); 
    1752     return (Pq*dl);      
    1753          
     1752    return (Pq*dl); 
     1753 
    17541754} 
    17551755 
     
    17591759    double Pq,vcyl,dr; 
    17601760    double Pi,qr; 
    1761      
     1761 
    17621762    Pi = 4.0*atan(1.0); 
    17631763    qr = q*zi; 
    1764      
     1764 
    17651765    Pq = Sk_WR(q,Lc,Lb);                //does not have cross section term 
    17661766    Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 
    1767      
     1767 
    17681768    vcyl=Pi*zi*zi*Lc; 
    17691769    Pq *= vcyl*vcyl; 
    1770      
     1770 
    17711771    dr = SchulzPoint_cpr(zi,ravg,zz); 
    1772     return (Pq*dr);      
    1773          
     1772    return (Pq*dr); 
     1773 
    17741774} 
    17751775 
     
    17801780        double lolim,uplim,summ,yyy,zi; 
    17811781        int nord,i; 
    1782          
    1783         // set up the integration end points  
     1782 
     1783        // set up the integration end points 
    17841784        Pi = 4.0*atan(1.0); 
    17851785        nord = 76; 
     
    17871787        uplim = Pi/2; 
    17881788        halfheight = length/2.0; 
    1789          
     1789 
    17901790        summ = 0.0;                             // initialize integral 
    17911791        i=0; 
     
    17951795                summ += yyy; 
    17961796        } 
    1797          
     1797 
    17981798        // calculate value of integral to return 
    17991799        answer = (uplim-lolim)/2.0*summ; 
     
    18031803double 
    18041804CScyl(double qq, double rad, double radthick, double facthick, double rhoc, double rhos, double rhosolv, double length, double dum) 
    1805 {        
     1805{ 
    18061806        // qq is the q-value for the calculation (1/A) 
    18071807        // radius is the core radius of the cylinder (A) 
    18081808        //  radthick and facthick are the radial and face layer thicknesses 
    18091809        // rho(n) are the respective SLD's 
    1810         // length is the *Half* CORE-LENGTH of the cylinder  
     1810        // length is the *Half* CORE-LENGTH of the cylinder 
    18111811        // dum is the dummy variable for the integration (theta) 
    1812          
     1812 
    18131813        double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,t1,t2,retval; 
    18141814        double Pi; 
    1815          
    1816         Pi = 4.0*atan(1.0);  
    1817          
     1815 
     1816        Pi = 4.0*atan(1.0); 
     1817 
    18181818        dr1 = rhoc-rhos; 
    18191819        dr2 = rhos-rhosolv; 
    18201820        vol1 = Pi*rad*rad*(2.0*length); 
    18211821        vol2 = Pi*(rad+radthick)*(rad+radthick)*(2.0*length+2.0*facthick); 
    1822          
     1822 
    18231823        besarg1 = qq*rad*sin(dum); 
    18241824        besarg2 = qq*(rad+radthick)*sin(dum); 
    18251825        sinarg1 = qq*length*cos(dum); 
    18261826        sinarg2 = qq*(length+facthick)*cos(dum); 
    1827          
     1827 
    18281828        t1 = 2.0*vol1*dr1*sin(sinarg1)/sinarg1*NR_BessJ1(besarg1)/besarg1; 
    18291829        t2 = 2.0*vol2*dr2*sin(sinarg2)/sinarg2*NR_BessJ1(besarg2)/besarg2; 
    1830          
     1830 
    18311831        retval = ((t1+t2)*(t1+t2))*sin(dum); 
    18321832        return (retval); 
    1833      
     1833 
    18341834} 
    18351835 
     
    18381838CoreShellCylKernel(double qq, double rcore, double thick, double rhoc, double rhos, double rhosolv, double length, double dum) 
    18391839{ 
    1840          
     1840 
    18411841    double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,t1,t2,retval; 
    18421842    double Pi; 
    1843      
     1843 
    18441844    Pi = 4.0*atan(1.0); 
    1845      
     1845 
    18461846    dr1 = rhoc-rhos; 
    18471847    dr2 = rhos-rhosolv; 
    18481848    vol1 = Pi*rcore*rcore*(2.0*length); 
    18491849    vol2 = Pi*(rcore+thick)*(rcore+thick)*(2.0*length+2.0*thick); 
    1850      
     1850 
    18511851    besarg1 = qq*rcore*sin(dum); 
    18521852    besarg2 = qq*(rcore+thick)*sin(dum); 
    18531853    sinarg1 = qq*length*cos(dum); 
    18541854    sinarg2 = qq*(length+thick)*cos(dum); 
    1855      
     1855 
    18561856    t1 = 2.0*vol1*dr1*sin(sinarg1)/sinarg1*NR_BessJ1(besarg1)/besarg1; 
    18571857    t2 = 2.0*vol2*dr2*sin(sinarg2)/sinarg2*NR_BessJ1(besarg2)/besarg2; 
    1858      
     1858 
    18591859    retval = ((t1+t2)*(t1+t2))*sin(dum); 
    1860          
     1860 
    18611861    return (retval); 
    18621862} 
     
    18651865Cyl_PolyLenKernel(double q, double radius, double len_avg, double zz, double delrho, double dumLen) 
    18661866{ 
    1867          
     1867 
    18681868    double halfheight,uplim,lolim,zi,summ,yyy,Pi; 
    18691869    double answer,dr,Vcyl; 
    18701870    int i,nord; 
    1871      
     1871 
    18721872    Pi = 4.0*atan(1.0); 
    18731873    lolim = 0; 
     
    18761876    nord=20; 
    18771877    summ = 0.0; 
    1878      
     1878 
    18791879    //do the cylinder orientational average 
    18801880    for(i=0;i<nord;i++) { 
     
    18901890    Vcyl = Pi*radius*radius*dumLen; 
    18911891    answer *= Vcyl*Vcyl; 
    1892      
     1892 
    18931893    dr = SchulzPoint_cpr(dumLen,len_avg,zz); 
    18941894    return(dr*answer); 
     
    18981898double 
    18991899Stackdisc_kern(double qq, double rcore, double rhoc, double rhol, double rhosolv, double length, double thick, double dum, double gsd, double d, double N) 
    1900 {                
     1900{ 
    19011901        // qq is the q-value for the calculation (1/A) 
    19021902        // rcore is the core radius of the cylinder (A) 
     
    19041904        // length is the *Half* CORE-LENGTH of the cylinder = L (A) 
    19051905        // dum is the dummy variable for the integration (x in Feigin's notation) 
    1906          
    1907         //Local variables  
     1906 
     1907        //Local variables 
    19081908        double totald,dr1,dr2,besarg1,besarg2,area,sinarg1,sinarg2,t1,t2,retval,sqq,dexpt; 
    19091909        double Pi; 
    19101910        int kk; 
    1911          
    1912         Pi = 4.0*atan(1.0); 
    1913          
     1911 
     1912        Pi = 4.0*atan(1.0); 
     1913 
    19141914        dr1 = rhoc-rhosolv; 
    19151915        dr2 = rhol-rhosolv; 
    19161916        area = Pi*rcore*rcore; 
    19171917        totald=2.0*(thick+length); 
    1918          
     1918 
    19191919        besarg1 = qq*rcore*sin(dum); 
    19201920        besarg2 = qq*rcore*sin(dum); 
    1921          
     1921 
    19221922        sinarg1 = qq*length*cos(dum); 
    19231923        sinarg2 = qq*(length+thick)*cos(dum); 
    1924          
     1924 
    19251925        t1 = 2*area*(2*length)*dr1*(sin(sinarg1)/sinarg1)*(NR_BessJ1(besarg1)/besarg1); 
    19261926        t2 = 2*area*dr2*(totald*sin(sinarg2)/sinarg2-2*length*sin(sinarg1)/sinarg1)*(NR_BessJ1(besarg2)/besarg2); 
    1927          
     1927 
    19281928        retval =((t1+t2)*(t1+t2))*sin(dum); 
    1929          
     1929 
    19301930        // loop for the structure facture S(q) 
    19311931        sqq=0.0; 
     
    19331933                dexpt=qq*cos(dum)*qq*cos(dum)*d*d*gsd*gsd*kk/2.0; 
    19341934                sqq=sqq+(N-kk)*cos(qq*cos(dum)*d*kk)*exp(-1.*dexpt); 
    1935         }                        
    1936          
     1935        } 
     1936 
    19371937        // end of loop for S(q) 
    19381938        sqq=1.0+2.0*sqq/N; 
    19391939        retval *= sqq; 
    1940      
     1940 
    19411941        return(retval); 
    19421942} 
     
    19461946Cyl_PolyRadKernel(double q, double radius, double length, double zz, double delrho, double dumRad) 
    19471947{ 
    1948          
     1948 
    19491949    double halfheight,uplim,lolim,zi,summ,yyy,Pi; 
    19501950    double answer,dr,Vcyl; 
    19511951    int i,nord; 
    1952      
     1952 
    19531953    Pi = 4.0*atan(1.0); 
    19541954    lolim = 0; 
     
    19581958    nord=76; 
    19591959    summ = 0.0; 
    1960      
     1960 
    19611961    //do the cylinder orientational average 
    19621962        //    for(i=0;i<nord;i++) { 
     
    19771977    Vcyl = Pi*dumRad*dumRad*length; 
    19781978    answer *= Vcyl*Vcyl; 
    1979      
     1979 
    19801980    dr = SchulzPoint_cpr(dumRad,radius,zz); 
    19811981    return(dr*answer); 
     
    19861986{ 
    19871987    double dr; 
    1988      
     1988 
    19891989    dr = zz*log(dumRad) - gammaln(zz+1.0) + (zz+1.0)*log((zz+1.0)/radius)-(dumRad/radius*(zz+1.0)); 
    19901990    return(exp(dr)); 
     
    19991999                0.1208650973866179e-2,-0.5395239384953e-5}; 
    20002000        int j; 
    2001          
     2001 
    20022002        y=x=xx; 
    20032003        tmp=x+5.5; 
     
    20132013{ 
    20142014    double arg,nu,retval;               //local variables 
    2015          
     2015 
    20162016    nu = nua/a; 
    20172017    arg = qq*a*sqrt(1+dum*dum*(nu*nu-1)); 
    2018      
     2018 
    20192019    retval = (sin(arg)-arg*cos(arg))/(arg*arg*arg); 
    20202020    retval *= retval; 
    20212021    retval *= 9; 
    2022      
     2022 
    20232023    return(retval); 
    20242024}//Function EllipsoidKernel() 
     
    20282028{ 
    20292029    double gamma,arg1,arg2,lam1,lam2,psi,sinarg,t2,retval;              //local variables 
    2030      
     2030 
    20312031    gamma = rcore/rshell; 
    20322032    arg1 = qq*rshell*sqrt(1-dum*dum);           //1=shell (outer radius) 
     
    20352035    lam2 = 2*NR_BessJ1(arg2)/arg2; 
    20362036    psi = 1/(1-gamma*gamma)*(lam1 -  gamma*gamma*lam2);         //SRK 10/19/00 
    2037      
     2037 
    20382038    sinarg = qq*length*dum/2; 
    20392039    t2 = sin(sinarg)/sinarg; 
    2040      
     2040 
    20412041    retval = psi*psi*t2*t2; 
    2042      
     2042 
    20432043    return(retval); 
    20442044}//Function HolCylKernel() 
     
    20492049    // mu passed in is really mu*sqrt(1-sig^2) 
    20502050    double arg1,arg2,Pi,tmp1,tmp2;                      //local variables 
    2051          
     2051 
    20522052    Pi = 4.0*atan(1.0); 
    2053      
     2053 
    20542054    //handle arg=0 separately, as sin(t)/t -> 1 as t->0 
    20552055    arg1 = (mu/2)*cos(Pi*uu/2); 
     
    20602060                tmp1 = sin(arg1)*sin(arg1)/arg1/arg1; 
    20612061    } 
    2062      
     2062 
    20632063    if (arg2==0) { 
    20642064                tmp2 = 1; 
     
    20662066                tmp2 = sin(arg2)*sin(arg2)/arg2/arg2; 
    20672067    } 
    2068          
     2068 
    20692069    return (tmp1*tmp2); 
    2070          
     2070 
    20712071}//Function PPKernel() 
    20722072 
     
    20752075TriaxialKernel(double q, double aa, double bb, double cc, double dx, double dy) 
    20762076{ 
    2077          
     2077 
    20782078    double arg,val,pi;                  //local variables 
    2079          
     2079 
    20802080    pi = 4.0*atan(1.0); 
    2081      
     2081 
    20822082    arg = aa*aa*cos(pi*dx/2)*cos(pi*dx/2); 
    20832083    arg += bb*bb*sin(pi*dx/2)*sin(pi*dx/2)*(1-dy*dy); 
     
    20852085    arg = q*sqrt(arg); 
    20862086    val = 9 * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ) * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ); 
    2087      
     2087 
    20882088    return (val); 
    2089          
     2089 
    20902090}//Function TriaxialKernel() 
    20912091 
     
    20942094CylKernel(double qq, double rr,double h, double theta) 
    20952095{ 
    2096          
     2096 
    20972097        // qq is the q-value for the calculation (1/A) 
    20982098        // rr is the radius of the cylinder (A) 
    20992099        // h is the HALF-LENGTH of the cylinder = L/2 (A) 
    2100          
    2101     double besarg,bj,retval,d1,t1,b1,t2,b2;              //Local variables  
    2102          
    2103          
     2100 
     2101    double besarg,bj,retval,d1,t1,b1,t2,b2;              //Local variables 
     2102 
     2103 
    21042104    besarg = qq*rr*sin(theta); 
    2105          
     2105 
    21062106    bj =NR_BessJ1(besarg); 
    2107          
     2107 
    21082108        //* Computing 2nd power */ 
    21092109    d1 = sin(qq * h * cos(theta)); 
     
    21192119    b2 = d1 * d1; 
    21202120    retval = t1 * t2 / b1 / b2; 
    2121          
     2121 
    21222122    return (retval); 
    2123          
     2123 
    21242124}//Function CylKernel() 
    21252125 
     
    21272127EllipCylKernel(double qq, double ra,double nu, double theta) 
    21282128{ 
    2129         //this is the function LAMBDA1^2 in Feigin's notation    
     2129        //this is the function LAMBDA1^2 in Feigin's notation 
    21302130        // qq is the q-value for the calculation (1/A) 
    21312131        // ra is the transformed radius"a" in Feigin's notation 
    21322132        // nu is the ratio (major radius)/(minor radius) of the Ellipsoid [=] --- 
    21332133        // theta is the dummy variable of the integration 
    2134          
    2135         double retval,arg;               //Local variables  
    2136          
     2134 
     2135        double retval,arg;               //Local variables 
     2136 
    21372137        arg = qq*ra*sqrt((1+nu*nu)/2+(1-nu*nu)*cos(theta)/2); 
    2138          
     2138 
    21392139        retval = 2*NR_BessJ1(arg)/arg; 
    2140          
     2140 
    21412141        //square it 
    21422142        retval *= retval; 
    2143          
     2143 
    21442144    return(retval); 
    2145          
     2145 
    21462146}//Function EllipCylKernel() 
    21472147 
     
    21502150        double ax,z; 
    21512151        double xx,y,ans,ans1,ans2; 
    2152          
     2152 
    21532153        if ((ax=fabs(x)) < 8.0) { 
    21542154                y=x*x; 
     
    21702170                if (x < 0.0) ans = -ans; 
    21712171        } 
    2172          
     2172 
    21732173        return(ans); 
    21742174} 
Note: See TracChangeset for help on using the changeset viewer.