Question
PYTHON 3 The questions needed for answer are all the wa at the bottom. The Planck Function Revisited (Code 60%, Questions 40%) Recall the Planck
PYTHON 3
The questions needed for answer are all the wa at the bottom.
The Planck Function Revisited (Code 60%, Questions 40%)
Recall the Planck function:
B(,T)=2hc^2/^5(e(hc/kT)1) where h is Plancks constant, c is the speed of light, k is Boltzmanns constant, is the emission wavelength,
and T is the temperature of the blackbody.
Wiens Law:
max = b/T
where max is the peak wavelength in meters (m), T is the blackbody temperature in Kelvin (K), b is Wiens displacement constant equal to 2.898 103m K
Write a program that determines where the peak of the Planck function occurs in wavelength for a given temperature.
You cannot use the 'max' function in Python. You are essentially writing your own max function.
Procedure
1. Supply an initial guess for the wavelength where the blackbody peak occurs.
2. Use a while loop to increment your guess for the wavelength until you find the turnover point, i.e. the point where the value of B goes from increasing to decreasing.
3. Store the wavelength and B values in a list (or two) to help you verify that your algorithm finds the
peak.
4. Use a compound conditional statement to prevent the while loop from taking more than 100 steps.
Your program must also contain the following:
1. A variable temp representing the blackbody temperature, so your peak-finding algorithm can be applied
to different blackbodies by modifying a single line of code (i.e. the line where the value of temp is set).
2. A variable representing the wavelength increment, or step-size.
3. A variable maxIter, which determines the maximum number of iterations.
Questions
1. What is the peak wavelength of a T = 1.3 104 K blackbody in nanometers. Use 200 nm as your initial guess, and a step-size of +5 nm. Print your list(s) of wavelength and B values.
2. How many iterations did it take for your algorithm to find it?
3. How close is your result to the analytical result (Wiens Law)?
4. Re-run your algorithm with a step-size of 1 nm. How many iterations did it take to find the peak? How close is your result to Wiens Law now? Again, print your list(s) of wavelength and B values.
B (, T)2h@ B (, T)2h@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