Python 中的物理简单模拟?

发布于 2024-07-13 13:13:10 字数 232 浏览 11 评论 0原文

我想知道类似的具体模拟,例如此处的浇水模拟。

对于此类 Python 模拟,您最喜欢的库/互联网页面是什么?

我对 Simpy、Numpy 和 Pygame 知之甚少。 我想获得有关它们的例子。

I would like to know similar, concrete simulations, as the simulation about watering a field here.

What is your favorite library/internet page for such simulations in Python?

I know little Simpy, Numpy and Pygame. I would like to get examples about them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

朱染 2024-07-20 13:13:10

如果您正在寻找一些看起来真实并且相当的游戏物理(碰撞、变形、重力等),请考虑重复使用一些物理引擎库。

作为第一个参考,您可能需要查看 pymunk,它是 Chipmunk 2D 物理库。 您可以在维基百科中找到各种开源物理引擎(2D 和 3D)的列表。

如果您正在寻找物理上正确的模拟,无论您想使用什么语言,它都会得多(几乎不是实时的),并且您需要使用一些数值分析软件(并且可能自己编写一些东西)。 确切的答案取决于您想要解决的问题。 这是一个相当复杂的(数学)领域。

例如,如果您需要进行连续介质力学或电磁学的模拟,您可能需要有限差分、有限体积或有限元方法。 对于 Python,有一些现成的库,例如: FiPy (FVM) 、GetFem++ (FEM)、FEniCS/DOLFIN (FEM),以及其他一些。

If you are looking for some game physics (collisions, deformations, gravity, etc.) which looks real and is reasonably fast consider re-using some physics engine libraries.

As a first reference, you may want to look into pymunk, a Python wrapper of Chipmunk 2D physics library. You can find a list of various Open Source physics engines (2D and 3D) in Wikipedia.

If you are looking for physically correct simulations, no matter what language you want to use, it will be much slower (almost never real-time), and you need to use some numerical analysis software (and probably to write something yourself). Exact answer depends on the problem you want to solve. It is a fairly complicated field (of math).

For example, if you need to do simulations in continuum mechanics or electromagnetism, you probably need Finite Difference, Finite Volume or Finite Element methods. For Python, there are some ready-to-use libraries, for example: FiPy (FVM), GetFem++ (FEM), FEniCS/DOLFIN (FEM), and some other.

三生殊途 2024-07-20 13:13:10

这是一些简单的天文学相关的Python。 这是来自同一个人的硬核代码

Eagleclaw 使用一些 Python 求解并绘制各种双曲方程。 然而,大部分代码是用 Fortran 编写的来进行计算,并用 Python 来绘制结果。 如果您正在学习物理,那么您可能必须习惯这种 Fortran 包装的代码。 这是现实。 但我猜这并不是你真正想要的。 好处是它以文字编程风格记录,因此应该是可以理解的。

Here is some simple astronomy related python. And here is a hardcore code from the same guy.

And Eagleclaw solves and plots various hyperbolic equations using some python. However, most of the code is written in Fortran to do the computations and python to plot the results. If you are studying physics though you may have to get used to this kind of Fortran wrapped code. It is a reality. But this isn't really what your looking for I guess. The good thing it that it is documented in a literate programming style so it should be understandable.

迷路的信 2024-07-20 13:13:10

我听说过 PyBox2D,它是真正的不错的 Box2D。 引用该网站:

Box2D 是一个功能丰富的 2D 刚体物理引擎,由 Erin Catto 用 C++ 编写。 它已被用于许多游戏中,包括荣获 2008 年独立游戏节大奖的《蜡笔物理豪华版》。

I've heard of PyBox2D, which is a port of the really nice Box2D. To quote the site:

Box2D is a feature rich 2d rigid body physics engine, written in C++ by Erin Catto. It has been used in many games, including Crayon Physics Deluxe, winner of the 2008 Independent Game Festival Grand Prize.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文