Angular distribution with source_newgen.f

Hi everyone,

I’ve defined a custom source by using two BEAMPOS cards to create a uniform distribution within a cylinder with known radius and height, and this part is working correctly.
Beampos

The energy distribution of the beam is already implemented inside my source_newgen.f routine as follows:
momentum_energy = sample_loghistogram_momentum_energy( "AmBe_spec.txt", "MeV" )

Now, I would like to apply a polar angular distribution (anisotropy) to the source. I have a discrete probability distribution over cos(theta), with values ranging from -1 to +1, where theta is the angle with respect to the x-axis.

Could someone please advise on how to modify source_newgen.f to sample the direction of particles accordingly?

Thanks in advance!
Giorgia

Dear @giorgia.fossati,

You are already on the right track.

  1. It would be helpful to upload your source_newgen.f routine, especially since you already have modified it.

  2. the sample_loghistogram_momentum_energyfunction is not within the already available ones (there is though the sample_histogram_momentum_energy function, without the log).

  3. To sample a (polar) angular distribution, you can adjust the section 6. Beam direction, from source_newgen.f (20.8 KB). There, you can provide values to the direction cosines of your source, along x,y and z.

If you do not change the default direction_flag = 0, the 3 direction cosines will be normalized automatically.

  1. You can sample from a discrete distribution, e.g.:
    direction_cos_x = sample_discrete_file(“filename_x”)
    direction_cos_y = sample_discrete_file(“filename_y”)
    direction_cos_z = sample_discrete_file(“filename_z”)

You can have three different files along the 3 directions, or the same one.

  1. You mention that you are interested in the polar angle, but what about the \phi azimuthal direction?

Best,
Daniel

Hi @dprelipc

To clarify my current implementation:

  • For the energy spectrum, I’m using the following line
momentum_energy = sample_histogram_momentum_energy("Energy.txt", "MeV")

and this is working well.

  • For the polar angular distribution, I’ve added:
direction_cosx = sample_discrete_file("AngleX.txt")

where AngleX.txt contains a discrete probability distribution over cos(theta) (with theta defined with respect to the x-axis). This also seems to work properly.

Now, I’d like to sample direction_cosy and direction_cosz isotropically. Is there a recommended way to do this within source_newgen.f?

Also, regarding the spatial distribution, I used two BEAMPOS cards to define a uniform distribution in a cylinder. However, I understand that when using source_newgen.f, the CYLI-VOL card is ignored (Issue with cylindrical surface source - Source Definition - FLUKA User Forum).
I also noticed that calling sample_annular_distribution does not help in my case, since I need a finite-height cylinder.
Is there a recommended approach to implement uniform sampling within a finite cylinder directly inside source_newgen.f?

Best,
Giorgia

Dear @giorgia.fossati,

  1. To sample isotropically, you could:
    a) sample from a uniform/constant file,
    b) or you could use the available:
    call sample_isotropic_direction( direction_cosx, direction_cosy, direction_cosz )
    followed by your
    direction_cosx = sample_discrete_file("AngleX.txt") to superseed the previous assignment of direction_cosx.

  2. To have a finite cylinder, you can follow the logic of the same post you mention, namely:
    call sample_annular_distribution( 49.2633D0, 50.0D0, coordinate_x, coordinate_y )
    then sampling uniformly along the z direction:
    coordinate_z = sample_flat_distribution([min], [max])

Do let me know if you need further assistances.

Best,
Daniel

1 Like