Changeset 0f5bc9f in sasview for sansmodels/src/sans/models/c_models
- Timestamp:
- Aug 19, 2008 2:42:22 PM (16 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:
- d30fdde
- Parents:
- a86bbe9
- Location:
- sansmodels/src/sans/models/c_models
- Files:
-
- 11 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CCylinderModel.cpp
raf03ddd r0f5bc9f 83 83 84 84 // Initialize parameter dictionary 85 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d", self->model->scale()));86 PyDict_SetItemString(self->params,"length",Py_BuildValue("d", self->model->length()));87 PyDict_SetItemString(self->params,"cyl_theta",Py_BuildValue("d", self->model->cyl_theta()));88 PyDict_SetItemString(self->params,"background",Py_BuildValue("d", self->model->background()));89 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d", self->model->radius()));90 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d", self->model->contrast()));91 PyDict_SetItemString(self->params,"cyl_phi",Py_BuildValue("d", self->model->cyl_phi()));85 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 86 PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000)); 87 PyDict_SetItemString(self->params,"cyl_theta",Py_BuildValue("d",1.000000)); 88 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 89 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000)); 90 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000003)); 91 PyDict_SetItemString(self->params,"cyl_phi",Py_BuildValue("d",1.000000)); 92 92 // Initialize dispersion / averaging parameter dict 93 93 DispersionVisitor* visitor = new DispersionVisitor(); -
sansmodels/src/sans/models/c_models/WrapperGenerator.py
raf03ddd r0f5bc9f 213 213 param_str = "// Initialize parameter dictionary\n" 214 214 for par in self.params: 215 param_str += " PyDict_SetItemString(self->params,\"%s\",Py_BuildValue(\"d\", self->model->%s()));\n" % \216 (par, par)215 param_str += " PyDict_SetItemString(self->params,\"%s\",Py_BuildValue(\"d\",%f));\n" % \ 216 (par, self.params[par]) 217 217 218 218 param_str += " // Initialize dispersion / averaging parameter dict\n" -
sansmodels/src/sans/models/c_models/cylinder.cpp
raf03ddd r0f5bc9f 189 189 190 190 printf("Length = %g\n", c.length()); 191 printf("I(Qx=%g,Qy=%g) = %g\n", 0.001, 0.001, c(0.001, 0.001)); 191 192 printf("I(Q=%g) = %g\n", 0.001, c(0.001)); 192 193 c.radius.dispersion = new GaussianDispersion(); -
sansmodels/src/sans/models/c_models/models.hh
raf03ddd r0f5bc9f 24 24 25 25 class CylinderModel{ 26 27 26 public: 28 27 // Model parameters … … 34 33 Parameter cyl_theta; 35 34 Parameter cyl_phi; 36 // TODO: replace this by an array of parameters37 35 38 36 // Constructor … … 45 43 }; 46 44 45 class SphereModel{ 46 public: 47 // Model parameters 48 Parameter radius; 49 Parameter scale; 50 Parameter contrast; 51 Parameter background; 52 53 // Constructor 54 SphereModel(); 55 56 // Operators to get I(Q) 57 double operator()(double q); 58 double operator()(double qx, double qy); 59 double evaluate_rphi(double q, double phi); 60 }; 61 62 class CoreShellModel{ 63 public: 64 // Model parameters 65 Parameter radius; 66 Parameter scale; 67 Parameter thickness; 68 Parameter core_sld; 69 Parameter shell_sld; 70 Parameter solvent_sld; 71 Parameter background; 72 73 // Constructor 74 CoreShellModel(); 75 76 // Operators to get I(Q) 77 double operator()(double q); 78 double operator()(double qx, double qy); 79 double evaluate_rphi(double q, double phi); 80 }; 81 82 class CoreShellCylinderModel{ 83 public: 84 // Model parameters 85 Parameter radius; 86 Parameter scale; 87 Parameter thickness; 88 Parameter length; 89 Parameter core_sld; 90 Parameter shell_sld; 91 Parameter solvent_sld; 92 Parameter background; 93 Parameter axis_theta; 94 Parameter axis_phi; 95 96 // Constructor 97 CoreShellCylinderModel(); 98 99 // Operators to get I(Q) 100 double operator()(double q); 101 double operator()(double qx, double qy); 102 double evaluate_rphi(double q, double phi); 103 }; 104 105 class EllipsoidModel{ 106 public: 107 // Model parameters 108 Parameter radius_a; 109 Parameter scale; 110 Parameter radius_b; 111 Parameter contrast; 112 Parameter background; 113 Parameter axis_theta; 114 Parameter axis_phi; 115 116 // Constructor 117 EllipsoidModel(); 118 119 // Operators to get I(Q) 120 double operator()(double q); 121 double operator()(double qx, double qy); 122 double evaluate_rphi(double q, double phi); 123 }; 124 125 class EllipticalCylinderModel{ 126 public: 127 // Model parameters 128 Parameter r_minor; 129 Parameter scale; 130 Parameter r_ratio; 131 Parameter length; 132 Parameter contrast; 133 Parameter background; 134 Parameter cyl_theta; 135 Parameter cyl_phi; 136 Parameter cyl_psi; 137 138 // Constructor 139 EllipticalCylinderModel(); 140 141 // Operators to get I(Q) 142 double operator()(double q); 143 double operator()(double qx, double qy); 144 double evaluate_rphi(double q, double phi); 145 }; 146 47 147 #endif -
sansmodels/src/sans/models/c_models/notes.txt
rfca6936 r0f5bc9f 11 11 parameters and the C++ Parameter class. 12 12 13 13 Length = 400 14 I(Q=0.001) = 450.355 15 I(Q=0.001) = 472.332 16 I(Q=0.001) = 4723.32 17 I(Qx=0.001, Qy=0.001) = 4743.56 18 I(Q=0.00447, Phi=0.7854) = 4733 19 pi=3.14159 20 21 I(Qx=0.01, Qy=0.01) = 2299 22 I(Q=0.0141421) = 2326.75 23 ratio 0.988074 1.01207 24 25 Cyl (python): 450.35506578 26 Disp(pyhton): 472.332213339 27 28 -------------- 29 Hello cylinder 30 450.35506578 31 449.358988524 32 446.344929175 33 34 {'npts': 1, 'type': 'gaussian', 'nsigmas': 2, 'width': 0.0} 35 {'npts': 1, 'type': 'flat', 'width': 0.0} 36 37 q= 0.001 38 New Cyl : 450.35506578 39 New Disp: 472.332213339 40 41 cyl(0.01, 0.01) =96.8691 42 cyl(0.0141421) =232.675 43 {'type': 'array'} 44 cyl(0.01, 0.01) =229.9 45 Hello cylinder 46 47 Old Cyl : 450.35506578 48 Old Disp: 472.332213339
Note: See TracChangeset
for help on using the changeset viewer.