Changeset 5eb9154 in sasview for sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp
- Timestamp:
- Aug 31, 2009 5:25:44 PM (15 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:
- 5be36bb
- Parents:
- 572beba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp
r870f131 r5eb9154 18 18 * 19 19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 20 * DO NOT MODIFY THIS FILE, MODIFY Hardsphere.h20 * DO NOT MODIFY THIS FILE, MODIFY hardsphere.h 21 21 * AND RE-RUN THE GENERATOR SCRIPT 22 22 * … … 33 33 #include <math.h> 34 34 #include <time.h> 35 #include " Hardsphere.h"35 #include "hardsphere.h" 36 36 } 37 37 … … 86 86 87 87 // Initialize parameter dictionary 88 PyDict_SetItemString(self->params," radius",Py_BuildValue("d",50.000000));88 PyDict_SetItemString(self->params,"effect_radius",Py_BuildValue("d",50.000000)); 89 89 PyDict_SetItemString(self->params,"volfraction",Py_BuildValue("d",0.200000)); 90 90 // Initialize dispersion / averaging parameter dict … … 92 92 PyObject * disp_dict; 93 93 disp_dict = PyDict_New(); 94 self->model-> radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);95 PyDict_SetItemString(self->dispersion, " radius", disp_dict);94 self->model->effect_radius.dispersion->accept_as_source(visitor, self->model->effect_radius.dispersion, disp_dict); 95 PyDict_SetItemString(self->dispersion, "effect_radius", disp_dict); 96 96 97 97 … … 225 225 226 226 // Reader parameter dictionary 227 self->model-> radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );227 self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") ); 228 228 self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") ); 229 229 // Read in dispersion parameters 230 230 PyObject* disp_dict; 231 231 DispersionVisitor* visitor = new DispersionVisitor(); 232 disp_dict = PyDict_GetItemString(self->dispersion, " radius");233 self->model-> radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);232 disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius"); 233 self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict); 234 234 235 235 … … 294 294 295 295 // Reader parameter dictionary 296 self->model-> radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );296 self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") ); 297 297 self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") ); 298 298 // Read in dispersion parameters 299 299 PyObject* disp_dict; 300 300 DispersionVisitor* visitor = new DispersionVisitor(); 301 disp_dict = PyDict_GetItemString(self->dispersion, " radius");302 self->model-> radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);301 disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius"); 302 self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict); 303 303 304 304 … … 338 338 } 339 339 } 340 340 /** 341 * Function to call to calculate_ER 342 * @return: effective radius value 343 */ 344 static PyObject * calculate_ER(CHardsphereStructure *self) { 345 346 PyObject* pars; 347 int npars; 348 349 // Get parameters 350 351 // Reader parameter dictionary 352 self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") ); 353 self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") ); 354 // Read in dispersion parameters 355 PyObject* disp_dict; 356 DispersionVisitor* visitor = new DispersionVisitor(); 357 disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius"); 358 self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict); 359 360 361 return Py_BuildValue("d",(*(self->model)).calculate_ER()); 362 363 } 341 364 /** 342 365 * Function to call to evaluate model in cartesian coordinates … … 352 375 353 376 // Reader parameter dictionary 354 self->model-> radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );377 self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") ); 355 378 self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") ); 356 379 // Read in dispersion parameters 357 380 PyObject* disp_dict; 358 381 DispersionVisitor* visitor = new DispersionVisitor(); 359 disp_dict = PyDict_GetItemString(self->dispersion, " radius");360 self->model-> radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);382 disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius"); 383 self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict); 361 384 362 385 … … 414 437 // Ugliness necessary to go from python to C 415 438 // TODO: refactor this 416 if (!strcmp(par_name, " radius")) {417 self->model-> radius.dispersion = dispersion;439 if (!strcmp(par_name, "effect_radius")) { 440 self->model->effect_radius.dispersion = dispersion; 418 441 } else { 419 442 PyErr_SetString(CHardsphereStructureError, … … 435 458 {"runXY", (PyCFunction)runXY , METH_VARARGS, 436 459 "Evaluate the model at a given Q or Qx, Qy"}, 460 {"calculate_ER", (PyCFunction)calculate_ER , METH_VARARGS, 461 "Evaluate the model at a given Q or Q, phi"}, 437 462 438 463 {"evalDistribution", (PyCFunction)evalDistribution , METH_VARARGS,
Note: See TracChangeset
for help on using the changeset viewer.