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