Created
December 30, 2024 15:12
-
-
Save hannorein/0d27955358993c439eca2b849b1bb444 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": 49, | |
| "id": "f5e15f09-0894-40c8-b236-cdb0161aafd7", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Created Simulationarchive for random <rebound.simulationarchive.Simulationarchive object at 0x143596640, nblobs=24941, reb_version=4.4.5>\n", | |
| "Created Simulationarchive for resonant <rebound.simulationarchive.Simulationarchive object at 0x143596940, nblobs=102497, reb_version=4.4.5>\n" | |
| ] | |
| } | |
| ], | |
| "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": "15a6c2d1-fa49-4541-b68f-e6a44dc9a210", | |
| "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