File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ def rotation_partition_function(moment_of_inertia: float,
2+ temperature: float) -> float:
3+ """
4+ Calculates the rotational partition
5+ function for linear molecules.
6+
7+ >>> round(rotation_partition_function(1e-46, 300), 4)
8+ 5.9275
9+ >>> round(rotation_partition_function(2e-46, 300), 4)
10+ 11.855
11+ >>> round(rotation_partition_function(-2e-46, 300), 4)
12+ Traceback (most recent call last):
13+ ...
14+ ValueError: Moment of inertia must be positive
15+ >>> round(rotation_partition_function(1e-46, -300), 4)
16+ Traceback (most recent call last):
17+ ...
18+ ValueError: Temperature must be positive
19+ """
20+
21+ if moment_of_inertia <= 0:
22+ raise ValueError("Moment of inertia must be positive")
23+ if temperature <= 0:
24+ raise ValueError("Temperature must be positive")
25+
26+ k_B = 1.380649e-23 # Boltzmann constant
27+ h = 6.62607015e-34 # Planck's constant
28+
29+ return (2 * math.pi * moment_of_inertia * k_B * temperature) / (h ** 2)
30+
31+ if __name__ == "__main__":
32+ import doctest
33+ doctest.testmod(name="rotation_partition_function")
You can’t perform that action at this time.
0 commit comments