Questions tagged [physics]
Physics is a science that studies the interactions of energy and matter. The physics tag should be used for questions about how physics can be simulated or implemented in programming.
17
questions
5
votes
1
answer
231
views
Calculating the energy of the harmonic oscillator using a Monte Carlo method
The problem
The partition function for the quantum harmonic oscillator can be written in the path integral formulation as
$$Z\propto\int Dx(\tau)\exp\left(-\frac{S_E}{\hbar}\right)=\int Dx(\tau)\exp\...
126
votes
4
answers
24k
views
Celebratory fireworks animation
To celebrate an important event, I hastily cobbled together an HTML canvas-based animation.
A few concerns I have include:
Performance: Does it run reasonably smoothly on most modern machines? How ...
33
votes
9
answers
8k
views
Simple n-body class in C++
As part of my training, I implemented a n-body class in C++ to simulate gravitational interaction of bodies and to get more familiar with features that C++ offers such as object oriented programming.
...
21
votes
2
answers
7k
views
Barnes-Hut N-body simulator
I have written an n-body simulator, implementing the Barnes-Hut algorithm. Please comment on anything you can see wrong with this.
Wikipedia Barnes-Hut page
This is a screen shot of the simulation 20 ...
15
votes
3
answers
1k
views
Simulating gravitational attraction between bodies
I'm currently working on a simple simulator in Unity3D that involves planets orbiting each other. I wrote the following C# script to do that. It uses the classic gravitational formula,
$$F=G\frac{...
8
votes
3
answers
2k
views
Python differential analysis of heat loss across a pipe
I made a differential equation solver to forecast heat loss through a pipe with heat loss coefficient contours. It does what I want it to do but I had to use global variables to change the outputs of ...
8
votes
2
answers
1k
views
Golf game boilerplate
I wrote a program in pygame that basically acts as a physics engine for a ball. You can hit the ball around and your strokes are counted, as well as an extra stroke for going out of bounds. If I do ...
7
votes
3
answers
247
views
Solving for every variable in a number of physics formulas
I'm working on making an iOS app to solve physics problems and I'm starting by just having it solve basic kinematics problems with the following formulas (I've coded it in C instead of Swift to start ...
6
votes
2
answers
339
views
Simulating the orbits of the Earth, Moon and Sun together in Fortran
This has been racking my brain for hours now. I will try to explain as much as I can. I'm aware this code is horrendously ungraceful, but I'm new to Fortran and making things more efficient is not ...
5
votes
1
answer
67
views
Exploring the space of 8 parameters of a physics problem to then be evaluated in ODE integrator as LSODA millions of times, efficently
there's a function in one of the scripts I've been working on that I really want to improve.
Disclaimer: Being honest, I'm not really very good at programming but I've been learning day to day and it'...
4
votes
2
answers
253
views
Python object-oriented pipe cooling simulations
Here is my code simulating liquid in a pipe cooling under different conditions. How did I do approaching this in an object orientated way? Is there any way I can improve this code?
...
4
votes
1
answer
93
views
Phase diagrams of particles in a mirror
I have completed my project which models the paths of particles in a plasma experiencing a force. The program creates phase diagrams of a particle's perpendicular velocity against its parallel ...
3
votes
2
answers
2k
views
Diffusion Limited Aggregation Simulator
Based on my answer to another code review question I wrote my own python script for DLA (Diffusion Limited Aggregation).
The DLA algorithm task:
Place seed at the center of the canvas.
Release a ...
3
votes
2
answers
670
views
Simulating a system of moving points
This is an update of the code from my previous question.
I'm simulating a system of particles which interact with each other and move and rotate due to the interaction. There are 2000 particles in ...
2
votes
2
answers
5k
views
Simulation of 2D elastic balls
Following this SO post and this Wikipedia article, I wrote a Python script to simulate physics of 2D elastic balls.
I define the physical behaviour of each ball in the ...