{"id":24889027,"url":"https://github.com/oadultradeepfield/gravigo","last_synced_at":"2026-04-29T14:05:36.721Z","repository":{"id":275242920,"uuid":"925519809","full_name":"oadultradeepfield/gravigo","owner":"oadultradeepfield","description":"A porting of C++ N-body orbit simulation to Go with native plotting and goroutines for concurrency.","archived":false,"fork":false,"pushed_at":"2025-02-01T04:19:45.000Z","size":4980,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T05:19:55.257Z","etag":null,"topics":["golang","goroutines","gravity","simulation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oadultradeepfield.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-01T04:02:52.000Z","updated_at":"2025-02-01T04:19:49.000Z","dependencies_parsed_at":"2025-02-01T05:29:59.781Z","dependency_job_id":null,"html_url":"https://github.com/oadultradeepfield/gravigo","commit_stats":null,"previous_names":["oadultradeepfield/gravigo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oadultradeepfield%2Fgravigo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oadultradeepfield%2Fgravigo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oadultradeepfield%2Fgravigo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oadultradeepfield%2Fgravigo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oadultradeepfield","download_url":"https://codeload.github.com/oadultradeepfield/gravigo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841586,"owners_count":20681182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","goroutines","gravity","simulation"],"created_at":"2025-02-01T16:16:34.342Z","updated_at":"2026-04-29T14:05:31.698Z","avatar_url":"https://github.com/oadultradeepfield.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gravigo\n\nGravigo is a Go program for simulating the orbit of N objects under their mutual gravitation. It is a porting of my two continuous previous projects written in C++. Visit [this repository](https://github.com/oadultradeepfield/n-body-orbit-simulation) for more details. Gravigo is meant to be the exact replica but with supports for concurrent simulation using goroutines to allow more efficient processing.\n\n## Development Roadmap\n\n- [x] Port the previous C++ implementation to Go with additional project structure improvement.\n- [x] Parallelize the loop with goroutines to make the iterations run concurrently.\n\n## Getting Started\n\n1. Begin by cloning the repository and navigate to the respective directory\n\n   ```bash\n   git clone https://github.com/oadultradeepfield/gravigo\n   cd gravigo\n   ```\n\n2. Download all dependencies using the following command:\n\n   ```bash\n   go mod tidy\n   ```\n\n3. Make sure you have Go installed. This project is built using Go version 1.23.4. You can run the simulation using the following command line:\n\n   ```bash\n   go run cmd/simulation/main.go config.json\n   ```\n\n   Please refer to the below section to set up the configuration file `config.json`,\n\n## Usage\n\n1.  From the previous section, you have seen how to run the simulation using the command line. Note that the configuration file is mandatory as it contains the data of the objects you would like to examine. Below is the example of how you can set up the file:\n\n    ```json\n    {\n      \"simulator_config\": {\n        \"gravitational_constant\": 6.6743e-11,\n        \"dt\": 1000,\n        \"total_time\": 3.16e7,\n        \"output_file\": \"example_sun_earth_lagrangian_points.txt\"\n      },\n      \"coordinate_type\": \"spherical\",\n      \"bodies\": [\n        {\n          \"_name\": \"Sun\",\n          \"mass\": 1.989e30,\n          \"position\": [0.0, 0.0, 1.5707963268],\n          \"velocity\": [0.0, 0.0, 0.0]\n        },\n        {\n          \"_name\": \"Earth\",\n          \"mass\": 5.972e24,\n          \"position\": [1.496e11, 0.0, 1.5707963268],\n          \"velocity\": [0.0, 2.9788e4, 0.0]\n        },\n        {\n          \"_name\": \"L1\",\n          \"mass\": 6500,\n          \"position\": [1.481e11, 0.0, 1.5707963268],\n          \"velocity\": [0.0, 2.9489e4, 0.0]\n        },\n        {\n          \"_name\": \"L2\",\n          \"mass\": 6500,\n          \"position\": [1.511e11, 0.0, 1.5707963268],\n          \"velocity\": [0.0, 3.0087e4, 0.0]\n        },\n        {\n          \"_name\": \"L3\",\n          \"mass\": 6500,\n          \"position\": [1.496e11, 3.1415926536, 1.5707963268],\n          \"velocity\": [0.0, 2.978e4, 0.0]\n        },\n        {\n          \"_name\": \"L4\",\n          \"mass\": 6500,\n          \"position\": [1.496e11, 1.0471975512, 1.5707963268],\n          \"velocity\": [0.0, 2.978e4, 0.0]\n        },\n        {\n          \"_name\": \"L5\",\n          \"mass\": 6500,\n          \"position\": [1.496e11, -1.0471975512, 1.5707963268],\n          \"velocity\": [0.0, 2.978e4, 0.0]\n        }\n      ]\n    }\n    ```\n\n    The parameter `dt` is the time step size used to estimate the integration. The smaller ones would generally yield more accurate results but require longer to process. In addition, using large values will sometimes cause incorrect orbit shapes since the error is high. If you use Cartesian coordinates, the three components of `position` and `velocity` should be simply X, Y, and Z. For spherical coordinates, they are R, Theta, and Phi. In this project, Theta is measured from the X-axis, while Phi is measured from the Z-axis down to the XY plane.\n\n2.  As you have previously seen, you can run the simulation using the following command line:\n\n    ```bash\n    go run cmd/simulation/main.go config.json\n    ```\n\n    The output from this command is a `.txt` file located at the specified path in `config.json`:\n\n    ```\n    0.057882, 0.000005, -0.000000\n    149599980722.057831, 89363998.228348, -0.763470\n    148099980905.314911, 88466998.245267, -0.755815\n    151099980527.170044, 90260998.210362, -0.771125\n    -149599980722.042450, -89339999.755764, -0.763470\n    74722619652.576691, 129602053710.282852, -0.763470\n    74877361068.657425, -129512713712.054565, -0.763470\n    ...\n    ```\n\n    Each line corresponds to the Cartesian coordinates of each object in the same order as the input. There are seven objects in the above example, so the line will repeat for the same objects every seven lines at the new time step.\n\n3.  (Optional) To test the performance of your machine when simulating a large number of objects, you can run the following command:\n\n    ```bash\n    go run cmd/benchmark/main.go\n    ```\n\n    On my machine (M3 Macbook Air with 8-Core CPU), the following results were logged to the console:\n\n    ```\n    2025/02/01 18:37:11 Starting benchmark...\n    2025/02/01 18:37:11 Simulating 10 bodies...\n    2025/02/01 18:37:11 N=10: Time taken: 120ms\n    2025/02/01 18:37:11 Simulating 50 bodies...\n    2025/02/01 18:37:11 N=50: Time taken: 302ms\n    2025/02/01 18:37:11 Simulating 250 bodies...\n    2025/02/01 18:37:13 N=250: Time taken: 1.507s\n    2025/02/01 18:37:13 Simulating 1250 bodies...\n    2025/02/01 18:37:26 N=1250: Time taken: 12.907s\n    2025/02/01 18:37:26 Simulating 6250 bodies...\n    2025/02/01 18:40:51 N=6250: Time taken: 3m25.483s\n    2025/02/01 18:40:51 Benchmark completed.\n    ```\n\n4.  (Optional) Use the following command line to create a visualization of the trajectory of each object.\n\n    ```bash\n    python3 python/plot.py --filename example_sun_earth_lagrangian_points.txt --N 7 --labels Sun,Earth,L1,L2,L3,L4,L5\n    ```\n\n    The output plot will be saved in the same directory as the input `.txt` file.\n\n    |                          **Example 3D Trajectory**                           |                            **Example XY Projection**                            |\n    | :--------------------------------------------------------------------------: | :-----------------------------------------------------------------------------: |\n    | ![Example 3D Trajectory](example_sun_earth_lagrangian_points_trajectory.png) | ![Example 2D Projection](example_sun_earth_lagrangian_points_2d_projection.png) |\n\n## License\n\nThis project is licensed under the MIT License. See the [`LICENSE`](/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foadultradeepfield%2Fgravigo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foadultradeepfield%2Fgravigo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foadultradeepfield%2Fgravigo/lists"}