|
1 | | -#from __future__ import print_function |
2 | | -import numpy |
| 1 | +""" |
| 2 | +Gravity potential example from Astrophysical Recipes |
| 3 | +
|
| 4 | +Implements a code simulating the galactic center. As the center itself |
| 5 | +does not evolve we only need to define the 'get_gravity_at_point' and |
| 6 | +'get_potential_at_point'. Note that both functions get arrays of |
| 7 | +points. |
| 8 | +""" |
3 | 9 | from amuse.units import units |
4 | 10 | from amuse.units import quantities |
5 | 11 | from amuse.units import constants |
|
13 | 19 | from matplotlib import pyplot as plt |
14 | 20 | from amuse.ic.kingmodel import new_king_model |
15 | 21 |
|
16 | | -plt.style.use('../lib/matplotlibrc') |
17 | | - |
18 | | -""" |
19 | | -Implements a code simulating the galactic center. As the center itself |
20 | | -does not evolve we only need to define the 'get_gravity_at_point' and |
21 | | -'get_potential_at_point'. Note that both functions get arrays of |
22 | | -points. |
23 | | -""" |
24 | 22 |
|
25 | 23 | # #BOOKLISTSTART1# # |
26 | 24 | class GalacticCenterGravityCode(object): |
@@ -67,12 +65,13 @@ def make_king_model_cluster(nbodycode, N, W0, Mcluster, |
67 | 65 | # #BOOKLISTSTOP3# # |
68 | 66 |
|
69 | 67 | def plot_cluster(f, x, y, c): |
70 | | - |
71 | | - #from prepare_figure import single_frame, get_distinct |
72 | | - #f = single_frame('X [pc]', 'Y [pc]') |
| 68 | + figure = plt.figure() |
| 69 | + ax = figure.add_subplot(111) |
| 70 | + ax.set_xlabel("X [pc]") |
| 71 | + ax.set_ylabel("Y [pc]") |
73 | 72 | #plt.xlim(-60, 60) |
74 | 73 | #plt.ylim(-60, 60) |
75 | | - plt.scatter(x,y, c=c, s=50, lw=0, alpha=0.2) |
| 74 | + ax.scatter(x, y, c=c, s=50, lw=0, alpha=0.2) |
76 | 75 |
|
77 | 76 | save_file = 'Arches.pdf' |
78 | 77 | plt.savefig("../figures/"+save_file) |
@@ -120,9 +119,9 @@ def evolve_cluster_in_galaxy(N, W0, Rinit, tend, timestep, M, R): |
120 | 119 | cluster_code.stop() |
121 | 120 | # #BOOKLISTSTOP2# # |
122 | 121 |
|
123 | | - |
124 | 122 | return x, y |
125 | 123 |
|
| 124 | + |
126 | 125 | if __name__ == "__main__": |
127 | 126 | N=1024 |
128 | 127 | W0=3 |
|
0 commit comments