From f2c93401c7dcb2660534c708d47a90dc0a537262 Mon Sep 17 00:00:00 2001 From: Raghav <83136390+Raghav-Bell@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:10:31 +0530 Subject: [PATCH 1/4] Added Photoelectric effect equation Photoelectric effect is one of the demonstration of quanta of energy. --- physics/photoelectric_effect.py | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 physics/photoelectric_effect.py diff --git a/physics/photoelectric_effect.py b/physics/photoelectric_effect.py new file mode 100644 index 000000000000..4a5d3ff332d7 --- /dev/null +++ b/physics/photoelectric_effect.py @@ -0,0 +1,67 @@ +""" +The photoelectric effect is the emission of electrons when electromagnetic radiation , +such as light, hits a material. Electrons emitted in this manner are called +photoelectrons. + +In 1905, Einstein proposed a theory of the photoelectric effect using a concept that +light consists of tiny packets of energy known as photons or light quanta. Each packet +carries energy hv that is proportional to the frequency v of the corresponding +electromagnetic wave. The proportionality constant h has become known as the +Planck constant. In the range of kinetic energies of the electrons that are removed from +their varying atomic bindings by the absorption of a photon of energy hv, the highest +kinetic energy K_max is : + +K_max = hv-W + +Here, W is the minimum energy required to remove an electron from the surface of the +material. It is called the work function of the surface + +Reference: https://en.wikipedia.org/wiki/Photoelectric_effect + +""" + +PLANCK_CONSTANT_JS = 6.6261 * pow(10, -34) # in SI (Js) +PLANCK_CONSTANT_EVS = 4.1357 * pow(10, -15) # in eVs + + +def maximum_kinetic_energy( + frequency: float, work_function: float, in_ev: bool = False +) -> float: + """ + Calculates the maximum kinetic energy of emitted electron from the surface. + if the maximum kinetic energy is zero then no electron will be emitted + or given electromagnetic wave frequency is small. + + frequency (float): Frequency of electromagnetic wave. + work_function (float): Work function of the surface. + in_ev (optional)(bool): Pass True if values are in eV. + + Usage example: + >>> maximum_kinetic_energy(1000000,2) + 0 + >>> maximum_kinetic_energy(1000000,2,True) + 0 + >>> maximum_kinetic_energy(10000000000000000,2,True) + 39.357000000000006 + >>> maximum_kinetic_energy(-9,20) + Traceback (most recent call last): + ... + ValueError: Frequency can't be negative. + + >>> maximum_kinetic_energy(1000,"a") + Traceback (most recent call last): + ... + TypeError: unsupported operand type(s) for -: 'float' and 'str' + + """ + if frequency < 0: + raise ValueError("Frequency can't be negative.") + if in_ev: + return max(PLANCK_CONSTANT_EVS * frequency - work_function, 0) + return max(PLANCK_CONSTANT_JS * frequency - work_function, 0) + + +if __name__ == "__main__": + import doctest + + doctest.testmod(name="maximum_kinetic_energy") From 243b9d11968a38c9cef33cd877d7054700c7f73c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 03:48:34 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/photoelectric_effect.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/physics/photoelectric_effect.py b/physics/photoelectric_effect.py index 4a5d3ff332d7..d00d4c7622ee 100644 --- a/physics/photoelectric_effect.py +++ b/physics/photoelectric_effect.py @@ -1,20 +1,20 @@ """ The photoelectric effect is the emission of electrons when electromagnetic radiation , -such as light, hits a material. Electrons emitted in this manner are called +such as light, hits a material. Electrons emitted in this manner are called photoelectrons. -In 1905, Einstein proposed a theory of the photoelectric effect using a concept that -light consists of tiny packets of energy known as photons or light quanta. Each packet +In 1905, Einstein proposed a theory of the photoelectric effect using a concept that +light consists of tiny packets of energy known as photons or light quanta. Each packet carries energy hv that is proportional to the frequency v of the corresponding -electromagnetic wave. The proportionality constant h has become known as the +electromagnetic wave. The proportionality constant h has become known as the Planck constant. In the range of kinetic energies of the electrons that are removed from -their varying atomic bindings by the absorption of a photon of energy hv, the highest +their varying atomic bindings by the absorption of a photon of energy hv, the highest kinetic energy K_max is : K_max = hv-W -Here, W is the minimum energy required to remove an electron from the surface of the -material. It is called the work function of the surface +Here, W is the minimum energy required to remove an electron from the surface of the +material. It is called the work function of the surface Reference: https://en.wikipedia.org/wiki/Photoelectric_effect From e49c6497183487b7fad908bb7ef0ab926147041d Mon Sep 17 00:00:00 2001 From: Raghav <83136390+Raghav-Bell@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:26:08 +0530 Subject: [PATCH 3/4] fixed doctest Co-authored-by: Rohan Anand <96521078+rohan472000@users.noreply.github.com> --- physics/photoelectric_effect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/physics/photoelectric_effect.py b/physics/photoelectric_effect.py index d00d4c7622ee..18c1672b6140 100644 --- a/physics/photoelectric_effect.py +++ b/physics/photoelectric_effect.py @@ -64,4 +64,5 @@ def maximum_kinetic_energy( if __name__ == "__main__": import doctest - doctest.testmod(name="maximum_kinetic_energy") + doctest.testmod() + From b8b58cdcbe642cd6908c005b36a7e44d0ed7bde3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:57:08 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/photoelectric_effect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/physics/photoelectric_effect.py b/physics/photoelectric_effect.py index 18c1672b6140..3a0138ffe045 100644 --- a/physics/photoelectric_effect.py +++ b/physics/photoelectric_effect.py @@ -65,4 +65,3 @@ def maximum_kinetic_energy( import doctest doctest.testmod() -