I am trying to simulate a volumic source distributed inside a Marinelli beaker using the source_newgen.f routine. I use sample_discrete_momentum_energy to simulate a set of discrete gamma energies.
Following discussions from previous threads, I implemented volumic sampling within the Marinelli geometry using random sampling. However, based on the 2D USRBIN results, the source does not appear to be uniformly distributed throughout the beaker volume. (Please see the attached image for reference.)
Regarding the coordinates coordinate_x, coordinate_y, and coordinate_z in source_newgen.f, I set them to the center of the Marinelli region. Is that the correct ?
It looks like your implementation of the source routine is right. It is simply difficult to check the uniformity of the primary vertices simply looking at a fluence map. Keep in mind there will be backscatter from the beaker walls and that points inside the beaker are more likely to meet a photon track.
I suggest that, just for the purposes of debugging, you set the material of the beaker to vacuum and then blackhole. The uniformity will be more apparent. You could also use the debugging function of the source routine (see Section 9, activate the debug logical flag and set the desired number of lines). You will see the full phase space in the log files and check if it makes sense.
Finally, please note that you do not need to set at all the values of the variables coordinate_{x,y,z} and direction_cos{x,y,z} since you are using routines for the direction and initial position. These routines take a reference to the variables and overwrite them.