Ignore:
Timestamp:
Jan 5, 2012 4: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/lamellarPC.cpp

    r67424cd r82c11d3  
    2020 
    2121#include <math.h> 
    22 #include "models.hh" 
    2322#include "parameters.hh" 
    2423#include <stdio.h> 
    2524using namespace std; 
     25#include "lamellarPC.h" 
    2626 
    2727extern "C" { 
    28         #include "libCylinder.h" 
    29         #include "lamellarPC.h" 
     28#include "libCylinder.h" 
    3029} 
    3130 
    3231LamellarPCrystalModel :: LamellarPCrystalModel() { 
    33         scale      = Parameter(1.0); 
    34         thickness     = Parameter(33.0, true); 
    35         thickness.set_min(0.0); 
    36         Nlayers    = Parameter(20.0, true); 
    37         Nlayers.set_min(0.0); 
    38         spacing   = Parameter(250); 
    39         pd_spacing   = Parameter(0.0); 
    40         sld_layer  = Parameter(1.0e-6); 
    41         sld_solvent    = Parameter(6.34e-6); 
    42         background = Parameter(0.0); 
     32  scale      = Parameter(1.0); 
     33  thickness     = Parameter(33.0, true); 
     34  thickness.set_min(0.0); 
     35  Nlayers    = Parameter(20.0, true); 
     36  Nlayers.set_min(0.0); 
     37  spacing   = Parameter(250); 
     38  pd_spacing   = Parameter(0.0); 
     39  sld_layer  = Parameter(1.0e-6); 
     40  sld_solvent    = Parameter(6.34e-6); 
     41  background = Parameter(0.0); 
    4342 
    4443} 
     
    5150 */ 
    5251double LamellarPCrystalModel :: operator()(double q) { 
    53         double dp[8]; 
     52  double dp[8]; 
    5453 
    55         // Fill parameter array for IGOR library 
    56         // Add the background after averaging 
    57         dp[0] = scale(); 
    58         dp[1] = thickness(); 
    59         dp[2] = Nlayers(); 
    60         dp[3] = spacing(); 
    61         dp[4] = pd_spacing(); 
    62         dp[5] = sld_layer(); 
    63         dp[6] = sld_solvent(); 
    64         dp[7] = 0.0; // Do not apply background here. 
     54  // Fill parameter array for IGOR library 
     55  // Add the background after averaging 
     56  dp[0] = scale(); 
     57  dp[1] = thickness(); 
     58  dp[2] = Nlayers(); 
     59  dp[3] = spacing(); 
     60  dp[4] = pd_spacing(); 
     61  dp[5] = sld_layer(); 
     62  dp[6] = sld_solvent(); 
     63  dp[7] = 0.0; // Do not apply background here. 
    6564 
    66         // Get the dispersion points for the head thickness 
    67         vector<WeightPoint> weights_thickness; 
    68         thickness.get_weights(weights_thickness); 
     65  // Get the dispersion points for the head thickness 
     66  vector<WeightPoint> weights_thickness; 
     67  thickness.get_weights(weights_thickness); 
    6968 
    70         // Let's provide from the func which is more accurate especially for small q region. 
    71         // Get the dispersion points for the tail length 
    72         //vector<WeightPoint> weights_spacing; 
    73         //spacing.get_weights(weights_spacing); 
     69  // Let's provide from the func which is more accurate especially for small q region. 
     70  // Get the dispersion points for the tail length 
     71  //vector<WeightPoint> weights_spacing; 
     72  //spacing.get_weights(weights_spacing); 
    7473 
    75         // Perform the computation, with all weight points 
    76         double sum = 0.0; 
    77         double norm = 0.0; 
     74  // Perform the computation, with all weight points 
     75  double sum = 0.0; 
     76  double norm = 0.0; 
    7877 
    79         // Loop over thickness and spacing weight points 
    80         for(int i=0; i< (int)weights_thickness.size(); i++) { 
    81                 dp[1] = weights_thickness[i].value; 
    82                 //for (int j=0; j< (int)weights_spacing.size(); j++){ 
    83                         //dp[3] = weights_spacing[j].value; 
    84                         sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q); 
    85                         norm += weights_thickness[i].weight; 
    86                 //} 
    87         } 
    88         //apply norm and background 
    89         return sum/norm + background(); 
     78  // Loop over thickness and spacing weight points 
     79  for(int i=0; i< (int)weights_thickness.size(); i++) { 
     80    dp[1] = weights_thickness[i].value; 
     81    //for (int j=0; j< (int)weights_spacing.size(); j++){ 
     82    //dp[3] = weights_spacing[j].value; 
     83    sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q); 
     84    norm += weights_thickness[i].weight; 
     85    //} 
     86  } 
     87  //apply norm and background 
     88  return sum/norm + background(); 
    9089} 
    9190 
     
    9897 
    9998double LamellarPCrystalModel :: operator()(double qx, double qy) { 
    100         double q = sqrt(qx*qx + qy*qy); 
    101         return (*this).operator()(q); 
     99  double q = sqrt(qx*qx + qy*qy); 
     100  return (*this).operator()(q); 
    102101} 
    103102 
     
    110109 */ 
    111110double LamellarPCrystalModel :: evaluate_rphi(double q, double phi) { 
    112         return (*this).operator()(q); 
     111  return (*this).operator()(q); 
    113112} 
    114113/** 
     
    117116 */ 
    118117double LamellarPCrystalModel :: calculate_ER() { 
    119 //NOT implemented yet!!! 
    120         return 0.0; 
     118  //NOT implemented yet!!! 
     119  return 0.0; 
    121120} 
Note: See TracChangeset for help on using the changeset viewer.