From 6f127c6b8d187d8ac247d8a5429bfe7bea8cae49 Mon Sep 17 00:00:00 2001 From: nikhitha79 <115790230+nikhitha79@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:15:39 +0530 Subject: [PATCH 1/2] Create rotational_partition --- physics/rotational_partition | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 physics/rotational_partition diff --git a/physics/rotational_partition b/physics/rotational_partition new file mode 100644 index 000000000000..73095cbbdfeb --- /dev/null +++ b/physics/rotational_partition @@ -0,0 +1,33 @@ +def rotation_partition_function(moment_of_inertia: float, + temperature: float) -> float: + """ + Calculates the rotational partition + function for linear molecules. + + >>> round(rotation_partition_function(1e-46, 300), 4) + 5.9275 + >>> round(rotation_partition_function(2e-46, 300), 4) + 11.855 + >>> round(rotation_partition_function(-2e-46, 300), 4) + Traceback (most recent call last): + ... + ValueError: Moment of inertia must be positive + >>> round(rotation_partition_function(1e-46, -300), 4) + Traceback (most recent call last): + ... + ValueError: Temperature must be positive + """ + + if moment_of_inertia <= 0: + raise ValueError("Moment of inertia must be positive") + if temperature <= 0: + raise ValueError("Temperature must be positive") + + k_B = 1.380649e-23 # Boltzmann constant + h = 6.62607015e-34 # Planck's constant + + return (2 * math.pi * moment_of_inertia * k_B * temperature) / (h ** 2) + +if __name__ == "__main__": + import doctest + doctest.testmod(name="rotation_partition_function") From 8368803dac370f774e48b67c751780c56b1a43ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:47:28 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/rotational_partition | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/rotational_partition b/physics/rotational_partition index 73095cbbdfeb..5dfbb3b73867 100644 --- a/physics/rotational_partition +++ b/physics/rotational_partition @@ -1,7 +1,7 @@ -def rotation_partition_function(moment_of_inertia: float, +def rotation_partition_function(moment_of_inertia: float, temperature: float) -> float: """ - Calculates the rotational partition + Calculates the rotational partition function for linear molecules. >>> round(rotation_partition_function(1e-46, 300), 4)