Ignore:
Timestamp:
Aug 29, 2018 10:01:23 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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)
Message:

cherry picking sascalc changes from master SASVIEW-996
minor unit test fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/calculator/c_extensions/sld2i.c

    rf54e82cf rb8080e1  
    2525 * @param s_theta: angle (from x-axis) of the up spin in degree 
    2626 */ 
    27 void initGenI(GenI* this, int npix, double* x, double* y, double* z, double* sldn, 
     27void initGenI(GenI* this, int is_avg, int npix, double* x, double* y, double* z, double* sldn, 
    2828                        double* mx, double* my, double* mz, double* voli, 
    2929                        double in_spin, double out_spin, 
    3030                        double s_theta) { 
     31        this->is_avg = is_avg; 
    3132        this->n_pix = npix; 
    3233        this->x_val = x; 
     
    6364        Cplx temp_fi; 
    6465 
     66        double count = 0.0; 
    6567        int i, j; 
    66  
    67         double count = 0.0; 
    68         //check if this computation is for averaging 
    6968 
    7069        cassign(&iqr, 0.0, 0.0); 
     
    7877 
    7978        // Loop over q-values and multiply apply matrix 
     79 
     80        //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 
    8081        for(i=0; i<npoints; i++){ 
    8182                //I_out[i] = 0.0; 
     
    8687                //printf("i: %d\n", i); 
    8788                //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 
     89 
    8890                for(j=0; j<this->n_pix; j++){ 
    8991                        if (this->sldn_val[j]!=0.0 
     
    143145                I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 
    144146        } 
    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]); 
    146148} 
    147149/** 
     
    154156        // Assumes that q doesn't have qz component and sld_n is all real 
    155157        //double Pi = 4.0*atan(1.0); 
    156         int is_sym = this->n_pix < 0; 
    157158        double qr = 0.0; 
    158159        double sumj; 
    159160        double sld_j = 0.0; 
    160161        double count = 0.0; 
    161         int n_pix = is_sym ? -this->n_pix : this->n_pix; 
     162        int i, j, k; 
     163 
    162164        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    163165        // Loop over q-values and multiply apply matrix 
    164     int i, j, k; 
    165166        for(i=0; i<npoints; i++){ 
    166167                sumj =0.0; 
    167                 for(j=0; j<n_pix; j++){ 
     168                for(j=0; j<this->n_pix; j++){ 
    168169                        //Isotropic: Assumes all slds are real (no magnetic) 
    169170                        //Also assumes there is no polarization: No dependency on spin 
    170                         if (is_sym == 1){ 
     171                        if (this->is_avg == 1){ 
    171172                                // approximation for a spherical symmetric particle 
    172173                                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]; 
     
    182183                                //full calculation 
    183184                                //pragma omp parallel for 
    184                                 for(k=0; k<n_pix; k++){ 
     185                                for(k=0; k<this->n_pix; k++){ 
    185186                                        sld_j =  this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 
    186187                                        qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ 
     
    201202                } 
    202203                I_out[i] = sumj; 
    203                 if (is_sym == 1){ 
     204                if (this->is_avg == 1) { 
    204205                        I_out[i] *= sumj; 
    205206                } 
    206207                I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 
    207208        } 
    208         //printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 
     209        //printf("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]); 
    209210} 
Note: See TracChangeset for help on using the changeset viewer.