# Defining a beam using external spectrum that has rectangular shape

Dear Experts,
I am trying to define a source that will (1) Use an external spectrum and (2) Have beam that is rectangular in X and Y (45 mm in along the X axis and 1 mm along the Y axis). Using the new source file template (Modified on 17 November 2020 by David Horvath), I can use the external spectrum. The new ‘source.f’ does read an external spectrum file that I pass to it and takes inputs from the BEAM card as mentioned on the comments of the new ‘source.f’ file. However, it only works when I select “isotropic” beam on the BEAM card. If I define a rectangular beam from the “BEAM” card, the result is a narrow pencil beam, not a rectangular beam. Most probably I am missing something.

Please let me know your take on this.

Best,
UC

Attn. @horvathd

Dear uchow,

Only some of the parameters set on the BEAM card passed to the source routine, the X-Y beam shape is not one of them. You will have to manually set / sample the actual starting position of a primary in section 5.1. of the routine.

Cheers,
David

Hi David,
Thanks a lot for your prompt response. Here is what I tried on section 5:

``````  ! 5. Beam starting position
! =========================

! 5.1. Coordinates
! ----------------
! Sets the starting coordinates (x,y,z) of the beam [cm]
! Defaults:
!    Coordinates set on the BEAMPOS card if present, (0.0D0, 0.0D0, 0.0D0) otherwise

coordinate_x =0
coordinate_y = 0
coordinate_z = -250

! 5.2. Sampling functions and subroutines
! ----------------------------------------

! 5.2.1. Flat distribution
! ------
! Replace [a] with "x", "y", or "z".
``````
• ``````coordinate_[a] = sample_flat_distribution( [min], [max] )

coordinate_x = sample_flat_distribution( [-22.5], [22.5] )
coordinate_y = sample_flat_distribution( [-0.05], [0.05])
``````

No luck so far. Also tried defining some parameters on the BEAMPOS card as per the instruction suggest ("!Coordinates set on the BEAMPOS card if present, (0.0D0, 0.0D0, 0.0D0) otherwise"), but no luck. FLAIR returns errors.

Best,
UC

Dear Uchow,

remove the `[` and `]` brackets around the numbers, and use the double precision format, like `2.25D1`.

Cheers,
David

Hi David,
Thank you so much! The double precision seem to do the trick. Also, you may want to consider rephrasing lines 69 and 70 on the template?

"* The parameters between the ‘[’ and ‘]’ brackets need to be replaced

• ``````   with numbers, or user variables containing the desired values."
``````

Doing some final checks, so please keep the thread open for a while longer.

Best regards,
UC

Hi David,
Thanks again for your help. Everything is looking good and you can close the thread.

Best regards,
UC