Skip to content

Commit 3dbff3c

Browse files
committed
updated Makefile
2 parents 36d7ae0 + 7876107 commit 3dbff3c

Some content is hidden

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

41 files changed

+1285
-639
lines changed

hermitepn/Makefile renamed to Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ LDFLAGS += -lm $(MUSE_LD_FLAGS)
1717

1818
OBJS = interface.o
1919

20-
CODELIB = src/libhermitepn.a
20+
CODELIB = src/libhermite_grx.a
2121

2222
CODE_GENERATOR = $(AMUSE_DIR)/build.py
2323

24-
all: hermitepn_worker
24+
all: hermite_grx_worker
2525

2626
clean:
2727
$(RM) -f *.so *.o *.pyc worker_code.cc worker_code.h
28-
$(RM) *~ hermitepn_worker worker_code.cc
28+
$(RM) *~ hermite_grx_worker worker_code.cc
2929
$(RM) -f *~
3030
make -C src clean
3131

3232
$(CODELIB):
3333
make -C src all
3434

3535
worker_code.cc: interface.py
36-
$(CODE_GENERATOR) --type=c interface.py HermitePNInterface -o $@
36+
$(CODE_GENERATOR) --type=c interface.py HermiteGRXInterface -o $@
3737

3838
worker_code.h: interface.py
39-
$(CODE_GENERATOR) --type=H -i amuse.community.interface.stopping_conditions.StoppingConditionInterface interface.py HermitePNInterface -o $@
39+
$(CODE_GENERATOR) --type=H -i amuse.community.interface.stopping_conditions.StoppingConditionInterface interface.py HermiteGRXInterface -o $@
4040

41-
hermitepn_worker: worker_code.cc worker_code.h $(CODELIB) $(OBJS)
42-
$(MPICXX) $(CXXFLAGS) $< -o $@ $(OBJS) $(CODELIB) -L./src -L$(AMUSE_DIR)/lib/stopcond -lstopcond -lhermitepn
41+
hermite_grx_worker: worker_code.cc worker_code.h $(CODELIB) $(OBJS)
42+
$(MPICXX) $(CXXFLAGS) $< -o $@ $(OBJS) $(CODELIB) -L./src -L$(AMUSE_DIR)/lib/stopcond -lstopcond -lhermite_grx
4343

4444
interface.o: interface.cc
4545
$(CXX) $(CXXFLAGS) -c -o $@ $<

README.md

100755100644
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
# Hermite_GRX
2-
location: https://github.com/amusecode/Hermite_GRX
1+
# Hermite Post-Newtonian
2+
3+
This code expands the original hermite code with post-newtonian terms.
4+
5+
## Installation
6+
From the AMUSE source directory run the following git command `git submodule add [email protected]:amusecode/Hermite_GRX.git src/amuse/community/hermite_grx`. This will add the code as a submodule such that the respective git structures do not interfere.
7+
The code can then be compiled using `make hermite_grx.code` or all codes can be built together using `python setup.py develop_build`.

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# generated file

GalacticCenter.py renamed to examples/GalacticCenter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from amuse.units import constants
44

55
import orbital_elements as orb_elem
6-
from hermitepn.interface import *
6+
from amuse.community.hermite_grx.interface import *
77

88
import numpy as np
99
import time
@@ -93,7 +93,7 @@ def setup_sim(initial, num_threads, dt_param, integrator, perturbation):
9393
mbh, bhs, converter = initial
9494

9595
if perturbation != None:
96-
grav = HermitePN(converter)
96+
grav = HermiteGRX(converter)
9797
grav.parameters.light_speed = constants.c
9898
grav.parameters.perturbation = perturbation
9999
grav.parameters.integrator = integrator

HTPHermite.py renamed to examples/HTPHermite.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from amuse.lab import *
22
from amuse.units.units import *
33
from amuse.units import constants
4-
from hermitepn.interface import *
4+
from amuse.community.hermite_grx.interface import *
55

66
def HTpulsar(m1, m2, a, e):
77
converter = nbody_system.nbody_to_si(m1+m2, a)
@@ -46,28 +46,30 @@ def get_trajectories(initial, grav, t_end, pert=None):
4646

4747
return x1, y1, z1, x2, y2, z2, time, E
4848

49-
m1 = 1.441 | units.MSun
50-
m2 = 1.397 | units.MSun
51-
a = 1950100 | units.km
52-
e = 0.6171334
53-
initial = HTpulsar(m1, m2, a, e)
54-
bodies = initial[0]
55-
Porb = 7.751938773864 | units.hour
56-
57-
converter = initial[1]
58-
Nbody_code = Hermite
59-
grav = Nbody_code(converter)
60-
grav.parameters.dt_param = 0.1
6149

