Changeset 0b717c5 in sasmodels


Ignore:
Timestamp:
Oct 14, 2016 12:53:59 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
5bddd89
Parents:
ec9d329
Message:

bcc/fcc/sc: slightly slower but more robust calculation of Zq

Location:
sasmodels/models
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/bcc_paracrystal.c

    r11ca2ab r0b717c5  
    9898 
    9999    const double qd = 0.5*q*dnn; 
    100     const double exp_qd = exp(0.5*square(qd*d_factor)*(a1*a1 + a2*a2 + a3*a3)); 
    101     const double sinh_qd = 0.5*exp_qd - 0.5/exp_qd; 
    102     const double cosh_qd = 0.5*exp_qd + 0.5/exp_qd; 
    103  
    104     const double Zq = sinh_qd/(cosh_qd - cos(qd*a1)) 
    105                     * sinh_qd/(cosh_qd - cos(qd*a2)) 
    106                     * sinh_qd/(cosh_qd - cos(qd*a3)); 
     100    const double arg = 0.5*square(qd*d_factor)*(a1*a1 + a2*a2 + a3*a3); 
     101    const double tanh_qd = tanh(arg); 
     102    const double cosh_qd = cosh(arg); 
     103    const double Zq = tanh_qd/(1. - cos(qd*a1)/cosh_qd) 
     104                    * tanh_qd/(1. - cos(qd*a2)/cosh_qd) 
     105                    * tanh_qd/(1. - cos(qd*a3)/cosh_qd); 
    107106 
    108107    const double Fq = sphere_form(q,radius,sld,solvent_sld)*Zq; 
  • sasmodels/models/fcc_paracrystal.c

    rec9d329 r0b717c5  
    9797    const double a3 = cos_a2 + cos_a1; 
    9898    const double qd = 0.5*q*dnn; 
    99     const double exp_qd = exp(0.5*square(qd*d_factor)*(a1*a1 + a2*a2 + a3*a3)); 
    100     const double sinh_qd = 0.5*exp_qd - 0.5/exp_qd; 
    101     const double cosh_qd = 0.5*exp_qd + 0.5/exp_qd; 
     99    const double arg = 0.5*square(qd*d_factor)*(a1*a1 + a2*a2 + a3*a3); 
     100    const double tanh_qd = tanh(arg); 
     101    const double cosh_qd = cosh(arg); 
     102    const double Zq = tanh_qd/(1. - cos(qd*a1)/cosh_qd) 
     103                    * tanh_qd/(1. - cos(qd*a2)/cosh_qd) 
     104                    * tanh_qd/(1. - cos(qd*a3)/cosh_qd); 
    102105 
    103     const double Zq = sinh_qd/(cosh_qd - cos(qd*a1)) 
    104                     * sinh_qd/(cosh_qd - cos(qd*a2)) 
    105                     * sinh_qd/(cosh_qd - cos(qd*a3)); 
     106    //if (isnan(Zq)) printf("q:(%g,%g) qd: %g a1: %g a2: %g a3: %g arg: %g\n", qx, qy, qd, a1, a2, a3, arg); 
    106107 
    107108    const double Fq = sphere_form(q,radius,sld,solvent_sld)*Zq; 
  • sasmodels/models/sc_paracrystal.c

    r11ca2ab r0b717c5  
    116116 
    117117    const double qd = q*dnn; 
    118     const double exp_qd = exp(0.5*square(qd*d_factor)); 
    119     const double sinh_qd = 0.5*exp_qd - 0.5/exp_qd; 
    120     const double cosh_qd = 0.5*exp_qd + 0.5/exp_qd; 
    121  
    122     const double Zq = sinh_qd/(cosh_qd - cos(qd*cos_a1)) 
    123                     * sinh_qd/(cosh_qd - cos(qd*cos_a2)) 
    124                     * sinh_qd/(cosh_qd - cos(qd*cos_a3)); 
     118    const double arg = 0.5*square(qd*d_factor); 
     119    const double tanh_qd = tanh(arg); 
     120    const double cosh_qd = cosh(arg); 
     121    const double Zq = tanh_qd/(1. - cos(qd*cos_a1)/cosh_qd) 
     122                    * tanh_qd/(1. - cos(qd*cos_a2)/cosh_qd) 
     123                    * tanh_qd/(1. - cos(qd*cos_a3)/cosh_qd); 
    125124 
    126125    const double Fq = sphere_form(q, radius, sphere_sld, solvent_sld)*Zq; 
Note: See TracChangeset for help on using the changeset viewer.