# Spherical volume source in source_newgen.f

Dear Experts,

I am able to model spherical source using CALL RACO(TXX, TYY, TZZ) function as per old format of source.f routine.

However. there is no document on modelling of a spherical volume source using source_newgen.f.
Kindly suggest me how to model a spherical volume source using source_newgen.f.

Dear ArghyaC,

the `RACO` subroutine is still usable in the source_newgen.f user routine without any issues. But if you prefer you can use the wrapper subroutine `sample_isotropic_direction`.

Cheers,
David

call sample_isotropic_direction( direction_cosx, direction_cosy, direction_cosz ) will sample the isotropic emission of the particles.

I want to model a spherical volume source of radius 2.5 cm and emission is isotropic. How to do this?

Hi ArghyaC,

`RACO` is also for sampling isotropic direction.

If you replace the `direction_cosx`, â€¦ variables with the coordinate ones in `sample_isotropic_direction`, then you get a sampling on the surface of a sphere.
Then you can call it again, now with the variables for the directions, to get the isotropic source distribution.

Cheers,
David

Hi @ArghyaC
I guess that the SPHE-VOL can simply solve your question.

@horvathd please correct me if Iâ€™m wrong.

Cheers,
Yousef

My source is not uniform random distribution over the surface of the sphere. It is uniform random distribution of source particles throughout the entire volume of the the sphere.
Co-ordinate sampling is something like below:

``````CALL RACO(TXX, TYY, TZZ)
R = 2.5D0
XFLK(NPFLKA) = R*TXX-5.0D0
YFLK(NPFLKA) = R*TYY
ZFLK(NPFLKA) = R*TZZ+38.0D0
``````

Note that, the co-ordinate of the centre of the sphere is (-5cm, 0cm, 38 cm)

Under module source_variables, I have included the line

``````double precission, save :: TXX, TYY, TZZ, R
``````

I am able to do this. But is there any direct CALL function for this type of source (like annular source, Flood source etc) in the source_newgen.f ?

But this configuration is useful for monoenergetic volume source not for poly-energetic source.

1 Like

Dear ArghyaC,

with this sampling, you only sample the position on the surface of the sphere, you need to sample the radius correctly as well, see: python - Sampling uniformly distributed random points inside a spherical volume - Stack Overflow

You can define your variables, but using the `SAVE` option is unnecessary since you donâ€™t need to keep their values between the primaries.

There is a subroutine for annular source sampling, but the volumetric sources are not implemented.

Cheers,
David

Thank you very much for the clarification.
Whether using â€śSAVEâ€ť option will make any difference in the final output?

Hi Arghya,

adding the `SAVE` option when it is not necessary wonâ€™t change the behavior of the routines.
See more: SAVE (FORTRAN 77 Language Reference)

Cheers,
David

Thank you very much.