Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot run the demo successfully #2

Open
xiangzi1992 opened this issue Jun 23, 2022 · 5 comments
Open

cannot run the demo successfully #2

xiangzi1992 opened this issue Jun 23, 2022 · 5 comments

Comments

@xiangzi1992
Copy link

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'

@yuanming-hu
Copy link
Member

yuanming-hu commented Jun 23, 2022

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

@strongoier
Copy link
Contributor

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.

@xiangzi1992
Copy link
Author

xiangzi1992 commented Jun 23, 2022

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.

@yuanming-hu
Copy link
Member

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.

@xiangzi1992
Copy link
Author

xiangzi1992 commented Jun 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants