Skip to content
/ galaxy Public

Implementation of the Barnes Hut algorithm to simulate the evolution of a galaxy.

License

Notifications You must be signed in to change notification settings

weka511/galaxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

galaxy

Implementation of the Barnes Hut algorithm to simulate the evolution of a galaxy. This code has been compiled under Cygwin.

Acknowledgements

I learned about the Barnes Hut Algorithm from the Simulation and modeling of natural processes from the University of Geneva.

I am grateful to the following people who have geneously made code available the the world at large:

NB Their source code is available under whichever licences the authors have used. It is not covered by the license for the galaxy package.

Contents

galaxy.exe

File Header Purpose
barnes-hut.cpp barnes-hut.h Calculate accelerations using Barnes Hut
catch.hpp Catch2 Unit testing framework
center-of-mass.cpp center-of-mass.h Find centre of mass for internal nodes
collision.xml Parameter file to set up for colliding galaxies
configs.cpp configs.h Configuration management
factory.cpp factory.h Abstract Factory for creating configurations of particles
galaxy.cpp galaxy.h Simulate Galaxy using Barnes Hut
GalaxySimulator.xml Notepad++ Workspace
Makefile Build galaxy simulation
mt.cc mt.h Mersenne twister
mtex.cc Test code for Mersenne twister
mttest.cc Test code for Mersenne twister
particle-factory.cpp particle-factory.h Create particles as specified by an XML file
particle.h particle.h Represents the particles whose motion is being simulated
physics.cpp physics.h Physical constants, law of gravitation, etc
plummer.cpp plummer.h Factory for creating particles
spdlog Header files for spdlog super fast C++ logging library.
tinyxml2.cpp tinyxml2.h Lee Thomason's XML Parser
stepper.cpp stepper.h A class to support multi -threading
tests.cpp Test harness
test-kepler.cpp Test for Kepler problem
test-plummer.cpp Test for Plummer model
test-random.cpp Test for Various random number generators
test-serialization.cpp Test that serialization works OK
test-tree.cpp Test treecode
threading.cpp Test to determine whether threads can speed up code
timing.sh Script to determine execution times
treecode.cpp treecode.h Barnes-Hut Tree
utils.cpp utils.h Assorted utility functions
verlet.cpp verlet.h Verlet "leapfrog" integrator

Helper programs

File Purpose
adze.py Cut logfiles up and analyze data
configure.py Create configuration for galaxy.exe
make_3d.py Plot output from galaxy
make_img.py Plot output from galaxy
plot_energy.py Used to investigate distribution of energies - do we thermalize?
plot_orbits.py Select a few stars at random and plot their orbits
utils.py Code shared by other python scripts
Date Remarks
31 Jan 18 Program segfaults. Turn off Barnes-Hut and try some easy test cases, e.g. Kepler, Lagrange points, and a resonance
4 Feb 18 Traced problem to acceleration calcs: when we figure out force on a particular particle we included the particle itself. This has been corrected, but the fix is a kludge, so some work still needs to be done.
Particles are diverging, is the initial velocity too high?
6 Feb 18 Reset centre of mass and linear momentum to (0,0,0) at start of run, and checked code. Configuration still d rifts. Need to construct simplest possible case that exhibits error.
7 Feb 18 I have done some more checking by adding tracing statements, and code appears to be working, albeit with large error. I am studying Error analysis of a tree code by Barnes and Hut. Do errors decrease for very many particles? What if we soften gravitational potential? Another thought: what is error in Geneva code?
8 Feb 18 Downloaded Geneva version and modified to display energy. At present this does not appear to be conserved
13 Feb 18 I am logging parameters, so can now investigate dependence of energy anomaly on dt, softening, and theta. I'm also doing some long runs to study long-term behaviour.
26 Feb 18 The kinetic energy and potential energy aren't following Virial theorem very well. I will check mass distribution first.
17 Mar 18 After a week of development I now have a multithreaded version. I don't think I'd have started if I'd realized how much work it was. Just doing a few time comparisons. Later: very disappointing - multi-threaded is slower than single threaded.
18 Mar 18 What if there many more than 1000 bodies? We possibly need the acceleration calculation to be much longer to see the benefit of threads? No: I have just tested, with 100000 bodies, 10 iterations. 4 threads, 448 seconds; 2 threads, 448; unthreaded, 165
  I have created a factory to allow more complex simulations, e.g. colliding galaxies. I decided to use XML rather than CSV, and used Lee Thomason's TinyXML-2, following the discussion here. XML is more than I require at present, but I expect the complexity of the input files weill increase, so this is by way of future proofing.
25 Mar 18 I'm curious to see whether the configuration eventually becomes thermalized--see Debarshee Bagchi and Constantino Tsallis: Fermi-Pasta-Ulam-Tsingou problems: Passage from Boltzmann to qq-statistics. Since we were throwing away the momentum when we write the configuration, I've raised Issue #32 to fix this. This is also a good time to simplify the code by removing energy calcs, so we use c++ for heavy lifting, but do as much as possible in Python.
26 Mar 18 This shows the distribution after 5400 iterations, compared with the Bolzmann Distribution. Alt text Here is version from earlier in the simulation, which is not very Boltzmann.Alt textThis shows the evolution of the beta parameter. Alt text
2 Apr 18 Revisit Virial Theorem - what is the effect of the softening length?

About

Implementation of the Barnes Hut algorithm to simulate the evolution of a galaxy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages