Changeset b8080e1 in sasview for src/sas/sascalc/calculator/c_extensions/sld2i.c
- Timestamp:
- Aug 29, 2018 10:01:23 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 9463ca2
- Parents:
- ce30949
- git-author:
- Piotr Rozyczko <rozyczko@…> (08/29/18 09:59:56)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (08/29/18 10:01:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i.c
rf54e82cf rb8080e1 25 25 * @param s_theta: angle (from x-axis) of the up spin in degree 26 26 */ 27 void initGenI(GenI* this, int npix, double* x, double* y, double* z, double* sldn,27 void initGenI(GenI* this, int is_avg, int npix, double* x, double* y, double* z, double* sldn, 28 28 double* mx, double* my, double* mz, double* voli, 29 29 double in_spin, double out_spin, 30 30 double s_theta) { 31 this->is_avg = is_avg; 31 32 this->n_pix = npix; 32 33 this->x_val = x; … … 63 64 Cplx temp_fi; 64 65 66 double count = 0.0; 65 67 int i, j; 66 67 double count = 0.0;68 //check if this computation is for averaging69 68 70 69 cassign(&iqr, 0.0, 0.0); … … 78 77 79 78 // Loop over q-values and multiply apply matrix 79 80 //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 80 81 for(i=0; i<npoints; i++){ 81 82 //I_out[i] = 0.0; … … 86 87 //printf("i: %d\n", i); 87 88 //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 89 88 90 for(j=0; j<this->n_pix; j++){ 89 91 if (this->sldn_val[j]!=0.0 … … 143 145 I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 144 146 } 145 //printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0],mz_val[0]);147 //printf("count = %d %g %g %g %g\n", count, this->sldn_val[0],this->mx_val[0], this->my_val[0], this->mz_val[0]); 146 148 } 147 149 /** … … 154 156 // Assumes that q doesn't have qz component and sld_n is all real 155 157 //double Pi = 4.0*atan(1.0); 156 int is_sym = this->n_pix < 0;157 158 double qr = 0.0; 158 159 double sumj; 159 160 double sld_j = 0.0; 160 161 double count = 0.0; 161 int n_pix = is_sym ? -this->n_pix : this->n_pix; 162 int i, j, k; 163 162 164 //Assume that pixel volumes are given in vol_pix in A^3 unit 163 165 // Loop over q-values and multiply apply matrix 164 int i, j, k;165 166 for(i=0; i<npoints; i++){ 166 167 sumj =0.0; 167 for(j=0; j< n_pix; j++){168 for(j=0; j<this->n_pix; j++){ 168 169 //Isotropic: Assumes all slds are real (no magnetic) 169 170 //Also assumes there is no polarization: No dependency on spin 170 if ( is_sym== 1){171 if (this->is_avg == 1){ 171 172 // approximation for a spherical symmetric particle 172 173 qr = sqrt(this->x_val[j]*this->x_val[j]+this->y_val[j]*this->y_val[j]+this->z_val[j]*this->z_val[j])*q[i]; … … 182 183 //full calculation 183 184 //pragma omp parallel for 184 for(k=0; k< n_pix; k++){185 for(k=0; k<this->n_pix; k++){ 185 186 sld_j = this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 186 187 qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ … … 201 202 } 202 203 I_out[i] = sumj; 203 if ( is_sym == 1){204 if (this->is_avg == 1) { 204 205 I_out[i] *= sumj; 205 206 } 206 207 I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 207 208 } 208 //printf 209 //printf("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 209 210 }
Note: See TracChangeset
for help on using the changeset viewer.