Ignore:
Timestamp:
Jan 5, 2012 6:24:51 PM (13 years ago)
Author:
Mathieu Doucet <doucetm@…>
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
Message:

refactored bunch of models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/c_models/binaryHS.cpp

    r67424cd r82c11d3  
    2121 
    2222#include <math.h> 
    23 #include "models.hh" 
    2423#include "parameters.hh" 
    2524#include <stdio.h> 
    2625using namespace std; 
     26#include "binaryHS.h" 
    2727 
    2828extern "C" { 
    29         #include "libSphere.h" 
    30         #include "binaryHS.h" 
     29#include "libSphere.h" 
    3130} 
    3231 
    3332BinaryHSModel :: BinaryHSModel() { 
    3433 
    35         l_radius     = Parameter(160.0, true); 
    36         l_radius.set_min(0.0); 
    37         s_radius    = Parameter(25.0, true); 
    38         s_radius.set_min(0.0); 
    39         vol_frac_ls  = Parameter(0.2); 
    40         vol_frac_ss  = Parameter(0.1); 
    41         ls_sld      = Parameter(3.5e-6); 
    42         ss_sld     = Parameter(5e-7); 
    43         solvent_sld   = Parameter(6.36e-6); 
    44         background = Parameter(0.0); 
     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); 
    4544} 
    4645 
     
    5251 */ 
    5352double BinaryHSModel :: operator()(double q) { 
    54         double dp[8]; 
     53  double dp[8]; 
    5554 
    56         // Fill parameter array for IGOR library 
    57         // Add the background after averaging 
    58         dp[0] = l_radius(); 
    59         dp[1] = s_radius(); 
    60         dp[2] = vol_frac_ls(); 
    61         dp[3] = vol_frac_ss(); 
    62         dp[4] = ls_sld(); 
    63         dp[5] = ss_sld(); 
    64         dp[6] = solvent_sld(); 
    65         dp[7] = 0.0; 
     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; 
    6665 
    6766 
    68         // Get the dispersion points for the large radius 
    69         vector<WeightPoint> weights_l_radius; 
    70         l_radius.get_weights(weights_l_radius); 
     67  // Get the dispersion points for the large radius 
     68  vector<WeightPoint> weights_l_radius; 
     69  l_radius.get_weights(weights_l_radius); 
    7170 
    72         // Get the dispersion points for the small radius 
    73         vector<WeightPoint> weights_s_radius; 
    74         s_radius.get_weights(weights_s_radius); 
     71  // Get the dispersion points for the small radius 
     72  vector<WeightPoint> weights_s_radius; 
     73  s_radius.get_weights(weights_s_radius); 
    7574 
    76         // Perform the computation, with all weight points 
    77         double sum = 0.0; 
    78         double norm = 0.0; 
     75  // Perform the computation, with all weight points 
     76  double sum = 0.0; 
     77  double norm = 0.0; 
    7978 
    80         // Loop over larger radius weight points 
    81         for(int i=0; i< (int)weights_l_radius.size(); i++) { 
    82                 dp[0] = weights_l_radius[i].value; 
     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; 
    8382 
    84                 // Loop over small radius weight points 
    85                 for(int j=0; j< (int)weights_s_radius.size(); j++) { 
    86                         dp[1] = weights_s_radius[j].value; 
     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; 
    8786 
    8887 
    89                         sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS(dp, q); 
    90                         norm += weights_l_radius[i].weight *weights_s_radius[j].weight; 
    91                 } 
    92         } 
    93         return sum/norm + background(); 
     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(); 
    9493} 
    9594 
     
    101100 */ 
    102101double BinaryHSModel :: operator()(double qx, double qy) { 
    103         double q = sqrt(qx*qx + qy*qy); 
    104         return (*this).operator()(q); 
     102  double q = sqrt(qx*qx + qy*qy); 
     103  return (*this).operator()(q); 
    105104} 
    106105 
     
    113112 */ 
    114113double BinaryHSModel :: evaluate_rphi(double q, double phi) { 
    115         return (*this).operator()(q); 
     114  return (*this).operator()(q); 
    116115} 
    117116 
     
    121120 */ 
    122121double BinaryHSModel :: calculate_ER() { 
    123         //NOT implemented yet!!! 
    124         return 0.0; 
     122  //NOT implemented yet!!! 
     123  return 0.0; 
    125124} 
    126125 
Note: See TracChangeset for help on using the changeset viewer.