Changeset 82c11d3 in sasview for sansmodels/src/c_models/binaryHS.cpp
- Timestamp:
- Jan 5, 2012 6:24:51 PM (13 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:
- 20d91bd
- Parents:
- 98fdccd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/binaryHS.cpp
r67424cd r82c11d3 21 21 22 22 #include <math.h> 23 #include "models.hh"24 23 #include "parameters.hh" 25 24 #include <stdio.h> 26 25 using namespace std; 26 #include "binaryHS.h" 27 27 28 28 extern "C" { 29 #include "libSphere.h" 30 #include "binaryHS.h" 29 #include "libSphere.h" 31 30 } 32 31 33 32 BinaryHSModel :: BinaryHSModel() { 34 33 35 36 37 38 39 40 41 42 43 44 34 l_radius = Parameter(160.0, true); 35 l_radius.set_min(0.0); 36 s_radius = Parameter(25.0, true); 37 s_radius.set_min(0.0); 38 vol_frac_ls = Parameter(0.2); 39 vol_frac_ss = Parameter(0.1); 40 ls_sld = Parameter(3.5e-6); 41 ss_sld = Parameter(5e-7); 42 solvent_sld = Parameter(6.36e-6); 43 background = Parameter(0.0); 45 44 } 46 45 … … 52 51 */ 53 52 double BinaryHSModel :: operator()(double q) { 54 53 double dp[8]; 55 54 56 57 58 59 60 61 62 63 64 65 55 // Fill parameter array for IGOR library 56 // Add the background after averaging 57 dp[0] = l_radius(); 58 dp[1] = s_radius(); 59 dp[2] = vol_frac_ls(); 60 dp[3] = vol_frac_ss(); 61 dp[4] = ls_sld(); 62 dp[5] = ss_sld(); 63 dp[6] = solvent_sld(); 64 dp[7] = 0.0; 66 65 67 66 68 69 70 67 // Get the dispersion points for the large radius 68 vector<WeightPoint> weights_l_radius; 69 l_radius.get_weights(weights_l_radius); 71 70 72 73 74 71 // Get the dispersion points for the small radius 72 vector<WeightPoint> weights_s_radius; 73 s_radius.get_weights(weights_s_radius); 75 74 76 77 78 75 // Perform the computation, with all weight points 76 double sum = 0.0; 77 double norm = 0.0; 79 78 80 81 82 79 // Loop over larger radius weight points 80 for(int i=0; i< (int)weights_l_radius.size(); i++) { 81 dp[0] = weights_l_radius[i].value; 83 82 84 85 86 83 // Loop over small radius weight points 84 for(int j=0; j< (int)weights_s_radius.size(); j++) { 85 dp[1] = weights_s_radius[j].value; 87 86 88 87 89 90 91 92 93 88 sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS(dp, q); 89 norm += weights_l_radius[i].weight *weights_s_radius[j].weight; 90 } 91 } 92 return sum/norm + background(); 94 93 } 95 94 … … 101 100 */ 102 101 double BinaryHSModel :: operator()(double qx, double qy) { 103 104 102 double q = sqrt(qx*qx + qy*qy); 103 return (*this).operator()(q); 105 104 } 106 105 … … 113 112 */ 114 113 double BinaryHSModel :: evaluate_rphi(double q, double phi) { 115 114 return (*this).operator()(q); 116 115 } 117 116 … … 121 120 */ 122 121 double BinaryHSModel :: calculate_ER() { 123 124 122 //NOT implemented yet!!! 123 return 0.0; 125 124 } 126 125
Note: See TracChangeset
for help on using the changeset viewer.