# 2D-Particle-Simulations
https://quantumwarlock.github.io/2D-Particle-Simulations/
This repository features several scripts for simulating non-relativistic elastic 2D collisions. In all cases, the particles are modeled as circles.
I may include a relativistic, inelastic example from nuclear physics in the future. Please send me an e-mail, if there is enough interest I'll include it sooner than later.
## Requirements
**Anaconda Python** is recommended (need version information) but not required. A **Python3** distribution with the following modules are required: **numpy**, **random**, **matplotlib**, **math**.
## Python Scripts
All of the following simulations scale the radius of the particles based on the number of the particles chosen (so they fit nicely and don't overlap). The initial time-step is also scaled based on the radius and initial velocities. The radius and time-step algorithms are conservative and could both easily be increased. The scripts feature various random and initial condition correction code that can be uncommented and used to suite ones needs if useful.
The following files are located in the *scripts* directory:
* **ghost_box.py**
The ghost particles in this simulation do not interact with each other. They simply pass through each other trying to escape the box. However the walls of the box have been enchanted with magic and stuff so they simply bounce off. It's almost like Sir Isaac Newton specified the laws governing the walls...
* **ghost_circle.py**
This ghostly simulation is much like the *ghost_box*. However, in this version of pergatory the ghosts are trapped in a circle. There is definitely something magical about finding the correct perpendicular axis to the tangent plane going on here!
* **hard_box.py**
This simulation is a bit *billiard ball* like. The circular particles are now theoretically impenetrable. One may even conclude the collisions are elastic. Of course, my computer represents numbers by a finite collection of binary "bits" and the time-steps are kinda large by calculus standards. I'm just saying interesting (non-physical) things can happen. There is also the infinite potential at the surface of the circle assumption thing...
* **hard_circle.py**
Hard-sphere elastic collitions in a circle.
* **hard_gravity_box.py**
Particles undergo elastic collisions between each other and the walls while in a uniform gravity field.
* **hard_diffmass_box.py**
Similar to *hard_box* but now the particles all have different masses which are represented by correspondingly larger or smaller radii. The radius scaling is based on constant density, *i.e.* all balls have the same density. The relationship between the radius and the mass is given by: mass = radius**2 (density = 1/Pi).
* **hard_diffmass_circle.py**
Similar to *hard_diffmass_box* but in a circular boundary.
* **pentagon_zombie_apocalypse.py**
This simulation features hard-sphere elatic collions in a pentagon. While this simulation is a bit *"...and now for something completely different"* its purpose is to create an application for the type of physics represented in this repository.
*Backstory:*
It is a busy day at the Pentagon. Many very important people are busily doing very important things. However, some things are more super secret than others. What only a select few people and two scientists know is that Dr. Maxbrain has been flown in from AREA51. Dr. Maxbrain is the scientist who was recruited as a 10 year old prodigy and educated at the best schools earning several PhDs and a MD before turning 18 and could finally get a *GREENDAWN* security clearance! Dr. Maxbrain's expertise has been requested at the highest level to help in the fight against the current pandemic. The years of being locked away underground working with aliens has taken its toll and the good doctors ethics have gotten a bit shaky. In an effort to impress the brass and spend time with humans, a cross with experimental alien DNA is attempted. The result is a human-alien hybrid that infects everyone it comes in contact with ... but the "hybrids" don't look like or have any of the advanced capabilities of the aliens. Dr. Maxbrain has been tricked! It's a zombie apocalypse at the pentagon...
* **nuclear_box.py**
TBD
* **ngon_bounce_house.py**
TBD
## Movies
The following files are in the *movies* directory. The animated gifs are meant to demonstrate a capability for each simulation of the same name.
* **ghost_box.gif**
6 circles uniformly distributed in a 10m X 10m box stylishly colored red and blue on a white background. Initial velocities for each particle (circle) are chosen randomly (OK, pseudorandomly) from a uniform distribution between -10m/s and 10m/s. Graphic is updated once for every 10 time-steps.
* **ghost_circle.gif**
100 (what value!) circles on a uniform grid, based on the largest square that can be inscribed in a circle (sides chosen parallel to the enclosing box as there are an infinite number of such boxes if orientation is considered ... but, yes, they all have the same area). The circular circle (particle) boundary has a 10m diameter. The circles are colored based on thier abscissa (x-position) via a wonderfully delightful rainbow scheme! Initial velocities are chosen from a uniform distribution between -3m/s and 3m/s. Graphic is updated every 10 time-steps.
* **hard_box.gif**
9 circles uniformly distributed in the enclosing box with initial velocities chosen randomly between -10m/s and 10m/s. The rainbow coloring map is used. If you are feeling stressed choose this simulation to watch ... kinda like a screen-saver.
* **hard_circle.gif**
400 hard circles bouncing around in a circle. Graphic is updated every 10 time-steps. It's Petri dish like.
* **hard_gravity_box.gif**
Balls are released with zero initial velocity. They fall in vertical columns under the influence of gravity and then do only what a simulation can.
* **hard_diffmass_box.gif**
100 particles are given random velocities between -10m/s and 10m/s. If the x-component of velocity is in the interval [-10,0] the radius is halved and, therefore, the mass reduced by a factor of 4. If you ever wondered what soap bubbles would do if they didn't stick or pop this is what you have been waiting to see!
* **hard_diffmass_circle.gif**
TBD
* **pentagon_zombie_apocalypse.gif**
Two hundred fifty very unlucky people and one messed up zombie make for an interesting movie.
* **nuclear_box.gif**
TBD
没有合适的资源?快使用搜索试试~ 我知道了~
2D-Particle-Simulations:圆形粒子的各种模拟程序
共20个文件
py:9个
gif:7个
md:1个
需积分: 9 2 下载量 161 浏览量
2021-02-20
05:11:40
上传
评论 1
收藏 50.78MB ZIP 举报
温馨提示
2D粒子模拟 该存储库具有几个用于模拟非相对论性弹性2D碰撞的脚本。 在所有情况下,粒子都将建模为圆形。 未来我可能会列举一个相对论,无弹性的核物理学例子。 请给我发送电子邮件,如果有足够的兴趣,我会尽快将其包括在内。 要求 推荐使用Anaconda Python (需要版本信息),但不是必需的。 需要具有以下模块的Python3发行版: numpy , random , matplotlib和math 。 Python脚本 下面的所有模拟都根据所选粒子的数量缩放粒子的半径(因此它们很好地契合并且不会重叠)。 初始时间步长也会根据半径和初始速度进行缩放。 半径和时间步长算法比较保守,很容易增加。 该脚本具有各种随机和初始条件校正代码,可以对它们进行注释,并在需要时用于满足需要。 以下文件位于脚本目录中: ghost_box.py 此模拟中的重影粒子不会相互影响。 他们只是互相穿越
资源详情
资源评论
资源推荐
收起资源包目录
2D-Particle-Simulations-master.zip (20个子文件)
2D-Particle-Simulations-master
scripts
nuclear_box.py 143B
hard_box.py 9KB
hard_diffmass_box.py 10KB
hard_diffmass_circle.py 461B
pentagon_zombie_apocalypse.py 17KB
hard_gravity_box.py 10KB
hard_circle.py 10KB
ghost_box.py 8KB
ghost_circle.py 9KB
LICENSE 1KB
README.md 6KB
.gitignore 2KB
_config.yml 26B
movies
hard_box.gif 7.81MB
hard_gravity_box.gif 21.65MB
pentagon_zombie_apocalypse.gif 22.91MB
ghost_box.gif 7.25MB
ghost_circle.gif 9.63MB
hard_circle.gif 11.44MB
hard_diffmass_box.gif 11.21MB
共 20 条
- 1
胡轶强
- 粉丝: 18
- 资源: 4572
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0