【发布时间】:2014-01-14 12:55:10
【问题描述】:
基本上,我想做的是为星系的 n 体模拟设置初始条件。我试图通过的论文可以在这里找到http://arxiv.org/abs/1204.0513。
论文描述了两个密度函数:
rho(r) 形式的表面密度函数,用于距离中心 r 处的密度
和形式为 rho(r, z) 的密度函数,其中 z 是 (x,y,z) 坐标中的 z 分量。
到目前为止,我对每个粒子(星)所做的是:
- 使用带有第一个函数的蒙特卡罗方法来获取距星系中心的距离
- 使用带有第二个函数的蒙特卡罗方法来获取 z 分量
- 在半径为 r、高度为 z 的圆上随机生成 x,y 坐标
但也许这方面的代码会更有帮助:
/* generate 3 random numbers x,y,z having a domain from 0 to 1 (not including 0.0) */
// The distance from the galaxy center for the current star.
// Rs is a constant parameter in the surface density function.
float r = -Rs * log(1.0f - x);
// The z coordinate for the current star
float Sz = -0.5f * (0.1f * Rs) * log(-((z-1)/z));
// The x,y coordinates for the current star
float Sx = sqrt(r*r - Sz*Sz) * cos(2.0f * PI * y);
float Sy = sqrt(r*r - Sz*Sz) * sin(2.0f * PI * y);
在视觉上,这会产生预期的形状,直到出现明显的情况,即如果生成的 Sz 值高于生成的 r 值。
所以我的问题首先是我是否一开始就走在正确的轨道上,如果是这样,是否有人可以针对我上面描述的情况提出一种更正机制或生成这些坐标的替代方法。
【问题讨论】:
标签: distribution volume galaxy montecarlo