Git Product home page Git Product logo

game201_hw1's Introduction

GAME201 HW1

Implemented explicit and implicit euler of mass spring.

Explicit euler, implemented

  • Forward euler
  • RK2
  • RK3
  • RK4

Implicit euler, implemented

  • Backward euler with jacobi iteration (#iteration=20)

More details:

  • Code was based on mass_spring_explicit.py example.
  • Moved "Collide with ground" to after "Compute new position" because my explicit code updates x and v at the same time (I didn't know whether this was acceptable or not)
  • Didn't know how to compute gradient in implicit euler. Used auto-grad in taichi to compute the gradient.
  • Settings:
    • #particles = 10
    • damping = 20.0
    • dt = 1e-3

Comparsion

\ Forward Euler RK2 RK3 RK4 Implicit euler
latency per step * ~0.4ms ~0.5ms ~0.6ms ~0.7ms ~5m (~3m w/o auto-grad computing time)
energy stableness ** ~0.92 ~0.92 ~0.92 ~0.92 ~0.98
energy stableness (damping=0.0) *** unstable ~1.0 ~1.0 ~1.0 ~0.99 - ~1.0
max spring stiffness ~7,500 ~45,000 ~300,000 ~700,000 ~300,000 (similar value for #iteration=50)
max dt (spring stiffness=1000) ~2e-3 ~8e-3 ~0.02 ~0.03 ~0.15

* environment (windows 10, ram=16G, cpu=AMD Ryzen 1700X, gpu=Nvidia GTX 1700Ti)

** energy (mgh + mv^2 / 2 + kΔx^2 / 2) stableness = moving average rate of (energy at step t / energy at step t-100) after the rate becomes stable and before the springs hit the ground (the rate is ~1.0 after the springs hit the ground)

*** Record rate after the rate becomes stable.

Observation

  • When damping exists, energy stableness of implicit euler is better; otherwise, all methods are great.
  • When damping exists, all simulation looks similar; otherwise, all looks different (please check the following GIFs)
  • RK3 / RK4 / implicit euler provide good max spring stiffness.
  • Implicit euler provides much better max dt.

GIFs (damping = 20.0)

Forward Euler RK2 RK3
RK4 Implicit euler

GIFs (damping = 0.0)

Forward Euler RK2 RK3
RK4 Implicit euler

game201_hw1's People

Contributors

hakic avatar

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.