Changeset 348557a in sasmodels


Ignore:
Timestamp:
Mar 16, 2016 11:41:50 AM (8 years ago)
Author:
richardh
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
5041682
Parents:
91c5fdc
Message:

rkh new hayter_msa, new squarewell, unit test to lamellar

Location:
sasmodels/models
Files:
1 added
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hayter_msa.py

    rec2ca99 r348557a  
    4545from numpy import inf 
    4646 
    47 source = ["HayterMSAsq_kernel.c"] 
     47source = ["hayter_msa_kernel.c"] 
    4848 
    49 name = "HayterMSAsq" 
     49name = "hayter_msa" 
    5050title = "Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor" 
    5151description = """\ 
     
    5757        parameters used in P(Q). 
    5858""" 
    59 single = False  # double precision only for now 
     59single = False  # double precision only! 
    6060 
    6161# pylint: disable=bad-whitespace, line-too-long 
     
    9999            effect_radius_pd_n=40) 
    100100# 
    101 # attempt to use same values as old sasview unit test 
     101# attempt to use same values as old sasview unit test at Q=.001 was 0.0712928,  
     102# then add lots new ones assuming values from new model are OK, need some low Q values to test the small Q Taylor expansion 
    102103tests = [ 
    103104    [{'scale': 1.0, 
     
    110111      'dielectconst': 78.0, 
    111112      'effect_radius_pd': 0}, 
    112      [0.0010], [0.0712928]] 
     113     [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 
     114    [{'scale': 1.0, 
     115      'background': 0.0, 
     116      'effect_radius': 20.75, 
     117      'charge': 19.0, 
     118      'volfraction': 0.0192, 
     119      'temperature': 298.0, 
     120      'saltconc': 0.05, 
     121      'dielectconst': 78.0, 
     122      'effect_radius_pd': 0.1, 
     123      'effect_radius_pd_n': 40}, 
     124     [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 
    113125    ] 
    114126 
  • sasmodels/models/hayter_msa_kernel.c

    r48f0194 r348557a  
    4545        //                      Kappa (Debye-Huckel screening length in m) 
    4646        //      and             gamma Exp(-k) 
     47         
     48        // the zz*VolFrac/Vp is for the counterions from the micelle, assumed monovalent, the 2.0*cs if for added salt, assumed 1:1 electolyte  
    4749        IonSt=0.5 * Elcharge*Elcharge*(zz*VolFrac/Vp+2.0*cs); 
    4850        Kappa=sqrt(2*Beta*IonSt/Perm);     //Kappa calc from Ionic strength 
     
    505507        ak2 = akz*akz; 
    506508         
    507         if (qq<=0.0) { 
     509        qk = qq/gMSAWave[13]; 
     510        q2k = qk*qk; 
     511        if (qk<=1.0e-08) { 
    508512                SofQ = -1.0/gMSAWave[0]; 
    509513        } else { 
    510                 qk = qq/gMSAWave[13]; 
    511                 q2k = qk*qk; 
     514        // this rescales Q.sigma = 2.Q.Radius, so is hard to predict the value to test the function 
     515        if (qk<=0.01) { 
     516                // try Taylor series expansion at small qk (RKH Feb 2016, with help from Mathematica),  
     517                // transition point may need to depend on precision of cpu used and ALAS on the values of some of the parameters ! 
     518                // note have adsorbed a factor 24 from SofQ= 
     519                // needs thorough test over wide range of parameter space! 
     520                // there seem to be some rounding issues here in single precision, must use double 
     521                aqk = gMSAWave[0]*(8.0+2.0*etaz) + 6*gMSAWave[1] -12.0*gMSAWave[3]  
     522                        -24*(gekz*(1.0+akz) -ck*akz*gMSAWave[2] +gMSAWave[3]*(ck-1.0) +(gMSAWave[2]-gMSAWave[3]*akz)*sk )/ak2 
     523                        +q2k*( -(gMSAWave[0]*(48.0+15.0*etaz) +40.0*gMSAWave[1])/60.0 +gMSAWave[3]  
     524                        +(4.0/ak2)*(gekz*(9.0+7.0*akz) +ck*(9.0*gMSAWave[3] -7.0*gMSAWave[2]*akz) +sk*(9.0*gMSAWave[2] -7.0*gMSAWave[3]*akz)) ); 
     525                SofQ = 1.0/(1.0-gMSAWave[10]*aqk); 
     526        } else { 
    512527                qk2 = 1.0/q2k; 
    513528                qk3 = qk2/qk; 
    514529                qqk = 1.0/(qk*(q2k+ak2)); 
    515                 sink = sin(qk); 
    516                 cosk = cos(qk); 
     530                SINCOS(qk,sink,cosk); 
    517531                asink = akz*sink; 
    518532                qcosk = qk*cosk; 
     
    525539                aqk=aqk +gMSAWave[3]*(cosk-1.0)*qk2; 
    526540                aqk=aqk -gekz*(asink+qcosk)*qqk; 
    527                 SofQ = 1.0/(1.0-e24*aqk); 
    528         } 
     541                SofQ = 1.0/(1.0  -e24*aqk); 
     542        } } 
    529543        return (SofQ); 
    530544} 
  • sasmodels/models/lamellar.py

    reb69cce r348557a  
    9999oldname = 'LamellarModel' 
    100100oldpars = dict(sld='sld_bi', solvent_sld='sld_sol', thickness='bi_thick') 
    101  
     101tests = [ 
     102        [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 50.0, 'sld' : 1.0,'solvent_sld' : 6.3, 'thickness_pd' : 0.0,  
     103           }, [0.001], [882289.54309]] 
     104        ] 
     105# ADDED by: converted by PAK? (or RKH?)     ON: 16Mar2016 - RKH adding unit tests from sasview to early 2015 conversion 
     106#  [(qx1, qy1), (qx2, qy2), ...], [I(qx1,qy1), I(qx2,qy2), ...]], 
Note: See TracChangeset for help on using the changeset viewer.