Changeset b36e7c7 in sasview


Ignore:
Timestamp:
Mar 29, 2019 4:13:15 AM (5 years ago)
Author:
dirk
Branches:
magnetic_scatt
Children:
1342f6a
Parents:
a48831a8
Message:

clean up obsolete? code of magnetic scattering calculation. Addresses #1086.

Location:
src/sas/sascalc/calculator
Files:
6 edited

Legend:

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

    r144e032a rb36e7c7  
    8787} 
    8888 
     89//The code calculating magnetic sld below seems to be not used. 
     90//Keeping it in order to check if it is not breaking anything. 
    8991// calculate magnetic sld and return total sld 
    9092// bn : contrast (not just sld of the layer) 
     
    9597// spintheta: angle (anti-clock-wise) between neutron spin(up) and x axis 
    9698// Note: all angles are in degrees. 
    97 void cal_msld(polar_sld *p_sld, int isangle, double qx, double qy, double bn, 
    98                                 double m01, double mtheta1, double mphi1, 
    99                                 double spinfraci, double spinfracf, double spintheta) 
    100 { 
    101         //locals 
    102         double q_x = qx; 
    103         double q_y = qy; 
    104         double sld = bn; 
    105         int is_angle = isangle; 
    106         double pi = 4.0*atan(1.0); 
    107         double s_theta = spintheta * pi/180.0; 
    108         double m_max = m01; 
    109         double m_phi = mphi1; 
    110         double m_theta = mtheta1; 
    111         double in_spin = spinfraci; 
    112         double out_spin = spinfracf; 
    113  
    114         double m_perp = 0.0; 
    115         double m_perp_z = 0.0; 
    116         double m_perp_y = 0.0; 
    117         double m_perp_x = 0.0; 
    118         double m_sigma_x = 0.0; 
    119         double m_sigma_z = 0.0; 
    120         double m_sigma_y = 0.0; 
    121         //double b_m = 0.0; 
    122         double q_angle = 0.0; 
    123         double mx = 0.0; 
    124         double my = 0.0; 
    125         double mz = 0.0; 
    126         double uu = sld; 
    127         double dd = sld; 
    128         double re_ud = 0.0; 
    129         double im_ud = 0.0; 
    130         double re_du = 0.0; 
    131         double im_du = 0.0; 
    132  
    133         //No mag means no further calculation 
    134         if (isangle>0) { 
    135                 if (m_max < 1.0e-32){ 
    136                         uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
    137                         dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
    138                 } 
    139         } 
    140         else if (fabs(m_max)< 1.0e-32 && fabs(m_phi)< 1.0e-32 && fabs(m_theta)< 1.0e-32){ 
    141                         uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
    142                         dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
    143         } else { 
    144  
    145                 //These are needed because of the precision of inputs 
    146                 if (in_spin < 0.0) in_spin = 0.0; 
    147                 if (in_spin > 1.0) in_spin = 1.0; 
    148                 if (out_spin < 0.0) out_spin = 0.0; 
    149                 if (out_spin > 1.0) out_spin = 1.0; 
    150  
    151                 if (q_x == 0.0) q_angle = pi / 2.0; 
    152                 else q_angle = atan(q_y/q_x); 
    153                 if (q_y < 0.0 && q_x < 0.0) q_angle -= pi; 
    154                 else if (q_y > 0.0 && q_x < 0.0) q_angle += pi; 
    155  
    156                 q_angle = pi/2.0 - q_angle; 
    157                 if (q_angle > pi) q_angle -= 2.0 * pi; 
    158                 else if (q_angle < -pi) q_angle += 2.0 * pi; 
    159  
    160                 if (fabs(q_x) < 1.0e-16 && fabs(q_y) < 1.0e-16){ 
    161                         m_perp = 0.0; 
    162                         } 
    163                 else { 
    164                         m_perp = m_max; 
    165                         } 
    166                 if (is_angle > 0){ 
    167                         m_phi *= pi/180.0; 
    168                         m_theta *= pi/180.0; 
    169                         mx = m_perp * cos(m_theta) * cos(m_phi); 
    170                         my = m_perp * sin(m_theta); 
    171                         mz = -(m_perp * cos(m_theta) * sin(m_phi)); 
    172                 } 
    173                 else{ 
    174                         mx = m_perp; 
    175                         my = m_phi; 
    176                         mz = m_theta; 
    177                 } 
    178                 //ToDo: simplify these steps 
    179                 // m_perp1 -m_perp2 
    180                 m_perp_x = (mx) *  cos(q_angle); 
    181                 m_perp_x -= (my) * sin(q_angle); 
    182                 m_perp_y = m_perp_x; 
    183                 m_perp_x *= cos(-q_angle); 
    184                 m_perp_y *= sin(-q_angle); 
    185                 m_perp_z = mz; 
    186  
    187                 m_sigma_x = (m_perp_x * cos(-s_theta) - m_perp_y * sin(-s_theta)); 
    188                 m_sigma_y = (m_perp_x * sin(-s_theta) + m_perp_y * cos(-s_theta)); 
    189                 m_sigma_z = (m_perp_z); 
    190  
    191                 //Find b 
    192                 uu -= m_sigma_x; 
    193                 dd += m_sigma_x; 
    194                 re_ud = m_sigma_y; 
    195                 re_du = m_sigma_y; 
    196                 im_ud = m_sigma_z; 
    197                 im_du = -m_sigma_z; 
    198  
    199                 uu = sqrt(sqrt(in_spin * out_spin)) * uu; 
    200                 dd = sqrt(sqrt((1.0 - in_spin) * (1.0 - out_spin))) * dd; 
    201  
    202                 re_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * re_ud; 
    203                 im_ud = sqrt(sqrt(in_spin * (1.0 - out_spin))) * im_ud; 
    204                 re_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * re_du; 
    205                 im_du = sqrt(sqrt((1.0 - in_spin) * out_spin)) * im_du; 
    206         } 
    207         p_sld->uu = uu; 
    208         p_sld->dd = dd; 
    209         p_sld->re_ud = re_ud; 
    210         p_sld->im_ud = im_ud; 
    211         p_sld->re_du = re_du; 
    212         p_sld->im_du = im_du; 
    213 } 
     99// void cal_msld(polar_sld *p_sld, int isangle, double qx, double qy, double bn, 
     100//                              double m01, double mtheta1, double mphi1, 
     101//                              double spinfraci, double spinfracf, double spintheta) 
     102// { 
     103//      //locals 
     104//      double q_x = qx; 
     105//      double q_y = qy; 
     106//      double sld = bn; 
     107//      int is_angle = isangle; 
     108//      double pi = 4.0*atan(1.0); 
     109//      double s_theta = spintheta * pi/180.0; 
     110//      double m_max = m01; 
     111//      double m_phi = mphi1; 
     112//      double m_theta = mtheta1; 
     113//      double in_spin = spinfraci; 
     114//      double out_spin = spinfracf; 
     115// 
     116//      double m_perp = 0.0; 
     117//      double m_perp_z = 0.0; 
     118//      double m_perp_y = 0.0; 
     119//      double m_perp_x = 0.0; 
     120//      double m_sigma_x = 0.0; 
     121//      double m_sigma_z = 0.0; 
     122//      double m_sigma_y = 0.0; 
     123//      //double b_m = 0.0; 
     124//      double q_angle = 0.0; 
     125//      double mx = 0.0; 
     126//      double my = 0.0; 
     127//      double mz = 0.0; 
     128//      double uu = sld; 
     129//      double dd = sld; 
     130//      double re_ud = 0.0; 
     131//      double im_ud = 0.0; 
     132//      double re_du = 0.0; 
     133//      double im_du = 0.0; 
     134// 
     135//      //No mag means no further calculation 
     136//      if (isangle>0) { 
     137//              if (m_max < 1.0e-32){ 
     138//                      uu = sqrt((1+in_spin)/2 * (1+out_spin)/2) * uu; 
     139//                      dd = sqrt((1.0 - in_spin)/2 * (1.0 - out_spin)/2) * dd; 
     140//              } 
     141//      } 
     142//      else if (fabs(m_max)< 1.0e-32 && fabs(m_phi)< 1.0e-32 && fabs(m_theta)< 1.0e-32){ 
     143//                      uu = sqrt((1+in_spin)/2 * (1+out_spin)/2) * uu; 
     144//                      dd = sqrt((1.0 - in_spin)/2 * (1.0 - out_spin)/2) * dd; 
     145//      } else { 
     146// 
     147//              //These are needed because of the precision of inputs 
     148//              if (in_spin < 0.0) in_spin = 0.0; 
     149//              if (in_spin > 1.0) in_spin = 1.0; 
     150//              if (out_spin < 0.0) out_spin = 0.0; 
     151//              if (out_spin > 1.0) out_spin = 1.0; 
     152// 
     153//              if (q_x == 0.0) q_angle = pi / 2.0; 
     154//              else q_angle = atan(q_y/q_x); 
     155//              if (q_y < 0.0 && q_x < 0.0) q_angle -= pi; 
     156//              else if (q_y > 0.0 && q_x < 0.0) q_angle += pi; 
     157// 
     158//              q_angle = pi/2.0 - q_angle; 
     159//              if (q_angle > pi) q_angle -= 2.0 * pi; 
     160//              else if (q_angle < -pi) q_angle += 2.0 * pi; 
     161// 
     162//              if (fabs(q_x) < 1.0e-16 && fabs(q_y) < 1.0e-16){ 
     163//                      m_perp = 0.0; 
     164//                      } 
     165//              else { 
     166//                      m_perp = m_max; 
     167//                      } 
     168//              if (is_angle > 0){ 
     169//                      m_phi *= pi/180.0; 
     170//                      m_theta *= pi/180.0; 
     171//                      mx = m_perp * cos(m_theta) * cos(m_phi); 
     172//                      my = m_perp * sin(m_theta); 
     173//                      mz = -(m_perp * cos(m_theta) * sin(m_phi)); 
     174//              } 
     175//              else{ 
     176//                      mx = m_perp; 
     177//                      my = m_phi; 
     178//                      mz = m_theta; 
     179//              } 
     180//              //ToDo: simplify these steps 
     181//              // m_perp1 -m_perp2 
     182//              m_perp_x = (mx) *  cos(q_angle); 
     183//              m_perp_x -= (my) * sin(q_angle); 
     184//              m_perp_y = m_perp_x; 
     185//              m_perp_x *= cos(-q_angle); 
     186//              m_perp_y *= sin(-q_angle); 
     187//              m_perp_z = mz; 
     188// 
     189//              m_sigma_x = (m_perp_x * cos(-s_theta) - m_perp_y * sin(-s_theta)); 
     190//              m_sigma_y = (m_perp_x * sin(-s_theta) + m_perp_y * cos(-s_theta)); 
     191//              m_sigma_z = (m_perp_z); 
     192// 
     193//              //Find b 
     194//              uu -= m_sigma_x; 
     195//              dd += m_sigma_x; 
     196//              re_ud = m_sigma_y; 
     197//              re_du = m_sigma_y; 
     198//              im_ud = m_sigma_z; 
     199//              im_du = -m_sigma_z; 
     200// 
     201//              uu = sqrt((1+in_spin) * (1 + out_spin)) * uu; 
     202//              dd = sqrt((1.0 - in_spin) * (1.0 - out_spin)) * dd; 
     203// 
     204//              re_ud = sqrt(in_spin * (1.0 - out_spin)) * re_ud; 
     205//              im_ud = sqrt(in_spin * (1.0 - out_spin)) * im_ud; 
     206//              re_du = sqrt((1.0 - in_spin) * out_spin) * re_du; 
     207//              im_du = sqrt((1.0 - in_spin) * out_spin) * im_du; 
     208//      } 
     209//      p_sld->uu = uu; 
     210//      p_sld->dd = dd; 
     211//      p_sld->re_ud = re_ud; 
     212//      p_sld->im_ud = im_ud; 
     213//      p_sld->re_du = re_du; 
     214//      p_sld->im_du = im_du; 
     215// } 
    214216 
    215217 
  • src/sas/sascalc/calculator/c_extensions/libfunc.h

    r144e032a rb36e7c7  
    1818//double gamln(double x); 
    1919 
    20 void cal_msld(polar_sld*, int isangle, double qx, double qy, double bn, double m01, double mtheta1,  
    21                         double mphi1, double spinfraci, double spinfracf, double spintheta); 
     20//void cal_msld(polar_sld*, int isangle, double qx, double qy, double bn, double m01, double mtheta1, 
     21//                      double mphi1, double spinfraci, double spinfracf, double spintheta); 
    2222 
    2323//void gser(float *gamser, float a, float x, float *gln); 
  • src/sas/sascalc/calculator/c_extensions/sld2i.c

    r144e032a rb36e7c7  
    4747 * Compute 2D anisotropic 
    4848 */ 
    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// } 
    149154/** 
    150155 * Compute 1D isotropic 
  • src/sas/sascalc/calculator/c_extensions/sld2i.h

    r54b0650 rb36e7c7  
    3232                double s_theta); 
    3333// compute function 
    34 void genicomXY(GenI*, int npoints, double* qx, double* qy, double *I_out); 
     34//void genicomXY(GenI*, int npoints, double* qx, double* qy, double *I_out); 
    3535void genicom(GenI*, int npoints, double* q, double *I_out); 
    3636 
  • src/sas/sascalc/calculator/c_extensions/sld2i_module.c

    r7ba6470 rb36e7c7  
    1818// Vector binding glue 
    1919#if (PY_VERSION_HEX > 0x03000000) && !defined(Py_LIMITED_API) 
    20   // Assuming that a view into a writable vector points to a  
    21   // non-changing pointer for the duration of the C call, capture  
     20  // Assuming that a view into a writable vector points to a 
     21  // non-changing pointer for the duration of the C call, capture 
    2222  // the view pointer and immediately free the view. 
    2323  #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \ 
     
    101101 * GenI the given input (2D) according to a given object 
    102102 */ 
    103 PyObject * genicom_inputXY(PyObject *self, PyObject *args) { 
    104         PyObject *gen_obj; 
    105         PyObject *qx_obj; 
    106         PyObject *qy_obj; 
    107         PyObject *I_out_obj; 
    108         Py_ssize_t n_qx, n_qy, n_out; 
    109         double *qx; 
    110         double *qy; 
    111         double *I_out; 
    112         GenI* sld2i; 
    113  
    114         //printf("in genicom_inputXY\n"); 
    115         if (!PyArg_ParseTuple(args, "OOOO",  &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 
    116         sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 
    117         VECTOR(qx_obj, qx, n_qx); 
    118         VECTOR(qy_obj, qy, n_qy); 
    119         VECTOR(I_out_obj, I_out, n_out); 
    120         //printf("qx, qy, I_out: %d %d %d, %d %d %d\n", qx, qy, I_out, n_qx, n_qy, n_out); 
    121  
    122         // Sanity check 
    123         //if(n_q!=n_out) return Py_BuildValue("i",-1); 
    124  
    125         genicomXY(sld2i, (int)n_qx, qx, qy, I_out); 
    126         //printf("done calc\n"); 
    127         //return PyCObject_FromVoidPtr(s, del_genicom); 
    128         return Py_BuildValue("i",1); 
    129 } 
     103// PyObject * genicom_inputXY(PyObject *self, PyObject *args) { 
     104//      PyObject *gen_obj; 
     105//      PyObject *qx_obj; 
     106//      PyObject *qy_obj; 
     107//      PyObject *I_out_obj; 
     108//      Py_ssize_t n_qx, n_qy, n_out; 
     109//      double *qx; 
     110//      double *qy; 
     111//      double *I_out; 
     112//      GenI* sld2i; 
     113// 
     114//      //printf("in genicom_inputXY\n"); 
     115//      if (!PyArg_ParseTuple(args, "OOOO",  &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 
     116//      sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 
     117//      VECTOR(qx_obj, qx, n_qx); 
     118//      VECTOR(qy_obj, qy, n_qy); 
     119//      VECTOR(I_out_obj, I_out, n_out); 
     120//      //printf("qx, qy, I_out: %d %d %d, %d %d %d\n", qx, qy, I_out, n_qx, n_qy, n_out); 
     121// 
     122//      // Sanity check 
     123//      //if(n_q!=n_out) return Py_BuildValue("i",-1); 
     124// 
     125//      genicomXY(sld2i, (int)n_qx, qx, qy, I_out); 
     126//      //printf("done calc\n"); 
     127//      //return PyCObject_FromVoidPtr(s, del_genicom); 
     128//      return Py_BuildValue("i",1); 
     129// } 
    130130 
    131131/** 
     
    161161        {"genicom",(PyCFunction)genicom_input, METH_VARARGS, 
    162162                  "genicom the given 1d input arrays"}, 
    163         {"genicomXY",(PyCFunction)genicom_inputXY, METH_VARARGS, 
    164                   "genicomXY the given 2d input arrays"}, 
     163//      {"genicomXY",(PyCFunction)genicom_inputXY, METH_VARARGS, 
     164//                "genicomXY the given 2d input arrays"}, 
    165165    {NULL} 
    166166}; 
  • src/sas/sascalc/calculator/sas_gen.py

    r952ea1f rb36e7c7  
    134134        sldn -= self.params['solvent_SLD'] 
    135135        # **** WARNING **** new_GenI holds pointers to numpy vectors 
    136         # be sure that they are contiguous double precision arrays and make  
     136        # be sure that they are contiguous double precision arrays and make 
    137137        # sure the GC doesn't eat them before genicom is called. 
    138138        # TODO: rewrite so that the parameters are passed directly to genicom 
Note: See TracChangeset for help on using the changeset viewer.