Skip to content

Commit

Permalink
Documentaiton and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottbiondo committed Jul 4, 2014
1 parent 286f736 commit 629cb95
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 215 deletions.
2 changes: 1 addition & 1 deletion cpp/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <math.h>

#include "measure.hpp"
#include "measure.h"

class CartVect {
private:
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions cpp/source_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ void Sampler::get_mesh_geom_data(MBRange ves, vect_d &volumes) {
MBCartVect x(coords[3], coords[4], coords[5]);
MBCartVect y(coords[9], coords[10], coords[11]);
MBCartVect z(coords[12], coords[13], coords[14]);
edge_vects ev = {o, x-o, y-o, z-o};
_all_edge_vects.push_back(ev);
edge_points ep = {o, x-o, y-o, z-o};
_all_edge_points.push_back(ep);
} else if (_ve_type == MBTET) {
MBCartVect o(coords[0], coords[1], coords[2]);
MBCartVect x(coords[3], coords[4], coords[5]);
MBCartVect y(coords[6], coords[7], coords[8]);
MBCartVect z(coords[9], coords[10], coords[11]);
edge_vects ev = {o, x-o, y-o, z-o};
_all_edge_vects.push_back(ev);
edge_points ep = {o, x-o, y-o, z-o};
_all_edge_points.push_back(ep);
}
}
}
Expand All @@ -112,7 +112,7 @@ void Sampler::get_mesh_tag_data(MBRange ves, const vect_d volumes) {
MB_TYPE_DOUBLE,
src_tag);
// THIS rval FAILS because we do not know number of energy groups a priori.

// That's okay. That's what the next line is all about:
_num_e_groups = get_num_groups(src_tag);
vect_d pdf(_num_ves*_num_e_groups);
rval = _mesh->tag_get_data(src_tag, ves, &pdf[0]);
Expand Down Expand Up @@ -226,10 +226,10 @@ MBCartVect Sampler::get_xyz(int ve_idx, vect_d rands) {
}
}

return s*_all_edge_vects[ve_idx].x_vec + \
t*_all_edge_vects[ve_idx].y_vec + \
u*_all_edge_vects[ve_idx].z_vec + \
_all_edge_vects[ve_idx].o_point;
return s*_all_edge_points[ve_idx].x_vec + \
t*_all_edge_points[ve_idx].y_vec + \
u*_all_edge_points[ve_idx].z_vec + \
_all_edge_points[ve_idx].o_point;
}

double Sampler::get_e(int e_idx, double rand) {
Expand Down
42 changes: 25 additions & 17 deletions cpp/source_sampling.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
#ifndef PYNE_6OR6BJURKJHHTOFWXO2VMQM5EY
#define PYNE_6OR6BJURKJHHTOFWXO2VMQM5EY
/// \file source_sampling.h
/// \author Elliott Biondo (biondo\@wisc.edu)
///
/// \brief The tally class and helper functions
/// \brief Mesh-based Monte Carlo source sampling.
///
/// The tally class is in essesence a structure containing attributes
/// related to tallies
/// The Sampler class is used for Monte Carlo source sampling from mesh-based
/// sources. The source density distribution and optional biased source density
/// distribution are defined on a MOAB mesh. Upon instantiation, a Sampler
/// object reads this mesh and creates an alias table for randomly sampling
/// particle birth parameters. The particle_birth member function is supplied
/// with 6 pseudo-random numbers and returns the position, energy, and weight
/// of a particle upon birth. There are three sampling modes: analog, uniform,
/// and user. In analog sampling, no source biasing is used and birth weights
/// are all 1. In uniform sampling, all phase space is sampled evenly and weights
/// are adjusted accordingly. In user mode, a user-supplied biased source
/// density distribution is used for sampling and particle weights are adjusted
/// accordingly. The biased source density distribution must have the same number
/// of energy groups as the unbiased distribution. Alternatively, it may have
/// exactly 1 energy group, in which case this value is used for all energies
/// within a particular mesh volume element.

#ifndef PYNE_6OR6BJURKJHHTOFWXO2VMQM5EY
#define PYNE_6OR6BJURKJHHTOFWXO2VMQM5EY

#include <assert.h>
#include <iostream>
Expand All @@ -20,7 +34,7 @@

#include "moab/Range.hpp"
#include "MBCore.hpp"
#include "measure.hpp"
#include "measure.h"
#include "MBCartVect.hpp"

#ifdef __cplusplus
Expand All @@ -31,13 +45,7 @@ void get_e_bounds_data(std::string e_bounds_file);
typedef std::vector<double> vect_d;
typedef std::string str;

struct Sample {
vect_d xyz; /// \param type
double e;
double w;
};

struct edge_vects {
struct edge_points {
MBCartVect o_point;
MBCartVect x_vec;
MBCartVect y_vec;
Expand Down Expand Up @@ -66,9 +74,9 @@ class Sampler
Sampler(str filename, str src_tag_name, vect_d e_bounds, bool uniform);
Sampler(str filename, str src_tag_name, vect_d e_bounds, str bias_tag_name);
~Sampler() {
delete _mesh;
delete _at;
};
delete _mesh;
delete _at;
};
vect_d particle_birth(vect_d rands);

private:
Expand All @@ -84,7 +92,7 @@ class Sampler
int _num_ves;
MBEntityType _ve_type;
int _verts_per_ve;
std::vector<edge_vects> _all_edge_vects;
std::vector<edge_points> _all_edge_points;
AliasTable* _at;
std::vector<double> _biased_weights;

Expand Down
52 changes: 52 additions & 0 deletions docs/theorymanual/source_sampling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _source_sampling:

=============================
Source Sampling
=============================

.. currentmodule:: pyne.source_sampling

This page presents a detailed explanation of how :py:mod:`Source Sampling` works, including
underlying theory, any assocaited assumptions, and information about correct and
appropriate use of this physics.


*****************************
Descriptive Heading of Method
*****************************

Mathematical Details, some example math syntax:

You can use LaTeX format in rst. To do inline expressions (what $expression$ would
do in LaTeX) :math:`A\vec{x} = \vec{b}`.

To have blocks of mathematical content, do this

.. math::
A\vec{x} = \vec{b}
Support is limited to a subset of LaTeX math by the conversion required for many output formats.

***********
Assumptions
***********

Any assumptions (explicit or implicit) about this method that would impact use, conclusions, validity, etc.



**********************
Additional Information
**********************

Details about impact of this theory on method use.

**********
References
**********

All of the justification for us listening to you.



17 changes: 0 additions & 17 deletions pyne/cpp_source_sampling.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,5 @@ cdef extern from "source_sampling.h" :



cdef extern from "source_sampling.h" :

cdef cppclass Sample:
# constructors
Sample() except +

# attributes
double e
double w
cpp_vector[double] xyz

# methods

pass




{'cpppxd_footer': '', 'pyx_header': '', 'pxd_header': '', 'pxd_footer': '', 'cpppxd_header': '', 'pyx_footer': ''}
13 changes: 0 additions & 13 deletions pyne/source_sampling.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
################################################


cimport dtypes
cimport numpy as np
from libcpp.vector cimport vector as cpp_vector
from pyne cimport cpp_source_sampling


Expand All @@ -24,16 +21,6 @@ cdef class Sampler:



cdef class Sample:
cdef void * _inst
cdef public bint _free_inst
cdef public np.ndarray _xyz
pass





cdef class AliasTable:
cdef void * _inst
cdef public bint _free_inst
Expand Down
Loading

0 comments on commit 629cb95

Please sign in to comment.