Changeset 34756fd in sasmodels
- Timestamp:
- Dec 3, 2014 5:04:40 PM (10 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3699587, 8a3e0af
- Parents:
- 34d49af
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
compare_many.py
r216a9e1 r34756fd 9 9 eval_opencl, eval_ctypes, make_data) 10 10 11 def get_stats(target, model_eval, name, pars, data, index, dtype, cutoff): 12 value, _ = model_eval(name, pars, data, dtype='single', cutoff=cutoff) 11 def get_stats(target, value, index): 13 12 resid = abs(value-target)[index] 14 13 relerr = resid/target[index] … … 45 44 46 45 env = environment() 47 gpu_single = get_stats(target, eval_opencl, name, pars, data, index, 'single', cutoff) 46 gpu_single_value,_ = eval_opencl(name, pars, data, dtype='single', cutoff=cutoff) 47 gpu_single = get_stats(target, gpu_single_value, index) 48 48 if env.has_double: 49 gpu_double = get_stats(target, eval_opencl, name, pars, data, index, 'double', cutoff) 49 gpu_double_value,_ = eval_opencl(name, pars, data, dtype='double', cutoff=cutoff) 50 gpu_double = get_stats(target, gpu_double_value, index) 50 51 else: 51 52 gpu_double = [0]*len(gpu_single) 52 cpu_double = get_stats(target, eval_ctypes, name, pars, data, index, 'double', cutoff) 53 cpu_double_value,_ = eval_ctypes(name, pars, data, dtype='double', cutoff=cutoff) 54 cpu_double = get_stats(target, cpu_double_value, index) 55 single_double = get_stats(cpu_double_value, gpu_single_value, index) 53 56 54 values = list(gpu_single) + list(gpu_double) + list(cpu_double) + [v for _,v in sorted(pars.items())] 57 values = (list(gpu_single) + list(gpu_double) + list(cpu_double) 58 + list(single_double) + [v for _,v in sorted(pars.items())]) 55 59 if gpu_single[0] > 5e-5: 56 60 if first: 57 print_column_headers(pars,'GPU single|GPU double|CPU double '.split('|'))61 print_column_headers(pars,'GPU single|GPU double|CPU double|single/double'.split('|')) 58 62 first = False 59 63 print(("%d,"%seed)+','.join("%g"%v for v in values)) -
sasmodels/models/capped_cylinder.c
r994d77f r34756fd 52 52 { 53 53 // cap radius should never be less than radius when this is called 54 // Note: cap volume = pi hc/6 * (3 a^2 + hc^2), where a is the cylinder 55 // radius and hc is the height of the cap. Multiply by two for both ends. 56 // So: 57 // cap V = pi hc (r^2 + hc^2/3) 58 // cylinder V = pi r^2 L 59 // V = cylinder V + cap V 54 55 // Note: volume V = 2*V_cap + V_cyl 56 // 57 // V_cyl = pi r_cyl^2 L 58 // V_cap = 1/6 pi h_c (3 r_cyl^2 + h_c^2) = 1/3 pi h_c^2 (3 r_cap - h_c) 59 // 60 // The docs for capped cylinder give the volume as: 61 // V = pi r^2 L + 2/3 pi (R-h)^2 (2R + h) 62 // where r_cap=R and h = R - h_c. 63 // 64 // The first part is clearly V_cyl. The second part requires some work: 65 // (R-h)^2 => h_c^2 66 // (2R+h) => 2R+ h_c-h_c + h => 2R + (R-h)-hc + h => 3R-h_c 67 // And so: 68 // 2/3 pi (R-h)^2 (2R + h) => 2/3 pi h_c^2 (3 r_cap - h_c) 69 // which is 2 V_cap, using the second form above. 70 // 71 // In this function we are going to use the first form of V_cap 72 // 73 // V = V_cyl + 2 V_cap 60 74 // = pi r^2 L + pi hc (r^2 + hc^2/3) 61 // = pi *(r^2 (L+hc) + hc^3/3)75 // = pi (r^2 (L+hc) + hc^3/3) 62 76 const double hc = cap_radius - sqrt(cap_radius*cap_radius - radius*radius); 63 77 return M_PI*(radius*radius*(length+hc) + 0.333333333333333*hc*hc*hc);
Note: See TracChangeset
for help on using the changeset viewer.