source: sasview/sansmodels/igor_wrapper/src/weighted_elliptical_cylinder.c @ a86260e2

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

moving a folder

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