Changeset 99658f6 in sasmodels for sasmodels/models/parallelepiped.c
- Timestamp:
- Nov 6, 2018 2:10:43 PM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/parallelepiped.c
rd42dd4a r99658f6 6 6 7 7 static double 8 radius_from_excluded_volume(double length_a, double length_b, double length_c) 9 { 10 double r_equiv, length; 11 double lengths[3] = {length_a, length_b, length_c}; 12 double lengthmax = fmax(lengths[0],fmax(lengths[1],lengths[2])); 13 double length_1 = lengthmax; 14 double length_2 = lengthmax; 15 double length_3 = lengthmax; 16 17 for(int ilen=0; ilen<3; ilen++) { 18 if (lengths[ilen] < length_1) { 19 length_2 = length_1; 20 length_1 = lengths[ilen]; 21 } else { 22 if (lengths[ilen] < length_2) { 23 length_2 = lengths[ilen]; 24 } 25 } 26 } 27 if(length_2-length_1 > length_3-length_2) { 28 r_equiv = sqrt(length_2*length_3/M_PI); 29 length = length_1; 30 } else { 31 r_equiv = sqrt(length_1*length_2/M_PI); 32 length = length_3; 33 } 34 35 return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length + (r_equiv + length)*(M_PI*r_equiv + length))); 36 } 37 38 static double 8 39 effective_radius(int mode, double length_a, double length_b, double length_c) 9 40 { 10 41 switch (mode) { 11 42 default: 12 case 1: // equivalent sphere 43 case 1: // equivalent cylinder excluded volume 44 return radius_from_excluded_volume(length_a,length_b,length_c); 45 case 2: // equivalent volume sphere 13 46 return cbrt(length_a*length_b*length_c/M_4PI_3); 14 case 2: // half length_a47 case 3: // half length_a 15 48 return 0.5 * length_a; 16 case 3: // half length_b49 case 4: // half length_b 17 50 return 0.5 * length_b; 18 case 4: // half length_c51 case 5: // half length_c 19 52 return 0.5 * length_c; 20 case 5: // equivalent circular cross-section53 case 6: // equivalent circular cross-section 21 54 return sqrt(length_a*length_b/M_PI); 22 case 6: // half ab diagonal55 case 7: // half ab diagonal 23 56 return 0.5*sqrt(length_a*length_a + length_b*length_b); 24 case 7: // half diagonal57 case 8: // half diagonal 25 58 return 0.5*sqrt(length_a*length_a + length_b*length_b + length_c*length_c); 26 59 }
Note: See TracChangeset
for help on using the changeset viewer.