geogunow / MultiGroupMC

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

Spatial Heterogeneity #7

Closed ljeure closed 8 years ago

ljeure commented 8 years ago

The mesh class can now be passed a material type. Different cells can be filled with different types of material. When a mesh is initialized, it can be passed a material to be set for all the cells. If no material is passed, all the cells are set to material type 'water'.

The material of certain sections of the box can be changed with the function 'fill_material()'.

Previously monte_carlo.py ran into trouble when a neutron was on the upper edge of a cell. For example, in an mesh from -1 to 1 with delta_x = .1, when a neutron was at x=-.9, it should have been counted as in cell x=0 if its direction of movement was into cell x=0. The previous code counted it as in cell x=1, however. We tried to overcome that by nudging the neutron, but that must not have been implemented properly because it wasn't working. I added in code in mesh.py that simply checks the direction of travel of the neutron in the case that it's on the lower boundary of a cell. There are almost certainly more elegant solutions to this problem, but this is the only one I could get to work.

The plotter was plotting the heat map on with the axes switched. I fixed that.

geogunow commented 8 years ago

I just did my first pass of comments. It's looking pretty good. I haven't tried running it yet. I'll take a closer look tomorrow.

geogunow commented 8 years ago

I just did some testing and the answers are looking pretty good. Although, I would like to change the structure a bit. Right now, you are adding materials with strings. I would like to change this so that _cell_materials in the Mesh class contains actual material objects. For example, in the constructor for the Mesh, rather than default_material being 'water', let's have default_material be an actual material. And instead of initializing everything with water, let's initialize with None (Python syntax that means a null or empty pointer -- we'll discuss pointers later when we move to C++).

The advantage here is that this will require the user to specify every cell. If we don't do this, a user could encounter unexpected behavior. Say the user forgets to specify the material for a certain range, where it should be fuel. In the current code it will default to water and run without hitting any error messages but deliver incorrect results. When we have an error in the input, we would like to know about it, if possible.