# Changeset ee60aa7 in sasmodels

Ignore:
Timestamp:
Sep 10, 2018 4:16:46 PM (12 months ago)
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
d299327
Parents:
3f818b2
Message:

clean up effective radius functions; improve mono_gauss_coil accuracy; start moving VR into C

Files:
59 edited

Unmodified
Removed
• ## explore/precision.py

 r2a7e20e ) add_function( name="debye", name="gauss_coil", mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, ocl_function=make_ocl(""" const double qsq = q*q; if (qsq < 1.0) { // Pade approximation // For double: use O(5) Pade with 0.5 cutoff (10 mad + 1 divide) // For single: use O(7) Taylor with 0.8 cutoff (7 mad) if (qsq < 0.0) { const double x = qsq; if (0) { // 0.36 single const double B1=3./8., B2=3./56., B3=1./336.; return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); } else if (1) { // 1.0 for single, 0.25 for double } else if (0) { // 1.0 for single, 0.25 for double // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); } } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double } else if (qsq < 0.8) { const double x = qsq; const double C0 = +1.;
• ## sasmodels/core.py

 r5399809 actual = [p.name for p in model.info.parameters.kernel_parameters] target = ("sld sld_solvent radius length theta phi" " radius_effective volfraction structure_factor_mode" " radius_effective volfraction " " structure_factor_mode radius_effective_mode" " A_sld A_sld_solvent A_radius").split() assert target == actual, "%s != %s"%(target, actual)
• ## sasmodels/kernel.py

 r5399809 def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray raise NotImpmentedError() raise NotImplementedError()

• ## sasmodels/models/barbell.py

 rd277229 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] have_Fq = True effective_radius_type = ["equivalent sphere","radius","half length","half total length"] effective_radius_type = [ "equivalent sphere", "radius", "half length", "half total length", ] def random():

• ## sasmodels/models/capped_cylinder.py

 rd277229 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] have_Fq = True effective_radius_type = ["equivalent sphere","radius","half length","half total length"] effective_radius_type = [ "equivalent sphere", "radius", "half length", "half total length", ] def random():

• ## sasmodels/models/core_multi_shell.py

 rd277229 return np.asarray(z), np.asarray(rho) #def ER(radius, n, thickness): #    """Effective radius""" #    n = int(n[0]+0.5)  # n is a control parameter and is not polydisperse #    return np.sum(thickness[:n], axis=0) + radius demo = dict(sld_core=6.4, radius=60,
• ## sasmodels/models/core_shell_bicelle.c

 rd277229 effective_radius(int mode, double radius, double thick_rim, double thick_face, double length) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return radius_from_volume(radius, thick_rim, thick_face, length); } else if (mode == 2) { case 2: // outer rim radius return radius + thick_rim; } else if (mode == 3) { case 3: // half outer thickness return 0.5*length + thick_face; } else { case 4: // half diagonal return radius_from_diagonal(radius,thick_rim,thick_face,length); }
• ## sasmodels/models/core_shell_bicelle.py

 rd277229 "core_shell_bicelle.c"] have_Fq = True effective_radius_type = ["equivalent sphere","outer rim radius", "half outer thickness","half diagonal"] effective_radius_type = [ "equivalent sphere", "outer rim radius", "half outer thickness", "half diagonal", ] def random():
• ## sasmodels/models/core_shell_bicelle_elliptical.c

 rd277229 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); } else if (mode == 2) { case 2: // outer rim average radius return 0.5*r_minor*(1.0 + x_core) + thick_rim; } else if (mode == 3) { case 3: // outer rim min radius return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); } else if (mode == 4) { case 4: // outer max radius return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); } else if (mode ==5) { case 5: // half outer thickness return 0.5*length + thick_face; } else { case 6: // half diagonal return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); }
• ## sasmodels/models/core_shell_bicelle_elliptical.py

 rd277229 "core_shell_bicelle_elliptical.c"] have_Fq = True effective_radius_type = ["equivalent sphere","outer rim average radius","outer rim min radius", "outer max radius", "half outer thickness","half diagonal"] effective_radius_type = [ "equivalent sphere", "outer rim average radius", "outer rim min radius", "outer max radius", "half outer thickness", "half diagonal", ] def random():
• ## sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c

 rd277229 effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); } else if (mode == 2) { case 2: // outer rim average radius return 0.5*r_minor*(1.0 + x_core) + thick_rim; } else if (mode == 3) { case 3: // outer rim min radius return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); } else if (mode == 4) { case 4: // outer max radius return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); } else if (mode ==5) { case 5: // half outer thickness return 0.5*length + thick_face; } else { case 6: // half diagonal return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); }
• ## sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py

 rd277229 "core_shell_bicelle_elliptical_belt_rough.c"] have_Fq = True effective_radius_type = ["equivalent sphere","outer rim average radius","outer rim min radius", "outer max radius", "half outer thickness","half diagonal"] effective_radius_type = [ "equivalent sphere", "outer rim average radius", "outer rim min radius", "outer max radius", "half outer thickness", "half diagonal", ] demo = dict(scale=1, background=0,

• ## sasmodels/models/core_shell_ellipsoid.py

 rd277229 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] have_Fq = True effective_radius_type = ["equivalent sphere","average outer curvature", "min outer radius", "max outer radius"] #def ER(radius_equat_core, x_core, thick_shell, x_polar_shell): #    """ #        Returns the effective radius used in the S*P calculation #    """ #    from .ellipsoid import ER as ellipsoid_ER #    polar_outer = radius_equat_core*x_core + thick_shell*x_polar_shell #    equat_outer = radius_equat_core + thick_shell #    return ellipsoid_ER(polar_outer, equat_outer) effective_radius_type = [ "equivalent sphere", "average outer curvature", "min outer radius", "max outer radius", ] def random():
• ## sasmodels/models/core_shell_parallelepiped.c

 ra94046f double thick_rim_a, double thick_rim_b, double thick_rim_c) { const double volume_paral = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); return cbrt(0.75*volume_paral/M_PI); const double volume = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); return cbrt(volume/M_4PI_3); } effective_radius(int mode, double length_a, double length_b, double length_c, double thick_rim_a, double thick_rim_b, double thick_rim_c) //effective_radius_type = ["equivalent sphere","half outer length_a", "half outer length_b", "half outer length_c", //                         "equivalent circular cross-section","half outer ab diagonal","half outer diagonal"] // note the core box is A*B*C with slabs ta, tb & tc on each face but missing the corners, though that fact is ignored here // in the equvalent sphere option { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return radius_from_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); } else if (mode == 2) { case 2: // half outer length a return 0.5 * length_a + thick_rim_a; } else if (mode == 3) { case 3: // half outer length b return 0.5 * length_b + thick_rim_b; } else if (mode == 4) { case 4: // half outer length c return 0.5 * length_c + thick_rim_c; } else if (mode == 5) { case 5: // equivalent circular cross-section return radius_from_crosssection(length_a, length_b, thick_rim_a, thick_rim_b); } else if (mode == 6) { case 6: // half outer ab diagonal return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b)); } else { case 7: // half outer diagonal return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b) + square(length_c+ 2.0*thick_rim_c)); }
