首页 > > 详细

Assignment 4 phys248

 Assignment 4

 
Problem 1 requires Lab 11.2, Problem 2 requires Lecture 11.2. Start with Problem 3 and 4.
As part of this assignment you need to add some files you produce. Add these directly to your Exam_Assignment_Quiz along with your copy of this Assignment notebook. Do not change the name of the notebook, and make sure you only have one Assignment 4 notebook file in your repo. Do add the required files with the name exactly as specified.
 
Problem 1
Solve the network from Lab 11.1 along a trajectory (see Lab 11.2), i.e the time evolution of T which you will use as input. Use the same value for 𝜌 as in Lab 11.1. Follow these steps:
 
Read the time and temperature data from the file T-evol.dat but reverse the time direction. That means, read time and temperature arrays but then reverse the direction of the temperature array using array slicing. Make a plot of 𝑇9 vs. log𝑡. 𝑇9 (T9) is temperature in units of 109K.
Create a linear interpolation function called get_T9 that returns the temperature as T9 from an input of time in seconds. Test the function by overplotting a few points to the plot of part 2.1. Test the function get_rates by making a plot of the four rates as a function of T9 in the range of temperatures covered in the trajectory file, and as a function of time covered in the trajectory.
Modify function react_terms from Lab 11.1 (and call it react_terms_t) in two ways. It should use the get_rates subroutine from Lab 11.2 Activity 2 and it should take a molar abundance vector Y as well as the time in seconds as input. Then it needs to use get_T9 to get the temperature for the given time, and then the rates for the temperature obtained using the get_rates function. Use the code from Lab 11.1 Activity 1 to read the initial abundances. Test your function react_terms_t.
Create a modified version of f_rhs called f_rhs_yt that uses react_terms_t and solve the system of network ODEs for the range of 𝑡∈[0.1,104.6]. Plot the evolution of all species mass fractions over log10 of the time, and make sure that the time resolution for plotting the results is about 0.02 dex. Use appropriate spacing of glyphs.
Investigate your solution. One species has a maximum during the evolution. Which one and at which time? One species has a minimum? Which one and at which time?
%pylab ipympl
Problem 2
Search for the global minimum of a function. Consider the function 𝑓(𝑥)=0.4𝑥4+0.2𝑥3−2.5𝑥2−cos(4𝜋𝑥)
Make a plot of the function for 𝑥∈[−3.1,2.9]. The global minimum is clearly near 𝑥≈−2.
Confirm this fact by searching for the global mimum using simulated annealing. Start with 𝑥ini=1.5 with moves (neighbour function) that replace 𝑥→𝑥+𝛿 where 𝛿 is a random number drawn from a Gaussian distribution with mean zero and standard deviation 𝜎. Use an exponential cooling schedule of the form 𝑇=𝑎exp(−𝑏𝑡) with 𝑡∈[0,𝑡end].
Using some guesses for 𝜎, 𝑎, 𝑏 and 𝑡end make a plot of all 𝑥 values as a function of step number with markers only. Add the 𝑥 values that have been used for an update (those 𝑥′ for which 𝑃(𝑥′,𝑥,𝑇)>=𝑟𝑎𝑛𝑑𝑜𝑚()).
Use this plot to systematically adjust the parameters 𝜎, 𝑎, 𝑏 and 𝑡end until you find values that give good answers in the smallest number of steps (the number of steps are the number of intervals of 𝑡). A good choice of parameters should reliable give the correct answer each of 10 subsequent attempts.
Make a plot called global-minimum.png and commit that along with your solution notebook.
Problem 3
3.1
Visualize the Recaman sequence up to 𝑛=66 by plotting a half-circle between 𝑎𝑛 and 𝑎𝑛−1 below the number ray for 𝑛 uneven and above for 𝑛 even. Plot each half circle a different color increasing with 𝑛 along a continuous color map of your choosing.
 
 
3.2
In Lab 10.1 Activity 1 you have calculated the Recaman sequence up to 𝑛=198. Create a wav file called recaman-100.wav that represents the audification of this sequence up to 𝑛=100. Use the function 𝑓(𝑛)=𝑓02𝑛/36 with 𝑓0=466.16/6 to map the integer numbers of the sequence to frequencies. Use a sampling rate of 8192 and make each tone 0.2s long. To test your audio file play a version with a bit longer tone length (e.g. 0.4s) and follow along the figure you created in Lab 10.2 Activitiy 1 (the _music score_) to see if you recognize the Recaman melodie.
 
Note: Make a plot of the frequency mapping function 𝑓0 for the range of integer values that the Recaman series assumes up to 𝑛=100 to convince yourself that the sampling rate is just barely sufficient to cover the highest-pitch tones.
 
Check the size of your recaman-100.wav. It should be well below 1MB. Add the file to your Exam_Assignment_Quiz folder.
Problem 4
4.1
Using your work from Lab 10.1 Activity 2 establish a relationship between the boundary width expressed in the standard deviation of the Gauss fit of the radial derivative of the concentration (see class 10.2) and the grid resolution.
Create a list of cases with heating factor (X_Lfactors) equal to 1000. They all have the time 1360 hours, and there are four of them. Don't create this list by hand, but write code that finds these and arranges the case labels in a list.
Write a loop in which each resolution case is fitted with a Gaussian. Record the sigmas and the grid values in two lists called sigmas and grids.
Make log-log plot of the sigmas vs grids. Interpret the graph in terms of the convergence properties of this metric under grid resolution. What is the true or accurate boundary width?
4.2
Recall that data sets are given for each case and that for some cases there is a profile for more than one time. The following case and time combinations constitute a sequence of profiles for different luminosities or convection driving strength and similar mass-entrainment rates (i.e. the location of the peak in grad(FV) should approximately be at the same radius). The different luminosities are expressed in terms of factors to the nominal heating which represents the heating in a global model that represents best the luminosity in the actual star.
 
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!