|
| 1 | +""" |
| 2 | +The photoelectric effect is the emission of electrons when electromagnetic radiation , |
| 3 | +such as light, hits a material. Electrons emitted in this manner are called |
| 4 | +photoelectrons. |
| 5 | +
|
| 6 | +In 1905, Einstein proposed a theory of the photoelectric effect using a concept that |
| 7 | +light consists of tiny packets of energy known as photons or light quanta. Each packet |
| 8 | +carries energy hv that is proportional to the frequency v of the corresponding |
| 9 | +electromagnetic wave. The proportionality constant h has become known as the |
| 10 | +Planck constant. In the range of kinetic energies of the electrons that are removed from |
| 11 | +their varying atomic bindings by the absorption of a photon of energy hv, the highest |
| 12 | +kinetic energy K_max is : |
| 13 | +
|
| 14 | +K_max = hv-W |
| 15 | +
|
| 16 | +Here, W is the minimum energy required to remove an electron from the surface of the |
| 17 | +material. It is called the work function of the surface |
| 18 | +
|
| 19 | +Reference: https://en.wikipedia.org/wiki/Photoelectric_effect |
| 20 | +
|
| 21 | +""" |
| 22 | + |
| 23 | +PLANCK_CONSTANT_JS = 6.6261 * pow(10, -34) # in SI (Js) |
| 24 | +PLANCK_CONSTANT_EVS = 4.1357 * pow(10, -15) # in eVs |
| 25 | + |
| 26 | + |
| 27 | +def maximum_kinetic_energy( |
| 28 | + frequency: float, work_function: float, in_ev: bool = False |
| 29 | +) -> float: |
| 30 | + """ |
| 31 | + Calculates the maximum kinetic energy of emitted electron from the surface. |
| 32 | + if the maximum kinetic energy is zero then no electron will be emitted |
| 33 | + or given electromagnetic wave frequency is small. |
| 34 | +
|
| 35 | + frequency (float): Frequency of electromagnetic wave. |
| 36 | + work_function (float): Work function of the surface. |
| 37 | + in_ev (optional)(bool): Pass True if values are in eV. |
| 38 | +
|
| 39 | + Usage example: |
| 40 | + >>> maximum_kinetic_energy(1000000,2) |
| 41 | + 0 |
| 42 | + >>> maximum_kinetic_energy(1000000,2,True) |
| 43 | + 0 |
| 44 | + >>> maximum_kinetic_energy(10000000000000000,2,True) |
| 45 | + 39.357000000000006 |
| 46 | + >>> maximum_kinetic_energy(-9,20) |
| 47 | + Traceback (most recent call last): |
| 48 | + ... |
| 49 | + ValueError: Frequency can't be negative. |
| 50 | +
|
| 51 | + >>> maximum_kinetic_energy(1000,"a") |
| 52 | + Traceback (most recent call last): |
| 53 | + ... |
| 54 | + TypeError: unsupported operand type(s) for -: 'float' and 'str' |
| 55 | +
|
| 56 | + """ |
| 57 | + if frequency < 0: |
| 58 | + raise ValueError("Frequency can't be negative.") |
| 59 | + if in_ev: |
| 60 | + return max(PLANCK_CONSTANT_EVS * frequency - work_function, 0) |
| 61 | + return max(PLANCK_CONSTANT_JS * frequency - work_function, 0) |
| 62 | + |
| 63 | + |
| 64 | +if __name__ == "__main__": |
| 65 | + import doctest |
| 66 | + |
| 67 | + doctest.testmod() |
0 commit comments