Skip to content

AndersenFred/Datenverarbeitung

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Before you start (Git & SSH)

If you have never used Git with SSH before, follow these guides once:


Project structure

.
├── environment.yml     # Conda environment (name: DV)
├── demo.py             # Example N-body simulation
├── Visualizer.py       # Visualization class (creates GIF animations)
└── README.md

Installation (Conda environment)

Only run this on your personal computer (not on CIP).

  1. Open a terminal in the project directory.

  2. Create the environment:

    conda env create -f environment.yml
  3. Activate the environment:

    conda activate DV

All required packages (NumPy, Matplotlib, Pillow) are now installed.


Using Git

Clone the repository to your local machine:

git clone git@github.com:AndersenFred/Datenverarbeitung.git
cd Datenverarbeitung

Create your own working branch:

git checkout -b <your-branch-name>

Work only on your own branch. Once you have implemented new features:

git checkout main
git merge <your-branch-name>

Running the demo

After activating the environment:

python demo.py

When the script finishes, a file called

nbody.gif

will appear in the project directory.

Example output:


VS Code (CIP)

On CIP systems, load and start VS Code using:

module load vscode
code

Collision formular

p_i+p_j&\to p_i'+p_j'\\
n_{ij}&=\frac{x_i-x_j}{||x_i-x_j||}\\
v_i'&=v_i-\frac{2m_j}{m_i+m_j}[(v_i-v_j)\cdot n_{ij}]n_{ij}\\
v_j'&=v_j-\frac{2m_i}{m_i+m_j}[(v_j-v_i)\cdot n_{ji}]n_{ji}

Extension ideas

(Coding a Physics Engine from scratch!)[https://www.youtube.com/watch?v=nXrEX6j-Mws]

- [ ] Reflecting walls → clamp positions at box edges, flip velocity component
- [ ] Periodic boundaries → modulo position by box size
- [ ] Central force (harmonic trap) → add F = -k r to acceleration
- [ ] Lennard–Jones–type force → pairwise force with cutoff radius
- [ ] Velocity-dependent drag → add F = -γ v
- [ ] External constant field → add uniform acceleration (e.g. gravity)
- [ ] Two-species particles → store type array, condition forces on type
- [ ] Soft collisions → short-range repulsive force instead of hard contact
- [ ] Hard-sphere collisions → detect overlap, swap normal velocity components
- [ ] Random kicks (noise) → add small Gaussian velocity increments
- [ ] Initial condition presets → lattice, ring, or disk setups

Analysis ideas

- [ ] Total energy vs time → compute kinetic + potential energy
- [ ] Momentum conservation → sum m·v and check constancy
- [ ] Center-of-mass motion → track COM position and velocity
- [ ] Speed distribution → histogram of |v|
- [ ] Pair distance distribution → histogram of |r_i − r_j|
- [ ] Radial density profile → bin particles by distance from origin
- [ ] Timestep dependence → compare results for different dt
- [ ] Collision rate → count collision events per unit time
- [ ] Energy exchange → track kinetic energy per particle
- [ ] Equilibration time → detect when observables stabilize
- [ ] Chaos indicator (qualitative) → compare nearby initial conditions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages