Giter Site home page Giter Site logo

jared-ni / dark-matter-simulator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14.89 MB

CS205 Final Project: Dark Matter Simulator, capable of simulating celestial N-body gravitational problems with randomized initial states, up to N=100,000.

C++ 93.99% Python 1.07% Shell 4.94%

dark-matter-simulator's Introduction

Instructions

  1. Set the initial state of the universe in initial_state.txt (see next section for format).
    • You can generate a random initial state by running python3 input.py > initial_state.txt. Set the number of objects within input.py (the variable is called n).
  2. Set the desired parameters at the top of gravity.cpp.
    • Set all to false to accurately evaluate runtime, which is printed in the .err file.
    • Set OUTPUT_VIDEO_FRAMES to true if you want to see the video (see Step 4).
    • Set CHECK_MOMENTUM to true to calculate momentum and print it in .err.
    • Set BENCHMARK_PAPI to true to use PAPI, and set PAPI_TYPE_DESCRIPTION. The result is printed in the .err file.
  3. Run using sbatch job.sh.
    • You can change the number of nodes and ranks there.
  4. If OUTPUT_VIDEO_FRAMES is true, the .out file will contain pixel data corresponding to video frames. Use ffmpeg to generate the video.
    • Download the .out file.
    • Run cat <name of .out file> | ffmpeg -y -f rawvideo -pixel_format gbrp -video_size 1024x768 -i - -c:v h264 -pix_fmt yuv420p video.mov.
    • Open video.mov with a video player.
    • The version of ffmpeg in the repository is for Windows. Visit https://ffmpeg.org/download.html for other versions.
    • You may need to add .../ffmpeg/bin/ to the PATH environment variable.

Format for initial_state.txt

Syntax:

  • First line: num_time_steps num_objects
  • Next num_objects lines: mass radius pos.x pos.y pos.z vel.x vel.y vel.z

Meaning:

  • num_time_steps: Number of time steps for which to run the simulation
  • num_objects: Number of objects in the initial state of the universe
  • Each of the lines after the first line gives the initial state of one object
  • mass: Mass of object
  • radius: Radius of object
  • pos.x, pos.y, pos.z: x-, y-, and z-components of the object's initial position
  • vel.x, vel.y, vel.z: x-, y-, and z-components of the object's initial velocity

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.