62-
x1, y1, z1, x2, y2, z2, time, E = get_trajectories(initial,
63-
grav,
64-
10*Porb)
65-
66-
print("n=", len(x1))
67-
from matplotlib import pyplot
68-
pyplot.plot(x1.value_in(units.au), y1.value_in(units.au), c='r', lw=1)
69-
pyplot.plot(x2.value_in(units.au), y2.value_in(units.au), c='g', lw=1)
70-
pyplot.show()
50+
if __name__=="__main__":
51+
m1 = 1.441 | units.MSun
52+
m2 = 1.397 | units.MSun
53+
a = 1950100 | units.km
54+
e = 0.6171334
55+
initial = HTpulsar(m1, m2, a, e)
56+
bodies = initial[0]
57+
Porb = 7.751938773864 | units.hour
58+
59+
converter = initial[1]
60+
Nbody_code = Hermite
61+
grav = Nbody_code(converter)
62+
grav.parameters.dt_param = 0.1
63+
64+
x1, y1, z1, x2, y2, z2, time, E = get_trajectories(initial,
65+
grav,
66+
10*Porb)
67+
68+
print("n=", len(x1))
69+
from matplotlib import pyplot
70+
pyplot.plot(x1.value_in(units.au), y1.value_in(units.au), c='r', lw=1)
71+
pyplot.plot(x2.value_in(units.au), y2.value_in(units.au), c='g', lw=1)
72+
pyplot.show()
7173

72-
pyplot.scatter(time.value_in(units.yr), E/E[0], c='g')
73-
pyplot.sh
74+
pyplot.scatter(time.value_in(units.yr), E/E[0], c='g')
75+
pyplot.sh

HulseTaylor.py renamed to examples/HulseTaylor.py

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from matplotlib import pyplot
44
from amuse.units import constants
55
import numpy as np
6-
from hermitepn.interface import *
6+
from amuse.community.hermite_grx.interface import *
77
from amuse.ext.orbital_elements import new_binary_from_orbital_elements
88
from amuse.ext.orbital_elements import orbital_elements_from_binary
99

@@ -74,7 +74,7 @@ def get_trajectories(initial, grav, t_end, dt, pert=None):
7474

7575
def run_nbody_code(Nbody_code, label, dt, tend):
7676
grav = Nbody_code(converter)
77-
if Nbody_code==HermitePN:
77+
if Nbody_code==HermiteGRX:
7878
pert = '1PN_Pairwise'
7979
grav.parameters.integrator = 'RegularizedHermite'
8080
if "EIH" in label:
@@ -95,50 +95,52 @@ def run_nbody_code(Nbody_code, label, dt, tend):
9595
dt,
9696
pert)
9797
return x1, y1, z1, x2, y2, z2, time, E, sma, ecc
98-
m1 = 1.441 | units.MSun
99-
m2 = 1.397 | units.MSun
100-
a = 1950100 | units.km
101-
e = 0.6171334
102-
initial = HTpulsar(m1, m2, a, e)
103-
bodies = initial[0]
104-
Porb = 7.751938773864 | units.hour
105-
converter = initial[1]
106-
Nbody_codes = [Hermite, HermitePN, HermitePN]
107-
colors = ['r', 'b', 'g']
108-
labels = ["Hermite", "hermitePN", "HermitePN\_EIH"]
109-
dt = 0.1*Porb
110-
t_end = 10*Porb
11198

112-
figure = pyplot.figure(figsize = (10, 10))
99+
if __name__=="__main__":
100+
m1 = 1.441 | units.MSun
101+
m2 = 1.397 | units.MSun
102+
a = 1950100 | units.km
103+
e = 0.6171334
104+
initial = HTpulsar(m1, m2, a, e)
105+
bodies = initial[0]
106+
Porb = 7.751938773864 | units.hour
107+
converter = initial[1]
108+
Nbody_codes = [Hermite, HermiteGRX, HermiteGRX]
109+
colors = ['r', 'b', 'g']
110+
labels = ["Hermite", "hermitePN", "HermitePN\_EIH"]
111+
dt = 0.1*Porb
112+
t_end = 10*Porb
113113

114-
for Nbody_code, ci, li in zip(Nbody_codes, colors, labels):
115-
x1, y1, z1, x2, y2, z2, time, E, sma, ecc = run_nbody_code(Nbody_code, li, dt, t_end)
116-
print("n=", len(x1))
117-
print("t=", time/Porb)
114+
figure = pyplot.figure(figsize = (10, 10))
118115

119-
subplot = figure.add_subplot(2, 2, 1)
120-
pyplot.plot(x1.value_in(units.au), y1.value_in(units.au), c=ci, lw=1)
121-
pyplot.plot(x2.value_in(units.au), y2.value_in(units.au), c=ci, lw=1)
122-
pyplot.xlabel('x')
123-
pyplot.ylabel('y')
116+
for Nbody_code, ci, li in zip(Nbody_codes, colors, labels):
117+
x1, y1, z1, x2, y2, z2, time, E, sma, ecc = run_nbody_code(Nbody_code, li, dt, t_end)
118+
print("n=", len(x1))
119+
print("t=", time/Porb)
124120

