# Blog: AMUSE lecture at UVA on 25 jan 2016: cluster_exercise2.2.ipynb

File cluster_exercise2.2.ipynb, 11.4 KB (added by pelupes, 3 years ago) |
---|

Line | |
---|---|

1 | { |

2 | "metadata": { |

3 | "name": "", |

4 | "signature": "sha256:09cc7c29fb1d409840e13fcd1907665be627ec3195b499eb1b0e9c17a5a204b2" |

5 | }, |

6 | "nbformat": 3, |

7 | "nbformat_minor": 0, |

8 | "worksheets": [ |

9 | { |

10 | "cells": [ |

11 | { |

12 | "cell_type": "markdown", |

13 | "metadata": {}, |

14 | "source": [ |

15 | "Testing the Evolution of Starclusters with Amuse and making predictions for Gaia \n", |

16 | "================================================================================\n", |

17 | "\n", |

18 | "In this tutorial you will be guided to use AMUSE to conduct a numerical n-body experiment and make predictions for Gaia. \n", |

19 | "\n", |

20 | "The bigger question you will address concerns the question of how stars form. We know that stars typically (and possibly always) form in clusters. However, the birth conditions are very hard to measure. For example: How \"clumpy\" or \"smooth\" are these clusters? How \"virialized\" are they? \n", |

21 | "\n", |

22 | "You will simulate the evolution of star clusters, with different initial conditions. The aim is to investigate if the initial conditions leave imprints that Gaia can observe. Specifically you will investigate the population of \"escapers\" and possible \"runaway stars\", i.e. stars that escape their birth cluster. To do this we will very closely follow the work by Allison (2012, MNRAS 421, 3338). \n", |

23 | "\n", |

24 | "You will report the results of your numerical experiments in the style of a \"letter\" (= short paper normally on a very timely topic.) Detailed instructions below. The questions in this tutorial are to guide you through the experiment. You can use them the narrative of your report, but the report should be in the style of a self containing paper, not a numbered list to the questions here. " |

25 | ] |

26 | }, |

27 | { |

28 | "cell_type": "markdown", |

29 | "metadata": {}, |

30 | "source": [ |

31 | "(1) Introduction\n", |

32 | "----------------\n", |

33 | "a) Read the paper by Allison (2012) and discuss with your peers. What did the author do? What was the motivation for it? Which terms or concept are new to you? Look them up.\n", |

34 | "\n", |

35 | "b) What is the Gaia mission? What will Gaia measure? What will Gaia measure that is relevant for this paper?\n" |

36 | ] |

37 | }, |

38 | { |

39 | "cell_type": "markdown", |

40 | "metadata": {}, |

41 | "source": [ |

42 | "(2) Initial conditions\n", |

43 | "-----------------------\n", |

44 | "\n", |

45 | "a) Lookup the references given in the paper of the initial conditions for the spatial distribution of stars and their mass distribution. Keep them for reference.\n", |

46 | "\n", |

47 | "Luckily the initial conditions are already included with AMUSE!\n", |

48 | "\n", |

49 | "b) Import the fractal model cluster, and read the help to get information on the arguments of this function:\n" |

50 | ] |

51 | }, |

52 | { |

53 | "cell_type": "code", |

54 | "collapsed": false, |

55 | "input": [ |

56 | "from amuse.ic.fractalcluster import new_fractal_cluster_model\n", |

57 | "help(new_fractal_cluster_model)" |

58 | ], |

59 | "language": "python", |

60 | "metadata": {}, |

61 | "outputs": [] |

62 | }, |

63 | { |

64 | "cell_type": "markdown", |

65 | "metadata": {}, |

66 | "source": [ |

67 | "c) Generate a N=100 model:" |

68 | ] |

69 | }, |

70 | { |

71 | "cell_type": "code", |

72 | "collapsed": false, |

73 | "input": [ |

74 | "parts=new_fractal_cluster_model(100, do_scale=True)\n", |

75 | "print parts" |

76 | ], |

77 | "language": "python", |

78 | "metadata": {}, |

79 | "outputs": [] |

80 | }, |

81 | { |

82 | "cell_type": "markdown", |

83 | "metadata": {}, |

84 | "source": [ |

85 | "d) Do you remember from the tutorial what the units are? Confirm that the total mass and potential and kinetic energies match the expected values. (The potential energy calculation is given below - what happens if you do not provide G? can you understand the generated error?)\n", |

86 | "\n", |

87 | "e) explore the effect of the fractal dimension and virial ratio parameters on the model by plotting the positions and \n", |

88 | "velocities of various models. Do you understand the physical meaning of these?" |

89 | ] |

90 | }, |

91 | { |

92 | "cell_type": "code", |

93 | "collapsed": false, |

94 | "input": [ |

95 | "from amuse.units import units,constants, nbody_system\n", |

96 | "\n", |

97 | "parts.potential_energy(G=nbody_system.G)" |

98 | ], |

99 | "language": "python", |

100 | "metadata": {}, |

101 | "outputs": [] |

102 | }, |

103 | { |

104 | "cell_type": "markdown", |

105 | "metadata": {}, |

106 | "source": [ |

107 | "To finish the initial conditions we need to convert the model to physical units, and give the stars a realistic distribution of masses.\n", |

108 | "\n", |

109 | "f) The Kroupa mass distribution used in the paper can be generated by a a piece-wise power law distribution. Generate a set of masses described by this, and plot the resulting mass distribution.Adapt the parameters to match the paper!" |

110 | ] |

111 | }, |

112 | { |

113 | "cell_type": "code", |

114 | "collapsed": false, |

115 | "input": [ |

116 | "from amuse.ic.brokenimf import new_broken_power_law_mass_distribution\n", |

117 | "masses=new_broken_power_law_mass_distribution(1000, mass_boundaries=[0.1,100] | units.MSun, alphas=[-2.35])" |

118 | ], |

119 | "language": "python", |

120 | "metadata": {}, |

121 | "outputs": [] |

122 | }, |

123 | { |

124 | "cell_type": "markdown", |

125 | "metadata": {}, |

126 | "source": [ |

127 | "g) The way to convert a scaleless model to SI units is by providing a converter. An N-body converter takes two values, fixing the scale of the model (together with the requirement of G=1). (can you understand the units of the converted values below?)" |

128 | ] |

129 | }, |

130 | { |

131 | "cell_type": "code", |

132 | "collapsed": false, |

133 | "input": [ |

134 | "radius=1 | units.parsec\n", |

135 | "\n", |

136 | "convert=nbody_system.nbody_to_si( masses.sum(), radius)\n", |

137 | "\n", |

138 | "print convert.to_si( 1 | nbody_system.length )\n", |

139 | "print convert.to_nbody( 1 | units.km/units.s )\n", |

140 | "print convert.to_nbody( constants.G )" |

141 | ], |

142 | "language": "python", |

143 | "metadata": {}, |

144 | "outputs": [] |

145 | }, |

146 | { |

147 | "cell_type": "markdown", |

148 | "metadata": {}, |

149 | "source": [ |

150 | "h) at this point you should be able to generate intitial conditions matching those of the paper! Do so." |

151 | ] |

152 | }, |

153 | { |

154 | "cell_type": "markdown", |

155 | "metadata": {}, |

156 | "source": [ |

157 | "(3) Evolving the models\n", |

158 | "-----------------------\n", |

159 | "\n", |

160 | "a) Like the paper mentions, the experiments where done using purely gravitational dynamics. A number of codes for this \n", |

161 | "are available in AMUSE. Choose an appropiate one from the tabel given in the AMUSE code paper. " |

162 | ] |

163 | }, |

164 | { |

165 | "cell_type": "code", |

166 | "collapsed": false, |

167 | "input": [ |

168 | "from amuse.community.huayno.interface import Huayno\n", |

169 | "\n", |

170 | "h=Huayno(convert_nbody=convert)\n", |

171 | "print h.parameters\n", |

172 | "print help(h.parameters)" |

173 | ], |

174 | "language": "python", |

175 | "metadata": {}, |

176 | "outputs": [] |

177 | }, |

178 | { |

179 | "cell_type": "markdown", |

180 | "metadata": {}, |

181 | "source": [ |

182 | "b) write an evolve loop to evolve the model to some specified end_time with some dt, measuring and reporting the energy error \n", |

183 | "\n", |

184 | "c) conduct the simulations as reported in the paper. It may be that a simulation takes too long or the energy error is not acceptable ((E-E0)/E0 should be smaller than 0.001). You can try with smaller number of particles, introducing smoothing (epsilon_squared parameter) or change the timestep parameter (usually timestep_parameter), or vary the random seed of the initial distribution (can you figure out the rationale behind these suggestions?)" |

185 | ] |

186 | }, |

187 | { |

188 | "cell_type": "markdown", |

189 | "metadata": {}, |

190 | "source": [ |

191 | "(4) Analysis\n", |

192 | "------------\n", |

193 | "\n", |

194 | "a) reproduce the spatial distribution plot of Allison 2012. Note similarities and differences\n", |

195 | "\n", |

196 | "b) analyse the kinematics of the escaping stars, discussing Allision 2012.\n", |

197 | "\n", |

198 | "Explore a bit of parameter space if you feel like it!" |

199 | ] |

200 | }, |

201 | { |

202 | "cell_type": "markdown", |

203 | "metadata": {}, |

204 | "source": [ |

205 | "(5) Wrapping it up\n", |

206 | "------------------\n", |

207 | "\n", |

208 | "a) This exercise is completed by writing short report, see instructions below. You can distill from the above notebook (maybe copying from the above to a new notebook). Include 1 or 2 figures for the results (matching those from the paper) and maybe 1 or 2 more showing the initial conditions.\n", |

209 | "\n", |

210 | "b) If you didn't succeed, try to describe why not and what the problems where you ran into. \n", |

211 | "\n", |

212 | "c) Bonus points if you extend the model with any of the additional physics mentioned in the paper (stellar evolution, binaries natal gas,.. etc)! But first make sure you full fill the basics. " |

213 | ] |

214 | }, |

215 | { |

216 | "cell_type": "markdown", |

217 | "metadata": {}, |

218 | "source": [ |

219 | "Format of your report\n", |

220 | "---------------------\n", |

221 | "\n", |

222 | "Write your report as a ``letter'' (= a brief paper of 4-5 pages max in 2 column format when using the ``emulateapj'' package. This is a latex class that will give it the appearance of a real ApJ letter. You can download it online. I suggest you use the following latex packages/\n", |

223 | " \\\\documentclass[apjl]{emulateapj} % paper will get the appearance of a real ApJ Letter\n", |

224 | " \\\\usepackage{graphicx} % for including plots\n", |

225 | " \\\\usepackage{natbib} % for a proper bibiography\n", |

226 | " \\\\bibliographystyle{apj} % to set the style of the bibliography\n", |

227 | " \\\\usepackage{hyperref} % will make all references in your paper act as hyperlinks in the pdf\n", |

228 | "\n", |

229 | "Make sure you have the following sections and do not exceed 5 pages.\n", |

230 | " 1. Introduction\n", |

231 | " 2. Method\n", |

232 | " 3. Results\n", |

233 | " 4. Conclusion & Discussion.\n", |

234 | "\n", |

235 | "Some hints for writing\n", |

236 | "----------------------\n", |

237 | "\n", |

238 | "##### Introduction:\n", |

239 | "A good introduction briefly explains\n", |

240 | "\n", |

241 | "* the astrophysical context / the bigger question your work adresses / why your work is timely (hint: maybe because it relevant for the data that Gaia will soon release)\n", |

242 | "* the state of the art and gives credit to most relevant earlier papers (Hint: it would be nice to state that you follow the approach taken by Allison 2012)\n", |

243 | "* formulate the specific scientific question you are adressing in this work.\n", |

244 | "* is concise: aim for 0.5-0.75 page in the 2 col format\n", |

245 | "\n", |

246 | "##### Method\n", |

247 | "\n", |

248 | "Here you explain which code(s) you are using and you give a very brief summary of what they do providing references. Then state the assumptions and initial conditions you adopt. Typical length is ~1-1.5 page in a letter.\n", |

249 | "\n", |

250 | "##### Results\n", |

251 | "\n", |

252 | "Here you describe your main results by systematically dicussing your findings. Hint: It often helps to first decide what the key plots are that you want to show. Often the result section is often a systematic explanationof what the plots illustate. Typical length is 2 pages in a letter.\n", |

253 | "\n", |

254 | "##### Discussion & conclusion \n", |

255 | "Summarize your key message. Here you can disuss the implications of your findings, the limitations of your method and possibly state future improvements. Typical length is 0.5 pages in a letter.\n" |

256 | ] |

257 | }, |

258 | { |

259 | "cell_type": "code", |

260 | "collapsed": false, |

261 | "input": [], |

262 | "language": "python", |

263 | "metadata": {}, |

264 | "outputs": [] |

265 | } |

266 | ], |

267 | "metadata": {} |

268 | } |

269 | ] |

270 | } |