geogunow / MultiGroupMC

Tutorial to build a multi-group Monte Carlo solver
1 stars 1 forks source link

Assignment 1 #1

Closed ljeure closed 9 years ago

ljeure commented 9 years ago

In circle.py, I created a function that calculated pi by randomly placing points in a 2x2 square and comparing the number of points that landed in a circle circumscribed in the square to the number of points that landed outside the circle.

In monte_carlo.py I defined a function transport_neutron that creates a neutron and follows it until it is absorbed, tracking the distance it travels and storing this distance in the crow_distances list.

The reason that the second plot in assignment.py failed to have evenly scattered points was that the function creating it used an incorrect polar angle as an argument.

geogunow commented 9 years ago

I just went through and made a lot of style comments. In general, we try to be pretty strict on style so that all code conforms to the same style guide. Many companies have their own style guide (like Google's C++ style guide) but for Python, the PEP8 style guide (https://www.python.org/dev/peps/pep-0008/) is standard for pretty much everyone since it is provided by Python.

geogunow commented 9 years ago

As far as the functionality of the code, cicle.py works great. I noticed you ask the user for input. While that is good for some applications, we typically put the values directly into the python script without explicitly asking the user for input. It's not too hard to change a value in a python script and it reduces the work the user has to do (ie type the number of darts each time).

geogunow commented 9 years ago

For monte_carlo.py, we are interested in calculating the mean crow flight. This is the average distance between the start point and end point. Right now you are calculating the average distance traveled. These are two different quantities since scattering interactions will lead to the distance between the start and end point to be less than the total distance traveled. To calculate the distance between the start and end point you will need to explicitly track the particle through the geometry. That means remembering a bit of spherical coordinates and having some code that might look like:

x += distance * sin(theta) * cos(phi)
geogunow commented 9 years ago

Luke, great job updating the code! Once all the comments above have been addressed and become outdated, I will merge the changes.