Changeset 2bb0b26 in sasview


Ignore:
Timestamp:
Sep 27, 2007 11:16:55 AM (17 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
02cb31a
Parents:
d1101bb
Message:

Added underlying 2D real-space simulation

Location:
realSpaceModeling/pointsmodelpy
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • realSpaceModeling/pointsmodelpy/libpointsmodelpy/points_model.cc

    rf2d6445 r2bb0b26  
    375375  return I; 
    376376} 
     377 
     378/* 
     379 * 2D simulation for oriented systems 
     380 * The beam direction is assumed to be in the z direction. 
     381 *  
     382 * @param points: vector of space points 
     383 * @param qx: qx [A-1] 
     384 * @param qy: qy [A-1] 
     385 * @return: I(qx, qy) for the system described by the space points [cm-1] 
     386 *  
     387 */ 
     388double PointsModel::CalculateIQ_2D(const vector<Point3D>&points, double qx, double qy){ 
     389        /* 
     390         * TODO: the vector of points should really be part of the class 
     391         *           This is a design flaw inherited from the original programmer. 
     392         */ 
     393         
     394        int size = points.size(); 
     395 
     396        double cos_term = 0; 
     397        double sin_term = 0; 
     398        for (int i = 0; i < size; i++) { 
     399                //the sld for the pair of points 
     400         
     401                double phase = qx*points[i].getX() + qy*points[i].getY(); 
     402                                 
     403                cos_term += cos(phase) * points[i].getSLD(); 
     404                sin_term += sin(phase) * points[i].getSLD(); 
     405         
     406        }                        
     407 
     408        // P(q) = 1/V I(q) = (V/N)^2 (1/V) (cos_term^2 + sin_term^2)  
     409        // We divide by N here and we will multiply by the density later. 
     410 
     411        return (cos_term*cos_term + sin_term*sin_term)/size;     
     412} 
     413 
  • realSpaceModeling/pointsmodelpy/libpointsmodelpy/points_model.h

    rf2d6445 r2bb0b26  
    2121  double CalculateIQ(double q); 
    2222  double CalculateIQError(double q); 
     23   
     24  // Old lengthy 2D simulation (unchecked)  
    2325  void CalculateIQ_2D(IQ *iq,double phi); 
    2426  double CalculateIQ_2D(double qx, double qy); 
     27   
     28  // Fast 2D simulation 
     29  double CalculateIQ_2D(const vector<Point3D>&, double qx, double qy); 
    2530   
    2631  //given a set of points, calculate distance correlation 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/bindings.cc

    rf2d6445 r2bb0b26  
    9797     METH_VARARGS, pypointsmodelpy_calculateIQ_2D__doc__}, 
    9898 
    99     //calculateIQ 2D(Qx,Qy) 
    100     {pypointsmodelpy_calculateI_Qxy__name__, pypointsmodelpy_calculateI_Qxy, 
    101      METH_VARARGS, pypointsmodelpy_calculateI_Qxy__doc__}, 
     99     //calculateIQ 2D(points, Qx,Qy) 
     100     {pypointsmodelpy_calculateI_Qvxy__name__, pypointsmodelpy_calculateI_Qvxy, 
     101      METH_VARARGS, pypointsmodelpy_calculateI_Qvxy__doc__}, 
     102 
     103      //calculateIQ 2D(Qx,Qy) 
     104      {pypointsmodelpy_calculateI_Qxy__name__, pypointsmodelpy_calculateI_Qxy, 
     105       METH_VARARGS, pypointsmodelpy_calculateI_Qxy__doc__}, 
    102106 
    103107    //PDBModel calculateIQ 
     
    105109     METH_VARARGS, pypointsmodelpy_get_pdb_iq__doc__}, 
    106110 
    107     //PDBModel calculateIQ(Qx,Qy) 
    108     {pypointsmodelpy_get_pdb_Iqxy__name__, pypointsmodelpy_get_pdb_Iqxy, 
    109      METH_VARARGS, pypointsmodelpy_get_pdb_Iqxy__doc__}, 
     111     //PDBModel calculateIQ(Qx,Qy) 
     112     {pypointsmodelpy_get_pdb_Iqxy__name__, pypointsmodelpy_get_pdb_Iqxy, 
     113      METH_VARARGS, pypointsmodelpy_get_pdb_Iqxy__doc__}, 
     114 
     115      //PDBModel calculateIQ(pts,Qx,Qy) 
     116      {pypointsmodelpy_get_pdb_Iqvxy__name__, pypointsmodelpy_get_pdb_Iqvxy, 
     117       METH_VARARGS, pypointsmodelpy_get_pdb_Iqvxy__doc__}, 
     118 
     119       //ComplexModel calculateIQ(pts,Qx,Qy) 
     120       {pypointsmodelpy_get_complex_Iqxy__name__, pypointsmodelpy_get_complex_Iqxy, 
     121        METH_VARARGS, pypointsmodelpy_get_complex_Iqxy__doc__}, 
    110122 
    111123    //ComplexModel calculateIQ 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.cc

    rf2d6445 r2bb0b26  
    424424} 
    425425 
     426// method calculateI_Qxy(poitns, Qx,Qy) 
     427char pypointsmodelpy_calculateI_Qvxy__name__[] = "calculateI_Qvxy"; 
     428char pypointsmodelpy_calculateI_Qvxy__doc__[] = "calculate scattering intensity on a 2D pixel"; 
     429 
     430PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *args) 
     431{ 
     432  PyObject *pylores = 0, *pypoint3dvec = 0; 
     433  double qx = 0, qy = 0; 
     434  double I = 0; 
     435 
     436  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx,&qy); 
     437  if(!ok) return NULL; 
     438 
     439  void *temp = PyCObject_AsVoidPtr(pylores); 
     440  LORESModel * thislores = static_cast<LORESModel *>(temp); 
     441  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); 
     442  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); 
     443   
     444  I = thislores->CalculateIQ_2D(*thisvec, qx,qy); 
     445 
     446  return Py_BuildValue("d",I); 
     447} 
     448 
    426449// PDBModel method calculateIQ(iq) 
    427450char pypointsmodelpy_get_pdb_iq__name__[] = "get_pdb_iq"; 
     
    466489} 
    467490 
     491// PDBModel method calculateIQ_2Dv(points,qx,qy) 
     492char pypointsmodelpy_get_pdb_Iqvxy__name__[] = "get_pdb_Iqvxy"; 
     493char pypointsmodelpy_get_pdb_Iqvxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model"; 
     494 
     495PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *args) 
     496{ 
     497  PyObject *pypdb = 0, *pypoint3dvec = 0; 
     498  double qx = 0, qy = 0; 
     499  double I = 0; 
     500 
     501  int ok = PyArg_ParseTuple(args, "OOdd", &pypdb, &pypoint3dvec, &qx,&qy); 
     502  if(!ok) return NULL; 
     503 
     504  void *temp = PyCObject_AsVoidPtr(pypdb); 
     505  PDBModel * thispdb = static_cast<PDBModel *>(temp); 
     506  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); 
     507  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); 
     508 
     509  I = thispdb->CalculateIQ_2D(*thisvec,qx,qy); 
     510 
     511  return Py_BuildValue("d",I); 
     512} 
     513 
    468514// ComplexModel method calculateIQ(iq) 
    469515char pypointsmodelpy_get_complex_iq__name__[] = "get_complex_iq"; 
     
    485531 
    486532  return Py_BuildValue("i",0); 
     533} 
     534 
     535//LORESModel method CalculateIQ_2D(points,qx,qy)  
     536char pypointsmodelpy_get_complex_Iqxy__name__[] = "get_complex_iq_2D"; 
     537char pypointsmodelpy_get_complex_Iqxy__doc__[] = "calculate averaged scattering intensity from a single q"; 
     538 
     539PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *args) 
     540{ 
     541  PyObject *pylores = 0, *pypoint3dvec = 0; 
     542  double qx = 0, qy = 0; 
     543  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy); 
     544  if(!ok) return NULL; 
     545 
     546  void *temp = PyCObject_AsVoidPtr(pylores); 
     547  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); 
     548  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); 
     549  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); 
     550 
     551  double I = thiscomplex->CalculateIQ_2D(*thisvec,qx,qy); 
     552 
     553  return Py_BuildValue("d",I); 
    487554} 
    488555 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.h

    rf2d6445 r2bb0b26  
    152152PyObject * pypointsmodelpy_calculateI_Qxy(PyObject *, PyObject *); 
    153153 
     154// method calculateI_Qvxy(points,Qx,Qy) 
     155extern char pypointsmodelpy_calculateI_Qvxy__name__[]; 
     156extern char pypointsmodelpy_calculateI_Qvxy__doc__[]; 
     157extern "C" 
     158PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *); 
     159 
    154160// PDBModel method calculateIQ(iq) 
    155161extern char pypointsmodelpy_get_pdb_iq__name__[]; 
     
    164170PyObject * pypointsmodelpy_get_pdb_Iqxy(PyObject *, PyObject *); 
    165171 
     172// PDBModel method calculateIQ_2D(pts,qx,qy) 
     173extern char pypointsmodelpy_get_pdb_Iqvxy__name__[]; 
     174extern char pypointsmodelpy_get_pdb_Iqvxy__doc__[]; 
     175extern "C" 
     176PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *); 
     177 
     178// ComplexModel method calculateIQ_2D(pts,qx,qy) 
     179extern char pypointsmodelpy_get_complex_Iqxy__name__[]; 
     180extern char pypointsmodelpy_get_complex_Iqxy__doc__[]; 
     181extern "C" 
     182PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *); 
     183 
    166184// ComplexModel method calculateIQ(iq) 
    167185extern char pypointsmodelpy_get_complex_iq__name__[]; 
Note: See TracChangeset for help on using the changeset viewer.