{"id":13439347,"url":"https://github.com/yuanming-hu/taichi_mpm","last_synced_at":"2025-05-15T12:05:41.200Z","repository":{"id":40738032,"uuid":"144358602","full_name":"yuanming-hu/taichi_mpm","owner":"yuanming-hu","description":"High-performance moving least squares material point method (MLS-MPM) solver. (ACM Transactions on Graphics, SIGGRAPH 2018)","archived":false,"fork":false,"pushed_at":"2022-02-23T05:43:10.000Z","size":25909,"stargazers_count":2442,"open_issues_count":31,"forks_count":317,"subscribers_count":94,"default_branch":"master","last_synced_at":"2025-04-14T22:18:47.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuanming-hu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-11T05:36:31.000Z","updated_at":"2025-04-14T10:39:43.000Z","dependencies_parsed_at":"2022-07-18T03:30:43.401Z","dependency_job_id":null,"html_url":"https://github.com/yuanming-hu/taichi_mpm","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanming-hu%2Ftaichi_mpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanming-hu%2Ftaichi_mpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanming-hu%2Ftaichi_mpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanming-hu%2Ftaichi_mpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuanming-hu","download_url":"https://codeload.github.com/yuanming-hu/taichi_mpm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337613,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:13.155Z","updated_at":"2025-05-15T12:05:36.185Z","avatar_url":"https://github.com/yuanming-hu.png","language":"C++","funding_links":[],"categories":["C++","Maths","其他_机器学习与深度学习"],"sub_categories":[],"readme":"#  High-Performance MLS-MPM Solver with Cutting and Coupling (CPIC)  *(MIT License)*\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/water_wheel.gif\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/sand_paddles.gif\"\u003e\n\n**A Moving Least Squares Material Point Method with Displacement Discontinuity and Two-Way Rigid Body Coupling**, ACM Transactions on Graphics (SIGGRAPH 2018).\n\nBy [Yuanming Hu (MIT CSAIL)](https://yuanming.taichi.graphics/), [Yu Fang (Tsinghua University)](http://squarefk.com/), Ziheng Ge (University of Science and Technology of China), Ziyin Qu (University of Pennsylvania), [Yixin Zhu (UCLA)](https://www.yzhu.io/), [Andre Pradhana (University of Pennsylvania)](https://www.seas.upenn.edu/~apradh/menu/about.html), [Chenfanfu Jiang (University of Pennsylvania)](https://www.seas.upenn.edu/~cffjiang/).\n\nWelcome to join the [Discussion Forum](https://forum.taichi.graphics/).\n\n### News\n - (August 2019) Check out our [SIGGRAPH 2019 course on high-performance MPM](https://yuanming.taichi.graphics/publication/2019-mpm-tutorial/)!\n - (May 2019) Check out niall's MLS-MPM [Unity implementation](https://github.com/nialltl/incremental_mpm) and [tutorial](https://nialltl.neocities.org/articles/mpm_guide.html)! \n - (March 2019) David Medina contributed [mls-mpm88-explained.cpp](https://github.com/yuanming-hu/taichi_mpm/blob/master/mls-mpm88-explained.cpp) which is much easier to read than the original 88-line version.\n - (March 2019) Roberto Toro made [mls-mpm.js](https://github.com/r03ert0/mls-mpm.js) that [runs in your browser](https://r03ert0.github.io/mls-mpm.js/index.html)!\n - (March 2019) This software is now released under the **MIT license**. Feel free to use it commercially. We would appreciate your acknoledgements if our software helps you.\n\n#### [[Introduction \u0026 Demo Video](https://www.youtube.com/watch?v=8iyvhGF9f7o)] [[Paper](https://yuanming.taichi.graphics/publication/2018-mlsmpm/mls-mpm-cpic.pdf)] [[Supplemental Document](https://yuanming.taichi.graphics/publication/2018-mlsmpm/mls-mpm-cpic-supp.pdf)] [[88-Line MLS-MPM](https://github.com/yuanming-hu/taichi_mpm#88-line-version-mit-license-download-c--javascript-versions)]\n#### [[SIGGRAPH 2018 Fast Forward](https://youtu.be/9RlNEgwTtPI)] [[PDF Slides](https://github.com/yuanming-hu/taichi_mpm/releases/download/SIGGRAPH2018/mls-mpm-cpic-slides.pdf)] [[PDF Slides with Notes](https://github.com/yuanming-hu/taichi_mpm/releases/download/SIGGRAPH2018/mls-mpm-cpic-slides-with-notes.pdf)]\n\n\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/armodillo.gif\" style=\"\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/debris_flow.gif\"\u003e\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/sand-sweep.gif\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/sand_stir.gif\"\u003e\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/bunny.gif\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/robot_forward.gif\"\u003e\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/banana.gif\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/cheese.gif\"\u003e\n\n\n## 88-Line Version (MIT License) [[Download C++ \u0026 Javascript versions](https://github.com/yuanming-hu/taichi_mpm/releases/download/SIGGRAPH2018/mls-mpm88.zip)]\n\n--------\n\n**Update Nov 2021: with the new [Taichi programming language](https://github.com/taichi-dev/taichi), you can run [MLS-MPM on GPU](https://github.com/taichi-dev/taichi/blob/master/python/taichi/examples/simulation/mpm128.py) with Python 3 after `pip install taichi`**\n\n--------\n\nSupports Linux, OS X and Windows. Tested on Ubuntu 16.04, Ubuntu 18.04, Arch Linux, MinGW, VS2017, OS X 10.11~10.14.\nNo need to install `taichi` or `taichi_mpm` - see the end of code for instructions.\n\n\u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/mls-mpm88-lowres.gif\" width=\"400px\"\u003e \u003cimg src=\"https://github.com/yuanming-hu/public_files/raw/master/graphics/mls-mpm-cpic/mls-mpm88-highres.gif\" width=\"400px\"\u003e\n\n\n``` C++\n//88-Line 2D Moving Least Squares Material Point Method (MLS-MPM)[with comments]\n//#define TC_IMAGE_IO   // Uncomment this line for image exporting functionality\n#include \"taichi.h\"    // Note: You DO NOT have to install taichi or taichi_mpm.\nusing namespace taichi;// You only need [taichi.h] - see below for instructions.\nconst int n = 80 /*grid resolution (cells)*/, window_size = 800;\nconst real dt = 1e-4_f, frame_dt = 1e-3_f, dx = 1.0_f / n, inv_dx = 1.0_f / dx;\nauto particle_mass = 1.0_f, vol = 1.0_f;\nauto hardening = 10.0_f, E = 1e4_f, nu = 0.2_f;\nreal mu_0 = E / (2 * (1 + nu)), lambda_0 = E * nu / ((1+nu) * (1 - 2 * nu));\nusing Vec = Vector2; using Mat = Matrix2; bool plastic = true;\nstruct Particle { Vec x, v; Mat F, C; real Jp; int c/*color*/;\n  Particle(Vec x, int c, Vec v=Vec(0)) : x(x), v(v), F(1), C(0), Jp(1), c(c){}};\nstd::vector\u003cParticle\u003e particles;\nVector3 grid[n + 1][n + 1];          // velocity + mass, node_res = cell_res + 1\n\nvoid advance(real dt) {\n  std::memset(grid, 0, sizeof(grid));                              // Reset grid\n  for (auto \u0026p : particles) {                                             // P2G\n    Vector2i base_coord=(p.x*inv_dx-Vec(0.5_f)).cast\u003cint\u003e();//element-wise floor\n    Vec fx = p.x * inv_dx - base_coord.cast\u003creal\u003e();\n    // Quadratic kernels  [http://mpm.graphics   Eqn. 123, with x=fx, fx-1,fx-2]\n    Vec w[3]{Vec(0.5) * sqr(Vec(1.5) - fx), Vec(0.75) - sqr(fx - Vec(1.0)),\n             Vec(0.5) * sqr(fx - Vec(0.5))};\n    auto e = std::exp(hardening * (1.0_f - p.Jp)), mu=mu_0*e, lambda=lambda_0*e;\n    real J = determinant(p.F);         //                         Current volume\n    Mat r, s; polar_decomp(p.F, r, s); //Polar decomp. for fixed corotated model\n    auto stress =                           // Cauchy stress times dt and inv_dx\n        -4*inv_dx*inv_dx*dt*vol*(2*mu*(p.F-r) * transposed(p.F)+lambda*(J-1)*J);\n    auto affine = stress+particle_mass*p.C;\n    for (int i = 0; i \u003c 3; i++) for (int j = 0; j \u003c 3; j++) { // Scatter to grid\n        auto dpos = (Vec(i, j) - fx) * dx;\n        Vector3 mv(p.v * particle_mass, particle_mass); //translational momentum\n        grid[base_coord.x + i][base_coord.y + j] +=\n            w[i].x*w[j].y * (mv + Vector3(affine*dpos, 0));\n      }\n  }\n  for(int i = 0; i \u003c= n; i++) for(int j = 0; j \u003c= n; j++) { //For all grid nodes\n      auto \u0026g = grid[i][j];\n      if (g[2] \u003e 0) {                                // No need for epsilon here\n        g /= g[2];                                   //        Normalize by mass\n        g += dt * Vector3(0, -200, 0);               //                  Gravity\n        real boundary=0.05,x=(real)i/n,y=real(j)/n; //boundary thick.,node coord\n        if (x \u003c boundary||x \u003e 1-boundary||y \u003e 1-boundary) g=Vector3(0); //Sticky\n        if (y \u003c boundary) g[1] = std::max(0.0_f, g[1]);             //\"Separate\"\n      }\n    }\n  for (auto \u0026p : particles) {                                // Grid to particle\n    Vector2i base_coord=(p.x*inv_dx-Vec(0.5_f)).cast\u003cint\u003e();//element-wise floor\n    Vec fx = p.x * inv_dx - base_coord.cast\u003creal\u003e();\n    Vec w[3]{Vec(0.5) * sqr(Vec(1.5) - fx), Vec(0.75) - sqr(fx - Vec(1.0)),\n             Vec(0.5) * sqr(fx - Vec(0.5))};\n    p.C = Mat(0); p.v = Vec(0);\n    for (int i = 0; i \u003c 3; i++) for (int j = 0; j \u003c 3; j++) {\n        auto dpos = (Vec(i, j) - fx),\n            grid_v = Vec(grid[base_coord.x + i][base_coord.y + j]);\n        auto weight = w[i].x * w[j].y;\n        p.v += weight * grid_v;                                      // Velocity\n        p.C += 4 * inv_dx * Mat::outer_product(weight * grid_v, dpos); // APIC C\n      }\n    p.x += dt * p.v;                                                // Advection\n    auto F = (Mat(1) + dt * p.C) * p.F;                      // MLS-MPM F-update\n    Mat svd_u, sig, svd_v; svd(F, svd_u, sig, svd_v);\n    for (int i = 0; i \u003c 2 * int(plastic); i++)                // Snow Plasticity\n      sig[i][i] = clamp(sig[i][i], 1.0_f - 2.5e-2_f, 1.0_f + 7.5e-3_f);\n    real oldJ = determinant(F); F = svd_u * sig * transposed(svd_v);\n    real Jp_new = clamp(p.Jp * oldJ / determinant(F), 0.6_f, 20.0_f);\n    p.Jp = Jp_new; p.F = F;\n  }\n}\nvoid add_object(Vec center, int c) {   // Seed particles with position and color\n  for (int i = 0; i \u003c 500; i++)  // Randomly sample 1000 particles in the square\n    particles.push_back(Particle((Vec::rand()*2.0_f-Vec(1))*0.08_f + center, c));\n}\nint main() {\n  GUI gui(\"Real-time 2D MLS-MPM\", window_size, window_size);\n  add_object(Vec(0.55,0.45), 0xED553B); add_object(Vec(0.45,0.65), 0xF2B134);\n  add_object(Vec(0.55,0.85), 0x068587); auto \u0026canvas = gui.get_canvas();int f=0;\n  for (int i = 0;; i++) {                              //              Main Loop\n    advance(dt);                                       //     Advance simulation\n    if (i % int(frame_dt / dt) == 0) {                 //        Visualize frame\n      canvas.clear(0x112F41);                          //       Clear background\n      canvas.rect(Vec(0.04), Vec(0.96)).radius(2).color(0x4FB99F).close();// Box\n      for(auto p:particles)canvas.circle(p.x).radius(2).color(p.c);//Particles\n      gui.update();                                              // Update image\n      // canvas.img.write_as_image(fmt::format(\"tmp/{:05d}.png\", f++));\n    }\n  }\n} //----------------------------------------------------------------------------\n\n/* -----------------------------------------------------------------------------\n** Reference: A Moving Least Squares Material Point Method with Displacement\n              Discontinuity and Two-Way Rigid Body Coupling (SIGGRAPH 2018)\n\n  By Yuanming Hu (who also wrote this 88-line version), Yu Fang, Ziheng Ge,\n           Ziyin Qu, Yixin Zhu, Andre Pradhana, Chenfanfu Jiang\n\n\n** Build Instructions:\n\nStep 1: Download and unzip mls-mpm88.zip (Link: http://bit.ly/mls-mpm88)\n        Now you should have \"mls-mpm88.cpp\" and \"taichi.h\".\n\nStep 2: Compile and run\n\n* Linux:\n    g++ mls-mpm88.cpp -std=c++14 -g -lX11 -lpthread -O3 -o mls-mpm\n    ./mls-mpm\n\n\n* Windows (MinGW):\n    g++ mls-mpm88.cpp -std=c++14 -lgdi32 -lpthread -O3 -o mls-mpm\n    .\\mls-mpm.exe\n\n\n* Windows (Visual Studio 2017+):\n  - Create an \"Empty Project\"\n  - Use taichi.h as the only header, and mls-mpm88.cpp as the only source\n  - Change configuration to \"Release\" and \"x64\"\n  - Press F5 to compile and run\n\n\n* OS X:\n    g++ mls-mpm88.cpp -std=c++14 -framework Cocoa -lpthread -O3 -o mls-mpm\n    ./mls-mpm\n\n\n** FAQ:\nQ1: What does \"1e-4_f\" mean?\nA1: The same as 1e-4f, a float precision real number.\n\nQ2: What is \"real\"?\nA2: real = float in this file.\n\nQ3: What are the hex numbers like 0xED553B?\nA3: They are RGB color values.\n    The color scheme is borrowed from\n    https://color.adobe.com/Copy-of-Copy-of-Core-color-theme-11449181/\n\nQ4: How can I get higher-quality?\nA4: Change n to 320; Change dt to 1e-5; Change E to 2e4;\n    Change particle per cube from 500 to 8000 (Ln 72).\n    After the change the whole animation takes ~3 minutes on my computer.\n\nQ5: How to record the animation?\nA5: Uncomment Ln 2 and 85 and create a folder named \"tmp\".\n    The frames will be saved to \"tmp/XXXXX.png\".\n\n    To get a video, you can use ffmpeg. If you already have taichi installed,\n    you can simply go to the \"tmp\" folder and execute\n\n      ti video 60\n\n    where 60 stands for 60 FPS. A file named \"video.mp4\" is what you want.\n\nQ6: How was taichi.h generated?\nA6: Please check out my #include \u003ctaichi\u003e talk:\n    http://taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf\n    and the generation script:\n    https://github.com/yuanming-hu/taichi/blob/master/misc/amalgamate.py\n    You can regenerate it using `ti amal`, if you have taichi installed.\n\nQuestions go to yuanming _at_ mit.edu\n                            or https://github.com/yuanming-hu/taichi_mpm/issues.\n\n                                                      Last Update: March 6, 2019\n                                                      Version 1.5\n\n----------------------------------------------------------------------------- */\n```\n\n## Installing the High-Performance 3D Solver\n(This is for installing the high-performance 2D/3D solver including MLS-MPM and CPIC. If you want to play with the 88-line MLS-MPM, you don't have to install anything - see [here](https://github.com/yuanming-hu/taichi_mpm#88-line-version-mit-license-download-c--javascript-versions))\n### Linux and OSX\nInstall [`taichi (legacy branch)`](https://github.com/taichi-dev/taichi/blob/5ab90f03ef37701506c7034c3f1955d225b39957/docs/installation.rst).\nThen, in command line\n```\nti install mpm\n```\nand it will install this taichi package automatically.\n\n### Windows\nSupport coming later.\n\n## Run demos\nEvery script under the folder `scripts/mls-cpic` is executable with `python3`.\n# Visualize the results\n - Outputs are in `taichi/outputs/mpm/`;\n - Install [Houdini Apprentice](https://www.sidefx.com/products/houdini-apprentice/) (which is free);\n - Create a `File` node in Houdini to visualize the `bgeo` (particles), `obj` (3D meshes), `poly` (2D polygons) files.\n\n# Python 3 API\n\n## MPM.initialize\n(You only need to specify `res` in most cases. The default parameters generally work well.) \nAll parameters:\n - res: (`Vector\u003cdim, int\u003e`) grid resolution. The length of this vector also specifies the dimensionality of the simulation.\n - base_delta_t : (`real`, default: `1e-4`) delta t\n - delta_x: (`real`, default: `1.0 / res[0]`)\n - particle_collision (`bool`, default: `False`): push particles inside level sets out (turn off when you are using sticky level sets)\n - pushing_force: (`real`, default: `20000.0`) If things do not separate, use this. Typical value: 20000.0.\n - gravity (`Vector\u003cdim\u003e`, default: `(0, -10, 0)` for 3D, `(0, -10)` for 2D)\n - frame_dt: (`real`, default: `0.01`) You can set to `1 / 24` for real frame rate.\n - num_threads: (`int`, default: `-1`) Number of threads to use. `-1` means maximum threads.\n - num_frames: (`int`, default: `1000`) Number of frames to simulate.\n - penalty: (`real`, default: `0`) Penetration penalty. Typical values are `1e3` ~ `1e4`.\n - optimized: (`bool`, default: `True`) Turn on optimization or not. Turning it off if you need to benchmark the less optimized transfers.\n - task_id: (`string`, default: `taichi` will use the current file name)\n - rigid_body_levelset_collision: (`bool`, default: `False`) Collide rigid body with level set? (Useful for wine \u0026 glass.)\n - rpic_damping: (`real`, default: `0`) RPIC damping value should be between 0 and 1 (inclusive).\n - apic_damping: (`real`, default: `0`) APIC damping value should be between 0 and 1 (inclusive).\n - warn_particle_deletion: (`bool`, default: `False`) Log warning when particles get deleted\n - verbose_bgeo: (`bool`, default: `false`) If `true`, output particle attributes other than `position`.\n - reorder_interval: (`int`, default: `1000`) If bigger than error, sort particle storage in memory every `reorder_interval` substeps.\n - clean_boundary: (`int`, default: `1000`) If bigger than error, sort particle storage in memory every `reorder_interval` substeps.\n - ...\n \n## MPM.add_particles\n - type: `rigid`, `snow`, `jelly`, `sand`. For non-rigid type, see [Particle Attributes](#attributes)\n - color: (`Vector\u003c3, real\u003e`)\n - pd : (`bool`, default: `True`) Is poisson disk sampling or not? Doesn't support type: `rigid`, `sdf`\n - pd_periodic : (`bool`, default: `True`) Is poisson disk periodic or not? Doesn't support 2D\n - pd_source : (`bool`, default: `False`) Is poisson disk sampling from source or not (need to define`frame_update`)? Doesn't support 2D\n - For type `rigid`:\n - rotation_axis : (`Vector\u003c3, real\u003e`, default: `(0, 0, 0)`) Let the object rotate along with only this axis. Useful for fans or wheels.\n - codimensional : (`bool`, must be explicitly specified) Is thin shell or not?\n - restitution: (`real`, default: `0.0`) Coefficient of restitution\n - friction: (`real`, default: `0.0`) Coefficient of friction\n - density: (`real`, default: `40` for thin shell, `400` for non-thin shell) Volume/area density.\n - scale: (`Vector\u003c3, real\u003e`, default: `(1, 1, 1)`) rescale the object, bigger or smaller\n - initial_position: (`Vector\u003cdim, real\u003e`, must be explicitly specified)\n - initial_velocity: (`Vector\u003cdim, real\u003e`, default: `(0, 0, 0)`)\n - scripted_position: (`function(real) =\u003e Vector\u003c3, real\u003e`)\n - initial_rotation: (`Vector\u003c1 (2D) or 3 (3D), real\u003e`, default: `(0, 0, 0)`) Euler angles\n - initial_angular_velocity: (`Vector\u003c1 (2D) or 3 (3D), real\u003e`, default: `(0, 0, 0)`)\n - scripted_rotation: (`function(real) =\u003e Vector\u003c1 (2D) or 3 (3D), real\u003e`) Takes time, returns Euler angles\n - (Translational/Rotational) static objects are also considered as scripted, but with a fixed scripting function i.e. `tc.constant_function13(tc.Vector(0, 0, 0))`\n - linear_damping: (`real`, default: `0`) damping of linear velocity. Typical value: `1`\n - angular_damping: (`real`, default: `0`) damping of angular velocity. Typical value: `1`\n - ...\n \n# \u003ca name=\"attributes\"\u003e\u003c/a\u003eParticle Attributes\n * `jelly`\n    - `E`:  (`real`, default: `1e5`) Young's modulus\n    - `nu`:  (`real`, default: `0.3`) Poisson's ratio\n * `snow`\n    - `hardeing` (`real`, default: `10`) Hardening coefficient\n    - `mu_0` (`real`, default: `58333.3`) Lame parameter\n    - `lambda_0` (`real`, default: `38888.9`) Lame parameter\n    - `theta_c` (`real`, default: `2.5e-2`) Critical compression\n    - `theta_s` (`real`, default: `7.5e-3`) Critical stretch\n * `sand`\n    - `mu_0` (`real`, default: `136038`) Lame parameter\n    - `lambda_0` (`real`, default: `204057`) Lame parameter\n    - `friction_angle` (`real`, default: `30`)\n    - `cohesion` (`real`, default: `0`)\n    - `beta` (`real`, default: `1`)\n * `water`\n    - `k`:  (`real`, default: `1e5`) Bulk modulus\n    - `gamma`:  (`real`, default: `7`)\n * `von_mises`\n    - `youngs_modulus`:  (`real`, default: `5e3`) Young's modulus (for elasticity)\n    - `poisson_ratio`:  (`real`, default: `0.4`) Poisson's ratio (for elasticity, usually no need to change)\n    - `yield_stress`: (`real`, default:`1.0`) Radius of yield surface (for plasticity)\n * ...\n\n## Script Examples\n - Scripted motion: `scripted_motion_3d.py`.\n - Rigid-ground collison: `rigid_ground_collision.py`.\n - When you're making an rotating wheel example, e.g. `thin_wheels_fans.py` and the wheel is not turning in the right direction, you can try `reverse_vertices=True`.\n - ...\n \n# Notes\n - Matrices in taichi are column major. E.g. A[3][1] is the element at row 2 and column 4.\n - All indices, unless explicitly specified, are 0-based.\n - Use `real`, in most cases, instead of `float` or `double`.\n - Float point constants should be suffixed with `_f`, so that it will have type `real`, instead of `float` or `double`. Example: `1.5_f` (`float` or `double` depending on build precision) instead of `1.5` (always `double`) or `1.5f` (always `float`)\n - Always pull `taichi` (the main lib, *master* branch) after updating `taichi_mpm`.\n - When a particles moves too close to the boundary (4-8 dx) it will be deleted.\n - Whenever you can any compile/linking problem:\n   - Make sure `taichi` is up-to-date\n   - Invoke `CMake` so that all no source files will be detected\n   - Rebuild\n - ...\n  \n# Friction Coefficient\n - Separate: positive values, `0.4` means coeff of friction `0.4`\n - Sticky: -1\n - Slip: -2\n - Slip with friction: `-2.4` means coeff of friction `0.4` with slip\n \n# Articulation\n\nSyntax:\n\n```$python\n    object1 = mpm.add_particles(...)\n    object2 = mpm.add_particles(...)\n\n    mpm.add_articulation(type='motor', obj0=object1, obj1=object2, axis=(0, 0, 1), power=0.05)\n```\n\n * Rotation: enforce two objects to have the same rotation.\n   - `type`:  `rotation`\n   - `obj0`, `obj1`: two objects\n   - Use case: blabe and wheel in `water wheel` examples \n   \n * Distance: enforce two points on two different object to have constant distance\n   - `type`:  `distance`\n   - `obj0`, `obj1`: two objects\n   - `offset0`, `offset1`: (`Vector\u003cdim, real\u003e`, default: `(0, 0, 0)`) offset of two points to the center of mass to each object, in world space\n   - `distance` (`real`, default: initial distance between two poitns) target distance\n   - `penalty` (`real`, default: `1e5`) corrective penalty\n   - Use case: hammer in `crashing_castle` examples \n   \n * Motor: enforce object to rotate along an axis on another object, and apply torque\n   - `type`:  `motor`\n   - `obj0`: the `wheel` object\n   - `obj1`: the `body` object\n   - `axis`: (`Vector\u003cdim, real\u003e`) the rotation axis in world space\n   - `power` (`real`, default: `0`) torque applied per second\n   - Use case: wheels for cars, and legs for the robot\n   - Example: `motor.py`\n * Stepper: enforce object to rotate along an axis on another object at a fixed angular velocity\n   - `type`:  `motor`\n   - `obj0`: the `wheel` object\n   - `obj1`: the `body` object\n   - `axis`: (`Vector\u003cdim, real\u003e`) the rotation axis in world space\n   - `angular_velocity` (`real`) \n   - Use case: Fixed-rotation-speed wheels for cars, and legs for the robot\n\n# Source Sampling\n - If you want to source particles continuously from a object, please set `pd_source = True` in `add_particles`\n - `initial_velocity` should be a non-zero vector\n - Remember to also set `delta_t=frame_dt` in `add_particles`, which enables the frequency of sampling to be consistent with its initial velocity\n - There might be some artifact due to the effect of gravity. You can reduce that artifact by  increasing `update_frequency`.\n - Example: `source_sampling.py`, `source_sampling_2d.py`\n\n\n## Mathematical Comparisons with Traditional MPM\n\u003cimg src=\"/images/comparisons.jpg\" with=\"1000\"\u003e\n\n# Performance\n\n# Bibtex\nPlease cite our [paper](https://yuanming.taichi.graphics/publication/2018-mlsmpm/) if you use this code for your research: \n```\n@article{hu2018mlsmpmcpic,\n  title={A Moving Least Squares Material Point Method with Displacement Discontinuity and Two-Way Rigid Body Coupling},\n  author={Hu, Yuanming and Fang, Yu and Ge, Ziheng and Qu, Ziyin and Zhu, Yixin and Pradhana, Andre and Jiang, Chenfanfu},\n  journal={ACM Transactions on Graphics (TOG)},\n  volume={37},\n  number={4},\n  pages={150},\n  year={2018},\n  publisher={ACM}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanming-hu%2Ftaichi_mpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanming-hu%2Ftaichi_mpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanming-hu%2Ftaichi_mpm/lists"}