Question: ( For coding in Python ) We can write the Planck function as: B lambda ( lambda , T ) = 2 hc

(For coding in Python) We can write the Planck function as: B\lambda (\lambda , T)=2hc2\lambda 5(e hc \lambda kT 1)
Wiens Law is an expression indicating the wavelength where this blackbody emission peaks (is highest) for a given temperature: \lambda max = b T (2) where \lambda max is the peak wavelength in meters (m), T is the blackbody temperature in Kelvin (K), and b is Wiens displacement constant equal to 2.898\times 103 m K.
write code that numerically determines the wavelength where the peak of the Planck function occurs for a given temperature.
compare your results to the Wiens Law expression. Equation 1 above will be used in the loop to find wavelength where the blackbody spectrum has its maxiumum value; Use Equation 2 to check the wavelength that your loop identifies. The numerical solution will give you an approximate solution while Wiens law gives an exact solution. While writing code, you should use Wiens law to get an idea of the approximate values the numerical code should give you.
Your program must contain the following:
A variable that represents 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 that temperature variable is set).
A variable representing the initial wavelength guess.
A variable representing the wavelength increment, or step size.
A variable representing the current value of B.
A variable representing the previous value of B (this could be zero at start of loop).
A variable that keeps track ofstep number.
Lists to store the wavelengths and B values. Heres a sketch of the procedure the code should follow to numerically identify the peak of the blackbody function. the code should:
1. Calculate the intensity of light B\lambda (\lambda , T) for a given wavlength (\lambda ) and blackbody temperature (T)
Confirm the calculation of B does the math correctly. For a wavelength of \lambda =700nm (red light) and a temperature of T =6000K (temperature of the Sun), your calculation should yield 2.38\times 1013J/s/sr/m3
2. Be able to start with an initial guess for a wavelength that is close to (but less than) the peak blackbody wavelength.
3. Use while loops to increment the guess for wavelength and recompute B\lambda until finding the turnover point, the point where the value of B\lambda goes from increasing to decreasing.
- Dont use Wiens law to predetermine the peak. The point is to find the peak numerically!
4. Store wavelength and B values in a list to help verify that the algorithm finds the peak.
5. Use a compound conditional statement (Booleans!) to prevent the while loop from taking more than 1000 steps
Answer each question below in its own cell using a combination of code cells and Markdown cells. Its fine to write code to print out the explanation of the answers
1. Using your numerical algorithm, what is the wavelength of peak brightness of a T =12,000 K blackbody in nanometres? Use 10 nm as the initial guess and a step-size of +20 nm.
2. How many iterations did it take for the algorithm to find the blackbody peak?
3. How close is the result to the analytical result (Wiens Law)?
4. To confirm, print your list(s) of wavelength and B values. Use a for loop to print one pair of wavelength and brightness values per line. Make sure the wavelength prints in nanometers with the number taking up at least 5 characters, and with 0 digits after decimal place. Make sure the blackbody emission prints in fixed-point notation with the number taking up at least 20 characters and with 1 digit after the decimal place.
5. In a new code cell, copy and re-run the algorithm for the same temperature, with a step-size of +1 nm. How many iterations did it take to find the peak? How close is the result to Wiens Law now? print your list(s) of wavelength and B values.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!