danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
103 stars 223 forks source link

How to create a non-uniform distribution of particles? #454

Open abbasebriastro opened 1 year ago

abbasebriastro commented 1 year ago

To simulate our work, we need a non-uniform distribution of particles. as the case of "set_sphere.f90" which considers uniform and density changes only as a function of 1/r. In addition to 1/r, we want the change of density also to be a function of "phi" and "theta" so that to assign any desired value of density at any point in space (suppose we have a uniform background and want the density to be out of uniformity at some points). how is it possible?

danieljprice commented 1 year ago

This is a non-trivial problem, in SPH you do not control the density field directly but have to place the particles in the right way to achieve the desired density. Indeed stretch-mapping only works for 1D density profiles.

In general for an arbitrary 3D distributions you would have to do a Monte Carlo placement (rejection method) which does work but it's pretty noisy and ideally would need relaxing for a bit before starting the calculation

Can you explain a bit more what you are trying to set up?

abbasebriastro commented 1 year ago

This is a non-trivial problem, in SPH you do not control the density field directly but have to place the particles in the right way to achieve the desired density. Indeed stretch-mapping only works for 1D density profiles.

In general for an arbitrary 3D distributions you would have to do a Monte Carlo placement (rejection method) which does work but it's pretty noisy and ideally would need relaxing for a bit before starting the calculation

Can you explain a bit more what you are trying to set up?

Our goal is to investigate the effect of magnetic braking on a core with the presence of clump(In a way, maybe said density fluctuation) around it.

The raw idea that came to our mind is to use different "set_sphere"s for the non-uniformity around the core! (using several "set_sphere"s with different "xyz_origin", with "r_sphere" smaller than the "r_sphere" of core, in a space outside the core, inside the box, and giving each of these a different density profile so that they can play the role of clump for us). I don't know if it is possible(and also useful) or not!!!

Do you have any comments?

danieljprice commented 1 year ago

yes this kind of thing could work, you can repeatedly call set_sphere from your setup routine to setup different components of the problem

the other thing which is implemented is just adding a perturbation to a uniform sphere in the phi direction, e.g. to simulate binary star formation we add an m=2 perturbation, see e.g. section 4.2 of this paper:

http://adsabs.harvard.edu/abs/2007MNRAS.377...77P

the latter is implemented in the setup_sphereinbox.f90 routine (e.g. compiling with SETUP=jet or similar)

abbasebriastro commented 1 year ago

yes this kind of thing could work, you can repeatedly call set_sphere from your setup routine to setup different components of the problem

the other thing which is implemented is just adding a perturbation to a uniform sphere in the phi direction, e.g. to simulate binary star formation we add an m=2 perturbation, see e.g. section 4.2 of this paper:

http://adsabs.harvard.edu/abs/2007MNRAS.377...77P

the latter is implemented in the setup_sphereinbox.f90 routine (e.g. compiling with SETUP=jet or similar)

Thanks a lot of your comments I will send you the results of simulations!

abbasebriastro commented 11 months ago

Hello again When we want to call set_sphere repeatedly (for begining we used "sphere_in_box" setup for testing and tried to place different "sphere" with different "xyz_origin" in the low medium) we face the problem for example "4631 of 75639 OUTSIDE in periodic boundary, with box=4 and a sphere=4". And when we leave the periodic boundary condition, we face the problem of the "conservation error".

Do you have any idea what to do?