source: sasview/sansmodels/igor_wrapper/src/weighted_cylinder.c @ 9a945a2

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 9a945a2 was 25a60dc1, checked in by Jae Cho <jhjcho@…>, 13 years ago

moving a folder

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[ae3ce4e]1/**
2 * Evaluate CylinderModel 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 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_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]:   length          = 400.0 A
42    //         pars[3]:   contrast        = 3e-06 A-2
43    //         pars[4]:   background      = 0.0 cm-1
44    //         pars[5]:   cyl_theta       = 1.0 rad
45    //         pars[6]:   cyl_phi         = 1.0 rad
46
47    //         pars[7]:   dispersion of radius
48    //         pars[8]:   dispersion of cyl_theta
49    //         pars[9]:   dispersion of cyl_phi
50    //         pars[10]:   number of points in dispersion curve
51 *
52 * NOTE: DO NOT USE THETA AND PHI PARAMETERS WHEN
53 *       USING THIS FUNCTION TO APPLY ANGULAR DISTRIBUTIONS.
54 *
55 */
56double cylinder_Weights(double dp[], double *phi_values, double *phi_weights, int n_phi, 
57                                                                double *theta_values, double *theta_weights, int n_theta, 
58                                                                double q, double phi_q) {
59        // Copy of parameters
60        double pars[11];
61        // Parameter index for theta
62        int theta_index = 5;
63        // Parameter index for phi
64        int phi_index   = 6;
65        int i, i_theta;
66        double sum, norm;
67       
68        // Copy parameters because they will be modified
69        for(i=0; i<11; i++) {
70                pars[i] = dp[i];
71        }
72
73        if (n_theta == 0) {
74                return weight_dispersion( &disperse_cylinder_analytical_2D,
75                                phi_values, phi_weights, n_phi, phi_index, pars, q, phi_q );
76        } else {
77                sum = 0.0;
78                norm = 0.0;
79               
80                for(i_theta=0; i_theta<n_theta; i_theta++) {
81                        // Assign new theta value
82                        pars[theta_index] = theta_values[i_theta];
83                        // Evaluate the function, weight by sin(theta)
84                        sum += sin(theta_values[i_theta]) * theta_weights[i_theta] * 
85                                        weight_dispersion( &disperse_cylinder_analytical_2D,
86                                        phi_values, phi_weights, n_phi, phi_index, pars, q, phi_q );
87                        // Keep track of normalization
88                        norm += theta_weights[i_theta];
89                }
90               
91                // Protect against null weight vector
92                if(norm > 0) {
93                        return sum/norm;
94                }
95        }
96        return 0.0;
97}
98
99
100
Note: See TracBrowser for help on using the repository browser.