Skip to content

Instantly share code, notes, and snippets.

View rieder's full-sized avatar

Steven Rieder rieder

View GitHub Profile
@rieder
rieder / create_and_follow_binary.py
Last active November 29, 2022 14:55
Create a binary star pair
#!/usr/bin/env python
# coding: utf-8
import sys
import numpy
import argparse
from amuse.units import nbody_system, units, constants
from amuse.ic.plummer import new_plummer_model
from amuse.community.ph4 import Ph4
from amuse.community.smalln import Smalln
@rieder
rieder / plot_stars.py
Last active September 22, 2022 13:05
import sys
from amuse.units import units
from amuse.io import read_set_from_file
import matplotlib.pyplot as plt
def plot_stars(stars, length_unit=units.pc, plot_by_luminosity=True, scale=1/40):
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
if plot_by_luminosity:
import sys
from amuse.units import units, nbody_system
from amuse.io import read_set_from_file
from amuse.io import write_set_to_file
from amuse.community.ph4 import Ph4
def main():
time_step = 0.01 | units.Myr
time_end = 10 | units.Myr
@rieder
rieder / compare_clustertools_to_amuse.py
Last active October 11, 2022 15:07
Script to compare Clustertools analysis to internal AMUSE analysis
"""
Script to compare Clustertools analysis to native AMUSE analysis
"""
# requires amuse-framework, amuse-masc and clustertool to be installed
import numpy as np
import matplotlib.pyplot as plt
import clustertools as ctools
from amuse.units import units, nbody_system
from amuse.units.quantities import VectorQuantity
@rieder
rieder / setup_bridge_detailed.py
Created June 24, 2022 11:43
Setup AMUSE Bridge with external kicker codes
"""
Example of combining gas and stars via Bridge with a dedicated kicker code.
"""
from amuse.units import nbody_system, units
from amuse.couple.bridge import Bridge, CalculateFieldForCodes
from amuse.community.bhtree import Bhtree
from amuse.community.fastkick import Fastkick
from amuse.community.ph4 import Ph4
from amuse.community.gadget2 import Gadget2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Plot hydro and/or stars
"""
import os
import logging
import numpy
import copy
import argparse
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
PortSystem 1.0
PortGroup python 1.0
name py-amuse-framework
version 12.1.3.post1
revision 0
checksums rmd160 ef2892ab08fad3131e0da715d4bd7df95af71510 \
sha256 8a787aec81a7fada78891b326a4ff74bb57b71c056677f2dd34236afda931c4f \
@rieder
rieder / write_papers_entry.py
Last active October 6, 2019 09:41
Create an entry for the AMUSE papers database based on citekey
import sys
import ads
# from amuse.support.version import major_version, minor_version
major_version = 12
minor_version = 1
ver = "%s.%s" % (major_version, minor_version)
bibcodes = sys.argv[1:]
@rieder
rieder / makemovie.sh
Last active December 2, 2022 11:09
Make a movie from a set of PNG images, using ffmpeg
framerate=60
i=0
padtowidth=6
for plot in plot-??????.png; do
ln -s $plot `printf "frame-%0*d.png \n" $padtowidth $i`;
let i=i+1
done
ffmpeg -framerate $framerate \
-i frame-%06d.png \