Changeset f12357f in sasmodels for sasmodels/models/pearl_necklace.py


Ignore:
Timestamp:
Feb 3, 2016 8:49:57 AM (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:
a17fe40
Parents:
8696a87
Message:

Modified the pearl_necklace model for better double precision accuracy
and added unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/pearl_necklace.py

    r841753c rf12357f  
    5858""" 
    5959 
    60 from numpy import inf 
     60from numpy import inf, pi 
    6161 
    6262name = "pearl_necklace" 
     
    9696 
    9797source = ["lib/Si.c", "pearl_necklace.c"] 
     98# new flag to let the compiler know to never use single precision 
     99single = False 
     100 
     101def volume(radius, edge_separation, string_thickness, number_of_pearls): 
     102    """ 
     103    Calculates the total particle volume of the necklace. 
     104    Redundant with form_volume. 
     105    """ 
     106    number_of_strings = number_of_pearls - 1.0 
     107    string_vol = edge_separation * pi * pow((string_thickness / 2.0), 2.0) 
     108    pearl_vol = 4.0 /3.0 * pi * pow(radius, 3.0) 
     109    total_vol = number_of_strings * string_vol 
     110    total_vol += number_of_pearls * pearl_vol 
     111    return total_vol 
     112 
     113def ER(radius, edge_separation, string_thickness, number_of_pearls): 
     114    """ 
     115    Calculation for effective radius. 
     116    """ 
     117    tot_vol = volume(radius, edge_separation, string_thickness, number_of_pearls) 
     118    rad_out = pow((3.0*tot_vol/4.0/pi), 0.33333) 
     119    return rad_out 
    98120 
    99121# parameters for demo 
     
    114136               string_thickness='thick_string', sld='sld_pearl', 
    115137               string_sld='sld_string', edge_separation='edge_separation') 
     138 
     139tests = [[{}, 0.001, 17380.245], [{}, 'ER', 115.39502]] 
Note: See TracChangeset for help on using the changeset viewer.