I am considering starting to program a so-called MOC (method of characteristics) solver for neutron transport. I have some programming experience, mainly in FORTRAN and Perl. The goal of my solver would be to try various approximations pertaining to MOC solvers, and thus the program does not need to be blisteringly fast. If certain experiments are deemed worthwhile, they will be reprogrammed in FORTRAN for speed.
I'd like to use Python because I think it allows an easier code development, at the expense of being a bit slower than FORTRAN, but much easier to program, and the post-processing of results into graphics will probably be easier. I have never written one single line of Python so it will be a steep learning curve :-))
For the solver, I need to solve a differential equation along a straight line (the path of neutron travel). The geometry is 2D (x-y plane). For instance, there will be mostly cylinders oriented along the z-axis, in a regular square or rectangular lattice. For the integration along a path, I need to know the intersections of the straight line with each of the geometrical shapes in the (x-y) plane (thus, for instance, the intersections of a straight line with circles). It should be noted that because of the angular dependence, the inside of a cylinder would be divided into several "sectors".
I have been thinking about some ways to program this and it seems like a lot of work. There is a famous Monte Carlo code (MCNP) which use the concepts of cells bounded by curved surfaces, but it would seem like a lot of work to re-implement such a scheme. I would also like to extend the solver to non-uniform lattices, which would require a more "generic" mesh generator. Thus I went online and found MeshPy as a mesh generator for 2D and 3D geometries.
My question is the following: is there a package available somewhere to easily calculate the intersections of a straight line with the mesh elements? Or is there an easy mathematical trick? I have zero experience with meshing, ray tracing etc, so I don't really know where to start to learn. The information I need is: for each mesh element, I need to know the length of the straight line in the mesh element. I also need to know the "material" of the mesh element. Furthermore, I need to know the surface area of each mesh element. Also, the algorithm to calculate the intersections has to be fast, because in a typical calculation there may be between 10 and 100 mesh elements, and there would be several 100 straight lines at various angles for which to determine the intersections.
Regards, Wilfred van Rooijen