Skip to content

Commit 7d363db

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a1ff9a9 commit 7d363db

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

physics/Bragg_angle.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
import math
22

3+
34
def bragg_angle(distance: float, order: int, wavelength: float) -> float:
45
"""
56
Calculate the Bragg diffraction angle using the formula:
67
sin(θ) = (n * λ) / (2 * d)
7-
8+
89
Parameters:
910
distance d (float): Distance between crystal planes (in meters).
1011
order n (int): Order of reflection.
1112
wavelength λ (float): Wavelength of the radiation (in meters).
12-
13+
1314
Returns:
1415
float: The Bragg diffraction angle θ in degrees, rounded to the specified number of decimal places.
15-
16+
1617
Examples:
1718
>>> bragg_angle(2.2e-10, 1, 2.2e-10)
1819
30.0
19-
20+
2021
>>> bragg_angle(5e-10, 2, 1e-10)
2122
11.5
22-
23+
2324
>>> bragg_angle(4e-10, 1, 4e-10)
2425
30.0
25-
26+
2627
# Test case for an invalid sine value (out of range)
2728
>>> bragg_angle(1e-10, 2, 3e-10)
2829
Traceback (most recent call last):
@@ -36,6 +37,8 @@ def bragg_angle(distance: float, order: int, wavelength: float) -> float:
3637
theta_degrees = math.degrees(theta_radians)
3738
return round(theta_degrees, 1)
3839

40+
3941
if __name__ == "__main__":
4042
import doctest
43+
4144
doctest.testmod(verbose=True)

0 commit comments

Comments
 (0)