quantaichi
quantaichi copied to clipboard
cannot run the demo successfully
some errors when I run the Eulerian fluid demo.
-
KeyError: 'Unrecognized keyword argument(s) for ti.init: use_unified_memory' ---> delete this argument
-
cft = ti.quant.fixed(frac=21, signed=True, range=2**5) TypeError: fixed() got an unexpected keyword argument 'range' ----> delete range argument
-
AttributeError: 'MatrixField' object has no attribute 'get_field_members'
Ah, 2 is probably related to the recent quant API update - @strongoier could you help with this? Many thanks!
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.
It works. Thanks.
I am confused about the pressure projection when the velocity is stored in the grid center (eulerian_fluid/solver.py).
- 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)
- initializing mgpcg, and solving the Poisson equation
- 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:
- why do we need to add the average velocity?
- 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.
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.
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.