Skip to content

Commit dc7a1be

Browse files
committed
First commit for TRES code in git
1 parent c80c4dc commit dc7a1be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+29411
-0
lines changed

Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ifndef AMUSE_DIR
2+
AMUSE_DIR=../..
3+
endif
4+
5+
CODE_GENERATOR = $(AMUSE_DIR)/build.py
6+
7+
CXXFLAGS = -Wall -g -DTOOLBOX $(MUSE_INCLUDE_DIR)
8+
LDFLAGS = -lm $(MUSE_LD_FLAGS)
9+
10+
OBJS = src/main_code.o src/ODE_system.o src/helper_routines.o src/tidal_friction_parameters.o src/cvode/cvode.o src/cvode/cvode_dense.o src/cvode/cvode_direct.o src/cvode/cvode_io.o src/cvode/cvode_diag.o src/cvode/cvode_spils.o src/cvode/cvode_spgmr.o src/cvode/cvode_spbcgs.o src/cvode/cvode_sptfqmr.o src/cvode/nvector_serial.o src/cvode/sundials_dense.o src/cvode/sundials_direct.o src/cvode/sundials_math.o src/cvode/sundials_nvector.o src/cvode/sundials_spgmr.o src/cvode/sundials_iterative.o src/cvode/sundials_spbcgs.o src/cvode/sundials_sptfqmr.o
11+
12+
13+
all: worker_code
14+
15+
cleanall: clean
16+
rm worker_code
17+
18+
clean:
19+
rm -f *.so *.o *.pyc worker_code.cc src/*.o* src/cvode/*.o*
20+
21+
worker_code.cc: interface.py
22+
$(CODE_GENERATOR) --type=c interface.py SecularTripleInterface -o $@
23+
24+
worker_code: worker_code.cc $(OBJS)
25+
mpicxx $@.cc $(OBJS) -o $@
26+
27+
.cc.o: $<
28+
g++ $(CXXFLAGS) -c -o $@ $<
29+
30+
.c.o: $<
31+
g++ $(CXXFLAGS) -c -o $@ $<

__init__.py

Whitespace-only changes.

interface.py

+2,204
Large diffs are not rendered by default.

reduce_TRES_results.py

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from amuse.units import units, constants
2+
from amuse.io import write_set_to_file
3+
from amuse.io import read_set_from_file
4+
from amuse.support.console import set_printing_strategy
5+
import numpy as np
6+
7+
8+
9+
bin_type = {
10+
'unknown': 0,
11+
'merger': 1,
12+
'disintegrated': 2,
13+
'detached': 3,
14+
'contact': 4,
15+
'collision': 5,
16+
'semisecular': 6,
17+
'rlof': 7, #only used for stopping conditions
18+
'stable_mass_transfer': 8,
19+
'common_envelope': 9,
20+
'common_envelope_energy_balance': 10,
21+
'ce_e': 11,
22+
'ce_alpha': 12,
23+
'common_envelope_angular_momentum_balance': 13,
24+
'ce_J': 14,
25+
'ce_gamma': 15,
26+
'double_common_envelope': 16,
27+
'dce': 17,
28+
}
29+
30+
31+
32+
33+
34+
35+
def rdc(file_name_root, file_type):
36+
f_type = file_type
37+
if file_type == "hdf5":
38+
f_type = "hdf"
39+
40+
file_name = file_name_root + "." + f_type
41+
if file_name_root[-4:]==".hdf":
42+
file_name = file_name_root
43+
44+
triple=read_set_from_file(file_name , file_type)
45+
counter = list(enumerate(triple.history))[0][1].number
46+
47+
for i, triple in enumerate(triple.history):
48+
if triple[0].number == counter:
49+
counter += 1
50+
print('\n\n')
51+
52+
print(' ')
53+
print(i, triple[0].time, triple[0].number, triple[0].relative_inclination, triple[0].dynamical_instability, triple[0].kozai_type, triple[0].error_flag_secular)
54+
55+
print( ' bs: ', triple[0].child2.bin_type, triple[0].child2.is_stable, triple[0].child2.semimajor_axis, triple[0].child2.eccentricity, triple[0].child2.argument_of_pericenter, triple[0].child2.longitude_of_ascending_node,)# triple[0].child2.mass_transfer_rate,
56+
print( '|', triple[0].bin_type, triple[0].is_stable, triple[0].semimajor_axis, triple[0].eccentricity, triple[0].argument_of_pericenter, triple[0].longitude_of_ascending_node)#, triple[0].mass_transfer_rate
57+
print( ' st: ', triple[0].child2.child1.is_donor, triple[0].child2.child1.stellar_type, triple[0].child2.child1.mass, triple[0].child2.child1.spin_angular_frequency, triple[0].child2.child1.radius, triple[0].child2.child1.core_mass,)
58+
print( '|', triple[0].child2.child2.is_donor, triple[0].child2.child2.stellar_type, triple[0].child2.child2.mass, triple[0].child2.child2.spin_angular_frequency, triple[0].child2.child2.radius,triple[0].child2.child2.core_mass, )
59+
print( '|', triple[0].child1.is_donor, triple[0].child1.stellar_type, triple[0].child1.mass, triple[0].child1.spin_angular_frequency, triple[0].child1.radius, triple[0].child1.core_mass)
60+
61+
62+
63+
64+
def parse_arguments():
65+
from amuse.units.optparse import OptionParser
66+
parser = OptionParser()
67+
parser.add_option("-f", dest="file_name_root", default = "TRES",
68+
help="file name [%default]")
69+
parser.add_option("-F", dest="file_type", default = "hdf5",
70+
help="file type [%default]")
71+
72+
73+
options, args = parser.parse_args()
74+
return options.__dict__
75+
76+
77+
if __name__ == '__main__':
78+
options = parse_arguments()
79+
80+
set_printing_strategy("custom",
81+
preferred_units = [units.MSun, units.RSun, units.Myr],
82+
precision = 11, prefix = "",
83+
separator = " [", suffix = "]")
84+
85+
86+
87+
print(' ')
88+
rdc(**options)
89+

0 commit comments

Comments
 (0)