Giter Site home page Giter Site logo

jamiefarnes / negative-mass-simulator Goto Github PK

View Code? Open in Web Editor NEW
61.0 16.0 18.0 16 KB

Negative Mass N-body Simulation Codes

License: Apache License 2.0

Python 100.00%
n-body simulations nbody-gravity-simulation nbody-simulation n-body-simulator gravitational-simulations

negative-mass-simulator's Introduction

Negative Mass N-body Simulation Codes

This software allows one to perform three-dimensional (3D) gravitational N-body simulations in python, using both positive and negative masses.

These are corresponding codes for the paper "A unifying theory of dark energy and dark matter: Negative masses and matter creation within a modified LambdaCDM framework", available at:

http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:1712.07962

https://arxiv.org/abs/1712.07962

The paper has been accepted for publication in Astronomy and Astrophysics (A&A).

Notes

Most modern N-body software packages do not support exotic and rarely-studied phenomena such as negative masses. The code has therefore been deliberately written in order to achieve this goal. I have therefore written new software to perform three-dimensional (3D) gravitational N-body simulations using python, numpy, and matplotlib. The code is parallelised using Dask in order to make use of the multiple processing cores available in most modern machines.

The primary motivation for this computational perspective is not focussed on performance, but rather on providing easily-understandable, open-source software. This enables the presented results to be easily replicated and verified on any scientist's own machine, rather than requiring any specialised hardware or software setup. The simulations presented here are therefore necessarily primitive in comparison with the state-of-the-art, but provide examples that demonstrate what can be expected from such a toy model.

Negative masses are a creative explanation that require substantial scrutiny. The code therefore deliberately uses direct methods to evaluate the position and velocity of every particle at each timestep. This avoids the introduction of any approximations and maintains the highest accuracy. Nevertheless, this has a substantial cost in terms of computing time.

Using a 2015 MacBook Pro, 3.1 GHz Intel Core i7, with 16 GB RAM, a single iteration with 50,000 particles takes ~3 minutes. A full run of ~1000 iterations requires ~50 hours of run time. If the code should need to be stopped for any reason, the N-body simulation code, run_nbody(), can simply be re-run, and it will automatically pick up from where it left off - beginning its calculation from the latest .hdf5 file saved to disk.

Dependencies

numpy

matplotlib

h5py

Dask

ImageMagick

negative-mass-simulator's People

Contributors

jamiefarnes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

negative-mass-simulator's Issues

Unable to allocate 381. MiB for an array with shape

Traceback (most recent call last):
File "C:\Users\wane\Downloads\negative-mass-simulator-master\negative-mass-simulator-master\pipe.py", line 26, in
run_nbody()
File "C:\Users\wane\Downloads\negative-mass-simulator-master\negative-mass-simulator-master\negmass_nbody\simulate\sim.py", line 164, in run_nbody
velocity = update_velocities(position, velocity, mass, G, epsilon)
File "C:\Users\wane\Downloads\negative-mass-simulator-master\negative-mass-simulator-master\negmass_nbody\simulate\sim.py", line 98, in update_velocities
velocity = np.column_stack((velocity_x.compute(), velocity_y.compute(), velocity_z.compute()))
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\base.py", line 166, in compute
(result,) = compute(self, traverse=False, **kwargs)
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\base.py", line 444, in compute
results = schedule(dsk, keys, **kwargs)
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\threaded.py", line 84, in get
**kwargs
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\local.py", line 486, in get_async
raise_exception(exc, tb)
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\local.py", line 316, in reraise
raise exc
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\local.py", line 222, in execute_task
result = _execute_task(task, data)
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\core.py", line 121, in _execute_task
return func((_execute_task(a, cache) for a in args))
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\optimization.py", line 988, in call
return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\core.py", line 151, in get
result = _execute_task(task, cache)
File "C:\Users\wane\AppData\Local\Programs\Python\Python37\lib\site-packages\dask\core.py", line 121, in _execute_task
return func(
(_execute_task(a, cache) for a in args))
MemoryError: Unable to allocate 381. MiB for an array with shape (10000, 10000) and data type float32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.