Changeset b36e7c7 in sasview for src/sas/sascalc/calculator/c_extensions/sld2i.c
- Timestamp:
- Mar 29, 2019 4:13:15 AM (5 years ago)
- Branches:
- magnetic_scatt
- Children:
- 1342f6a
- Parents:
- a48831a8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i.c
r144e032a rb36e7c7 47 47 * Compute 2D anisotropic 48 48 */ 49 void genicomXY(GenI* this, int npoints, double *qx, double *qy, double *I_out){ 50 //npoints is given negative for angular averaging 51 // Assumes that q doesn't have qz component and sld_n is all real 52 //double q = 0.0; 53 //double Pi = 4.0*atan(1.0); 54 polar_sld b_sld; 55 double qr = 0.0; 56 Cplx iqr; 57 Cplx ephase; 58 Cplx comp_sld; 59 60 Cplx sumj_uu; 61 Cplx sumj_ud; 62 Cplx sumj_du; 63 Cplx sumj_dd; 64 Cplx temp_fi; 65 66 double count = 0.0; 67 int i, j; 68 69 cassign(&iqr, 0.0, 0.0); 70 cassign(&ephase, 0.0, 0.0); 71 cassign(&comp_sld, 0.0, 0.0); 72 73 //Assume that pixel volumes are given in vol_pix in A^3 unit 74 //int x_size = 0; //in Ang 75 //int y_size = 0; //in Ang 76 //int z_size = 0; //in Ang 77 78 // Loop over q-values and multiply apply matrix 79 80 //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 81 for(i=0; i<npoints; i++){ 82 //I_out[i] = 0.0; 83 cassign(&sumj_uu, 0.0, 0.0); 84 cassign(&sumj_ud, 0.0, 0.0); 85 cassign(&sumj_du, 0.0, 0.0); 86 cassign(&sumj_dd, 0.0, 0.0); 87 //printf("i: %d\n", i); 88 //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 89 90 for(j=0; j<this->n_pix; j++){ 91 if (this->sldn_val[j]!=0.0 92 ||this->mx_val[j]!=0.0 93 ||this->my_val[j]!=0.0 94 ||this->mz_val[j]!=0.0) 95 { 96 // printf("i,j: %d,%d\n", i,j); 97 //anisotropic 98 cassign(&temp_fi, 0.0, 0.0); 99 cal_msld(&b_sld, 0, qx[i], qy[i], this->sldn_val[j], 100 this->mx_val[j], this->my_val[j], this->mz_val[j], 101 this->inspin, this->outspin, this->stheta); 102 qr = (qx[i]*this->x_val[j] + qy[i]*this->y_val[j]); 103 cassign(&iqr, 0.0, qr); 104 cplx_exp(&ephase, iqr); 105 106 //Let's multiply pixel(atomic) volume here 107 rcmult(&ephase, this->vol_pix[j], ephase); 108 //up_up 109 if (this->inspin > 0.0 && this->outspin > 0.0){ 110 cassign(&comp_sld, b_sld.uu, 0.0); 111 cplx_mult(&temp_fi, comp_sld, ephase); 112 cplx_add(&sumj_uu, sumj_uu, temp_fi); 113 } 114 //down_down 115 if (this->inspin < 1.0 && this->outspin < 1.0){ 116 cassign(&comp_sld, b_sld.dd, 0.0); 117 cplx_mult(&temp_fi, comp_sld, ephase); 118 cplx_add(&sumj_dd, sumj_dd, temp_fi); 119 } 120 //up_down 121 if (this->inspin > 0.0 && this->outspin < 1.0){ 122 cassign(&comp_sld, b_sld.re_ud, b_sld.im_ud); 123 cplx_mult(&temp_fi, comp_sld, ephase); 124 cplx_add(&sumj_ud, sumj_ud, temp_fi); 125 } 126 //down_up 127 if (this->inspin < 1.0 && this->outspin > 0.0){ 128 cassign(&comp_sld, b_sld.re_du, b_sld.im_du); 129 cplx_mult(&temp_fi, comp_sld, ephase); 130 cplx_add(&sumj_du, sumj_du, temp_fi); 131 } 132 133 if (i == 0){ 134 count += this->vol_pix[j]; 135 } 136 } 137 } 138 //printf("aa%d=%g %g %d\n", i, (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im), (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im), count); 139 140 I_out[i] = (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im); 141 I_out[i] += (sumj_ud.re*sumj_ud.re + sumj_ud.im*sumj_ud.im); 142 I_out[i] += (sumj_du.re*sumj_du.re + sumj_du.im*sumj_du.im); 143 I_out[i] += (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im); 144 145 I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 146 } 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]); 148 } 49 50 51 //The code calculating magnetic scattering below seems to be not used. 52 //Keeping it in order to check if it is not breaking anything. 53 // void genicomXY(GenI* this, int npoints, double *qx, double *qy, double *I_out){ 54 // //npoints is given negative for angular averaging 55 // // Assumes that q doesn't have qz component and sld_n is all real 56 // //double q = 0.0; 57 // //double Pi = 4.0*atan(1.0); 58 // polar_sld b_sld; 59 // double qr = 0.0; 60 // Cplx iqr; 61 // Cplx ephase; 62 // Cplx comp_sld; 63 // 64 // Cplx sumj_uu; 65 // Cplx sumj_ud; 66 // Cplx sumj_du; 67 // Cplx sumj_dd; 68 // Cplx temp_fi; 69 // 70 // double count = 0.0; 71 // int i, j; 72 // 73 // cassign(&iqr, 0.0, 0.0); 74 // cassign(&ephase, 0.0, 0.0); 75 // cassign(&comp_sld, 0.0, 0.0); 76 // 77 // //Assume that pixel volumes are given in vol_pix in A^3 unit 78 // //int x_size = 0; //in Ang 79 // //int y_size = 0; //in Ang 80 // //int z_size = 0; //in Ang 81 // 82 // // Loop over q-values and multiply apply matrix 83 // 84 // //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 85 // for(i=0; i<npoints; i++){ 86 // //I_out[i] = 0.0; 87 // cassign(&sumj_uu, 0.0, 0.0); 88 // cassign(&sumj_ud, 0.0, 0.0); 89 // cassign(&sumj_du, 0.0, 0.0); 90 // cassign(&sumj_dd, 0.0, 0.0); 91 // //printf("i: %d\n", i); 92 // //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 93 // 94 // for(j=0; j<this->n_pix; j++){ 95 // 96 // if (this->sldn_val[j]!=0.0 97 // ||this->mx_val[j]!=0.0 98 // ||this->my_val[j]!=0.0 99 // ||this->mz_val[j]!=0.0) 100 // { 101 // // printf("i,j: %d,%d\n", i,j); 102 // //anisotropic 103 // cassign(&temp_fi, 0.0, 0.0); 104 // cal_msld(&b_sld, 0, qx[i], qy[i], this->sldn_val[j], 105 // this->mx_val[j], this->my_val[j], this->mz_val[j], 106 // this->inspin, this->outspin, this->stheta); 107 // qr = (qx[i]*this->x_val[j] + qy[i]*this->y_val[j]); 108 // cassign(&iqr, 0.0, qr); 109 // cplx_exp(&ephase, iqr); 110 // 111 // //Let's multiply pixel(atomic) volume here 112 // rcmult(&ephase, this->vol_pix[j], ephase); 113 // //up_up 114 // if (this->inspin > 0.0 && this->outspin > 0.0){ 115 // cassign(&comp_sld, b_sld.uu, 0.0); 116 // cplx_mult(&temp_fi, comp_sld, ephase); 117 // cplx_add(&sumj_uu, sumj_uu, temp_fi); 118 // } 119 // //down_down 120 // if (this->inspin < 1.0 && this->outspin < 1.0){ 121 // cassign(&comp_sld, b_sld.dd, 0.0); 122 // cplx_mult(&temp_fi, comp_sld, ephase); 123 // cplx_add(&sumj_dd, sumj_dd, temp_fi); 124 // } 125 // //up_down 126 // if (this->inspin > 0.0 && this->outspin < 1.0){ 127 // cassign(&comp_sld, b_sld.re_ud, b_sld.im_ud); 128 // cplx_mult(&temp_fi, comp_sld, ephase); 129 // cplx_add(&sumj_ud, sumj_ud, temp_fi); 130 // } 131 // //down_up 132 // if (this->inspin < 1.0 && this->outspin > 0.0){ 133 // cassign(&comp_sld, b_sld.re_du, b_sld.im_du); 134 // cplx_mult(&temp_fi, comp_sld, ephase); 135 // cplx_add(&sumj_du, sumj_du, temp_fi); 136 // } 137 // 138 // if (i == 0){ 139 // count += this->vol_pix[j]; 140 // } 141 // } 142 // } 143 // //printf("aa%d=%g %g %d\n", i, (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im), (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im), count); 144 // 145 // I_out[i] = (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im); 146 // I_out[i] += (sumj_ud.re*sumj_ud.re + sumj_ud.im*sumj_ud.im); 147 // I_out[i] += (sumj_du.re*sumj_du.re + sumj_du.im*sumj_du.im); 148 // I_out[i] += (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im); 149 // 150 // I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix 151 // } 152 // //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]); 153 // } 149 154 /** 150 155 * Compute 1D isotropic
Note: See TracChangeset
for help on using the changeset viewer.