Changeset 975ec8e in sasview for sansmodels/src/sans/models/c_models
- Timestamp:
- Aug 14, 2009 5:58:58 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:
- d5bd424
- Parents:
- cad821b
- Location:
- sansmodels/src/sans/models/c_models
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp
r9bd69098 r975ec8e 86 86 87 87 // Initialize parameter dictionary 88 PyDict_SetItemString(self->params,"vol_frac_ls",Py_BuildValue("d",0. 200000));88 PyDict_SetItemString(self->params,"vol_frac_ls",Py_BuildValue("d",0.100000)); 89 89 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000)); 90 90 PyDict_SetItemString(self->params,"vol_frac_ss",Py_BuildValue("d",0.200000)); … … 93 93 PyDict_SetItemString(self->params,"ss_sld",Py_BuildValue("d",0.000000)); 94 94 PyDict_SetItemString(self->params,"s_radius",Py_BuildValue("d",25.000000)); 95 PyDict_SetItemString(self->params,"l_radius",Py_BuildValue("d",1 60.000000));95 PyDict_SetItemString(self->params,"l_radius",Py_BuildValue("d",100.000000)); 96 96 // Initialize dispersion / averaging parameter dict 97 97 DispersionVisitor* visitor = new DispersionVisitor(); … … 170 170 return PyArray_Return(result); 171 171 } 172 /** 173 * Function to call to evaluate model 174 * @param args: input numpy array [q[],phi[]] 175 * @return: numpy array object 176 */ 177 static PyObject * evaluateTwoDim( BinaryHSModel* model, 178 PyArrayObject *q, PyArrayObject *phi) 179 { 180 PyArrayObject *result; 181 //check validity of input vectors 182 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 183 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 184 || phi->dimensions[0] != q->dimensions[0]){ 185 186 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 187 PyErr_SetString(PyExc_ValueError ,"wrong input"); 188 return NULL; 189 } 190 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 191 192 if (result == NULL){ 193 const char * message= "Could not create result "; 194 PyErr_SetString(PyExc_RuntimeError , message); 195 return NULL; 196 } 197 198 for (int i = 0; i < q->dimensions[0]; i++) { 199 double q_value = *(double *)(q->data + i*q->strides[0]); 200 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 201 double *result_value = (double *)(result->data + i*result->strides[0]); 202 if (q_value == 0) 203 *result_value = 0.0; 204 else 205 *result_value = model->evaluate_rphi(q_value, phi_value); 206 } 207 return PyArray_Return(result); 208 } 172 209 173 /** 210 174 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CCylinderModel.cpp
r9bd69098 r975ec8e 175 175 return PyArray_Return(result); 176 176 } 177 /** 178 * Function to call to evaluate model 179 * @param args: input numpy array [q[],phi[]] 180 * @return: numpy array object 181 */ 182 static PyObject * evaluateTwoDim( CylinderModel* model, 183 PyArrayObject *q, PyArrayObject *phi) 184 { 185 PyArrayObject *result; 186 //check validity of input vectors 187 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 188 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 189 || phi->dimensions[0] != q->dimensions[0]){ 190 191 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 192 PyErr_SetString(PyExc_ValueError ,"wrong input"); 193 return NULL; 194 } 195 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 196 197 if (result == NULL){ 198 const char * message= "Could not create result "; 199 PyErr_SetString(PyExc_RuntimeError , message); 200 return NULL; 201 } 202 203 for (int i = 0; i < q->dimensions[0]; i++) { 204 double q_value = *(double *)(q->data + i*q->strides[0]); 205 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 206 double *result_value = (double *)(result->data + i*result->strides[0]); 207 if (q_value == 0) 208 *result_value = 0.0; 209 else 210 *result_value = model->evaluate_rphi(q_value, phi_value); 211 } 212 return PyArray_Return(result); 213 } 177 214 178 /** 215 179 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CEllipsoidModel.cpp
r9bd69098 r975ec8e 175 175 return PyArray_Return(result); 176 176 } 177 /** 178 * Function to call to evaluate model 179 * @param args: input numpy array [q[],phi[]] 180 * @return: numpy array object 181 */ 182 static PyObject * evaluateTwoDim( EllipsoidModel* model, 183 PyArrayObject *q, PyArrayObject *phi) 184 { 185 PyArrayObject *result; 186 //check validity of input vectors 187 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 188 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 189 || phi->dimensions[0] != q->dimensions[0]){ 190 191 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 192 PyErr_SetString(PyExc_ValueError ,"wrong input"); 193 return NULL; 194 } 195 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 196 197 if (result == NULL){ 198 const char * message= "Could not create result "; 199 PyErr_SetString(PyExc_RuntimeError , message); 200 return NULL; 201 } 202 203 for (int i = 0; i < q->dimensions[0]; i++) { 204 double q_value = *(double *)(q->data + i*q->strides[0]); 205 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 206 double *result_value = (double *)(result->data + i*result->strides[0]); 207 if (q_value == 0) 208 *result_value = 0.0; 209 else 210 *result_value = model->evaluate_rphi(q_value, phi_value); 211 } 212 return PyArray_Return(result); 213 } 177 214 178 /** 215 179 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp
r9bd69098 r975ec8e 183 183 return PyArray_Return(result); 184 184 } 185 /** 186 * Function to call to evaluate model 187 * @param args: input numpy array [q[],phi[]] 188 * @return: numpy array object 189 */ 190 static PyObject * evaluateTwoDim( EllipticalCylinderModel* model, 191 PyArrayObject *q, PyArrayObject *phi) 192 { 193 PyArrayObject *result; 194 //check validity of input vectors 195 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 196 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 197 || phi->dimensions[0] != q->dimensions[0]){ 198 199 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 200 PyErr_SetString(PyExc_ValueError ,"wrong input"); 201 return NULL; 202 } 203 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 204 205 if (result == NULL){ 206 const char * message= "Could not create result "; 207 PyErr_SetString(PyExc_RuntimeError , message); 208 return NULL; 209 } 210 211 for (int i = 0; i < q->dimensions[0]; i++) { 212 double q_value = *(double *)(q->data + i*q->strides[0]); 213 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 214 double *result_value = (double *)(result->data + i*result->strides[0]); 215 if (q_value == 0) 216 *result_value = 0.0; 217 else 218 *result_value = model->evaluate_rphi(q_value, phi_value); 219 } 220 return PyArray_Return(result); 221 } 185 222 186 /** 223 187 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CLamellarModel.cpp
r9bd69098 r975ec8e 86 86 87 87 // Initialize parameter dictionary 88 PyDict_SetItemString(self->params,"sld_sol",Py_BuildValue("d",0.000006)); 88 89 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 89 PyDict_SetItemString(self->params," sigma",Py_BuildValue("d",0.150000));90 PyDict_SetItemString(self->params,"bi_thick",Py_BuildValue("d",50.000000)); 90 91 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 91 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); 92 PyDict_SetItemString(self->params,"delta",Py_BuildValue("d",50.000000)); 92 PyDict_SetItemString(self->params,"sld_bi",Py_BuildValue("d",0.000001)); 93 93 // Initialize dispersion / averaging parameter dict 94 94 DispersionVisitor* visitor = new DispersionVisitor(); 95 95 PyObject * disp_dict; 96 disp_dict = PyDict_New(); 97 self->model->bi_thick.dispersion->accept_as_source(visitor, self->model->bi_thick.dispersion, disp_dict); 98 PyDict_SetItemString(self->dispersion, "bi_thick", disp_dict); 96 99 97 100 … … 161 164 return PyArray_Return(result); 162 165 } 163 /** 164 * Function to call to evaluate model 165 * @param args: input numpy array [q[],phi[]] 166 * @return: numpy array object 167 */ 168 static PyObject * evaluateTwoDim( LamellarModel* model, 169 PyArrayObject *q, PyArrayObject *phi) 170 { 171 PyArrayObject *result; 172 //check validity of input vectors 173 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 174 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 175 || phi->dimensions[0] != q->dimensions[0]){ 176 177 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 178 PyErr_SetString(PyExc_ValueError ,"wrong input"); 179 return NULL; 180 } 181 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 182 183 if (result == NULL){ 184 const char * message= "Could not create result "; 185 PyErr_SetString(PyExc_RuntimeError , message); 186 return NULL; 187 } 188 189 for (int i = 0; i < q->dimensions[0]; i++) { 190 double q_value = *(double *)(q->data + i*q->strides[0]); 191 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 192 double *result_value = (double *)(result->data + i*result->strides[0]); 193 if (q_value == 0) 194 *result_value = 0.0; 195 else 196 *result_value = model->evaluate_rphi(q_value, phi_value); 197 } 198 return PyArray_Return(result); 199 } 166 200 167 /** 201 168 * Function to call to evaluate model … … 260 227 261 228 // Reader parameter dictionary 229 self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") ); 262 230 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 263 self->model-> sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );231 self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") ); 264 232 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 265 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 266 self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") ); 233 self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") ); 267 234 // Read in dispersion parameters 268 235 PyObject* disp_dict; 269 236 DispersionVisitor* visitor = new DispersionVisitor(); 237 disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick"); 238 self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict); 270 239 271 240 … … 330 299 331 300 // Reader parameter dictionary 301 self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") ); 332 302 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 333 self->model-> sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );303 self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") ); 334 304 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 335 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 336 self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") ); 305 self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") ); 337 306 // Read in dispersion parameters 338 307 PyObject* disp_dict; 339 308 DispersionVisitor* visitor = new DispersionVisitor(); 309 disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick"); 310 self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict); 340 311 341 312 … … 389 360 390 361 // Reader parameter dictionary 362 self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") ); 391 363 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 392 self->model-> sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );364 self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") ); 393 365 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 394 self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 395 self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") ); 366 self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") ); 396 367 // Read in dispersion parameters 397 368 PyObject* disp_dict; 398 369 DispersionVisitor* visitor = new DispersionVisitor(); 370 disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick"); 371 self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict); 399 372 400 373 … … 452 425 // Ugliness necessary to go from python to C 453 426 // TODO: refactor this 454 { 427 if (!strcmp(par_name, "bi_thick")) { 428 self->model->bi_thick.dispersion = dispersion; 429 } else { 455 430 PyErr_SetString(CLamellarModelError, 456 431 "CLamellarModel.set_dispersion expects a valid parameter name."); -
sansmodels/src/sans/models/c_models/COblateModel.cpp
r9bd69098 r975ec8e 178 178 return PyArray_Return(result); 179 179 } 180 /** 181 * Function to call to evaluate model 182 * @param args: input numpy array [q[],phi[]] 183 * @return: numpy array object 184 */ 185 static PyObject * evaluateTwoDim( OblateModel* model, 186 PyArrayObject *q, PyArrayObject *phi) 187 { 188 PyArrayObject *result; 189 //check validity of input vectors 190 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 191 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 192 || phi->dimensions[0] != q->dimensions[0]){ 193 194 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 195 PyErr_SetString(PyExc_ValueError ,"wrong input"); 196 return NULL; 197 } 198 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 199 200 if (result == NULL){ 201 const char * message= "Could not create result "; 202 PyErr_SetString(PyExc_RuntimeError , message); 203 return NULL; 204 } 205 206 for (int i = 0; i < q->dimensions[0]; i++) { 207 double q_value = *(double *)(q->data + i*q->strides[0]); 208 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 209 double *result_value = (double *)(result->data + i*result->strides[0]); 210 if (q_value == 0) 211 *result_value = 0.0; 212 else 213 *result_value = model->evaluate_rphi(q_value, phi_value); 214 } 215 return PyArray_Return(result); 216 } 180 217 181 /** 218 182 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CParallelepipedModel.cpp
r9bd69098 r975ec8e 88 88 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 89 89 PyDict_SetItemString(self->params,"longer_edgeB",Py_BuildValue("d",75.000000)); 90 PyDict_SetItemString(self->params,"parallel_psi",Py_BuildValue("d",0.000000)); 90 91 PyDict_SetItemString(self->params,"longuest_edgeC",Py_BuildValue("d",400.000000)); 91 PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d", 1.000000));92 PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d", 1.000000));92 PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d",0.000000)); 93 PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d",0.000000)); 93 94 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 94 95 PyDict_SetItemString(self->params,"short_edgeA",Py_BuildValue("d",35.000000)); … … 109 110 self->model->parallel_phi.dispersion->accept_as_source(visitor, self->model->parallel_phi.dispersion, disp_dict); 110 111 PyDict_SetItemString(self->dispersion, "parallel_phi", disp_dict); 112 disp_dict = PyDict_New(); 113 self->model->parallel_psi.dispersion->accept_as_source(visitor, self->model->parallel_psi.dispersion, disp_dict); 114 PyDict_SetItemString(self->dispersion, "parallel_psi", disp_dict); 111 115 disp_dict = PyDict_New(); 112 116 self->model->parallel_theta.dispersion->accept_as_source(visitor, self->model->parallel_theta.dispersion, disp_dict); … … 179 183 return PyArray_Return(result); 180 184 } 181 /** 182 * Function to call to evaluate model 183 * @param args: input numpy array [q[],phi[]] 184 * @return: numpy array object 185 */ 186 static PyObject * evaluateTwoDim( ParallelepipedModel* model, 187 PyArrayObject *q, PyArrayObject *phi) 188 { 189 PyArrayObject *result; 190 //check validity of input vectors 191 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 192 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 193 || phi->dimensions[0] != q->dimensions[0]){ 194 195 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 196 PyErr_SetString(PyExc_ValueError ,"wrong input"); 197 return NULL; 198 } 199 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 200 201 if (result == NULL){ 202 const char * message= "Could not create result "; 203 PyErr_SetString(PyExc_RuntimeError , message); 204 return NULL; 205 } 206 207 for (int i = 0; i < q->dimensions[0]; i++) { 208 double q_value = *(double *)(q->data + i*q->strides[0]); 209 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 210 double *result_value = (double *)(result->data + i*result->strides[0]); 211 if (q_value == 0) 212 *result_value = 0.0; 213 else 214 *result_value = model->evaluate_rphi(q_value, phi_value); 215 } 216 return PyArray_Return(result); 217 } 185 218 186 /** 219 187 * Function to call to evaluate model … … 280 248 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 281 249 self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 250 self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 282 251 self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 283 252 self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); … … 297 266 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 298 267 self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 268 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi"); 269 self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict); 299 270 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta"); 300 271 self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict); … … 363 334 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 364 335 self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 336 self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 365 337 self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 366 338 self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); … … 380 352 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 381 353 self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 354 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi"); 355 self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict); 382 356 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta"); 383 357 self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict); … … 435 409 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 436 410 self->model->longer_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") ); 411 self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 437 412 self->model->longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") ); 438 413 self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); … … 452 427 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi"); 453 428 self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict); 429 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi"); 430 self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict); 454 431 disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta"); 455 432 self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict); … … 517 494 } else if (!strcmp(par_name, "parallel_phi")) { 518 495 self->model->parallel_phi.dispersion = dispersion; 496 } else if (!strcmp(par_name, "parallel_psi")) { 497 self->model->parallel_psi.dispersion = dispersion; 519 498 } else if (!strcmp(par_name, "parallel_theta")) { 520 499 self->model->parallel_theta.dispersion = dispersion; -
sansmodels/src/sans/models/c_models/CSphereModel.cpp
r9bd69098 r975ec8e 163 163 return PyArray_Return(result); 164 164 } 165 /** 166 * Function to call to evaluate model 167 * @param args: input numpy array [q[],phi[]] 168 * @return: numpy array object 169 */ 170 static PyObject * evaluateTwoDim( SphereModel* model, 171 PyArrayObject *q, PyArrayObject *phi) 172 { 173 PyArrayObject *result; 174 //check validity of input vectors 175 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 176 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 177 || phi->dimensions[0] != q->dimensions[0]){ 178 179 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 180 PyErr_SetString(PyExc_ValueError ,"wrong input"); 181 return NULL; 182 } 183 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 184 185 if (result == NULL){ 186 const char * message= "Could not create result "; 187 PyErr_SetString(PyExc_RuntimeError , message); 188 return NULL; 189 } 190 191 for (int i = 0; i < q->dimensions[0]; i++) { 192 double q_value = *(double *)(q->data + i*q->strides[0]); 193 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 194 double *result_value = (double *)(result->data + i*result->strides[0]); 195 if (q_value == 0) 196 *result_value = 0.0; 197 else 198 *result_value = model->evaluate_rphi(q_value, phi_value); 199 } 200 return PyArray_Return(result); 201 } 165 202 166 /** 203 167 * Function to call to evaluate model -
sansmodels/src/sans/models/c_models/CStackedDisksModel.cpp
r9bd69098 r975ec8e 86 86 87 87 // Initialize parameter dictionary 88 PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000004)); 89 PyDict_SetItemString(self->params,"core_thick",Py_BuildValue("d",10.000000)); 90 PyDict_SetItemString(self->params,"layer_thick",Py_BuildValue("d",15.000000)); 91 PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",0.000000)); 92 PyDict_SetItemString(self->params,"layer_sld",Py_BuildValue("d",-0.000000)); 93 PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000)); 94 PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000005)); 88 95 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",0.010000)); 89 PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",1.000000));90 PyDict_SetItemString(self->params,"spacing",Py_BuildValue("d",0.000000));91 PyDict_SetItemString(self->params,"nlayers",Py_BuildValue("d",1.000000));92 PyDict_SetItemString(self->params,"layer_sld",Py_BuildValue("d",-0.000000));93 PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000005));94 PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",15.000000));95 PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",1.000000));96 PyDict_SetItemString(self->params,"length",Py_BuildValue("d",10.000000));97 PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000004));98 96 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",3000.000000)); 99 97 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000)); 98 PyDict_SetItemString(self->params,"sigma_d",Py_BuildValue("d",0.000000)); 99 PyDict_SetItemString(self->params,"n_stacking",Py_BuildValue("d",1.000000)); 100 100 // Initialize dispersion / averaging parameter dict 101 101 DispersionVisitor* visitor = new DispersionVisitor(); 102 102 PyObject * disp_dict; 103 103 disp_dict = PyDict_New(); 104 self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict); 105 PyDict_SetItemString(self->dispersion, "length", disp_dict); 104 self->model->core_thick.dispersion->accept_as_source(visitor, self->model->core_thick.dispersion, disp_dict); 105 PyDict_SetItemString(self->dispersion, "core_thick", disp_dict); 106 disp_dict = PyDict_New(); 107 self->model->layer_thick.dispersion->accept_as_source(visitor, self->model->layer_thick.dispersion, disp_dict); 108 PyDict_SetItemString(self->dispersion, "layer_thick", disp_dict); 106 109 disp_dict = PyDict_New(); 107 110 self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict); … … 180 183 return PyArray_Return(result); 181 184 } 182 /** 183 * Function to call to evaluate model 184 * @param args: input numpy array [q[],phi[]] 185 * @return: numpy array object 186 */ 187 static PyObject * evaluateTwoDim( StackedDisksModel* model, 188 PyArrayObject *q, PyArrayObject *phi) 189 { 190 PyArrayObject *result; 191 //check validity of input vectors 192 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 193 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 194 || phi->dimensions[0] != q->dimensions[0]){ 195 196 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 197 PyErr_SetString(PyExc_ValueError ,"wrong input"); 198 return NULL; 199 } 200 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 201 202 if (result == NULL){ 203 const char * message= "Could not create result "; 204 PyErr_SetString(PyExc_RuntimeError , message); 205 return NULL; 206 } 207 208 for (int i = 0; i < q->dimensions[0]; i++) { 209 double q_value = *(double *)(q->data + i*q->strides[0]); 210 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 211 double *result_value = (double *)(result->data + i*result->strides[0]); 212 if (q_value == 0) 213 *result_value = 0.0; 214 else 215 *result_value = model->evaluate_rphi(q_value, phi_value); 216 } 217 return PyArray_Return(result); 218 } 185 219 186 /** 220 187 * Function to call to evaluate model … … 279 246 280 247 // Reader parameter dictionary 248 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 249 self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") ); 250 self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") ); 251 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 252 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") ); 253 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 254 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") ); 281 255 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 282 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );283 self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );284 self->model->nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nlayers") );285 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );286 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );287 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );288 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );289 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );290 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );291 256 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 292 257 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 258 self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") ); 259 self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") ); 293 260 // Read in dispersion parameters 294 261 PyObject* disp_dict; 295 262 DispersionVisitor* visitor = new DispersionVisitor(); 296 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 297 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 263 disp_dict = PyDict_GetItemString(self->dispersion, "core_thick"); 264 self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict); 265 disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick"); 266 self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict); 298 267 disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 299 268 self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); … … 364 333 365 334 // Reader parameter dictionary 335 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 336 self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") ); 337 self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") ); 338 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 339 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") ); 340 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 341 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") ); 366 342 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 367 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );368 self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );369 self->model->nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nlayers") );370 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );371 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );372 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );373 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );374 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );375 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );376 343 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 377 344 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 345 self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") ); 346 self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") ); 378 347 // Read in dispersion parameters 379 348 PyObject* disp_dict; 380 349 DispersionVisitor* visitor = new DispersionVisitor(); 381 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 382 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 350 disp_dict = PyDict_GetItemString(self->dispersion, "core_thick"); 351 self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict); 352 disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick"); 353 self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict); 383 354 disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 384 355 self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); … … 438 409 439 410 // Reader parameter dictionary 411 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") ); 412 self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") ); 413 self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") ); 414 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 415 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") ); 416 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") ); 417 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") ); 440 418 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 441 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );442 self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );443 self->model->nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nlayers") );444 self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );445 self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );446 self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );447 self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );448 self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );449 self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );450 419 self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") ); 451 420 self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 421 self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") ); 422 self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") ); 452 423 // Read in dispersion parameters 453 424 PyObject* disp_dict; 454 425 DispersionVisitor* visitor = new DispersionVisitor(); 455 disp_dict = PyDict_GetItemString(self->dispersion, "length"); 456 self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict); 426 disp_dict = PyDict_GetItemString(self->dispersion, "core_thick"); 427 self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict); 428 disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick"); 429 self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict); 457 430 disp_dict = PyDict_GetItemString(self->dispersion, "radius"); 458 431 self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict); … … 516 489 // Ugliness necessary to go from python to C 517 490 // TODO: refactor this 518 if (!strcmp(par_name, "length")) { 519 self->model->length.dispersion = dispersion; 491 if (!strcmp(par_name, "core_thick")) { 492 self->model->core_thick.dispersion = dispersion; 493 } else if (!strcmp(par_name, "layer_thick")) { 494 self->model->layer_thick.dispersion = dispersion; 520 495 } else if (!strcmp(par_name, "radius")) { 521 496 self->model->radius.dispersion = dispersion; -
sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp
r9bd69098 r975ec8e 87 87 // Initialize parameter dictionary 88 88 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 89 PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",1.000000)); 89 PyDict_SetItemString(self->params,"axis_psi",Py_BuildValue("d",0.000000)); 90 PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",0.000000)); 90 91 PyDict_SetItemString(self->params,"semi_axisA",Py_BuildValue("d",100.000000)); 91 92 PyDict_SetItemString(self->params,"semi_axisB",Py_BuildValue("d",35.000000)); 92 93 PyDict_SetItemString(self->params,"semi_axisC",Py_BuildValue("d",400.000000)); 93 PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d", 1.000000));94 PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000)); 94 95 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 95 96 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); … … 103 104 self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict); 104 105 PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict); 106 disp_dict = PyDict_New(); 107 self->model->axis_psi.dispersion->accept_as_source(visitor, self->model->axis_psi.dispersion, disp_dict); 108 PyDict_SetItemString(self->dispersion, "axis_psi", disp_dict); 105 109 106 110 … … 170 174 return PyArray_Return(result); 171 175 } 172 /** 173 * Function to call to evaluate model 174 * @param args: input numpy array [q[],phi[]] 175 * @return: numpy array object 176 */ 177 static PyObject * evaluateTwoDim( TriaxialEllipsoidModel* model, 178 PyArrayObject *q, PyArrayObject *phi) 179 { 180 PyArrayObject *result; 181 //check validity of input vectors 182 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 183 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 184 || phi->dimensions[0] != q->dimensions[0]){ 185 186 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 187 PyErr_SetString(PyExc_ValueError ,"wrong input"); 188 return NULL; 189 } 190 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 191 192 if (result == NULL){ 193 const char * message= "Could not create result "; 194 PyErr_SetString(PyExc_RuntimeError , message); 195 return NULL; 196 } 197 198 for (int i = 0; i < q->dimensions[0]; i++) { 199 double q_value = *(double *)(q->data + i*q->strides[0]); 200 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 201 double *result_value = (double *)(result->data + i*result->strides[0]); 202 if (q_value == 0) 203 *result_value = 0.0; 204 else 205 *result_value = model->evaluate_rphi(q_value, phi_value); 206 } 207 return PyArray_Return(result); 208 } 176 209 177 /** 210 178 * Function to call to evaluate model … … 270 238 // Reader parameter dictionary 271 239 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 240 self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") ); 272 241 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 273 242 self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") ); … … 284 253 disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 285 254 self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 255 disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi"); 256 self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict); 286 257 287 258 … … 347 318 // Reader parameter dictionary 348 319 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 320 self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") ); 349 321 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 350 322 self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") ); … … 361 333 disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 362 334 self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 335 disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi"); 336 self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict); 363 337 364 338 … … 413 387 // Reader parameter dictionary 414 388 self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 389 self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") ); 415 390 self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") ); 416 391 self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") ); … … 427 402 disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi"); 428 403 self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict); 404 disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi"); 405 self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict); 429 406 430 407 … … 486 463 } else if (!strcmp(par_name, "axis_phi")) { 487 464 self->model->axis_phi.dispersion = dispersion; 465 } else if (!strcmp(par_name, "axis_psi")) { 466 self->model->axis_psi.dispersion = dispersion; 488 467 } else { 489 468 PyErr_SetString(CTriaxialEllipsoidModelError, -
sansmodels/src/sans/models/c_models/c_models.cpp
reba9885 r975ec8e 30 30 void addCLamellarPSModel(PyObject *module); 31 31 void addCLamellarPSHGModel(PyObject *module); 32 void addCCoreShellSpheroidModel(PyObject *module); 32 33 void addCOblateModel(PyObject *module); 33 34 void addCProlateModel(PyObject *module); … … 225 226 addCLamellarPSModel(m); 226 227 addCLamellarPSHGModel(m); 228 addCCoreShellSpheroidModel(m); 227 229 addCOblateModel(m); 228 230 addCProlateModel(m); -
sansmodels/src/sans/models/c_models/lamellar.cpp
r42f193a r975ec8e 34 34 LamellarModel :: LamellarModel() { 35 35 scale = Parameter(1.0); 36 delta = Parameter(50.0); 37 delta.set_min(0.0); 38 sigma = Parameter(0.15); 39 sigma.set_min(0.0); 40 contrast = Parameter(5.3e-6); 36 bi_thick = Parameter(50.0, true); 37 bi_thick.set_min(0.0); 38 sld_bi = Parameter(1.0e-6); 39 sld_sol = Parameter(6.3e-6); 41 40 background = Parameter(0.0); 42 41 … … 55 54 // Add the background after averaging 56 55 dp[0] = scale(); 57 dp[1] = delta();58 dp[2] = s igma();59 dp[3] = contrast();60 dp[4] = background();56 dp[1] = bi_thick(); 57 dp[2] = sld_bi(); 58 dp[3] = sld_sol(); 59 dp[4] = 0.0; 61 60 62 return LamellarFF(dp, q); 61 // Get the dispersion points for the bi_thick 62 vector<WeightPoint> weights_bi_thick; 63 bi_thick.get_weights(weights_bi_thick); 64 // Perform the computation, with all weight points 65 double sum = 0.0; 66 double norm = 0.0; 67 68 // Loop over short_edgeA weight points 69 for(int i=0; i< (int)weights_bi_thick.size(); i++) { 70 dp[1] = weights_bi_thick[i].value; 71 72 sum += weights_bi_thick[i].weight * lamellar_kernel(dp, q); 73 norm += weights_bi_thick[i].weight; 74 75 } 76 77 return sum/norm + background(); 63 78 } 64 79 -
sansmodels/src/sans/models/c_models/models.hh
r2c4b289 r975ec8e 46 46 class ParallelepipedModel{ 47 47 public: 48 // TODO: add 2D 48 // TODO: add 2D 49 49 // Model parameters 50 50 Parameter scale; … … 56 56 Parameter parallel_theta; 57 57 Parameter parallel_phi; 58 Parameter parallel_psi; 58 59 59 60 // Constructor … … 277 278 Parameter axis_theta; 278 279 Parameter axis_phi; 279 280 Parameter axis_psi; 281 280 282 // Constructor 281 283 TriaxialEllipsoidModel(); … … 298 300 Parameter axis_theta; 299 301 Parameter axis_phi; 300 302 301 303 // Constructor 302 304 FlexibleCylinderModel(); … … 312 314 // Model parameters 313 315 Parameter scale; 314 Parameter length;315 Parameter radius; 316 Parameter thickness;316 Parameter core_thick; 317 Parameter radius; 318 Parameter layer_thick; 317 319 Parameter core_sld; 318 320 Parameter layer_sld; 319 321 Parameter solvent_sld; 320 Parameter n layers;321 Parameter s pacing;322 Parameter background; 323 Parameter axis_theta; 324 Parameter axis_phi; 325 322 Parameter n_stacking; 323 Parameter sigma_d; 324 Parameter background; 325 Parameter axis_theta; 326 Parameter axis_phi; 327 326 328 // Constructor 327 329 StackedDisksModel(); … … 337 339 // Model parameters 338 340 Parameter scale; 339 Parameter delta;340 Parameter s igma;341 Parameter contrast;342 Parameter background; 343 341 Parameter bi_thick; 342 Parameter sld_bi; 343 Parameter sld_sol; 344 Parameter background; 345 344 346 // Constructor 345 347 LamellarModel(); … … 362 364 Parameter sld_solvent; 363 365 Parameter background; 364 366 365 367 // Constructor 366 368 LamellarFFHGModel(); … … 386 388 Parameter caille; 387 389 Parameter background; 388 390 389 391 // Constructor 390 392 LamellarPSModel(); … … 409 411 Parameter caille; 410 412 Parameter background; 411 413 412 414 // Constructor 413 415 LamellarPSHGModel(); 416 417 // Operators to get I(Q) 418 double operator()(double q); 419 double operator()(double qx, double qy); 420 double evaluate_rphi(double q, double phi); 421 }; 422 423 class CoreShellSpheroidModel{ 424 public: 425 // Model parameters 426 Parameter scale; 427 Parameter equat_core; 428 Parameter polar_core; 429 Parameter equat_shell; 430 Parameter polar_shell; 431 Parameter contrast; 432 Parameter sld_solvent; 433 Parameter background; 434 Parameter axis_theta; 435 Parameter axis_phi; 436 437 // Constructor 438 CoreShellSpheroidModel(); 414 439 415 440 // Operators to get I(Q) … … 432 457 Parameter axis_theta; 433 458 Parameter axis_phi; 434 459 435 460 // Constructor 436 461 OblateModel(); … … 454 479 Parameter axis_theta; 455 480 Parameter axis_phi; 456 481 457 482 // Constructor 458 483 ProlateModel(); … … 474 499 Parameter axis_theta; 475 500 Parameter axis_phi; 476 501 477 502 //Constructor 478 503 HollowCylinderModel(); 479 504 480 505 //Operators to get I(Q) 481 506 double operator()(double q); … … 495 520 Parameter n_pairs; 496 521 Parameter background; 497 522 498 523 //Constructor 499 524 MultiShellModel(); 500 525 501 526 //Operators to get I(Q) 502 527 double operator()(double q); … … 514 539 Parameter shell_sld; 515 540 Parameter background; 516 541 517 542 //Constructor 518 543 VesicleModel(); 519 544 520 545 //Operators to get I(Q) 521 546 double operator()(double q); … … 535 560 Parameter solvent_sld; 536 561 Parameter background; 537 562 538 563 //Constructor 539 564 BinaryHSModel(); 540 565 541 566 //Operators to get I(Q) 542 567 double operator()(double q); … … 556 581 Parameter solvent_sld; 557 582 Parameter background; 558 583 559 584 //Constructor 560 585 BinaryHSPSF11Model(); 561 586 562 587 //Operators to get I(Q) 563 588 double operator()(double q); -
sansmodels/src/sans/models/c_models/oblate.cpp
r96b59384 r975ec8e 121 121 * @return: function value 122 122 */ 123 123 /* 124 124 double OblateModel :: operator()(double qx, double qy) { 125 125 double q = sqrt(qx*qx + qy*qy); … … 127 127 return (*this).operator()(q); 128 128 } 129 129 */ 130 130 131 131 /** … … 140 140 } 141 141 142 /* disable below for now 143 double Oblate ShellModel :: operator()(double qx, double qy) {142 143 double OblateModel :: operator()(double qx, double qy) { 144 144 OblateParameters dp; 145 145 // Fill parameter array … … 233 233 return sum/norm + background(); 234 234 } 235 */// 235 -
sansmodels/src/sans/models/c_models/parallelepiped.cpp
r8a48713 r975ec8e 45 45 parallel_theta = Parameter(0.0, true); 46 46 parallel_phi = Parameter(0.0, true); 47 parallel_psi = Parameter(0.0, true); 47 48 } 48 49 … … 54 55 */ 55 56 double ParallelepipedModel :: operator()(double q) { 56 double dp[ 5];57 double dp[6]; 57 58 58 59 // Fill parameter array for IGOR library … … 63 64 dp[3] = longuest_edgeC(); 64 65 dp[4] = contrast(); 65 //dp[5] = background();66 66 dp[5] = 0.0; 67 67 … … 69 69 vector<WeightPoint> weights_short_edgeA; 70 70 short_edgeA.get_weights(weights_short_edgeA); 71 71 72 72 // Get the dispersion points for the longer_edgeB 73 73 vector<WeightPoint> weights_longer_edgeB; … … 83 83 double sum = 0.0; 84 84 double norm = 0.0; 85 85 86 86 // Loop over short_edgeA weight points 87 87 for(int i=0; i< (int)weights_short_edgeA.size(); i++) { … … 96 96 dp[3] = weights_longuest_edgeC[j].value; 97 97 98 sum += weights_short_edgeA[i].weight * weights_longer_edgeB[j].weight 98 sum += weights_short_edgeA[i].weight * weights_longer_edgeB[j].weight 99 99 * weights_longuest_edgeC[k].weight * Parallelepiped(dp, q); 100 100 … … 124 124 dp.parallel_theta = parallel_theta(); 125 125 dp.parallel_phi = parallel_phi(); 126 126 dp.parallel_psi = parallel_psi(); 127 127 128 128 129 // Get the dispersion points for the short_edgeA … … 146 147 parallel_phi.get_weights(weights_parallel_phi); 147 148 149 // Get angular averaging for psi 150 vector<WeightPoint> weights_parallel_psi; 151 parallel_psi.get_weights(weights_parallel_psi); 148 152 149 153 // Perform the computation, with all weight points … … 171 175 dp.parallel_phi = weights_parallel_phi[m].value; 172 176 173 double _ptvalue = weights_short_edgeA[i].weight 174 * weights_longer_edgeB[j].weight 175 * weights_longuest_edgeC[k].weight 176 * weights_parallel_theta[l].weight 177 * weights_parallel_phi[m].weight 178 * parallelepiped_analytical_2DXY(&dp, qx, qy); 179 if (weights_parallel_theta.size()>1) { 180 _ptvalue *= sin(weights_parallel_theta[l].value); 177 // Average over phi distribution 178 for(int n=0; n< (int)weights_parallel_psi.size(); n++) { 179 dp.parallel_psi = weights_parallel_psi[n].value; 180 181 double _ptvalue = weights_short_edgeA[i].weight 182 * weights_longer_edgeB[j].weight 183 * weights_longuest_edgeC[k].weight 184 * weights_parallel_theta[l].weight 185 * weights_parallel_phi[m].weight 186 * weights_parallel_psi[n].weight 187 * parallelepiped_analytical_2DXY(&dp, qx, qy); 188 if (weights_parallel_theta.size()>1) { 189 _ptvalue *= sin(weights_parallel_theta[l].value); 190 } 191 sum += _ptvalue; 192 193 norm += weights_short_edgeA[i].weight 194 * weights_longer_edgeB[j].weight 195 * weights_longuest_edgeC[k].weight 196 * weights_parallel_theta[l].weight 197 * weights_parallel_phi[m].weight 198 * weights_parallel_psi[n].weight; 181 199 } 182 sum += _ptvalue;183 184 norm += weights_short_edgeA[i].weight185 * weights_longer_edgeB[j].weight186 * weights_longuest_edgeC[k].weight187 * weights_parallel_theta[l].weight188 * weights_parallel_phi[m].weight;189 200 } 190 201 -
sansmodels/src/sans/models/c_models/stackeddisks.cpp
r9188cc1 r975ec8e 37 37 radius = Parameter(3000.0, true); 38 38 radius.set_min(0.0); 39 length= Parameter(10.0, true);40 length.set_min(0.0);41 thickness= Parameter(15.0);42 thickness.set_min(0.0);39 core_thick = Parameter(10.0, true); 40 core_thick.set_min(0.0); 41 layer_thick = Parameter(15.0); 42 layer_thick.set_min(0.0); 43 43 core_sld = Parameter(4.0e-6); 44 44 layer_sld = Parameter(-4.0e-7); 45 45 solvent_sld = Parameter(5.0e-6); 46 n layers= Parameter(1);47 s pacing= Parameter(0);46 n_stacking = Parameter(1); 47 sigma_d = Parameter(0); 48 48 background = Parameter(0.001); 49 49 axis_theta = Parameter(0.0, true); … … 64 64 dp[0] = scale(); 65 65 dp[1] = radius(); 66 dp[2] = length();67 dp[3] = thickness();66 dp[2] = core_thick(); 67 dp[3] = layer_thick(); 68 68 dp[4] = core_sld(); 69 69 dp[5] = layer_sld(); 70 70 dp[6] = solvent_sld(); 71 dp[7] = n layers();72 dp[8] = s pacing();71 dp[7] = n_stacking(); 72 dp[8] = sigma_d(); 73 73 dp[9] = 0.0; 74 75 // Get the dispersion points for the length76 vector<WeightPoint> weights_length;77 length.get_weights(weights_length);78 74 79 75 // Get the dispersion points for the radius … … 81 77 radius.get_weights(weights_radius); 82 78 83 // Get the dispersion points for the thickness 84 vector<WeightPoint> weights_thickness; 85 thickness.get_weights(weights_thickness); 79 // Get the dispersion points for the core_thick 80 vector<WeightPoint> weights_core_thick; 81 core_thick.get_weights(weights_core_thick); 82 83 // Get the dispersion points for the layer_thick 84 vector<WeightPoint> weights_layer_thick; 85 layer_thick.get_weights(weights_layer_thick); 86 86 87 87 // Perform the computation, with all weight points … … 90 90 91 91 // Loop over length weight points 92 for(int i=0; i< (int)weights_ length.size(); i++) {93 dp[1] = weights_ length[i].value;92 for(int i=0; i< (int)weights_radius.size(); i++) { 93 dp[1] = weights_radius[i].value; 94 94 95 95 // Loop over radius weight points 96 for(int j=0; j< (int)weights_ radius.size(); j++) {97 dp[2] = weights_ radius[j].value;96 for(int j=0; j< (int)weights_core_thick.size(); j++) { 97 dp[2] = weights_core_thick[j].value; 98 98 99 99 // Loop over thickness weight points 100 for(int k=0; k< (int)weights_ radius.size(); k++) {101 dp[3] = weights_ radius[k].value;102 103 sum += weights_ length[i].weight104 * weights_ radius[j].weight * weights_thickness[k].weight* StackedDiscs(dp, q);105 norm += weights_ length[i].weight106 * weights_ radius[j].weight* weights_thickness[k].weight;100 for(int k=0; k< (int)weights_layer_thick.size(); k++) { 101 dp[3] = weights_layer_thick[k].value; 102 103 sum += weights_radius[i].weight 104 * weights_core_thick[j].weight * weights_layer_thick[k].weight* StackedDiscs(dp, q); 105 norm += weights_radius[i].weight 106 * weights_core_thick[j].weight* weights_layer_thick[k].weight; 107 107 } 108 108 } … … 121 121 // Fill parameter array 122 122 dp.scale = scale(); 123 dp. length = length();123 dp.core_thick = core_thick(); 124 124 dp.radius = radius(); 125 dp. thickness = thickness();125 dp.core_thick = core_thick(); 126 126 dp.core_sld = core_sld(); 127 127 dp.layer_sld = layer_sld(); 128 128 dp.solvent_sld= solvent_sld(); 129 dp.n layers = nlayers();130 dp.s pacing = spacing();129 dp.n_stacking = n_stacking(); 130 dp.sigma_d = sigma_d(); 131 131 dp.background = 0.0; 132 132 dp.axis_theta = axis_theta(); … … 134 134 135 135 // Get the dispersion points for the length 136 vector<WeightPoint> weights_ length;137 length.get_weights(weights_length);136 vector<WeightPoint> weights_core_thick; 137 core_thick.get_weights(weights_core_thick); 138 138 139 139 // Get the dispersion points for the radius … … 142 142 143 143 // Get the dispersion points for the thickness 144 vector<WeightPoint> weights_ thickness;145 thickness.get_weights(weights_thickness);144 vector<WeightPoint> weights_layer_thick; 145 layer_thick.get_weights(weights_layer_thick); 146 146 147 147 // Get angular averaging for theta … … 158 158 159 159 // Loop over length weight points 160 for(int i=0; i< (int)weights_ length.size(); i++) {161 dp. length = weights_length[i].value;160 for(int i=0; i< (int)weights_core_thick.size(); i++) { 161 dp.core_thick = weights_core_thick[i].value; 162 162 163 163 // Loop over radius weight points … … 166 166 167 167 // Loop over thickness weight points 168 for(int k=0; k< (int)weights_ thickness.size(); k++) {169 dp. thickness = weights_thickness[k].value;168 for(int k=0; k< (int)weights_layer_thick.size(); k++) { 169 dp.layer_thick = weights_layer_thick[k].value; 170 170 171 171 for(int l=0; l< (int)weights_theta.size(); l++) { … … 176 176 dp.axis_phi = weights_phi[m].value; 177 177 178 double _ptvalue = weights_ length[i].weight178 double _ptvalue = weights_core_thick[i].weight 179 179 * weights_radius[j].weight 180 * weights_ thickness[k].weight180 * weights_layer_thick[k].weight 181 181 * weights_theta[l].weight 182 182 * weights_phi[m].weight … … 187 187 sum += _ptvalue; 188 188 189 norm += weights_ length[i].weight189 norm += weights_core_thick[i].weight 190 190 * weights_radius[j].weight 191 * weights_ thickness[k].weight191 * weights_layer_thick[k].weight 192 192 * weights_theta[l].weight 193 193 * weights_phi[m].weight; -
sansmodels/src/sans/models/c_models/triaxialellipsoid.cpp
r9188cc1 r975ec8e 44 44 axis_theta = Parameter(0.0, true); 45 45 axis_phi = Parameter(0.0, true); 46 axis_psi = Parameter(0.0, true); 46 47 } 47 48 … … 53 54 */ 54 55 double TriaxialEllipsoidModel :: operator()(double q) { 55 double dp[ 5];56 double dp[6]; 56 57 57 58 // Fill parameter array for IGOR library … … 119 120 dp.axis_theta = axis_theta(); 120 121 dp.axis_phi = axis_phi(); 122 dp.axis_psi = axis_psi(); 121 123 122 124 // Get the dispersion points for the semi_axis A … … 140 142 axis_phi.get_weights(weights_phi); 141 143 144 // Get angular averaging for psi 145 vector<WeightPoint> weights_psi; 146 axis_psi.get_weights(weights_psi); 147 142 148 // Perform the computation, with all weight points 143 149 double sum = 0.0; … … 163 169 for(int m=0; m <(int)weights_phi.size(); m++) { 164 170 dp.axis_phi = weights_phi[m].value; 165 166 double _ptvalue = weights_semi_axisA[i].weight 167 * weights_semi_axisB[j].weight 168 * weights_semi_axisC[k].weight 169 * weights_theta[l].weight 170 * weights_phi[m].weight 171 * triaxial_ellipsoid_analytical_2DXY(&dp, qx, qy); 172 if (weights_theta.size()>1) { 173 _ptvalue *= sin(weights_theta[k].value); 171 // Average over psi distribution 172 for(int n=0; n <(int)weights_psi.size(); n++) { 173 dp.axis_psi = weights_psi[n].value; 174 175 double _ptvalue = weights_semi_axisA[i].weight 176 * weights_semi_axisB[j].weight 177 * weights_semi_axisC[k].weight 178 * weights_theta[l].weight 179 * weights_phi[m].weight 180 * weights_psi[n].weight 181 * triaxial_ellipsoid_analytical_2DXY(&dp, qx, qy); 182 if (weights_theta.size()>1) { 183 _ptvalue *= sin(weights_theta[k].value); 184 } 185 sum += _ptvalue; 186 187 norm += weights_semi_axisA[i].weight 188 * weights_semi_axisB[j].weight 189 * weights_semi_axisC[k].weight 190 * weights_theta[l].weight 191 * weights_phi[m].weight 192 * weights_psi[m].weight; 174 193 } 175 sum += _ptvalue;176 177 norm += weights_semi_axisA[i].weight178 * weights_semi_axisB[j].weight179 * weights_semi_axisC[k].weight180 * weights_theta[l].weight181 * weights_phi[m].weight;182 194 } 183 195
Note: See TracChangeset
for help on using the changeset viewer.