Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can I get the answers for these computational physics and python programming problems? Textbooks for reference: ? Computational Physics by Mark Newman (guide to Python
Can I get the answers for these computational physics and python programming problems?
Textbooks for reference:
? "Computational Physics" by Mark Newman (guide to Python in computational physics)
? "Numerical Recipes" by W. H. Press et al. (covers very comprehensibly a vast range of numerical topics; 3rd edition is in C++; older editions, e.g. in C, are freely available online)
? "Clean Code" by Robert C. Martin (great book on good programming practices)
Exercise 1 Planetary orbits [15 points] The equations of motion for the position x, y of a planet in its orbital plane are d*x T d%y Y az = M. =M where G = 6.6738x 107! m? kg ! s =2 is Newton's gravitational constant, M = 1.9891x10% kg is the mass of the Sun, and r = /z2 + y2. (i (ii (iii ) ) ) o Transform this system of two second order ODEs into an equivalent system of four first order ODEs. The Earth's orbit is not perfectly ecircular, but rather slightly elliptical. When it is at its closest approach to the Sun, its perihelion, it is moving precisely tangentially (i.e., perpendicular to the line between itself and the Sun) and it has distance 1.4710 x 10" m from the Sun and linear velocity 3.0287 x 10* ms~!. Write a program to calculate the orbit of the Earth, using 4th order Runge-Kutta implemented explicitly. Make a plot of the orbit (i.e., a plot of y against x), showing at least two complete revolutions about the Sun. Make sure to set the aspect ratio so that the orbit does not appear distorted, for example by using the option plt.gca() .set_aspect('equal', adjustable='box') Repeat the calculation above using one of the library routines, scipy.integrate.odeint or scipy.integrate.solve_ivp. Make sure that you choose a sufficiently high accuracy to see the periodic orbit. Modify either one of your programs to calculate the orbit of a comet in the solar system. Many comets travel in highly elongated orbits around the sun. For much of their lives they are far out in the solar system, moving very slowly, but on rare occasions their orbit brings them close to the Sun for a fly-by and for a brief period of time they move very fast. As an initial condition, take a comet 4 billion kilometers away from the Sun (which is somewhere out around the orbit of Neptune) with initial velocity 500ms?. Make a graph showing the trajectory of the comet. Exercise 2 Quantum Oscillators [15 points| In the lab we studied the harmonic quantum oscillator: the one-dimensional, time-independent Schridinger equation with a harmonic potential. Modify your program from the lab to cal- culate the same three energies (ground state and first two excited states) for the anharmonic oscillator with V(z) = Vyz?/a, which cannot be solved analytically. The parameter values stay the same: m is the electron mass, 1) = 50eV, and a = 107! m. The secant method (see example in the lecture notes) works well for finding the energy levels, but you need to adjust the initial guesses to obtain the three different states. Modify yvour program further to calculate the properly normalized wavefunctions of the anharmonic oscillator for the three states and make a plot of them, all on the same axes, as a function of over a modest range near the originsay r = 5ba to = = 5a. To normalize the wavefunctions vou will have to evaluate the integral Ecm (z)|?dx and then rescale 1 appropriately to ensure that the area under the square of each of the wavefunc- tions is 1. Either the trapezoidal rule or Simpson's rule will give you a reasonable value for the integral. Note: You may find a few very large values at the end of the array holding the wavefunc- tion. These values are an artefact of the numerical calculation. By definition the wavefunction should go to zero at the boundary. It does not in the calculation because we have some nu- merical error in the energy estimate and the wavefunction is extremely sensitive to the energy value. You can choose plot limits such that the large values are not displayed. Another simple way to deal with the large values is to make use of the fact that the system is symmetric about its midpoint and calculate the integral of the wavefunction over only the left-hand half of the system, then double the result. This neatly misses out the large values. pit. title( 'Normalized Wavefunctions ') pit . legend( ) pit. show( ) C: \\Users \\menhe \\AppData\\Local\\Temp\\ipykernel_23688\\1135970226. py: 40: RuntimeWarning: invalid value encountered in sqrt E_ground = secant_method(lambda E : np . sqrt (Vo / (2 * m * a**2) ) - np. sqrt(E - vo * 0.1 / (a**4) ), Vo/2, vo) C: \\Users\\menhe\\AppData\\Local \\Temp\\ipykernel_23688\\1135970226. py : 41: RuntimeWarning: invalid value encountered in sqrt E_first_excited = secant_method(lambda E: np. sqrt(vo / (2 * m * a**2) ) - np. sqrt(E - Vo * 1.1 / (a**4) ), 3 * Vo, 4 * Vo) C: \\Users \\menhe \\AppData\\Local\\Temp\\ipykernel_23688\\1135970226. py: 42: RuntimeWarning: invalid value encountered in sqrt E_second_excited = secant_method(lambda E: np . sqrt(Vo / (2 * m * a**2) ) - np. sqrt(E - Vo * 2.1 / (a**4) ), 6 * Vo, 7 * Vo) Maximum iterations reached. No root found. Maximum iterations reached. No root found. Maximum iterations reached. No root found. TypeError Traceback (most recent call last) Cell In[5], line 48 45 x = np . linspace(-5*a, 5*a, 1000) 47 # Calculate wavefunctions ---> 48 psi_ground = psi(x, E_ground) 49 psi_first_excited = psi(x, E_first_excited) 50 psi_second_excited = psi(x, E_second_excited) Cell In[5], line 21, in psi(x, E) 20 def psi(x, E) : ---> 21 return np. exp( -np. sqrt(m * vo) * np. abs(x) ** 2 / (2 * h_bar) ) * np. exp(1j * np. sqrt(2 * m * (E - V(x))) * x / h bar) TypeError: unsupported operand type (s) for -: 'NoneType' and 'float"Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started