How do I make the correct non-uniform sampling along the depth direction?

Dear Experts,

After a period of study, I still haven’t solved the previous problem,I continue with the previous topic.

[Nonuniformly distributed volume source construction]

I looked for the old official tutorial,Despite the details, my programming ability cannot turn it into an executable program,this question bothers me.

According to my idea, this should be modified on the basis of the program defined by the regional source, but it seemed as if my idea was very immature.
disk.flair (3.0 KB)
disk.inp (2.3 KB)
source.f (9.8 KB)

I would like to ask the expert how I can get a distribution similar to the official tutorial:
y=exp( -A * x)

Maybe the problem is simple, but it’s really troubling!
Thanks in advance!
fengfeng

Dear Fengfeng,

as this is not a FLUKA, but a mathematical question, you can find many places, where sampling from probability distributions is explained, like this one.

Cheers,
David

1 Like

Dear Professor David,

    I set the increment to :

t=-(1/A)log(1-FLRNDM( z ))

I got the following results, I think it is in line with expectations, what do you think?
屏幕截图 2022-06-30 164917

Thanks in advance!
fengfeng

Dear Fengfeng,

Unfortunately I can’t verify if your implementation is correct or not based on a picture. Furthermore, you need to be careful, how the shift from z = 0 to z = zmin is implemented as it can influence what section of the exponential you are sampling from.

Cheers,
David

Dear Professor David,

I forgot to upload my source file,It seems to be working well for now. You check it out. I found that with the decrease of the coefficient A, the result of the calculation seemed to differ more from the numerical integral.This is a very strange result for me.
source.f (9.8 KB)

I hope that the teacher will analyze why the difference between the counting result and the numerical integral will become larger and larger as the coefficient A decreases.At the same time, first make sure that it does achieve exponential distribution sampling.

Thanks in advance!
fengfeng

Dear Fengfeng,

  1. I did not specify which results are you comparing to what numerical integral, so I can’t comment on their differences.

  2. The formula

    -0.25D0 * LOG (FLRNDM( ZCOORD ))
    

    will already give you a random number between 0 and +infinity. So the multiplication (ZMAX - ZMIN) will only alter the term of -(1/A) giving you a different distribution that you are expecting.

Cheers,
David

Dear Professor David,

It is a pleasure to have implemented the program with the help of my teachers.I think I got the best affirmation.The first one is not a fluka problem, I will solve it myself, delaying your time.This post can be closed.

Thanks to Mr. David, I can learn something new!
Fengfeng