MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / maximum_kinetic_energy

Function maximum_kinetic_energy

physics/photoelectric_effect.py:27–61  ·  view source on GitHub ↗

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)

(
    frequency: float, work_function: float, in_ev: bool = False
)

Source from the content-addressed store, hash-verified

25
26
27def 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
64if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected