Changeset 71b751d in sasmodels for sasmodels/models/spherical_sld.c


Ignore:
Timestamp:
Aug 14, 2018 10:09:34 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
86aa992
Parents:
2f8cbb9
Message:

update remaining form factors to use Fq interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/spherical_sld.c

    r3330bb4 r71b751d  
    101101} 
    102102 
     103static void Fq( 
     104    double q, 
     105    double *F1, 
     106    double *F2, 
     107    double fp_n_shells, 
     108    double sld_solvent, 
     109    double sld[], 
     110    double thickness[], 
     111    double interface[], 
     112    double shape[], 
     113    double nu[], 
     114    double fp_n_steps) 
     115{ 
     116    // iteration for # of shells + core + solvent 
     117    int n_shells = (int)(fp_n_shells + 0.5); 
     118    int n_steps = (int)(fp_n_steps + 0.5); 
     119    double f=0.0; 
     120    double r=0.0; 
     121    for (int shell=0; shell<n_shells; shell++){ 
     122        const double sld_l = sld[shell]; 
     123 
     124        // uniform shell; r=0 => r^3=0 => f=0, so works for core as well. 
     125        f -= M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 
     126        r += thickness[shell]; 
     127        f += M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 
     128 
     129        // iterate over sub_shells in the interface 
     130        const double dr = interface[shell]/n_steps; 
     131        const double delta = (shell==n_shells-1 ? sld_solvent : sld[shell+1]) - sld_l; 
     132        const double nu_shell = fmax(fabs(nu[shell]), 1.e-14); 
     133        const int shape_shell = (int)(shape[shell]); 
     134 
     135        // if there is no interface the equations don't work 
     136        if (dr == 0.) continue; 
     137 
     138        double sld_in = sld_l; 
     139        for (int step=1; step <= n_steps; step++) { 
     140            // find sld_i at the outer boundary of sub-shell step 
     141            //const double z = (double)step/(double)n_steps; 
     142            const double z = (double)step/(double)n_steps; 
     143            const double fraction = blend(shape_shell, nu_shell, z); 
     144            const double sld_out = fraction*delta + sld_l; 
     145            // calculate slope 
     146            const double slope = (sld_out - sld_in)/dr; 
     147            const double contrast = sld_in - slope*r; 
     148 
     149            // iteration for the left and right boundary of the shells 
     150            f -= f_linear(q, r, contrast, slope); 
     151            r += dr; 
     152            f += f_linear(q, r, contrast, slope); 
     153            sld_in = sld_out; 
     154        } 
     155    } 
     156    // add in solvent effect 
     157    f -= M_4PI_3 * cube(r) * sld_solvent * sas_3j1x_x(q*r); 
     158 
     159    *F1 = 1e-2*f; 
     160    *F2 = 1e-4*f*f; 
     161} 
Note: See TracChangeset for help on using the changeset viewer.