Ignore:
Timestamp:
Nov 6, 2018 2:10:43 PM (5 years ago)
Author:
grethevj
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
cf3d0ce
Parents:
5024a56
Message:

updated ER functions including cylinder excluded volume, to match 4.x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_parallelepiped.c

    rd42dd4a r99658f6  
    2828 
    2929static double 
     30radius_from_excluded_volume(double length_a, double length_b, double length_c, 
     31                   double thick_rim_a, double thick_rim_b, double thick_rim_c) 
     32{ 
     33    double r_equiv, length; 
     34    double lengths[3] = {length_a+thick_rim_a, length_b+thick_rim_b, length_c+thick_rim_c}; 
     35    double lengthmax = fmax(lengths[0],fmax(lengths[1],lengths[2])); 
     36    double length_1 = lengthmax; 
     37    double length_2 = lengthmax; 
     38    double length_3 = lengthmax; 
     39 
     40    for(int ilen=0; ilen<3; ilen++) { 
     41        if (lengths[ilen] < length_1) { 
     42            length_2 = length_1; 
     43            length_1 = lengths[ilen]; 
     44            } else { 
     45                if (lengths[ilen] < length_2) { 
     46                        length_2 = lengths[ilen]; 
     47                } 
     48            } 
     49    } 
     50    if(length_2-length_1 > length_3-length_2) { 
     51        r_equiv = sqrt(length_2*length_3/M_PI); 
     52        length  = length_1; 
     53    } else  { 
     54        r_equiv = sqrt(length_1*length_2/M_PI); 
     55        length  = length_3; 
     56    } 
     57 
     58    return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length + (r_equiv + length)*(M_PI*r_equiv + length))); 
     59} 
     60 
     61static double 
    3062radius_from_volume(double length_a, double length_b, double length_c, 
    3163                   double thick_rim_a, double thick_rim_b, double thick_rim_c) 
     
    4880    switch (mode) { 
    4981    default: 
    50     case 1: // equivalent sphere 
     82    case 1: // equivalent cylinder excluded volume 
     83        return radius_from_excluded_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 
     84    case 2: // equivalent volume sphere 
    5185        return radius_from_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 
    52     case 2: // half outer length a 
     86    case 3: // half outer length a 
    5387        return 0.5 * length_a + thick_rim_a; 
    54     case 3: // half outer length b 
     88    case 4: // half outer length b 
    5589        return 0.5 * length_b + thick_rim_b; 
    56     case 4: // half outer length c 
     90    case 5: // half outer length c 
    5791        return 0.5 * length_c + thick_rim_c; 
    58     case 5: // equivalent circular cross-section 
     92    case 6: // equivalent circular cross-section 
    5993        return radius_from_crosssection(length_a, length_b, thick_rim_a, thick_rim_b); 
    60     case 6: // half outer ab diagonal 
     94    case 7: // half outer ab diagonal 
    6195        return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b)); 
    62     case 7: // half outer diagonal 
     96    case 8: // half outer diagonal 
    6397        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)); 
    6498    } 
Note: See TracChangeset for help on using the changeset viewer.