|
| 1 | +import numpy |
| 2 | +from amuse.lab import * |
| 3 | +from matplotlib import pyplot |
| 4 | + |
| 5 | +R_young_stars = [ 0.1012221753955787, 0.2968660204589863, |
| 6 | + 0.5017430508551541, 0.7046418772801384, 0.8984687805821738, |
| 7 | + 1.1087212228990806, 1.296848150063784] |
| 8 | +S_young_stars = [ 69.68021137071266, 21.28302762211248 , |
| 9 | + 8.871846723535821 , 4.634361707743547 , 0.842276996426784 , |
| 10 | + 0.35283784451473543, 0.32284672967371486] |
| 11 | + |
| 12 | +R_all_stars = [ 0.09966839700574376, 0.29542608638995443, |
| 13 | + 0.4910636790322119, 0.6989696157755654, 0.9093883458890231, |
| 14 | + 1.1027718150669223, 1.3041555749011087] |
| 15 | + |
| 16 | +S_all_stars = [246.4266804633498 , 108.52660553059054, |
| 17 | + 59.62962877617595 , 22.170446486030563 |
| 18 | + , 6.83698178212555 , 2.8123977037860786 |
| 19 | + , 0.28189901519958876] |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +R_dense_gas = [ 0.10160842129883879, 0.30957902551862887, |
| 24 | + 0.5005420834356191, 0.6940641257773106, |
| 25 | + 0.8993648870413651, 1.107381682315753, |
| 26 | + 1.2954901330586175] |
| 27 | + |
| 28 | + |
| 29 | +S_dense_gas = [587.057496278814, 193.757708949030, 81.05652212929158, |
| 30 | + 25.83103135675521, 13.72720495792530, |
| 31 | + 4.161094960653975, 3.939217817754274] |
| 32 | + |
| 33 | +R_all_gas = [ 0.09890162549942522, 0.2971536318319011, |
| 34 | + 0.5047269929821525, 0.6955052866807527, |
| 35 | + 0.8934247174201266, 1.0960741121502846, |
| 36 | + 1.296349286674131] |
| 37 | +S_all_gas = [ 1011.82389615108 , 382.3950057709804, 262.3523868909657 |
| 38 | + , 154.2500699106347, |
| 39 | + 107.5704842567941, |
| 40 | + 88.9640154049995 , |
| 41 | + 68.72257895441606] |
| 42 | + |
| 43 | +pyplot.rcParams.update({'font.size': 30}) |
| 44 | +fig, ax = pyplot.subplots(figsize=[16,10]) |
| 45 | +ax.minorticks_on() # switch on the minor ticks |
| 46 | +ax.tick_params('both', length=15, width=2, which='major') |
| 47 | +ax.tick_params('both', length=6, width=1, which='minor') |
| 48 | +from distinct_colours import get_distinct |
| 49 | +colors = get_distinct(10) |
| 50 | + |
| 51 | +pyplot.scatter(R_young_stars, S_young_stars, s=100, marker='s', c=colors[6], lw=0) |
| 52 | +pyplot.scatter(R_all_stars, S_all_stars, s=100, marker='s', c=colors[0], lw=0) |
| 53 | +#pyplot.scatter(R_dense_gas, S_dense_gas, s=100, marker='s', c=colors[7], lw=0) |
| 54 | +pyplot.scatter(R_all_gas, S_all_gas, s=100, marker='s', c=colors[3], lw=0) |
| 55 | + |
| 56 | +def plot_radial_distribution(gas, nbin, c, lw): |
| 57 | + X = [] |
| 58 | + Ymean = [] |
| 59 | + Ystd = [] |
| 60 | + for gi in range(len(gas)-nbin): |
| 61 | + X.append(gas[gi: gi+nbin].r.value_in(units.parsec).mean()) |
| 62 | + S = (gas[gi+nbin].r**2-gas[gi].r**2) |
| 63 | + rho = gas[gi: gi+nbin].mass.sum()/S |
| 64 | + #if hasattr(gas, "rho"): |
| 65 | + #rho = gas[gi: gi+nbin].rho.max()*S.sqrt() |
| 66 | + Ymean.append(rho.value_in(units.MSun/units.parsec**2)) |
| 67 | + pyplot.plot(X, Ymean, c=colors[c], lw=lw) |
| 68 | + |
| 69 | +def plot_radial_density_distribution(gas, stars): |
| 70 | + |
| 71 | + com = stars.center_of_mass() |
| 72 | + |
| 73 | + gas.r = ((gas.x-com[0])**2 + (gas.y-com[1])**2).sqrt() |
| 74 | + gas = gas.sorted_by_attributes("r") |
| 75 | + |
| 76 | + stars.r = ((stars.x-com[0])**2 + (stars.y-com[1])**2).sqrt() |
| 77 | + stars = stars.sorted_by_attributes("r") |
| 78 | + |
| 79 | + max_age = stars.birth_age.max() |
| 80 | + young_stars = stars[max_age-stars.birth_age<1.5|units.Myr] |
| 81 | + |
| 82 | + mN2H = 2*29.02134 |
| 83 | + cutoff_density = 1e5 * mN2H * constants.atomic_unit_of_mass/(1|units.cm**3) |
| 84 | + dense_gas = gas[gas.density>cutoff_density] |
| 85 | + |
| 86 | + plot_radial_distribution(gas, 100, c=3, lw=4) |
| 87 | + |
| 88 | +# plot_radial_distribution(dense_gas, 100, c=7, lw=2) |
| 89 | + plot_radial_distribution(stars, 60, c=0, lw=4) |
| 90 | + plot_radial_distribution(young_stars, 10, c=6, lw=4) |
| 91 | + pyplot.xlim(0, 1.1) |
| 92 | + pyplot.ylim(1, 1100) |
| 93 | + pyplot.semilogy() |
| 94 | + pyplot.xlabel("R [pc]") |
| 95 | + pyplot.ylabel("$\Sigma$ [M$_\odot$ pc$^{-2}]$") |
| 96 | +# pyplot.show() |
| 97 | + pyplot.savefig("2017arXiv170307029H_Fig3") |
| 98 | + |
| 99 | +def main(filename=None): |
| 100 | + |
| 101 | + disk = Particles(0) |
| 102 | + stars = Particles(0) |
| 103 | + bodies = read_set_from_file(filename, "amuse") |
| 104 | + for bi in bodies.history: |
| 105 | + #print(bi) |
| 106 | + if len(bi)>0: |
| 107 | + if hasattr(bi, "name") and "gas" in str(bi.name): |
| 108 | + disk.add_particles(bi.copy()) |
| 109 | + elif "Star" in str(bi.name): |
| 110 | + stars.add_particles(bi.copy()) |
| 111 | + |
| 112 | + print("Stellar masses:", stars.mass.min().in_(units.MSun), stars.mass.mean().in_(units.MSun), stars.mass.max().in_(units.MSun), stars.mass.median().in_(units.MSun)) |
| 113 | + |
| 114 | + #plot_age_gasdensity(disk, stars) |
| 115 | + plot_radial_density_distribution(disk, stars) |
| 116 | + |
| 117 | +def new_option_parser(): |
| 118 | + from amuse.units.optparse import OptionParser |
| 119 | + result = OptionParser() |
| 120 | + result.add_option("-f", |
| 121 | + dest="filename", default ="GMC_R2pcN20k_SE_T45Myr.amuse", |
| 122 | + help="output filename [%default]") |
| 123 | + return result |
| 124 | + |
| 125 | +if __name__ in ('__main__', '__plot__'): |
| 126 | + o, arguments = new_option_parser().parse_args() |
| 127 | + main(**o.__dict__) |
| 128 | + |
| 129 | + |
0 commit comments