quantaichi icon indicating copy to clipboard operation
quantaichi copied to clipboard

cannot run the demo successfully

Open xiangzi1992 opened this issue 2 years ago • 5 comments

some errors when I run the Eulerian fluid demo.

  1. KeyError: 'Unrecognized keyword argument(s) for ti.init: use_unified_memory' ---> delete this argument

  2. cft = ti.quant.fixed(frac=21, signed=True, range=2**5) TypeError: fixed() got an unexpected keyword argument 'range' ----> delete range argument

  3. AttributeError: 'MatrixField' object has no attribute 'get_field_members'

xiangzi1992 avatar Jun 23 '22 09:06 xiangzi1992

Ah, 2 is probably related to the recent quant API update - @strongoier could you help with this? Many thanks!

yuanming-hu avatar Jun 23 '22 10:06 yuanming-hu

Hi @xiangzi1992. This repo was last updated 1 year ago, and many APIs of Taichi have been changed since then. If you want to run the demo immediately, you can use some version earlier than v0.7.20. I will update this repo to match the latest version of Taichi as soon as possible.

strongoier avatar Jun 23 '22 13:06 strongoier

It works. Thanks.

I am confused about the pressure projection when the velocity is stored in the grid center (eulerian_fluid/solver.py).

  1. calculating the divergence: div[i, j] = -0.5 * (v[i+1, j].x -v[i-1, j].x + v[i, j+1].y - v[i, j-1].y)
  2. initializing mgpcg, and solving the Poisson equation
  3. updating v based on the pressure, p v[i, j].x = v[i, j].x - 0.5 * (p[i +1, j] - p[i -1, j]) + avg_v[i, j] .x v[i, j].y = v[i, j].y - 0.5 * (p[i, j +1] - p[i, j -1]) + avg_v[i, j] .y

My confusions are:

  1. why do we need to add the average velocity?
  2. I realized incompressible fluid in the same way. After the projection, I recalculate the divergence, but it does not approximate to zero. I am not sure whether my understanding of the projection is right or not.

xiangzi1992 avatar Jun 23 '22 15:06 xiangzi1992

why do we need to add the average velocity?

I don't think there are these lines of code in this repo: https://github.com/taichi-dev/quantaichi/search?q=avg_v Do they come from somewhere else? I guess that's because you have all Neumann boundary conditions and there is a null space. See Algorithm 3 of https://www.math.ucla.edu/~jteran/papers/MST10.pdf.

yuanming-hu avatar Jun 23 '22 15:06 yuanming-hu

why do we need to add the average velocity?

I don't think there are these lines of code in this repo: https://github.com/taichi-dev/quantaichi/search?q=avg_v Do they come from somewhere else? I guess that's because you have all Neumann boundary conditions and there is a null space. See Algorithm 3 of https://www.math.ucla.edu/~jteran/papers/MST10.pdf.

I am sorry, I didn't express my problem clearly. These lines are not in the code, I just describe my understanding after reading your code.

Here is the original code.

self.mgpcg.reset() self.compute_div_and_init_pressure_solver(v) self.mgpcg.solve(max_iters=12, verbose=True) self.mgpcg.fetch_result(self.pressure.field) self.average_v[None] = [0] * self.dim

if enforce_zero_average: self.compute_average_v(v) self.apply_pressure_with_adjustments(v, self.pressure)

compute_div_and_init_pressure_solver does: div[i, j] = -0.5 * (v[i+1, j].x -v[i-1, j].x + v[i, j+1].y - v[i, j-1].y)

apply_pressure_with_adjustments does: v[i, j].x = v[i, j].x - 0.5 * (p[i +1, j] - p[i -1, j]) + avg_v[i, j] .x v[i, j].y = v[i, j].y - 0.5 * (p[i, j +1] - p[i, j -1]) + avg_v[i, j] .y

I did the projection in this way. After the projection, I recalculate the divergence, but the value is not approximate to zero. I indeed took the boundary into consideration. This is my problem.

xiangzi1992 avatar Jun 23 '22 15:06 xiangzi1992