Created
December 30, 2024 15:12
-
-
Save hannorein/b8531ee21797c5ca9b06b6984ae00b67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "9784abe4-7d83-421f-97bb-78dc82965db5", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import rebound\n", | |
| "import numpy as np" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "f5e15f09-0894-40c8-b236-cdb0161aafd7", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "for set in [\"random\", \"resonant\"]:\n", | |
| " dataset = np.genfromtxt(set+\"/clean_initial_conditions.csv\", delimiter=\",\", skip_header=1)\n", | |
| " sim = rebound.Simulation()\n", | |
| " for i in range(4): sim.add()\n", | |
| " sim.G=4*np.pi**2\n", | |
| " for r, d in enumerate(dataset):\n", | |
| " for i in range(4):\n", | |
| " sim.particles[i].m = d[1+i*7]\n", | |
| " sim.particles[i].xyz = d[2+i*7:5+i*7]\n", | |
| " sim.particles[i].vxyz = d[5+i*7:8+i*7]\n", | |
| " sim.save_to_file(set+\"/clean_initial_conditions.bin\", delete_file=(r==0))\n", | |
| " sa = rebound.Simulationarchive(set+\"/clean_initial_conditions.bin\")\n", | |
| " print(\"Created Simulationarchive for\", set, sa) " | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "60de7530-5075-45ce-92a3-74bc514ec782", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3 (ipykernel)", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.9.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment