0

I've been recently working on a JS program that models this scholarly article. The problem I've been recently having is this:

"Surface tension is usually caused by attraction between particles. Inside the fluid, this attraction, cancels out, but for the molecules near the surface, asymmetry in neighbor distribution results in a non-zero net force towards the fluid."

I'm assuming that this happens naturally in the double density relaxation method, but my program seems to show no sign of it.

Here's an excerpt from the double density relaxation method:

function doubleDensityRelaxation() {
  for(var i = 0; i<particles.length; i++) {
  var pi = particles[i];
  var p = 0;
  var pNear = 0;
  for(var j = i+1; j<particles.length; j++) {
    var pj = particles[j];
    var rij = sub(pi.r,pj.r);
    var q = length(rij)/h;
    if(q < 1) {
      p += (1-q)*(1-q);
      pNear += (1-q)*(1-q)*(1-q);
    }
  }
  var P = k*(p-p0);
  var PNear = kNear*pNear;
  var dx = [0,0];
  for(var j = i+1; j<particles.length; j++) {
    var pj = particles[j];
    var rij = sub(pi.r,pj.r);
    var q = length(rij)/h;
    if(q < 1) {

      var D = scale(normalize(rij), dtsq*(P*(1-q)+PNear*(1-q)*(1-q)));

      pj.r = add(pj.r,scale(D,0.5));
      dx = sub(dx,scale(D,0.5));
    }
  }
  pi.r = add(pi.r,dx);

  }
}
4

1 回答 1

0

这是一种表现得更像一种可识别的低粘度流体。这种模拟似乎在数值上一落千丈,帧速率越低就越不稳定。

我发现我认为您的代码存在一些问题。

  • 当我阅读这篇论文时,L ij是在时间步长上保留的弹簧长度三角矩阵的元素;gamma 和 alpha 控制它的变化速率。该矩阵没有保留在您的原始代码中,因此粘弹性不起作用。

  • 粒子间碰撞是不必要的,实际上会进一步破坏模拟。粘度通过中的 Beta 提供了这种排斥力。

  • p 0 /k的比率不能太低,否则你会以快速振荡的塌陷簇的形式出现不稳定。当簇确实破裂时,您会看到单个粒子从墙壁上弹起,就像失控的Flubber球一样。

  • 墙壁仍然有一些问题:即使我进行了调整,粒子往往会沿着它们排列成柱状,新粒子被迫进入底部,而旧粒子从顶部喷涌而出,形成一种双涡流流体。

  • 我正在尝试设置弹簧长度的下限,这有时可以稳定原本不稳定的参数集。我对它建模的物理特性的即兴猜测是膨胀行为。

于 2015-04-10T01:27:51.757 回答