• ## sasmodels/models/core_shell_parallelepiped.py

 rd277229 is the scattering length of the solvent. .. note:: .. note:: the code actually implements two substitutions: $d(cos\alpha)$ is source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] have_Fq = True effective_radius_type = ["equivalent sphere","half outer length_a", "half outer length_b", "half outer length_c", "equivalent circular cross-section","half outer ab diagonal","half outer diagonal"] #def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c): #    """ #        Return equivalent radius (ER) #    """ #    from .parallelepiped import ER as ER_p # #    a = length_a + 2*thick_rim_a #    b = length_b + 2*thick_rim_b #    c = length_c + 2*thick_rim_c #    return ER_p(a, b, c) # VR defaults to 1.0 effective_radius_type = [ "equivalent sphere", "half outer length_a", "half outer length_b", "half outer length_c", "equivalent circular cross-section", "half outer ab diagonal", "half outer diagonal", ] def random():
• ## sasmodels/models/core_shell_sphere.c

 rd277229 effective_radius(int mode, double radius, double thickness) { if (mode == 1) { switch (mode) { case 1: // outer radius return radius + thickness; } else { case 2: // core radius return radius; }
• ## sasmodels/models/core_shell_sphere.py

 r2cc8aa2 sld_core=1.0, sld_shell=2.0, sld_solvent=0.0) #def ER(radius, thickness): #    """ #        Equivalent radius #        @param radius: core radius #        @param thickness: shell thickness #    """ #    return radius + thickness def random(): outer_radius = 10**np.random.uniform(1.3, 4.3)

• ## sasmodels/models/cylinder.py

 rd277229 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] have_Fq = True effective_radius_type = ["equivalent sphere","radius","half length","half min dimension","half max dimension","half diagonal"] #def ER(radius, length): #    """ #        Return equivalent radius (ER) #    """ #    ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) #    return 0.5 * (ddd) ** (1. / 3.) effective_radius_type = [ "equivalent sphere", "radius", "half length", "half min dimension", "half max dimension", "half diagonal", ] def random():

• ## sasmodels/models/fuzzy_sphere.c

 rd277229 effective_radius(int mode, double radius, double fuzziness) { if (mode == 1) { switch (mode) { case 1: // radius return radius; } else { case 2: // radius + fuzziness return radius + fuzziness; }

• ## sasmodels/models/hollow_rectangular_prism.c

 ra94046f // TODO: interface to form_volume/shell_volume not yet settled static double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) shell_volume(double *total, double length_a, double b2a_ratio, double c2a_ratio, double thickness) { double length_b = length_a * b2a_ratio; double c_core = length_c - 2.0*thickness; double vol_core = a_core * b_core * c_core; double vol_total = length_a * length_b * length_c; double vol_shell = vol_total - vol_core; return vol_shell; *total = length_a * length_b * length_c; return *total - vol_core; } static double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) { double total; return shell_volume(&total, length_a, b2a_ratio, c2a_ratio, thickness); } // NOTE length_a is external dimension! { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); } else if (mode == 2) { case 2: // half length_a return 0.5 * length_a; } else if (mode == 3) { case 3: // half length_b return 0.5 * length_a*b2a_ratio; } else if (mode == 4) { case 4: // half length_c return 0.5 * length_a*c2a_ratio; } else if (mode == 5) { case 5: // equivalent outer circular cross-section return length_a*sqrt(b2a_ratio/M_PI); } else if (mode == 6) { case 6: // half ab diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); } else { case 7: // half diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); }
• ## sasmodels/models/hollow_rectangular_prism.py

 rc44b611 source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] have_Fq = True effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", "equivalent outer circular cross-section","half ab diagonal","half diagonal"] #def ER(length_a, b2a_ratio, c2a_ratio, thickness): #    """ #    Return equivalent radius (ER) #    thickness parameter not used #    """ #    b_side = length_a * b2a_ratio #    c_side = length_a * c2a_ratio # #    # surface average radius (rough approximation) #    surf_rad = sqrt(length_a * b_side / pi) # #    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) #    return 0.5 * (ddd) ** (1. / 3.) def VR(length_a, b2a_ratio, c2a_ratio, thickness): """ Return shell volume and total volume """ b_side = length_a * b2a_ratio c_side = length_a * c2a_ratio a_core = length_a - 2.0*thickness b_core = b_side - 2.0*thickness c_core = c_side - 2.0*thickness vol_core = a_core * b_core * c_core vol_total = length_a * b_side * c_side vol_shell = vol_total - vol_core return vol_total, vol_shell effective_radius_type = [ "equivalent sphere", "half length_a", "half length_b", "half length_c", "equivalent outer circular cross-section", "half ab diagonal", "half diagonal", ] def random():
• ## sasmodels/models/hollow_rectangular_prism_thin_walls.c

 rd277229 // TODO: interface to form_volume/shell_volume not yet settled static double form_volume(double length_a, double b2a_ratio, double c2a_ratio) shell_volume(double *total, double length_a, double b2a_ratio, double c2a_ratio) { double length_b = length_a * b2a_ratio; double length_c = length_a * c2a_ratio; double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); *total = length_a * length_b * length_c; return vol_shell; } static double form_volume(double length_a, double b2a_ratio, double c2a_ratio) { double total; return shell_volume(&total, length_a, b2a_ratio, c2a_ratio); } static double effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); } else if (mode == 2) { case 2: // half length_a return 0.5 * length_a; } else if (mode == 3) { case 3: // half length_b return 0.5 * length_a*b2a_ratio; } else if (mode == 4) { case 4: // half length_c return 0.5 * length_a*c2a_ratio; } else if (mode == 5) { case 5: // equivalent outer circular cross-section return length_a*sqrt(b2a_ratio/M_PI); } else if (mode == 6) { case 6: // half ab diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); } else { case 7: // half diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); }
• ## sasmodels/models/hollow_rectangular_prism_thin_walls.py

 rc44b611 source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] have_Fq = True effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", "equivalent outer circular cross-section","half ab diagonal","half diagonal"] #def ER(length_a, b2a_ratio, c2a_ratio): #    """ #        Return equivalent radius (ER) #    """ #    b_side = length_a * b2a_ratio #    c_side = length_a * c2a_ratio # #    # surface average radius (rough approximation) #    surf_rad = sqrt(length_a * b_side / pi) # #    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) #    return 0.5 * (ddd) ** (1. / 3.) def VR(length_a, b2a_ratio, c2a_ratio): """ Return shell volume and total volume """ b_side = length_a * b2a_ratio c_side = length_a * c2a_ratio vol_total = length_a * b_side * c_side vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side) return vol_shell, vol_total effective_radius_type = [ "equivalent sphere", "half length_a", "half length_b", "half length_c", "equivalent outer circular cross-section", "half ab diagonal", "half diagonal", ]
• ## sasmodels/models/mono_gauss_coil.c

 rd277229 effective_radius(int mode, double rg) { if (mode == 1) { switch (mode) { case 1: // R_g return rg; } else if (mode == 2) { case 2: // 2R_g return 2.0*rg; } else if (mode == 3) { case 3: // 3R_g return 3.0*rg; } else { case 4: // (5/3)^0.5*R_g return sqrt(5.0/3.0)*rg; } } static double gauss_coil(double qr) { const double x = qr*qr; // Use series expansion at low q for higher accuracy. We could use // smaller polynomials if we sacrifice some digits of precision or // introduce an additional series expansion around x == 1. // See explore/precision.py, gauss_coil function. #if FLOAT_SIZE>4 // DOUBLE_PRECISION // For double precision: use O(5) Pade with 0.5 cutoff (10 mad + 1 divide) if (x < 0.5) { // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] const double A1=1./12., A2=2./99., A3=1./2640., A4=1./23760., A5=-1./1995840.; const double B1=5./12., B2=5./66., B3=1./132., B4=1./2376., B5=1./95040.; return (((((A5*x + A4)*x + A3)*x + A2)*x + A1)*x + 1.) / (((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); } #else // For single precision: use O(7) Taylor with 0.8 cutoff (7 mad) if (x < 0.8) { const double C0 = +1.; const double C1 = -1./3.; const double C2 = +1./12.; const double C3 = -1./60.; const double C4 = +1./360.; const double C5 = -1./2520.; const double C6 = +1./20160.; const double C7 = -1./181440.; return ((((((C7*x + C6)*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; } #endif return 2.0 * (expm1(-x) + x)/(x*x); } double Iq(double q, double i_zero, double rg) { const double uarg = square(q*rg); const double inten; if (q == 0) { inten = i_zero; } else { inten = 2.0*i_zero * (exp(-uarg) + uarg - 1.0)/square(uarg); } return inten; return i_zero * gauss_coil(q*rg); }
• ## sasmodels/models/mono_gauss_coil.py

 rd277229 ["rg", "Ang", 75.0, [0.0, inf], "volume", "Radius of gyration"], ] # pylint: enable=bad-whitespace, line-too-long source = ["mono_gauss_coil.c"] have_Fq = False effective_radius_type = ["R_g","2R_g","3R_g","(5/3)^0.5*R_g"] effective_radius_type = ["R_g", "2R_g", "3R_g", "(5/3)^0.5*R_g"] # pylint: enable=bad-whitespace, line-too-long ## NB: Scale and Background are implicit parameters on every model #def Iq(q, i_zero, rg): #    # pylint: disable = missing-docstring #    z = (q * rg)**2 # #    with errstate(invalid='ignore'): #        inten = (i_zero * 2.0) * (exp(-z) + z - 1.0)/z**2 #        inten[q == 0] = i_zero #    return inten #Iq.vectorized = True # Iq accepts an array of q values def random():
• ## sasmodels/models/multilayer_vesicle.c

 rd277229 effective_radius(int mode, double radius, double thick_shell, double thick_solvent, double fp_n_shells) { // case 1: outer radius return radius + fp_n_shells*thick_shell + (fp_n_shells - 1.0)*thick_solvent; }
• ## sasmodels/models/multilayer_vesicle.py

 rd277229 effective_radius_type = ["outer radius"] #def ER(radius, thick_shell, thick_solvent, n_shells): #    n_shells = int(n_shells+0.5) #    return radius + n_shells * (thick_shell + thick_solvent) - thick_solvent def random(): volfraction = 10**np.random.uniform(-3, -0.5)  # scale from 0.1% to 30%

• ## sasmodels/models/onion.py

 rd277229 return np.asarray(z), np.asarray(rho) #def ER(radius_core, n_shells, thickness): #    """Effective radius""" #    n = int(n_shells[0]+0.5) #    return np.sum(thickness[:n], axis=0) + radius_core demo = { "sld_solvent": 2.2,
• ## sasmodels/models/parallelepiped.c

 rd277229 effective_radius(int mode, double length_a, double length_b, double length_c) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return cbrt(0.75*length_a*length_b*length_c/M_PI); } else if (mode == 2) { case 2: // half length_a return 0.5 * length_a; } else if (mode == 3) { case 3: // half length_b return 0.5 * length_b; } else if (mode == 4) { case 4: // half length_c return 0.5 * length_c; } else if (mode == 5) { case 5: // equivalent circular cross-section return sqrt(length_a*length_b/M_PI); } else if (mode == 6) { case 6: // half ab diagonal return 0.5*sqrt(length_a*length_a + length_b*length_b); } else { case 7: // half diagonal return 0.5*sqrt(length_a*length_a + length_b*length_b + length_c*length_c); } } static void
• ## sasmodels/models/parallelepiped.py

 rd277229 ensuring that the inequality $A < B < C$ is not violated,  The calculation will not report an error, but the results may be not correct. .. _parallelepiped-orientation: source = ["lib/gauss76.c", "parallelepiped.c"] have_Fq = True effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", "equivalent circular cross-section","half ab diagonal","half diagonal"] #def ER(length_a, length_b, length_c): #    """ #    Return effective radius (ER) for P(q)*S(q) #    """ #    # now that axes can be in any size order, need to sort a,b,c #    # where a~b and c is either much smaller or much larger #    abc = np.vstack((length_a, length_b, length_c)) #    abc = np.sort(abc, axis=0) #    selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) #    length = np.where(selector, abc[0], abc[2]) #    # surface average radius (rough approximation) #    radius = sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) # #    ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) #    return 0.5 * (ddd) ** (1. / 3.) # VR defaults to 1.0 effective_radius_type = [ "equivalent sphere", "half length_a", "half length_b", "half length_c", "equivalent circular cross-section", "half ab diagonal", "half diagonal", ] def random():
• ## sasmodels/models/pringle.c

 rd277229 effective_radius(int mode, double radius, double thickness, double alpha, double beta) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return cbrt(0.75*radius*radius*thickness); } else { case 2: // radius return radius; }
• ## sasmodels/models/pringle.py

 rd277229 source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", \ source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", "lib/sas_JN.c", "lib/gauss76.c", "pringle.c"] effective_radius_type = ["equivalent sphere","radius"] #def ER(radius, thickness, alpha, beta): #    """ #    Return equivalent radius (ER) #    """ #    ddd = 0.75 * radius * (2 * radius * thickness + (thickness + radius) \ #                           * (thickness + pi * radius)) #    return 0.5 * (ddd) ** (1. / 3.) effective_radius_type = ["equivalent sphere", "radius"] def random():

• ## sasmodels/models/rectangular_prism.c

 rd277229 effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) { if (mode == 1) { switch (mode) { case 1: // equivalent sphere return cbrt(0.75*cube(length_a)*b2a_ratio*c2a_ratio/M_PI); } else if (mode == 2) { case 2: // half length_a return 0.5 * length_a; } else if (mode == 3) { case 3: // half length_b return 0.5 * length_a*b2a_ratio; } else if (mode == 4) { case 4: // half length_c return 0.5 * length_a*c2a_ratio; } else if (mode == 5) { case 5: // equivalent circular cross-section return length_a*sqrt(b2a_ratio/M_PI); } else if (mode == 6) { case 6: // half ab diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); } else { case 7: // half diagonal return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); }
• ## sasmodels/models/rectangular_prism.py

 rd277229 source = ["lib/gauss76.c", "rectangular_prism.c"] have_Fq = True effective_radius_type = ["equivalent sphere","half length_a", "half length_b", "half length_c", "equivalent circular cross-section","half ab diagonal","half diagonal"] #def ER(length_a, b2a_ratio, c2a_ratio): #    """ #        Return equivalent radius (ER) #    """ #    b_side = length_a * b2a_ratio #    c_side = length_a * c2a_ratio # #    # surface average radius (rough approximation) #    surf_rad = sqrt(length_a * b_side / pi) # #    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) #    return 0.5 * (ddd) ** (1. / 3.) effective_radius_type = [ "equivalent sphere", "half length_a", "half length_b", "half length_c", "equivalent circular cross-section", "half ab diagonal", "half diagonal", ] def random():

• ## sasmodels/models/spherical_sld.c

 rd277229 static double form_volume( double fp_n_shells, double thickness[], double interface[]) { int n_shells= (int)(fp_n_shells + 0.5); double r = 0.0; for (int i=0; i < n_shells; i++) { r += thickness[i] + interface[i]; } return M_4PI_3*cube(r); } static double effective_radius(int mode, double fp_n_shells, double thickness[], double interface[]) outer_radius(double fp_n_shells, double thickness[], double interface[]) { int n_shells= (int)(fp_n_shells + 0.5); } return r; } static double form_volume( double fp_n_shells, double thickness[], double interface[]) { return M_4PI_3*cube(outer_radius(fp_n_shells, thickness, interface)); } static double effective_radius(int mode, double fp_n_shells, double thickness[], double interface[]) { // case 1: outer radius return outer_radius(fp_n_shells, thickness, interface); }
• ## sasmodels/models/spherical_sld.py

 re8eff7b 0: erf($\nu z$) 1: Rpow($z^\nu$) 2: Lpow($z^\nu$) 3: Rexp($-\nu z$) 4: Lexp($-\nu z$) #def ER(n_shells, thickness, interface): #    """Effective radius""" #    n_shells = int(n_shells + 0.5) #    total = (np.sum(thickness[:n_shells], axis=1) #             + np.sum(interface[:n_shells], axis=1)) #    return total demo = { "n_shells": 5,