Changeset 2bb0b26 in sasview
- Timestamp:
- Sep 27, 2007 11:16:55 AM (17 years ago)
- 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
- Location:
- realSpaceModeling/pointsmodelpy
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
realSpaceModeling/pointsmodelpy/libpointsmodelpy/points_model.cc
rf2d6445 r2bb0b26 375 375 return I; 376 376 } 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 */ 388 double 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 21 21 double CalculateIQ(double q); 22 22 double CalculateIQError(double q); 23 24 // Old lengthy 2D simulation (unchecked) 23 25 void CalculateIQ_2D(IQ *iq,double phi); 24 26 double CalculateIQ_2D(double qx, double qy); 27 28 // Fast 2D simulation 29 double CalculateIQ_2D(const vector<Point3D>&, double qx, double qy); 25 30 26 31 //given a set of points, calculate distance correlation -
realSpaceModeling/pointsmodelpy/pointsmodelpymodule/bindings.cc
rf2d6445 r2bb0b26 97 97 METH_VARARGS, pypointsmodelpy_calculateIQ_2D__doc__}, 98 98 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__}, 102 106 103 107 //PDBModel calculateIQ … … 105 109 METH_VARARGS, pypointsmodelpy_get_pdb_iq__doc__}, 106 110 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__}, 110 122 111 123 //ComplexModel calculateIQ -
realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.cc
rf2d6445 r2bb0b26 424 424 } 425 425 426 // method calculateI_Qxy(poitns, Qx,Qy) 427 char pypointsmodelpy_calculateI_Qvxy__name__[] = "calculateI_Qvxy"; 428 char pypointsmodelpy_calculateI_Qvxy__doc__[] = "calculate scattering intensity on a 2D pixel"; 429 430 PyObject * 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 426 449 // PDBModel method calculateIQ(iq) 427 450 char pypointsmodelpy_get_pdb_iq__name__[] = "get_pdb_iq"; … … 466 489 } 467 490 491 // PDBModel method calculateIQ_2Dv(points,qx,qy) 492 char pypointsmodelpy_get_pdb_Iqvxy__name__[] = "get_pdb_Iqvxy"; 493 char pypointsmodelpy_get_pdb_Iqvxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model"; 494 495 PyObject * 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 468 514 // ComplexModel method calculateIQ(iq) 469 515 char pypointsmodelpy_get_complex_iq__name__[] = "get_complex_iq"; … … 485 531 486 532 return Py_BuildValue("i",0); 533 } 534 535 //LORESModel method CalculateIQ_2D(points,qx,qy) 536 char pypointsmodelpy_get_complex_Iqxy__name__[] = "get_complex_iq_2D"; 537 char pypointsmodelpy_get_complex_Iqxy__doc__[] = "calculate averaged scattering intensity from a single q"; 538 539 PyObject * 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); 487 554 } 488 555 -
realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.h
rf2d6445 r2bb0b26 152 152 PyObject * pypointsmodelpy_calculateI_Qxy(PyObject *, PyObject *); 153 153 154 // method calculateI_Qvxy(points,Qx,Qy) 155 extern char pypointsmodelpy_calculateI_Qvxy__name__[]; 156 extern char pypointsmodelpy_calculateI_Qvxy__doc__[]; 157 extern "C" 158 PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *); 159 154 160 // PDBModel method calculateIQ(iq) 155 161 extern char pypointsmodelpy_get_pdb_iq__name__[]; … … 164 170 PyObject * pypointsmodelpy_get_pdb_Iqxy(PyObject *, PyObject *); 165 171 172 // PDBModel method calculateIQ_2D(pts,qx,qy) 173 extern char pypointsmodelpy_get_pdb_Iqvxy__name__[]; 174 extern char pypointsmodelpy_get_pdb_Iqvxy__doc__[]; 175 extern "C" 176 PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *); 177 178 // ComplexModel method calculateIQ_2D(pts,qx,qy) 179 extern char pypointsmodelpy_get_complex_Iqxy__name__[]; 180 extern char pypointsmodelpy_get_complex_Iqxy__doc__[]; 181 extern "C" 182 PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *); 183 166 184 // ComplexModel method calculateIQ(iq) 167 185 extern char pypointsmodelpy_get_complex_iq__name__[];
Note: See TracChangeset
for help on using the changeset viewer.