125-
subplot = figure.add_subplot(2, 2, 2)
126-
pyplot.plot(sma.value_in(units.RSun), ecc, c=ci, label=li)
127-
pyplot.xlabel('a')
128-
pyplot.ylabel('e')
121+
subplot = figure.add_subplot(2, 2, 1)
122+
pyplot.plot(x1.value_in(units.au), y1.value_in(units.au), c=ci, lw=1)
123+
pyplot.plot(x2.value_in(units.au), y2.value_in(units.au), c=ci, lw=1)
124+
pyplot.xlabel('x')
125+
pyplot.ylabel('y')
129126

130-
subplot = figure.add_subplot(2, 2, 3)
131-
pyplot.plot(time.value_in(units.yr), sma.value_in(units.RSun), c=ci)
132-
pyplot.xlabel('t')
133-
pyplot.ylabel('a')
127+
subplot = figure.add_subplot(2, 2, 2)
128+
pyplot.plot(sma.value_in(units.RSun), ecc, c=ci, label=li)
129+
pyplot.xlabel('a')
130+
pyplot.ylabel('e')
134131

135-
subplot = figure.add_subplot(2, 2, 4)
136-
pyplot.plot(time.value_in(units.yr), ecc, c=ci)
137-
pyplot.xlabel('t')
138-
pyplot.ylabel('e')
139-
140-
subplot = figure.add_subplot(2, 2, 2)
141-
pyplot.legend()
132+
subplot = figure.add_subplot(2, 2, 3)
133+
pyplot.plot(time.value_in(units.yr), sma.value_in(units.RSun), c=ci)
134+
pyplot.xlabel('t')
135+
pyplot.ylabel('a')
136+
137+
subplot = figure.add_subplot(2, 2, 4)
138+
pyplot.plot(time.value_in(units.yr), ecc, c=ci)
139+
pyplot.xlabel('t')
140+
pyplot.ylabel('e')
141+
142+
subplot = figure.add_subplot(2, 2, 2)
143+
pyplot.legend()
142144

143-
#pyplot.show()
144-
pyplot.savefig("HTpulsar.pdf", fontsize=10)
145+
#pyplot.show()
146+
pyplot.savefig("HTpulsar.pdf", fontsize=10)
File renamed without changes.
File renamed without changes.

Montgomery.py renamed to examples/Montgomery.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from amuse.units.units import *
33
from amuse.units import constants
44
import numpy as np
5-
from hermitepn.interface import *
5+
from amuse.community.hermite_grx.interface import *
66

77
def get_initial_conditions_figure_eight(unit_mass, unit_length):
88
converter = nbody_system.nbody_to_si(unit_mass, unit_length)
@@ -41,7 +41,7 @@ def get_trajectories(initial, grav, t_end, pert=None):
4141
E = [] | units.J
4242

4343
t = 0 * t_end
44-
dt = t_end / 10000.0
44+
dt = t_end / 1000.0
4545
i = 0.
4646

4747
while t < t_end:
@@ -69,19 +69,25 @@ def get_trajectories(initial, grav, t_end, pert=None):
6969
#initial[0].velocity += 10 |units.kms
7070
bodies = initial[0]
7171
converter = initial[1]
72-
Nbody_code = HermitePN
72+
Nbody_code = HermiteGRX
7373
#Nbody_code = Hermite
74-
#grav = HermitePN(converter)
7574
grav = Nbody_code(converter)
7675
pert = '1PN_Pairwise'
77-
if Nbody_code=="HermitePN":
76+
print(Nbody_code)
77+
if "HermiteGRX" in str(Nbody_code):
7878
print("perturbation=", grav.parameters.perturbation)
7979
grav.parameters.perturbation = pert
8080
grav.parameters.integrator = 'RegularizedHermite'
8181
grav.parameters.dt_param = 0.1
82-
grav.parameters.light_speed = 0.001*constants.c
82+
grav.parameters.light_speed = 0.01*constants.c
83+
84+
#grav.parameters.integrator = 'Hermite'
85+
#grav.parameters.perturbation = '1PN_EIH'
86+
#grav.parameters.integrator = 'SymmetrizedRegularizedHermite'
87+
#grav.parameters.light_speed = relative_lightspeed # * constants.c
8388
else:
8489
grav.parameters.dt_param = 0.1
90+
print(grav.parameters)
8591
print("v=", bodies[0].velocity.length()/grav.parameters.light_speed)
8692

8793
x1, y1, z1, x2, y2, z2, x3, y3, z3, time, E = get_trajectories(initial,
File renamed without changes.

0 commit comments

Comments
 (0)