# Computational particle physics

• I
• mehdi6
According to the conversation, in summary, the speaker is trying to use a random number generator in FORTRAN to assign initial velocities to particles in a three-dimensional system. They are seeking advice on how to make the particles move with a specific weight, such as a Maxwellian distribution, and how to keep the particles with a probability proportional to their weight. They also mention struggling with making the particles gain initial weight and ask for suggestions on how to do so. They mention the possibility of changing the distribution to a loss cone and clarify that they are analyzing the particles' trajectories and final distribution function. They also express uncertainty about whether to use the Maxwell-Boltzmann speed or velocity distribution and ask for clarification on how to make a weighted sum over the particles

#### mehdi6

Hi to all,
I have a random number generator in FORTRAN, which gives a random numbers to my particles initial velocity in three dimension (vx,vy,vz). If, I want to make my particles to embark to move with a specific weight (eg. Maxwellian), what should I do?

absv = sqrt(vx*vx+vy*vy+vz*vz)
wt= absv*absv*exp(-(absv*absv)/(a*a))
(a = sqrt(2*k*t/m))

if you simply plot any random numbers based on 'wt' you will get the maxwellian speed distribution as an output. I want to know, how can I make the 'wt' to be effective as a probability of particles initial distribution.
any suggestion is appreciated

If your initial velocities have a uniform distribution over some sufficient range: You can keep particles with a probability proportional to wt. You might lose most of them in the process, however. If you can keep them and assign a weight to them you might get better results.
Even better would be a process that directly produces Gaussian random numbers, e.g. via the Box-Muller transform.

mfb said:
If your initial velocities have a uniform distribution over some sufficient range: You can keep particles with a probability proportional to wt. You might lose most of them in the process, however. If you can keep them and assign a weight to them you might get better results.
Even better would be a process that directly produces Gaussian random numbers, e.g. via the Box-Muller transform.

As you may know, the random generator produce a number between -1 to 1 for the 3 velocity components. I make the arrangement so the velocity would be around -0.35 to 0.35 for each of them (non-relativistic range).
My code is a test particle code, and I could make it work efficiently for each test particle in both constant and dipolar field (with or without Electric field(acc)), but still I am struggling with making the particles to move based on their initial weight. I don't even know, whether I need to use the Maxwell–Boltzmann speed distribution or Maxwell–Boltzmann velocity distribution which in concept, both are telling the same story but giving me different result.
https://en.wikipedia.org/wiki/Maxwell–Boltzmann_distribution
"You can keep particles with a probability proportional to wt" would you please tell me how?
I will be appreciated if you can guide me through, cause I have been struggling with this issue for a while.
Thanks again

mfb said:
If your initial velocities have a uniform distribution over some sufficient range
I have generated those numbers by using a self made function, so it Not some pseudo random generator. I need to give my particles an specific ID's apart from just giving them random velocity. plus their distribution is not uniform in this domain (-0.35 up to 0.35).

Before I run the code, I need my particle to gain weight initially. If you plot the generated velocity over 'wt', you can find out that they follow the maxwellian, as I mentioned. The question simply comes down to a point that, how to make particles to gain initial weight? what should be done?

Modifying the way that I produce those random numbers (like Box-Muller transform) won't be the appropriate solution for that. later I may need to change the maxwellian to another type of distribution (eg. loss cone ), So the concept is what I am looking for which can be used in different situation.
please let me know if you have any suggestions.
Thanks.

mehdi6 said:
making the particles to move based on their initial weight
What do you mean by that?
mehdi6 said:
I don't even know, whether I need to use the Maxwell–Boltzmann speed distribution or Maxwell–Boltzmann velocity distribution which in concept, both are telling the same story but giving me different result.
As long as the system is spherically symmetric they should give the same result. What exactly are you doing?
mehdi6 said:
"You can keep particles with a probability proportional to wt" would you please tell me how?
What is unclear? Just keep every particle. If you want to know some property of your gas, make a weighted sum over the particles.
mehdi6 said:
Before I run the code, I need my particle to gain weight initially.
Weight as in m*g or a mathematical weight? Why, how? Giving them a mathematical weight: Just assign the weight to each of them.

mfb said:
What do you mean by that?
I meant Initial statistical weight.
mfb said:
As long as the system is spherically symmetric they should give the same result. What exactly are you doing?
I am trying to initially distribute my particle based on an specific statistical weight (e.g. maxwellian, loss cone or...) then put them in an specific field like dipolar field and analysis their trajectory. plus Analyzing and deriving the final distribution function (for large number of particles).
mfb said:
What is unclear? Just keep every particle. If you want to know some property of your gas, make a weighted sum over the particles.
maybe from your side everything is clear, but not in mine that's why I am asking question. My environment is solar atmosphere which is plasma. what is weighted sum over the particle? what does it represent?
mfb said:
Weight as in m*g or a mathematical weight? Why, how? Giving them a mathematical weight: Just assign the weight to each of them.
Statistical- I need to initialize them based on their density probability to see how the outcome would be.
by assigning you mean, simply multiplying the distribution function to the initial values? In any case?

mehdi6 said:
I meant Initial statistical weight.
That answer doesn't clarify what you mean by "make them move based on a weight".
mehdi6 said:
what is weighted sum over the particle? what does it represent?
Whatever you want to observe. Velocity, density, ...
100 particles in some volume with a weight of 1/10 each are the same thing as 10 particles with a weight of 1 - but the former will typically lead to smaller statistical fluctuations and it can be easier to generate.
mehdi6 said:
Statistical- I need to initialize them based on their density probability to see how the outcome would be.
by assigning you mean, simply multiplying the distribution function to the initial values? In any case?
If I understand your question right: Yes.