Changeset 168052c in sasmodels for sasmodels/models/be_polyelectrolyte.py


Ignore:
Timestamp:
Jan 29, 2016 4:02:35 AM (8 years ago)
Author:
piotr
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:
ed82794
Parents:
bf6631a
Message:

pylint prettification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/be_polyelectrolyte.py

    r07a6700 r168052c  
    4444J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545 
    4545 
    46 A Moussaid, F Schosseler, J P Munch, S Candau, *J. Journal de Physique II France*, 3 (1993) 573 
     46A Moussaid, F Schosseler, J P Munch, S Candau, 
     47*J. Journal de Physique II France*, 3 (1993) 573 
    4748 
    4849E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179 
     
    5051""" 
    5152 
    52 from numpy import inf, power, pi, sqrt 
     53from numpy import inf, pi, sqrt 
    5354 
    5455name = "be_polyelectrolyte" 
     
    6667category = "shape-independent" 
    6768 
    68 #            ["name", "units", default, [lower, upper], "type", "description"], 
    69 parameters = [["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"], 
    70               ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"], 
    71               ["virial_param",          "1/Ang^2", 12.0,  [-inf, inf], "", "Virial parameter"], 
    72               ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"], 
    73               ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"], 
    74               ["ionization_degree",     "",         0.05, [0, inf],    "", "Degree of ionization"], 
    75               ["polymer_concentration", "mol/L",    0.7,  [0, inf],    "", "Polymer molar concentration"], 
    76               ] 
     69# pylint: disable=bad-whitespace, line-too-long 
     70#   ["name", "units", default, [lower, upper], "type", "description"], 
     71parameters = [ 
     72    ["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"], 
     73    ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"], 
     74    ["virial_param",          "1/Ang^2", 12.0,  [-inf, inf], "", "Virial parameter"], 
     75    ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"], 
     76    ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"], 
     77    ["ionization_degree",     "",         0.05, [0, inf],    "", "Degree of ionization"], 
     78    ["polymer_concentration", "mol/L",    0.7,  [0, inf],    "", "Polymer molar concentration"], 
     79    ] 
     80# pylint: enable=bad-whitespace, line-too-long 
    7781 
    7882 
    7983def Iq(q, 
    80        contrast_factor, 
    81        bjerrum_length, 
    82        virial_param, 
    83        monomer_length, 
    84        salt_concentration, 
    85        ionization_degree, 
    86        polymer_concentration): 
     84       contrast_factor=10.0, 
     85       bjerrum_length=7.1, 
     86       virial_param=12.0, 
     87       monomer_length=10.0, 
     88       salt_concentration=0.0, 
     89       ionization_degree=0.05, 
     90       polymer_concentration=0.7): 
     91    """ 
     92    :param q:                     Input q-value 
     93    :param contrast_factor:       Contrast factor of the polymer 
     94    :param bjerrum_length:        Bjerrum length 
     95    :param virial_param:          Virial parameter 
     96    :param monomer_length:        Monomer length 
     97    :param salt_concentration:    Concentration of monovalent salt 
     98    :param ionization_degree:     Degree of ionization 
     99    :param polymer_concentration: Polymer molar concentration 
     100    :return:                      1-D intensity 
     101    """ 
    87102 
    88103    concentration = polymer_concentration * 6.022136e-4 
    89104 
    90105    k_square = 4.0 * pi * bjerrum_length * (2*salt_concentration + 
    91             ionization_degree * concentration) 
     106                                            ionization_degree * concentration) 
    92107 
    93108    r0_square = 1.0/ionization_degree/sqrt(concentration) * \ 
    94             (monomer_length/sqrt((48.0*pi*bjerrum_length))) 
     109                (monomer_length/sqrt((48.0*pi*bjerrum_length))) 
    95110 
    96111    term1 = contrast_factor/(4.0 * pi * bjerrum_length * 
    97         ionization_degree**2) * (q**2 + k_square) 
     112                             ionization_degree**2) * (q**2 + k_square) 
    98113 
    99114    term2 = 1.0 + r0_square**2 * (q**2 + k_square) * \ 
     
    106121 
    107122def Iqxy(qx, qy, *args): 
    108         iq = Iq(sqrt(qx**2 + qy**2), *args) 
    109  
    110         return iq 
     123    """ 
     124    :param qx:   Input q_x-value 
     125    :param qy:   Input q_y-value 
     126    :param args: Remaining arguments 
     127    :return:     2D-Intensity 
     128    """ 
     129    iq = Iq(sqrt(qx**2 + qy**2), *args) 
     130    return iq 
    111131 
    112132Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values 
     
    134154 
    135155tests = [ 
    136          # Accuracy tests based on content in test/utest_other_models.py 
    137          [{'contrast_factor':       10.0, 
    138            'bjerrum_length':         7.1, 
    139            'virial_param':          12.0, 
    140            'monomer_length':        10.0, 
    141            'salt_concentration':     0.0, 
    142            'ionization_degree':      0.05, 
    143            'polymer_concentration':  0.7, 
    144            'background':             0.001, 
    145            }, 0.001, 0.0948379], 
    146156 
    147          # Additional tests with larger range of parameters 
    148          [{'contrast_factor':       10.0, 
    149            'bjerrum_length':       100.0, 
    150            'virial_param':           3.0, 
    151            'monomer_length':         1.0, 
    152            'salt_concentration':    10.0, 
    153            'ionization_degree':      2.0, 
    154            'polymer_concentration': 10.0, 
    155            }, 0.1, -3.75693800588], 
     157    # Accuracy tests based on content in test/utest_other_models.py 
     158    [{'contrast_factor':       10.0, 
     159      'bjerrum_length':         7.1, 
     160      'virial_param':          12.0, 
     161      'monomer_length':        10.0, 
     162      'salt_concentration':     0.0, 
     163      'ionization_degree':      0.05, 
     164      'polymer_concentration':  0.7, 
     165      'background':             0.001, 
     166     }, 0.001, 0.0948379], 
    156167 
    157          [{'contrast_factor':       10.0, 
    158            'bjerrum_length':       100.0, 
    159            'virial_param':           3.0, 
    160            'monomer_length':         1.0, 
    161            'salt_concentration':    10.0, 
    162            'ionization_degree':      2.0, 
    163            'polymer_concentration': 10.0, 
    164            'background':           100.0 
    165            }, 5.0, 100.029142149], 
     168    # Additional tests with larger range of parameters 
     169    [{'contrast_factor':       10.0, 
     170      'bjerrum_length':       100.0, 
     171      'virial_param':           3.0, 
     172      'monomer_length':         1.0, 
     173      'salt_concentration':    10.0, 
     174      'ionization_degree':      2.0, 
     175      'polymer_concentration': 10.0, 
     176     }, 0.1, -3.75693800588], 
    166177 
    167          [{'contrast_factor':     100.0, 
    168            'bjerrum_length':       10.0, 
    169            'virial_param':        180.0, 
    170            'monomer_length':        1.0, 
    171            'salt_concentration':    0.1, 
    172            'ionization_degree':     0.5, 
    173            'polymer_concentration': 0.1, 
    174            }, 200., 1.80664667511e-06], 
    175          ] 
     178    [{'contrast_factor':       10.0, 
     179      'bjerrum_length':       100.0, 
     180      'virial_param':           3.0, 
     181      'monomer_length':         1.0, 
     182      'salt_concentration':    10.0, 
     183      'ionization_degree':      2.0, 
     184      'polymer_concentration': 10.0, 
     185      'background':           100.0 
     186     }, 5.0, 100.029142149], 
     187 
     188    [{'contrast_factor':     100.0, 
     189      'bjerrum_length':       10.0, 
     190      'virial_param':        180.0, 
     191      'monomer_length':        1.0, 
     192      'salt_concentration':    0.1, 
     193      'ionization_degree':     0.5, 
     194      'polymer_concentration': 0.1, 
     195     }, 200., 1.80664667511e-06], 
     196    ] 
Note: See TracChangeset for help on using the changeset viewer.