source: sasview/sansmodels/igor_wrapper/src/weighted_core_shell_cylinder.c @ 25a60dc1

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 25a60dc1 was 25a60dc1, checked in by Jae Cho <jhjcho@…>, 13 years ago

moving a folder

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/**
2 * Evaluate CoreShellCylinderModel with angular distribution given
3 * by user.
4 *
5 * This code was written as part of the DANSE project
6 *  http://danse.us/trac/sans/
7 *
8 * WARNING: THIS FILE WAS GENERATED BY IGORGENERATOR.PY
9 *          DO NOT MODIFY THIS FILE, MODIFY core_shell_cylinder.h
10 *          AND RE-RUN THE GENERATOR SCRIPT
11 *   
12 *  @copyright 2007: University of Tennessee, for the DANSE project
13 *
14 */
15
16#include "c_disperser.h"
17#include "danse.h"
18#include <math.h>
19
20/**
21 * Evaluate model for given angular distributions in theta and phi.
22 *
23 * Angles are in radian.
24 *
25 * See disp_core_shell_cylinder.c for more information about the model parameters.
26 *
27 * @param dp: model parameters
28 * @param phi_values: vector of phi_values
29 * @param phi_weights: vector of weights for each entry in phi_values
30 * @param n_phi: length of phi_values and phi_weights vectors
31 * @param theta_values: vector of theta values
32 * @param theta_weights: vector of weights for each entry in theta_values
33 * @param n_theta: length of theta_Values and theta_weights vectors
34 * @param q: q-value to evaluate the model at
35 * @param phi_q: angle between the q-vector and the q_x axis
36 * @return: scattering intensity
37 *
38    // List of default parameters:
39    //         pars[0]:   scale           = 1.0
40    //         pars[1]:   radius          = 20.0 A
41    //         pars[2]:   thickness       = 10.0 A
42    //         pars[3]:   length          = 400.0 A
43    //         pars[4]:   core_sld        = 1e-06 A-2
44    //         pars[5]:   shell_sld       = 4e-06 A-2
45    //         pars[6]:   solvent_sld     = 1e-06 A-2
46    //         pars[7]:   background      = 0.0 cm-1
47    //         pars[8]:   axis_theta      = 1.57 rad
48    //         pars[9]:   axis_phi        = 0.0 rad
49
50    //         pars[10]:   dispersion of radius
51    //         pars[11]:   dispersion of thickness
52    //         pars[12]:   dispersion of axis_theta
53    //         pars[13]:   dispersion of axis_phi
54    //         pars[14]:   number of points in dispersion curve
55 *
56 * NOTE: DO NOT USE THETA AND PHI PARAMETERS WHEN
57 *       USING THIS FUNCTION TO APPLY ANGULAR DISTRIBUTIONS.
58 *
59 */
60double core_shell_cylinder_Weights(double dp[], double *phi_values, double *phi_weights, int n_phi, 
61                                                                double *theta_values, double *theta_weights, int n_theta, 
62                                                                double q, double phi_q) {
63        // Copy of parameters
64        double pars[15];
65        // Parameter index for theta
66        int theta_index = 8;
67        // Parameter index for phi
68        int phi_index   = 9;
69        int i, i_theta;
70        double sum, norm;
71       
72        // Copy parameters because they will be modified
73        for(i=0; i<15; i++) {
74                pars[i] = dp[i];
75        }
76
77        if (n_theta == 0) {
78                return weight_dispersion( &disperse_core_shell_cylinder_analytical_2D,
79                                phi_values, phi_weights, n_phi, phi_index, pars, q, phi_q );
80        } else {
81                sum = 0.0;
82                norm = 0.0;
83               
84                for(i_theta=0; i_theta<n_theta; i_theta++) {
85                        // Assign new theta value
86                        pars[theta_index] = theta_values[i_theta];
87                        // Evaluate the function, weight by sin(theta)
88                        sum += sin(theta_values[i_theta]) * theta_weights[i_theta] * 
89                                        weight_dispersion( &disperse_core_shell_cylinder_analytical_2D,
90                                        phi_values, phi_weights, n_phi, phi_index, pars, q, phi_q );
91                        // Keep track of normalization
92                        norm += theta_weights[i_theta];
93                }
94               
95                // Protect against null weight vector
96                if(norm > 0) {
97                        return sum/norm;
98                }
99        }
100        return 0.0;
101}
102
103
104
Note: See TracBrowser for help on using the repository browser.