Changeset 380e8c9 in sasmodels
- Timestamp:
- Mar 24, 2016 10:56:44 AM (9 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:
- 151f3bc
- Parents:
- 60eab2a
- Location:
- sasmodels
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
re9b1663d r380e8c9 306 306 Format the parameter list for printing. 307 307 """ 308 if is2d:309 exclude = lambda n: False310 else:311 par1d = model_info['par_type']['1d']312 exclude = lambda n: n not in par1d313 308 lines = [] 314 for p in model_info['parameters']: 315 if exclude(p.name): continue 309 for p in model_info['parameters'].type['2d' if is2d else '1d']: 316 310 fields = dict( 317 311 value=pars.get(p.name, p.default), -
sasmodels/core.py
r60eab2a r380e8c9 177 177 value = values.get(parameter.name, parameter.default) 178 178 if parameter.type not in ('volume', 'orientation'): 179 return np.array([value]), np.array([1.0])179 return [value], [1.0] 180 180 relative = parameter.type == 'volume' 181 181 limits = parameter.limits … … 226 226 active = lambda name: True 227 227 228 vw_pairs = [(get_weights(p, pars) if active(p.name) else ([p.default], [1 ]))228 vw_pairs = [(get_weights(p, pars) if active(p.name) else ([p.default], [1.0])) 229 229 for p in kernel.info['parameters']] 230 230 values, weights = zip(*vw_pairs) -
sasmodels/generate.py
r60eab2a r380e8c9 614 614 # Note: the reversing view, x[::-1], does not require a copy 615 615 pd_length = np.array([len(w) for w in weights]) 616 print (pd_length)617 print (weights)618 616 pd_offset = np.cumsum(np.hstack((0, pd_length))) 619 617 pd_isvol = np.array([p.type=='volume' for p in pars]) 620 618 idx = np.argsort(pd_length)[::-1][:max_pd] 621 print (idx)622 619 pd_stride = np.cumprod(np.hstack((1, pd_length[idx][:-1]))) 623 620 par_offsets = np.cumsum(np.hstack((2, pd_length)))[:-1] 621 coord_offset = par_offset+npars 622 fast_coord_offset = par_offset+2*npars 624 623 625 624 theta_par = -1 … … 637 636 details[par_offset+0*npars:par_offset+1*npars] = par_offsets 638 637 details[par_offset+1*npars:par_offset+2*npars] = 0 # no coordination for most 639 details[par_offset+2*npars:par_offset+3*npars] = 0 # no fast coord with 0640 coord_offset = par_offset+1*npars641 638 for k,parameter_num in enumerate(idx): 642 639 details[coord_offset+parameter_num] = 2**k 640 details[fast_coord_offset] = idx[0] 641 details[fast_coord_offset+1:fast_coord_offset+npars] = 0 # no fast coord with 0 643 642 details[constants_offset] = 1 # fast_coord_count: one fast index 644 643 details[constants_offset+1] = theta_par 645 print ("details",details) 644 print("polydispersity details") 645 print_details(model_info, details) 646 646 return details 647 648 def print_details(model_info, details): 649 max_pd = model_info['max_pd'] 650 pars = model_info['parameters'].kernel_pars() 651 npars = len(pars) 652 par_offset = 5*max_pd 653 constants_offset = par_offset + 3*npars 654 655 print("pd_par", details[0*max_pd:1*max_pd]) 656 print("pd_length", details[1*max_pd:2*max_pd]) 657 print("pd_offset", details[2*max_pd:3*max_pd]) 658 print("pd_stride", details[3*max_pd:4*max_pd]) 659 print("pd_isvol", details[4*max_pd:5*max_pd]) 660 print("par_offsets", details[par_offset+0*npars:par_offset+1*npars]) 661 print("par_coord", details[par_offset+1*npars:par_offset+2*npars]) 662 print("fast_coord_pars", details[par_offset+2*npars:par_offset+3*npars]) 663 print("fast_coord_count", details[constants_offset]) 664 print("theta par", details[constants_offset+1]) 647 665 648 666 def constrained_poly_details(model_info, weights, constraints): -
sasmodels/kernel_header.c
r5cf3c33 r380e8c9 103 103 # define M_4PI_3 4.18879020478639 104 104 #endif 105 static double square(double x) { return x*x; }106 static double cube(double x) { return x*x*x; }107 static double sinc(double x) { return x==0 ? 1.0 : sin(x)/x; }105 static inline double square(double x) { return x*x; } 106 static inline double cube(double x) { return x*x*x; } 107 static inline double sinc(double x) { return x==0 ? 1.0 : sin(x)/x; } 108 108 -
sasmodels/kernel_iq.c
r60eab2a r380e8c9 54 54 double *pvec = (double *)(&local_values); // Alias named parameters with a vector 55 55 56 #if MAX_PD > 0 57 if (problem->pd_length[0] == 1) { 58 #endif // MAX_PD > 0 56 // Monodisperse computation 57 if (pd_stop == 1) { 59 58 // Shouldn't need to copy!! 60 59 for (int k=0; k < NPARS; k++) { … … 72 71 } 73 72 return; 73 } 74 74 75 #if MAX_PD > 0 75 } 76 77 // polydispersity loop index positions 78 local int offset[NPARS]; // NPARS excludes scale/background 79 80 printf("Entering polydispersity\n"); 76 77 printf("Entering polydispersity\n"); 81 78 // Since we are no longer looping over the entire polydispersity hypercube 82 79 // for each q, we need to track the normalization values for each q in a … … 107 104 // Location in the polydispersity hypercube, one index per dimension. 108 105 local int pd_index[MAX_PD]; 106 107 // polydispersity loop index positions 108 local int offset[NPARS]; // NPARS excludes scale/background 109 109 110 110 // Trigger the reset behaviour that happens at the end the fast loop … … 132 132 for (int k=1; k < MAX_PD; k++) { 133 133 pd_index[k] = (loop_index%problem->pd_length[k])/problem->pd_stride[k]; 134 const double wi = weights[problem->pd_offset[ 0]+pd_index[0]];134 const double wi = weights[problem->pd_offset[k]+pd_index[k]]; 135 135 partial_weight *= wi; 136 136 if (problem->pd_isvol[k]) partial_volweight *= wi; 137 137 } 138 printf("slow %d: ", loop_index); 138 139 for (int k=0; k < NPARS; k++) { 139 140 int coord = problem->par_coord[k]; … … 149 150 offset[k] = this_offset; 150 151 pvec[k] = values[this_offset]; 151 } 152 printf("p[%d]=v[%d]=%g ", k, offset[k], pvec[k]); 153 } 154 printf("\n"); 152 155 weight = partial_weight * weights[problem->pd_offset[0]+pd_index[0]]; 153 156 if (problem->theta_par >= 0) { … … 157 160 weight *= spherical_correction; 158 161 } 162 pd_index[0] += 1; 159 163 160 164 } else { 161 165 162 166 // INCREMENT INDICES 163 pd_index[0] += 1;164 167 const double wi = weights[problem->pd_offset[0]+pd_index[0]]; 165 168 weight = partial_weight*wi; 166 169 if (problem->pd_isvol[0]) vol_weight *= wi; 170 printf("fast %d: ", loop_index); 167 171 for (int k=0; k < problem->fast_coord_count; k++) { 168 printf("fast loop %d coord %d idx %d ?%d offset %d %g\n", 169 k,problem->fast_coord_pars[k],pd_index[0], 170 problem->fast_coord_pars[k], 171 offset[problem->fast_coord_pars[k]], 172 values[offset[problem->fast_coord_pars[k]]] 173 ); 174 pvec[problem->fast_coord_pars[k]] 175 = values[offset[problem->fast_coord_pars[k]]++]; 176 177 } 178 if (problem->theta_par ==problem->pd_par[0]) { 172 const int pindex = problem->fast_coord_pars[k]; 173 pvec[pindex] = values[++offset[pindex]]; 174 printf("p[%d]=v[%d]=%g ", pindex, offset[pindex], pvec[pindex]); 175 } 176 printf("\n"); 177 if (problem->theta_par == problem->pd_par[0]) { 179 178 weight *= fabs(cos(M_PI_180*pvec[problem->theta_par])); 180 179 } 180 pd_index[0] += 1; 181 181 } 182 182 #ifdef INVALID … … 201 201 } 202 202 203 // Makes anormalization available for the next round203 // Make normalization available for the next round 204 204 result[nq] = norm; 205 205 result[nq+1] = vol; 206 206 result[nq+2] = norm_vol; 207 207 208 // End of the PD loop we can normalize208 // End of the PD loop we can normalize 209 209 if (pd_stop >= problem->pd_stride[MAX_PD-1]) { 210 210 #ifdef USE_OPENMP -
sasmodels/kerneldll.py
re69b36f r380e8c9 270 270 max_pd = self.info['max_pd'] 271 271 start, stop = 0, details[4*max_pd-1] 272 print(details) 272 print("in kerneldll") 273 print("details", details) 274 print("weights", weights) 275 print("values", values) 273 276 args = [ 274 277 self.q_input.nq, # nq
Note: See TracChangeset
for help on using the changeset viewer.