Code Monkey home page Code Monkey logo

2deulerianfluidsolver's Introduction

2D Eulerian Fluid Solver

A interactive demo of 2D Eulerian Fluid Solver based on Taichi Lang :)

这是一个使用太极语言编程的2D欧拉流体求解器,该项目已经向太极语言提交pr,即将成为ti example的一部分, 该项目有以下特色:

  • 水面能够与鼠标进行交互
  • 添加旋度运算,更好的流体表现 :)
  • 自定义流体颜色场为背景图片,测试图片位于img目录下方(该功能默认不启用,默认用代码初始化太极图片,开启方法见下文2.2
  • 在 [512,512] 网格 830pfs左右 on RTX 4060 (laptop) (默认使用的是限制帧率60帧的GUI,为突破帧数限制需要使用taichi语言提供的CGUI系统,开启方法见下文2.3
  • 代码简短清晰(200 lines),方便阅读

仿真效果

1. Demo依赖包安装

python version == 3.9.16
taichi == 1.4.1
conda install taichi
conda install matplotlib

安装以上两个包之后,运行main.py即可以和demo玩耍

2. 代码阅读指北

scr/main.py:流体求解器主要代码,建议先看最后的循环部分。

src/Util.py:双Buffer类和双线性差值函数的实现,以及代码初始化太极图片的实现

2.1 流体模拟所需参数

eulerSimParam = {
    'use_image': False,
    'load_image':'../img/test2.jpg',
    'shape': [512, 512],
    'dt': 1 / 60.,
    'iteration_step': 20,
    'mouse_radius':0.01,# [0.0,1.0] float
    'mouse_speed': 125.,
    'mouse_respondDistance':0.5, # for every frame, only half the trace of the mouse will influence water
    'curl_param':15,
    'GUI_type':'GUI' #fill 'GUI' or 'CGUI'
}

2.2 如何切换流体初始图片

修改上方代码中以下参数:

  • use_imageTrue (如果该参数为False代码默认生成太极图像)
  • load_image为你希望初始化的流体的图片位置(默认为image下的一张图像)
  • 修改shape为所需图片的大小

2.3 如何开启CGUI

  • 修改上方代码中GUI_typeCGUI即可,同时建议调低curl_param(小于等于1)以获取更好的视觉表现。

3. 致谢

4. To do list

  • 修复底部有部分黑色的渗漏问题(fix on 3/11/2023)
  • 添加自动生成太极图形的代码(fix on 3/14/2023)
  • 添加CGUI相关代码,突破帧数限制(fix on 3/23/2023)

2deulerianfluidsolver's People

Contributors

lee-abcde avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

2deulerianfluidsolver's Issues

关于voricity_step的疑问

学长您好,我最近在学习这份代码的时候遇到了两个问题:

  1. 代码中加入了 voricity_step(),目的是“添加旋度运算,更好的流体表现 “,请问这一部分具体的原理是什么,是否有相关的文献可以推荐一下?
  2. 我在注释掉 voricity_step() 这一步之后再运行发现边界上的毛刺没有了,想问下这个原因是什么?我个人觉得这种效果更好一点

抱歉打扰,祝学长学业顺利!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.