# Assignment 2 Physics 141/241: Computational Physics I Instructor: Javier Duarte Spring 2023 Due date for first version: Friday, May 5, 2023 8pm_ Due date for corrected version: Wednesday, May 9, 2023 8pm_ Total points: 90 [141], 130 [241] ## Policies You are free to collaborate on all the problems, subject to the collaboration policy stated in the syllabus. You must submit all code used in the homework (if you don't there is a 50% penalty). You are welcome to use Python, C/C++, or any other language you are comfortable with **within reason**. Please comment your code such that the TA can follow along and run it without any issues. The *first version* of the assignment will be graded on effort and completeness and is worth 50% of the total grade. The *corrected version* of the assignment will be graded on effort and correctness and is worth 50% of the total grade. ## Submission Instructions **PLEASE NOTE** that there are two steps to submitting your assignment. Both must be submitted by the deadline. - Please submit your report as a single `.pdf` file to Gradescope under **Assignment 2 Report** or **Assignment 2 Report Corrections**. In the report, include any images generated by your code along with your answers to the questions. - For instructions specifically pertaining to the Gradescope submission process, see https://www.gradescope.com/get_started#student-submission. - Please submit your code as a `.zip` archive to Gradescope under **Assignment 2 Code** or **Assignment 2 Code Corrections**. The `.zip` file should contain your code files for all problems. Submit your code either as `.ipynb`, `.py`, or `.c` files (etc.). Follow this naming conventions: - For code related to Problem 1(a), include a file named `problem1a.ipynb`, `problem1a.py`, or `problem1a.c` (etc.). The assigned merit points are for sub-tasks of Assignment II, separate for the PHYS 141 group and for the PHYS 241 group with added tasks for PHYS 241 indicated. ## Problem 1: Plummer Sphere (a) [50 points] Using your own code, generate the point distribution in $(x, y, z, v_x, v_y, v_z)$ phase space for the Plummer sphere with 100,000 points as discussed in lecture and [this lab note](Plummer_Labnote.pdf). The mass of the sphere is $M=10^{11} M_{\odot}$ and the radius is $a = 1.5$ kpc. Note: the `mkplummer` app of Nemo is not acceptable as your solution. (b) [20 points] Plot the corresponding theoretical mass density distribution as a function of the radial distance from the origin $P(r) = 4\pi r^2\rho(r)$ and compare it with your point mass distribution. Use a histogram for the distribution. *Hint*: You may need to normalize your distributions appropriately to compare them on the same scale. (c) [20 points] Calculate the histogram of the energy $E=\frac{1}{2}v^2+\Phi(r)$ distribution of the phase space points and compare it with the analytic expression $f \propto (-E)^{7/2}$. *Edit*: Why don't they match up? Consider the density of $(x, y, z, v_x, v_y, v_z)$ phase space states for a given $E$. (d) [241 only, 20 points] Show evidence that your velocity distribution agrees with the expected theoretical distribution at some value of $r$. *Hint*: Consider points in thin spherical shell around radius $r$. (e) [241 only, 20 points] Based on the Plummer model provided in lecture, prove Eq. (6) of [this note](Plummer_Labnote.pdf), namely that the total energy is given by $$ \mathcal{E} = -\frac{3\pi G M^2}{64a} $$ Show that Eq. (6) satisfies the general virial theorem connecting the total energy, the kinetic energy, and potential energy of the phase space point distribution.