Changeset 0420af7 in sasmodels for sasmodels/models/hollow_cylinder.py


Ignore:
Timestamp:
Jan 21, 2016 4:17:17 PM (8 years ago)
Author:
krzywon
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:
0da2a01
Parents:
6458608
Message:

Modified hollow_cylinder to reject invalid inputs, added VR, ER and
tests. Si now has pre-calculated factorials for faster processing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hollow_cylinder.py

    rd18f8a8 r0420af7  
    6464""" 
    6565 
    66 from numpy import inf 
     66from numpy import pi, inf 
    6767 
    6868name = "hollow_cylinder" 
     
    9292source = ["lib/J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 
    9393 
     94def ER(radius, core_radius, length): 
     95    if radius == 0 or length == 0: 
     96        return 0.0 
     97    len1 = radius 
     98    len2 = length/2.0 
     99    term1 = len1*len1*2.0*len2/2.0 
     100    term2 = 1.0 + (len2/len1)*(1.0 + 1/len2/2.0)*(1.0 + pi*len1/len2/2.0) 
     101    ddd = 3.0*term1*term2 
     102    diam = pow(ddd, (1.0/3.0)) 
     103    return diam 
     104 
     105def VR(radius, core_radius, length): 
     106    vol_core = pi*core_radius*core_radius*length 
     107    vol_total = pi*radius*radius*length 
     108    vol_shell = vol_total - vol_core 
     109    return vol_shell, vol_total 
     110 
    94111# parameters for demo 
    95112demo = dict(scale=1.0,background=0.0,length=400.0,radius=30.0,core_radius=20.0, 
     
    97114            radius_pd=.2, radius_pd_n=9, 
    98115            length_pd=.2, length_pd_n=10, 
     116            core_radius_pd=.2, core_radius_pd_n=9, 
    99117            theta_pd=10, theta_pd_n=5, 
    100118            ) 
     
    109127# Parameters for unit tests 
    110128tests = [ 
    111          [{"radius" : 30.0},0.00005,1764.926] 
     129         [{"radius" : 30.0},0.00005,1764.926], 
     130         [{},'VR',1.8], 
     131         [{},0.001,1756.76] 
    112132         ] 
Note: See TracChangeset for help on using the changeset viewer.