repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
GraphLIME
GraphLIME-master/exp/noise_features/utils.py
import os import numpy as np from tqdm import tqdm import seaborn as sns import matplotlib.pyplot as plt import torch import torch.optim as optim import torch.nn.functional as F import torch_geometric.transforms as T from torch_geometric.datasets import Planetoid def prepare_data(args): dataset = args.dataset.ti...
5,089
28.766082
97
py
GraphLIME
GraphLIME-master/exp/noise_features/models.py
import torch.nn as nn import torch.nn.functional as F from torch_geometric.nn import GCNConv, GATConv class GCN(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim, dropout=0.5): super(GCN, self).__init__() self.dropout = dropout self.conv1 = GCNConv(input_dim, hidd...
1,699
32.333333
116
py
arl-eegmodels
arl-eegmodels-master/EEGModels.py
""" ARL_EEGModels - A collection of Convolutional Neural Network models for EEG Signal Processing and Classification, using Keras and Tensorflow Requirements: (1) tensorflow == 2.X (as of this writing, 2.0 - 2.3 have been verified as working) To run the EEG/MEG ERP classification sample script, you w...
18,033
43.74938
96
py
arl-eegmodels
arl-eegmodels-master/examples/ERP.py
""" Sample script using EEGNet to classify Event-Related Potential (ERP) EEG data from a four-class classification task, using the sample dataset provided in the MNE [1, 2] package: https://martinos.org/mne/stable/manual/sample_dataset.html#ch-sample-data The four classes used from this dataset are: L...
10,178
40.717213
86
py
sampling_for_genomic_surveillance
sampling_for_genomic_surveillance-master/compare_distribution.py
#libraries to use import pandas as pd from scipy.stats import mannwhitneyu from scipy.stats import ks_2samp from scipy.stats import ttest_ind def define_significance_value(p_value): summary = "" if p_value > 0.05: summary = "NS" elif p_value > 0.01 and p_value <= 0.05: summary = "*" el...
2,285
37.1
269
py
amuse
amuse-main/setup.py
from setuptools import setup, find_packages from support.setup_codes import setup_commands from support.misc import find_data_files name = 'amuse-devel' author = 'The AMUSE team' author_email = 'info@amusecode.org' license_ = "Apache License 2.0" url = 'http://www.amusecode.org/' install_requires = [ 'setuptools>=...
2,853
26.980392
67
py
amuse
amuse-main/examples/examples_galaxia/orbit_one_star.py
# --------------------------------------------------------------------------- # Script that uses galaxia and the bridge in rotating coordinates | # to integrate the orbit of a star. | # For a complete explanation of the possible parameters and models | # inclu...
9,533
37.756098
103
py
amuse
amuse-main/examples/examples_galaxia/resonances.py
# --------------------------------------------------------------------------- # This script generates the corrotation and Lindbland resonances | # as a function of radius using galaxia. | # For a complete explanation of the possible parameters and models | # includ...
2,479
36.014925
77
py
amuse
amuse-main/examples/examples_galaxia/evolution_cluster.py
# --------------------------------------------------------------------------- # Script that uses galaxia and the bridge in rotating coordinates | # to calculate the evolution of a star cluster in the Galaxy. | # The physical processes involved are self gravity, stellar evolution | # and th...
13,348
40.200617
79
py
amuse
amuse-main/examples/examples_galaxia/rotation_curve_Milky_Way.py
# --------------------------------------------------------------------------- # This script generates the rotation curve of the Milky Way using galaxia. | # For a complete explanation of the possible parameters and models | # included in galaxia, we refer the reader to the file: user_manual_galaxia.| # ------...
3,135
38.2
77
py
amuse
amuse-main/examples/examples_galaxia/utility_functions.py
# --------------------------------------------------------------------------- # Script that shows the utility functions of galaxia. | # These functions include: the computation of the components of the | # tidal tensor at a given point, the eigen-values and the tidal radius | # of a s...
3,913
39.350515
78
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/disk_script/boxedfi.py
from amuse.units import nbody_system from amuse.units import units import amuse.datamodel as core from amuse.community.fi.interface import Fi from amuse.ext.gasplummer import MakePlummerGasModel class BoxedFi(Fi): def __init__(self, *args, **kargs): Fi.__init__(self, *args, **kargs) self.escapers=core.Pa...
1,929
30.129032
69
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/disk_script/fast.py
# issues: # - for now, units in si # - a common coordinate system is used for all systems # - sync of systems should be checked # - timestepping: adaptive dt? from amuse.units import units from amuse.units.quantities import zero import threading from amuse import datamodel def radius_or_hsmooth(parts): d=set(dir(pa...
5,433
25.90099
100
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/disk_script/run.py
from binary import circumbinary_disc_run from amuse.units import units # kepler 16 circumbinary_disc_run( tend=40. | units.yr, # simulation time Ngas=100000, # number of gas particles m1=0.6897 | units.MSun, # primary mass ...
2,223
70.741935
119
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/disk_script/binary.py
import os from socket import gethostname import numpy import time import matplotlib matplotlib.use('Agg') from matplotlib import pyplot from amuse.community.twobody.twobody import TwoBody from amuse.units import units from amuse.units import nbody_system from amuse.units import constants from amuse.datamodel import P...
12,738
34.884507
123
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/disk_script/directsum.py
from amuse.units import constants from amuse.datamodel import Particles from amuse.units.quantities import zero from amuse.units.quantities import AdaptingVectorQuantity class directsum(object): def __init__(self, systems, G=constants.G): self.systems=systems self.G=G def get_gravity_at_po...
1,332
38.205882
81
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/three_body_script/python_interface.py
from amuse.rfi.core import * import cPickle as Pickle from amuse.units import units #from testmod import f from bin_planet import binary_with_planet_run as f def func(*arg,**kwarg): return f(*arg,**kwarg) class CodeImplementation(object): def _func(self,argin,kwargin,argout): try: arg=Pickle.loads(a...
1,540
30.44898
81
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/three_body_script/kepler_16_three_body.py
from python_interface import CodeInterface from amuse.units import units from amuse.rfi.channel import AsyncRequestsPool import numpy from matplotlib import pyplot ncpu=16 allhosts=[ ("paddegat",4), ("koppoel",4), ("gaasp",4), ("biesbosch",4), ] hosts=reduce(lambda x,y: x+...
2,111
21.709677
83
py
amuse
amuse-main/examples/publications/2013MNRAS.429..895P/three_body_script/bin_planet.py
import numpy import time from matplotlib import pyplot from amuse.units import nbody_system,units,constants from amuse.units.quantities import AdaptingVectorQuantity from amuse.io import write_set_to_file,read_set_from_file from amuse.community.huayno.interface import Huayno from amuse.datamodel import Particles d...
7,935
26.651568
98
py
amuse
amuse-main/examples/simple/pre_main_sequence_evolution.py
# -*- coding: ascii -*- """ Calculated theoretical pre-main-sequance evolutionary tracks for stars of various masses. After Iben, ApJ 141, 993, 1965 """ from __future__ import print_function from matplotlib import pyplot from amuse.units import units from amuse.community.mesa.interface import MESA from amuse import da...
2,752
31.011628
76
py
amuse
amuse-main/examples/simple/helium_star.py
# -*- coding: ascii -*- """ Creates a helium burning star from the inner shells of a main sequence star. """ from __future__ import print_function from amuse.units import units from amuse.datamodel import Particle from amuse.community.mesa.interface import MESA from matplotlib import pyplot from amuse.plot import logl...
3,738
35.656863
76
py
amuse
amuse-main/examples/simple/stellar_lifetime_vs_mass.py
# -*- coding: ascii -*- """ Calculates the stellar lifetime in a range of masses between Mmax and Mmin using SSE (or another stellar evolution code) and an analytic expression. """ from __future__ import print_function import numpy from optparse import OptionParser from amuse.units import units from amuse.datamodel imp...
2,332
29.697368
72
py
amuse
amuse-main/examples/simple/clump_finding.py
# -*- coding: ascii -*- """ Generates a random distribution of particles and uses Hop to determine clumps in the particle set. """ from __future__ import print_function # import numpy from numpy import random from matplotlib import pyplot from amuse.units import units from amuse.units import nbody_system from amuse.co...
2,734
25.553398
77
py
amuse
amuse-main/examples/simple/agb.py
# -*- coding: ascii -*- """ Evolves an the sun in it's AGB star phase using SSE """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.community.sse.interface import SSE from amuse.units import units # from amuse.ext import solarsystem from amuse import datamodel def plottil...
1,247
22.54717
74
py
amuse
amuse-main/examples/simple/cluster.py
# -*- coding: ascii -*- """ Evolves an equal mass stellar cluster. """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.units import nbody_system from amuse.community.hermite.interface import Hermite # import logging from amuse.ic.plummer import new_plummer_model # logging.bas...
4,118
28.847826
77
py
amuse
amuse-main/examples/simple/orbit_in_potential.py
# -*- coding: ascii -*- """ Integrates a stellar orbit in the galactic potential This example illustrates the use of a simple external potential and simple integrator, no amuse community code is used. """ from __future__ import print_function # import numpy from amuse.units.optparse import OptionParser from math impor...
6,325
36.431953
77
py
amuse
amuse-main/examples/simple/stellar_mass_loss.py
# -*- coding: ascii -*- """ Set an artificial mass loss rate at a specific point in the stellar evolution using MESA and calculate the effect this has on the stellar radius. """ from __future__ import print_function # import numpy from amuse.units import units from amuse.datamodel import Particle from amus...
2,442
30.727273
75
py
amuse
amuse-main/examples/simple/h2region.py
# -*- coding: ascii -*- """ Evolves the steady state solution of a star irridiating a H2 region. """ from __future__ import print_function # import numpy import os from matplotlib import pyplot from optparse import OptionParser from amuse.community.mocassin.interface import Mocassin, mocassin_rydberg_unit from amuse...
5,925
31.382514
129
py
amuse
amuse-main/examples/simple/hydro_star.py
# -*- coding: ascii -*- """ Converts a 1d stellar model into a 3d spherical gas model for a star """ from __future__ import print_function from amuse.units import units from amuse.community.evtwin.interface import EVtwin from amuse.ext.star_to_sph import convert_stellar_model_to_SPH from amuse.plot import sph_particle...
1,131
28.025641
73
py
amuse
amuse-main/examples/simple/unstable_binary.py
# -*- coding: ascii -*- """ Evolves two stars dynamically (hermit, nbody code) each star will lose mass during the evolution (evtwin, stellar evolution code) We start with two stars, one 10.0 and one 1.0 solar mass star. These stars start orbiting with a stable kepler orbit. After 2 orbital periods the stars will begi...
6,092
31.935135
99
py
amuse
amuse-main/examples/simple/brunt.py
# -*- coding: ascii -*- # -*-noplot-*- from __future__ import print_function from matplotlib import pyplot from amuse.plot import semilogy, xlabel, ylabel from amuse.units import units from amuse.community.mesa.interface import MESA from amuse.datamodel import Particle def brunt_vaisala_frequency_squared_profile(mas...
1,375
31.761905
81
py
amuse
amuse-main/examples/simple/supernova_in_binary_nbody.py
# -*- coding: ascii -*- from __future__ import print_function import numpy from amuse.units import constants, units, nbody_system from amuse.datamodel import Particles from amuse.community.hermite.interface import Hermite from amuse.ext.orbital_elements import orbital_elements_from_binary def get_relative_velocity(to...
3,242
32.091837
79
py
amuse
amuse-main/examples/simple/salpeter.py
# -*- coding: ascii -*- """ Generates a cluster using a plummer model with a salpeter Initial Mass Function. Compares the generated IMF against the expected line. """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.units import units from amuse.units import nbody_system from ...
2,175
26.544304
78
py
amuse
amuse-main/examples/simple/massloss.py
# -*- coding: ascii -*- """ Evolves the sun and earth where the sun will lose mass every 220th step. """ from __future__ import print_function import numpy from amuse.community.hermite.interface import Hermite # from amuse.community.sse.interface import SSE from amuse import datamodel from amuse.units import units from...
2,003
27.225352
86
py
amuse
amuse-main/examples/simple/stellar_structure.py
# -*- coding: ascii -*- """ Make plots of the stellar structure of a star of given mass and age """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.plot import semilogy, xlabel, ylabel from amuse.units import units from amuse.community.evtwin.interface import EVtwin from amu...
2,813
30.617978
72
py
amuse
amuse-main/examples/simple/boss_bodenheimer_test.py
# -*- coding: ascii -*- """ Fragmentation in a rotating protostar -- Boss & Bodenheimer (1979, BB79, http://adsabs.harvard.edu/abs/1979ApJ...234..289B) Calculate the collapse of an isothermal cloud with SPH code fi. The cloud is initially spherical, with an uniform density with a nonaxisymmetric perturbation o...
5,467
30.976608
81
py
amuse
amuse-main/examples/simple/hrdiagram.py
# -*- coding: ascii -*- """ Generates a Hertzsprung-Russell diagram for a single star """ from __future__ import print_function # import sys # import numpy from matplotlib import pyplot from amuse.plot import loglog, xlabel, ylabel from amuse.units import units from amuse.community.sse.interface import SSE from amus...
1,860
27.630769
71
py
amuse
amuse-main/examples/simple/evolve_binary.py
# -*- coding: ascii -*- """ Evolves a stellar binary and reports the mass of each star during the evolution. Shows the type of each star as they change. """ from __future__ import print_function from amuse.community.seba.interface import SeBa from amuse.datamodel import Particles from amuse.units import constants, uni...
3,237
30.134615
78
py
amuse
amuse-main/examples/simple/protoplanetarydisk.py
# -*- coding: ascii -*- """ Creates a protoplanetary disk around a sun-like star """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.community.fi.interface import Fi from amuse.units import units from amuse.units import nbody_system from amuse.ext.protodisk import ProtoPla...
2,223
23.711111
78
py
amuse
amuse-main/examples/simple/lagrange_points.py
# -*- coding: ascii -*- """ Make a contour plot of the effective potential of the Sun-Earth system (left) and a system with a 10000 times more massive Earth with the Lagrangian points visible. """ from __future__ import print_function # import numpy from matplotlib import pyplot from amuse.plot import xlabel, ylabel, e...
3,488
36.923913
77
py
amuse
amuse-main/examples/simple/stellar_mean_mass.py
# -*- coding: ascii -*- """ Calculates the mean mass of a stellar popultion as a function of time. This routine was used to measure the <m> of a star cluster in order to incorporate <m>(t) and d<m>/dt in a parametrized cluster evolution code. """ from __future__ import print_function # import sys # import numpy # from ...
2,863
38.232877
79
py
amuse
amuse-main/examples/simple/binary_population_synthesis.py
# -*- coding: ascii -*- """ Generates a grid of binaries with different, primary mass, mass ratio and separation and evolves these over time. """ from __future__ import print_function from amuse.units import units from amuse.units import quantities from amuse import datamodel from amuse.community.seba.interface import...
6,973
31.896226
79
py
amuse
amuse-main/examples/simple/molecular_cloud_chemistry.py
# -*- coding: ascii -*- """ Evolves a molecular cloud with chemical evolution The dynamics is evolved in the sph code Fi, chemistry with Krome, assuming an isothermal cloud (hence passive chemical evolution). Initial condition is a smooth spherical cloud with random velocities as in Bonnell et al. (2003) """ from __f...
3,266
29.53271
97
py
amuse
amuse-main/examples/simple/isochrone.py
# -*- coding: ascii -*- """ Generates an isochrone of a cluster of stars in a Hertzsprung-Russell diagram """ from __future__ import print_function from matplotlib import pyplot from amuse.units import units from amuse.datamodel import Particles from amuse.ic.brokenimf import new_scalo_mass_distribution from amuse.ext....
1,830
35.62
78
py
amuse
amuse-main/examples/simple/kelvin_helmholtz.py
# -*- coding: ascii -*- """ Runs the Kelvin-Helmholtz Instability problem in two dimensions with Athena. """ from __future__ import print_function import numpy from matplotlib import pyplot from amuse.community.athena.interface import Athena from amuse.units.generic_unit_system import ( length, mass, speed, time, d...
3,526
25.125926
76
py
amuse
amuse-main/examples/simple/collision.py
""" Evolves a cluster until a collision is detected between two stars in the cluster. The stars in the cluster are distributed using a plummer sphere, the masses are set according to a Salpeter initial mass function. By default the radii of all stars are equal and very large. All units are in nbody units. """ impo...
2,959
27.737864
78
py
amuse
amuse-main/examples/simple/gas_in_cluster.py
# -*- coding: ascii -*- """ Simultaniously evolves gas and stars in a cluster. The stars and gas particles evolve in their respective codes (Hermite and Gadget2) The force of the gas particles on the star particles is calculated by a seperate code (BHTree) The force of the star particles on the gas particles is calcul...
7,737
31.107884
79
py
amuse
amuse-main/examples/simple/evolve_orbit_in_potential.py
# -*- coding: ascii -*- """ Evolve the orbital evolution in the galactic center potential with different N-body codes. All codes use default settings and are integrated using Bridge. Since it is only a single particle being evolved, and the potential is handled by bridge (externally) there should no...
8,013
33.692641
78
py
amuse
amuse-main/examples/simple/plot_with_units.py
# -*- coding: ascii -*- """ Creates a number of plots using the AMUSE unit aware plot functions. """ from __future__ import print_function from amuse.units import units, quantities from amuse.plot import ( native_plot, plot, scatter, xlabel, ylabel, hist ) import numpy as np if __name__ == "__main__": # late...
1,688
28.12069
68
py
amuse
amuse-main/examples/simple/galactic_center.py
# -*- coding: ascii -*- """ Evolves a cluster in the potention of the galactic center Uses the bridge integrator to couple different codes. In this example a cluster is evolved circling the galactic center, represented by a static potential. """ from __future__ import print_function # import numpy from amuse.units im...
4,519
28.933775
79
py
amuse
amuse-main/examples/simple/molecular_cloud.py
# -*- coding: ascii -*- """ Evolves a molecular cloud with explictly split gravtiy evolution The gas is evolved in a sph code, and it's gravity is determined by a tree code. Initial condition is a smooth spherical cloud with random velocities as in Bonnell et al. (2003) """ from __future__ import print_function impor...
3,786
27.261194
77
py
amuse
amuse-main/examples/simple/save_and_load_particles.py
# -*- coding: ascii -*- """ Saves and loads a set of particles. The 'write_set_to_file' and 'read_set_from_file' functionso can hadle files in a variety of formats. """ from __future__ import print_function # from amuse.units import nbody_system from amuse.ic.plummer import new_plummer_model from amuse.plot import plot...
1,277
30.170732
78
py
amuse
amuse-main/examples/simple/pythagorean.py
# -*- coding: ascii -*- """ Calculates the Pythagorean 3-body problem using different values for the smoothing length in the n-body code. """ from __future__ import print_function # import numpy # import time # from amuse.community.phigrape.interface import PhiGRAPE from amuse.community.hermite.interface import Hermit...
2,491
30.15
79
py
amuse
amuse-main/examples/simple/__init__.py
0
0
0
py
amuse
amuse-main/examples/simple/grid_potential.py
# -*- coding: ascii -*- from __future__ import print_function from amuse.units import units, nbody_system from amuse.datamodel import Particle from amuse.community.athena.interface import Athena from amuse.community.hermite.interface import Hermite from matplotlib import pyplot def hydro_grid_in_potential_well(mass=...
3,310
32.444444
77
py
amuse
amuse-main/examples/simple/grav_stellar_simple.py
# -*- coding: ascii -*- """ simple coupling of a stellar evolution and a gravitational code to simulate a cluster of stars. """ from __future__ import print_function import os from amuse.units.optparse import OptionParser from amuse.units import units, nbody_system from amuse.datamodel.particles import Channel...
3,683
27.338462
79
py
amuse
amuse-main/examples/simple/orszag_tang.py
# -*- coding: ascii -*- """ Runs the Orszag-Tang Vortex problem described in the Athena test-suite (http://www.astro.virginia.edu/VITA/ATHENA/ot.html): 'The Orszag-Tang Vortex is a well-known test for MHD codes. The intial conditions lead to a system of supersonic MHD turbulence, making this problem a good test of the...
6,607
29.036364
79
py
amuse
amuse-main/examples/simple/galactic_center_in_code.py
# -*- coding: ascii -*- """ Evolves a cluster orbiting a massive central particle. """ from __future__ import print_function # import numpy from amuse.units import units from amuse.units import constants from amuse.units import nbody_system from amuse.datamodel import particles from amuse.community.phigrape.interface ...
3,000
26.53211
76
py
amuse
amuse-main/examples/simple/sunandearth.py
# -*- coding: ascii -*- """ Evolves the dynamic evolution of the earth around the sun. """ from __future__ import print_function from amuse.units import nbody_system from amuse.units import units from amuse.units import quantities from amuse.community.hermite.interface import Hermite from matplotlib import pyplot fr...
2,057
22.655172
60
py
amuse
amuse-main/examples/textbook/plot_hydro_disk_with_bump.py
""" Visualization for simple N-body integration. Reads particle set from file (nbody.hdf5) and prints subsequent frames. """ import os import sys import numpy import matplotlib #matplotlib.use('Agg') from matplotlib import pyplot #from matplotlib import pyplot from amuse.plot import scatter, xlabel, ylabel from ...
6,970
33.681592
126
py
amuse
amuse-main/examples/textbook/NonConservativeMassTransfer.py
#!/usr/bin/python from numpy import * from amuse.lab import * #a XiTau = 263.973|units.RSun = 1.2272459225 AU #HD a= 171.109773416 RSun = quantity<0.795511639712 AU> def orbital_separation_after_mass_transfer(a, md, mdf, ma, maf, nj) : mt = ma+md mtf = maf+mdf fa = ((mdf*maf)/(md*ma))**(-2.) * (mtf/mt)**...
1,955
36.615385
74
py
amuse
amuse-main/examples/textbook/plot_supernova_IIp_and_disk_temperature.py
import numpy from matplotlib import pyplot from amuse.lab import * from prepare_figure import single_frame, figure_frame, set_tickmarks from distinct_colours import get_distinct from supernova_IIp_Lightcurve import Supernova_IIp def read_supernova_irradiation_file(filename): t = [] Tmean = [] Tmax = [] ...
3,335
32.029703
100
py
amuse
amuse-main/examples/textbook/multiple_stellar_code.py
from amuse.lab import * ###BOOKLISTSTART### def evolve_with_different_stellar_model(): times = [10, 100, 1000] | units.Myr stars = Particles(mass=[1, 2, 4]|units.MSun) stellars = [SeBa(), MESA(), SSE()] channels = [] for star, stellar in zip(stars, stellars): stellar.particles.add_particle(...
1,350
31.95122
66
py
amuse
amuse-main/examples/textbook/merge_two_stars_sph_evolve.py
import numpy from matplotlib import pyplot from amuse.lab import * from amuse.ext.star_to_sph import convert_stellar_model_to_SPH from amuse.ext.sph_to_star import convert_SPH_to_stellar_model from prepare_figure import single_frame from distinct_colours import get_distinct def plot_clumps(groups): number_of_par...
11,648
37.319079
79
py
amuse
amuse-main/examples/textbook/basic_multiples_nbody.py
import numpy from amuse.units import nbody_system from amuse.ic.plummer import new_plummer_model from amuse.community.ph4.interface import ph4 from amuse.community.smalln.interface import SmallN from amuse.community.kepler.interface import Kepler from amuse.couple import multiples # Awkward syntax here because multipl...
3,322
27.895652
72
py
amuse
amuse-main/examples/textbook/gravity_gravity.py
#from __future__ import print_function import numpy from amuse.units import units from amuse.units import quantities from amuse.units import constants from amuse.units import nbody_system from amuse.ext.bridge import bridge from amuse.community.phigrape.interface import PhiGRAPE from amuse.community.ph4.interface impor...
4,555
34.874016
106
py
amuse
amuse-main/examples/textbook/hydro_give_or_take.py
import numpy from amuse.lab import * from amuse import datamodel from amuse.ext.evrard_test import uniform_unit_sphere def hydro_sink_particles(sinks, gas): removed_particles = Particles() for s in sinks: xs,ys,zs=s.x,s.y,s.z radius_squared = s.sink_radius**2 #print "R=", s.key, numpy.s...
6,603
37.847059
109
py
amuse
amuse-main/examples/textbook/merge_two_galaxies.py
import numpy from matplotlib import pyplot from amuse.lab import * from amuse.ext.galactics_model import new_galactics_model from prepare_figure import single_frame def make_plot(disk1, disk2, filename): x_label = "X [kpc]" y_label = "Y [kpc]" figure = single_frame(x_label, y_label, logy=False, xsize=14, y...
3,708
41.632184
78
py
amuse
amuse-main/examples/textbook/helium_star.py
""" Creates a helium burning star from the inner shells of a main sequence star. """ from __future__ import print_function from amuse.units import units from amuse.datamodel import Particle from amuse.community.mesa.interface import MESA from matplotlib import pyplot from amuse.plot import loglog, xlabel, ylabel, scat...
4,261
38.831776
92
py
amuse
amuse-main/examples/textbook/hydro_sink_particles.py
from amuse.lab import * def hydro_sink_particles(sinks, gas): removed_particles = Particles() for s in sinks: xs,ys,zs=s.x,s.y,s.z radius_squared = s.radius**2 insink=gas.select_array(lambda x,y,z: (x-xs)**2+(y-ys)**2+(z-zs)**2 < radius_squared,['x','y','z']) if len(insink)==0...
2,115
37.472727
109
py
amuse
amuse-main/examples/textbook/stellar_isochrone.py
""" Evolve a population of N stars. Initial mass function between Mmin and Mmax with stellar evolution for metallicity z. """ import sys import numpy from amuse.lab import * from matplotlib import pyplot from prepare_figure import single_frame, figure_frame, set_tickmarks from distinct_colours import get_dist...
5,316
35.170068
79
py
amuse
amuse-main/examples/textbook/plot_hydro_density_distributions.py
import numpy from matplotlib import pyplot from amuse.lab import * from amuse.plot import sph_particles_plot from prepare_figure import figure_frame from distinct_colours import get_distinct ###BOOKLISTSTART1### def stellar_model(N, M, t=0.0|units.Myr): star = Particle(mass=M) stellar_evolution = EVtwin() ...
2,543
31.202532
78
py
amuse
amuse-main/examples/textbook/three_body_bridge_order4m4.py
import numpy from amuse.lab import * from amuse.ext.composition_methods import * from amuse.couple import bridge from amuse.ext.solarsystem import new_solar_system def new_system_of_sun_and_earth(): stars = Particles(3) sun = stars[0] sun.mass = units.MSun(1.0) sun.position = units.m(numpy.array((0.0...
3,114
32.858696
103
py
amuse
amuse-main/examples/textbook/plot_solar_cluster.py
""" Visualization for simple N-body integration. Reads particle set from file (nbody.hdf5) and prints subsequent frames. """ import sys import numpy import matplotlib matplotlib.use('Agg') from matplotlib import pyplot #from matplotlib import pyplot from amuse.plot import scatter, xlabel, ylabel from amuse.lab i...
3,853
32.807018
111
py
amuse
amuse-main/examples/textbook/planetary_system.py
import math import numpy from amuse.lab import * from amuse.ext.protodisk import ProtoPlanetaryDisk from optparse import OptionParser from amuse.couple import bridge import make_planets_oligarch from amuse.ext.orbital_elements import orbital_elements_from_binary def calculate_orbital_elements(star, planet): p = P...
6,786
37.129213
100
py
amuse
amuse-main/examples/textbook/gravity_stellar_eventdriven.py
import numpy from amuse.lab import * from amuse.io import store from amuse.community.seba.interface import SeBa def merge_two_stars(bodies, particles_in_encounter): com_pos = particles_in_encounter.center_of_mass() com_vel = particles_in_encounter.center_of_mass_velocity() new_particle=Particles(1) new...
7,592
41.183333
88
py
amuse
amuse-main/examples/textbook/plot_sstar_orbits.py
import os.path import math import numpy from amuse.lab import * from amuse.ext.protodisk import ProtoPlanetaryDisk from amuse.ext.evrard_test import uniform_unit_sphere import time from initialize_sstars import * from amuse.community.adaptb.interface import Adaptb from gravity_class import Gravity #from prepare_figur...
3,020
32.566667
126
py
amuse
amuse-main/examples/textbook/merge_two_stars_sph_convergence.py
import sys import numpy from matplotlib import pyplot from amuse.lab import * from amuse.plot import plot from amuse.ext.sph_to_star import convert_SPH_to_stellar_model from prepare_figure import * from distinct_colours import get_distinct def return_evolved_star_hydro(mass, time, Nsph): star = Particle(mass=mas...
5,347
40.78125
109
py
amuse
amuse-main/examples/textbook/basic_multiples_si.py
import numpy from amuse.units import nbody_system, units, constants from amuse.ic.plummer import new_plummer_model from amuse.community.ph4.interface import ph4 from amuse.community.smalln.interface import SmallN from amuse.community.kepler.interface import Kepler from amuse.couple import multiples # Awkward syntax he...
3,848
30.54918
72
py
amuse
amuse-main/examples/textbook/plot_accretion_from_windy_star.py
""" Visualization for simple N-body integration. Reads particle set from file (nbody.hdf5) and prints subsequent frames. """ import sys import numpy from matplotlib import pyplot from amuse.lab import * from prepare_figure import single_frame from distinct_colours import get_distinct def Bondi_Hoyle_Littleton_a...
3,325
28.433628
163
py
amuse
amuse-main/examples/textbook/gravity_stellar_collision.py
""" N-body integration of N particles with a Salpeter initial mass function between Mmin and Mmax and with stellar evolution with metallicity z. """ from amuse.lab import * from amuse.io import store from amuse.community.seba.interface import SeBa ###BOOKLISTSTART1### def merge_two_stars(bodies, particles_in_...
7,077
37.89011
93
py
amuse
amuse-main/examples/textbook/plot_M67Data.py
#!/usr/bin/python from __future__ import division from matplotlib import pyplot import os def logLuminosity(V): VminMv = 9.7 MBolSun = 4.74 Mv = V - VminMv L = (MBolSun - Mv)/2.5 return L def logTeff(BminV): logT = (14.551 - BminV)/3.684 if logT > 3.961: a,b,c = [.344,-3.402,8.037...
1,589
22.043478
64
py
amuse
amuse-main/examples/textbook/orbital_elements_to_cartesian.py
from amuse.lab import * from math import pi, sin, cos, sqrt, atan2 import numpy #Solve Kepler equation by iterating: M = E - e sin E #Lit.: Sterne, T.E., 1960, An introduction to Celestial Mechanics, p. 13-14 def eccentric_anomaly(mean_anomaly, e) : ecc_anomaly = mean_anomaly + 2*pi*(e * sin(mean_anomaly) + 0.5*e*...
3,103
37.8
115
py
amuse
amuse-main/examples/textbook/molecular_cloud_collapse_with_sinks.py
import numpy from matplotlib import pyplot from amuse.lab import * from amuse.ext.molecular_cloud import molecular_cloud from amuse.ext.evrard_test import body_centered_grid_unit_cube from cooling_class import SimplifiedThermalModel, SimplifiedThermalModelEvolver from hydrodynamics_class import Hydro def run_molecu...
3,457
35.020833
79
py
amuse
amuse-main/examples/textbook/three_body_bridge.py
import numpy from amuse.lab import * from amuse.couple import bridge def new_system_of_sun_and_earth(): stars = Particles(3) sun = stars[0] sun.mass = units.MSun(1.0) sun.position = units.m(numpy.array((0.0,0.0,0.0))) sun.velocity = units.ms(numpy.array((0.0,0.0,0.0))) sun.radius = units.RSun(...
2,739
30.860465
82
py
amuse
amuse-main/examples/textbook/hydro_wind_disk_interaction.py
from amuse.lab import * from amuse.community.gadget2.interface import Gadget2 as Gadget2 from amuse.units import units, constants, nbody_system from amuse.ext.sink import new_sink_particles from amuse.ext.protodisk import ProtoPlanetaryDisk from amuse.datamodel import Particles import numpy import time as timing class...
12,985
40.225397
175
py
amuse
amuse-main/examples/textbook/plot_projected_density_distributions_all.py
import numpy from matplotlib import pyplot from amuse.lab import * from amuse.ext.molecular_cloud import molecular_cloud from amuse.plot import sph_particles_plot, native_plot from prepare_figure import figure_frame from distinct_colours import get_distinct def create_molecular_cloud(N, Mcloud, Rcloud, t_end): ...
5,060
34.145833
119
py
amuse
amuse-main/examples/textbook/hydro_disk_with_bump.py
""" Simulate the radiative and hydrodynamial evolution of a disk with a bump around a single star """ from time import time, localtime from amuse.lab import * from amuse.ext.molecular_cloud import ism_cube from amuse.community.simplex.interface import SimpleXInterface, SimpleX, \ SimpleXSplitSet from amuse....
10,086
38.402344
80
py
amuse
amuse-main/examples/textbook/plot_core_temperature_density.py
import math from amuse.lab import * from matplotlib import pyplot from distinct_colours import get_distinct Second_Asymptotic_Giant_Branch = 6 | units.stellar_type HeWhiteDwarf = 10 | units.stellar_type def stellar_remnant(stellar): remnant = True if stellar.particles[0].stellar_type < HeWhiteDwarf \ ...
2,649
26.894737
77
py
amuse
amuse-main/examples/textbook/gravity_stellar_minimal.py
from amuse.lab import * from amuse.units.optparse import OptionParser def main(N, t_end, W0, Rvir, Mmin, Mmax, z): ###BOOKLISTSTART1### masses = new_salpeter_mass_distribution(N, Mmin, Mmax) Mtot_init = masses.sum() converter = nbody_system.nbody_to_si(Mtot_init, Rvir) bodies = new_king_model(N, W...
3,607
35.444444
78
py
amuse
amuse-main/examples/textbook/supernova_grid.py
import numpy from amuse.lab import * #from amuse import plot from amuse.ext import cloud from matplotlib import pyplot from amuse import datamodel from amuse.ext.sph_to_grid import convert_SPH_to_grid from amuse.community.capreole.interface import Capreole from amuse.units.generic_unit_converter import ConvertBetweenGe...
7,421
37.65625
110
py
amuse
amuse-main/examples/textbook/plot_RLOF_triples.py
from matplotlib import pyplot from amuse.lab import * from prepare_figure import * from distinct_colours import get_distinct import numpy set_printing_strategy("custom", #nbody_converter = converter, preferred_units = [units.MSun, units.AU, units.Myr], precision = 4, prefi...
2,082
32.596774
75
py
amuse
amuse-main/examples/textbook/earthorbitvariation.py
from amuse.lab import * from amuse.ext.solarsystem import solar_system_in_time from prepare_figure import single_frame, figure_frame, \ set_tickmarks, get_distinct def integrate_solar_system(particles, end_time): convert_nbody = nbody_system.nbody_to_si(particles.mass.sum(), ...
2,857
31.850575
80
py
amuse
amuse-main/examples/textbook/plot_stellar_massloss_response.py
""" Visualization for simple N-body integration. Reads particle set from file (nbody.hdf5) and prints subsequent frames. """ import sys import numpy from matplotlib import pyplot from prepare_figure import single_frame, figure_frame, set_tickmarks from distinct_colours import get_distinct #filenames = ["Zeta_M1...
2,143
27.972973
87
py
amuse
amuse-main/examples/textbook/core_temperature_density.py
from amuse.lab import * Second_Asymptotic_Giant_Branch = 6 | units.stellar_type HeWhiteDwarf = 10 | units.stellar_type def stellar_remnant(stellar): remnant = True if stellar.particles[0].stellar_type<HeWhiteDwarf or stellar.particles[0].stellar_type>11|units.stellar_type: remnant = False retu...
1,554
36.02381
113
py
amuse
amuse-main/examples/textbook/plot_M67withBSS_tracks.py
""" Minimal routine for running a stellar evolution code. """ from amuse.lab import * from matplotlib import pyplot import plot_M67Data from prepare_figure import single_frame, figure_frame, set_tickmarks from distinct_colours import get_distinct TBSS = [6170, 6820, 6675, 7050, 6650] LBSS = [12.259, 11.078, 12.1...
2,775
32.853659
72
py
amuse
amuse-main/examples/textbook/sun_venus_earth.py
###BOOKLISTSTART1### from amuse.lab import Particles, units def sun_venus_and_earth(): particles = Particles(3) sun = particles[0] sun.mass = 1.0 | units.MSun sun.radius = 1.0 | units.RSun sun.position = (855251, -804836, -3186) |units.km sun.velocity = (7.893, 11.894, 0.20642) | (units.m/unit...
3,063
30.587629
76
py
amuse
amuse-main/examples/textbook/plot_Nbody_precision.py
from amuse.lab import * import numpy from distinct_colours import get_distinct from matplotlib import pyplot def energy_error_of_integrated_Nbody_system(code, particles, end_time, precision): gravity = code(number_of_workers=4) gravity.parameters.timestep_parameter...
2,236
28.434211
75
py
amuse
amuse-main/examples/textbook/gravity_class.py
import os.path import math import numpy from amuse.lab import * from amuse.ext.protodisk import ProtoPlanetaryDisk from amuse.ext.evrard_test import uniform_unit_sphere import time from initialize_sstars import * from calculate_orbital_parameters import calculate_orbital_parameters from amuse.community.mercury.interf...
3,827
37.666667
151
py
amuse
amuse-main/examples/textbook/prepare_figure.py
from matplotlib import pyplot #import seaborn # These are the "Tableau 20" colors as RGB. tableau20 = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120), (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150), (148, 103, 189), (197, 176, 213), (140, 86, 75), (196,...
6,734
29.613636
80
py