From d510ad8cbe16369f8ddfe836c4caf568fc56edfc Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" Date: Mon, 16 Nov 2020 16:27:24 -0300 Subject: [PATCH] Improve code with black --- tests/test_core.py | 40 ++- tests/test_rates.py | 34 +- tests/test_thermo_gas.py | 322 ++++++++++------- tests/test_thermo_solv.py | 727 ++++++++++++++++++++++---------------- 4 files changed, 671 insertions(+), 452 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 8770bcbf..c8d1455a 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -159,25 +159,31 @@ def test_private_functions_work(): assert list(core._unparse_reactions([(((1, "A"),), ((1, "B"),), True)])) == [ "A -> B" ] - assert list( - core._unparse_reactions( - [ - (((2, "A"),), ((3, "B"),), True), - (((1, "A"),), ((2, "C"),), True), - (((50, "A"),), ((1, "D"),), True), - ] + assert ( + list( + core._unparse_reactions( + [ + (((2, "A"),), ((3, "B"),), True), + (((1, "A"),), ((2, "C"),), True), + (((50, "A"),), ((1, "D"),), True), + ] + ) ) - ) == ["2 A -> 3 B", "A -> 2 C", "50 A -> D"] - assert list( - core._unparse_reactions( - [ - (((1, "E"), (1, "S")), ((1, "ES"),), True), - (((1, "ES"),), ((1, "E"), (1, "S")), True), - (((1, "ES"),), ((1, "ES‡"),), False), - (((1, "ES‡"),), ((1, "E"), (1, "P")), False), - ] + == ["2 A -> 3 B", "A -> 2 C", "50 A -> D"] + ) + assert ( + list( + core._unparse_reactions( + [ + (((1, "E"), (1, "S")), ((1, "ES"),), True), + (((1, "ES"),), ((1, "E"), (1, "S")), True), + (((1, "ES"),), ((1, "ES‡"),), False), + (((1, "ES‡"),), ((1, "E"), (1, "P")), False), + ] + ) ) - ) == ["E + S -> ES", "ES -> E + S", "ES -> ES‡", "ES‡ -> E + P"] + == ["E + S -> ES", "ES -> E + S", "ES -> ES‡", "ES‡ -> E + P"] + ) assert list( core._unparse_reactions( diff --git a/tests/test_rates.py b/tests/test_rates.py index 2bfc8ca9..5681d4ae 100644 --- a/tests/test_rates.py +++ b/tests/test_rates.py @@ -165,21 +165,27 @@ def test_liquid_viscosities_are_correct(): def test_conversion_of_rate_constants_work(): """Ensure converting reaction rate constants work.""" - assert rates.convert_rate_constant( - 12345e5, - "cm3 mol-1 s-1", - "l mol-1 s-1", - molecularity=2, - temperature=[200, 298.15, 300, 400], - ) == pytest.approx(12345e8) + assert ( + rates.convert_rate_constant( + 12345e5, + "cm3 mol-1 s-1", + "l mol-1 s-1", + molecularity=2, + temperature=[200, 298.15, 300, 400], + ) + == pytest.approx(12345e8) + ) - assert rates.convert_rate_constant( - 12345e10, - "cm3 particle-1 s-1", - "atm-1 s-1", - molecularity=2, - temperature=[200, 298.15, 300, 400], - ) == pytest.approx(13.63e-23 * 12345e10 * np.array([200, 298.15, 300, 400]), 1e-3) + assert ( + rates.convert_rate_constant( + 12345e10, + "cm3 particle-1 s-1", + "atm-1 s-1", + molecularity=2, + temperature=[200, 298.15, 300, 400], + ) + == pytest.approx(13.63e-23 * 12345e10 * np.array([200, 298.15, 300, 400]), 1e-3) + ) def test_conversion_rates_know_about_reaction_order(): diff --git a/tests/test_thermo_gas.py b/tests/test_thermo_gas.py index c4b7e06f..3508a0df 100644 --- a/tests/test_thermo_gas.py +++ b/tests/test_thermo_gas.py @@ -299,12 +299,16 @@ def test_entropy_ideal_monoatomic_gases(): j = np.array([0, 1, 0]) degeneracy = 2 * j + 1 energy = np.array([0.000, 159855.9745, 166277.4403]) - assert _thermo.calc_entropy( - 4.0026, - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) / constants.calorie == pytest.approx(30.13, 1e-3) + assert ( + _thermo.calc_entropy( + 4.0026, + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(30.13, 1e-3) + ) # Ne assert _thermo.calc_entropy( @@ -330,12 +334,16 @@ def test_entropy_ideal_monoatomic_gases(): j = np.array([0, 1, 2, 2, 0]) degeneracy = 2 * j + 1 energy = np.array([0.00000, 16.41671, 43.41350, 10192.66, 21648.02]) - assert _thermo.calc_entropy( - 12.011, - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) / constants.calorie == pytest.approx(37.76, 1e-4) + assert ( + _thermo.calc_entropy( + 12.011, + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(37.76, 1e-4) + ) # Na assert _thermo.calc_entropy( @@ -346,12 +354,16 @@ def test_entropy_ideal_monoatomic_gases(): j = np.array([1 / 2, 3 / 2, 1 / 2]) degeneracy = 2 * j + 1 energy = np.array([0.000, 112.061, 25347.756]) - assert _thermo.calc_entropy( - 26.982, - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) / constants.calorie == pytest.approx(39.30, 1e-4) + assert ( + _thermo.calc_entropy( + 26.982, + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(39.30, 1e-4) + ) # Ag assert _thermo.calc_entropy( @@ -378,11 +390,14 @@ def test_internal_energy_ideal_monoatomic_gases(): j = np.array([0, 1, 0]) degeneracy = 2 * j + 1 energy = np.array([0.000, 159855.9745, 166277.4403]) - assert _thermo.calc_internal_energy( - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) == pytest.approx(3718.44, 1e-5) + assert ( + _thermo.calc_internal_energy( + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + == pytest.approx(3718.44, 1e-5) + ) # Ne, Ar, Kr, Xe assert _thermo.calc_internal_energy(temperature=temperature) == pytest.approx( @@ -393,11 +408,14 @@ def test_internal_energy_ideal_monoatomic_gases(): j = np.array([0, 1, 2, 2, 0]) degeneracy = 2 * j + 1 energy = np.array([0.00000, 16.41671, 43.41350, 10192.66, 21648.02]) - assert _thermo.calc_internal_energy( - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) == pytest.approx(4057.05, 1e-5) + assert ( + _thermo.calc_internal_energy( + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + == pytest.approx(4057.05, 1e-5) + ) # Na assert _thermo.calc_internal_energy( @@ -408,11 +426,14 @@ def test_internal_energy_ideal_monoatomic_gases(): j = np.array([1 / 2, 3 / 2, 1 / 2]) degeneracy = 2 * j + 1 energy = np.array([0.000, 112.061, 25347.756]) - assert _thermo.calc_internal_energy( - energy=energy * 100 * constants.h * constants.c * constants.N_A, - degeneracy=degeneracy, - temperature=temperature, - ) == pytest.approx(4439.68, 1e-6) + assert ( + _thermo.calc_internal_energy( + energy=energy * 100 * constants.h * constants.c * constants.N_A, + degeneracy=degeneracy, + temperature=temperature, + ) + == pytest.approx(4439.68, 1e-6) + ) # Ag assert _thermo.calc_internal_energy( @@ -441,13 +462,17 @@ def test_entropy_ideal_diatomic_gases(): ) symmetry_number = 2 vibfreq = 6125 * constants.k * constants.centi / (constants.h * constants.c) - assert _thermo.calc_entropy( - 2 * 1.008, - moments=[0, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreq, - temperature=temperature, - ) / constants.calorie == pytest.approx(31.2, 1e-3) + assert ( + _thermo.calc_entropy( + 2 * 1.008, + moments=[0, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreq, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(31.2, 1e-3) + ) # O2 degeneracy = 3 @@ -456,14 +481,18 @@ def test_entropy_ideal_diatomic_gases(): ) symmetry_number = 2 vibfreq = 2256 * constants.k * constants.centi / (constants.h * constants.c) - assert _thermo.calc_entropy( - 2 * 15.999, - degeneracy=degeneracy, - moments=[0, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreq, - temperature=temperature, - ) / constants.calorie == pytest.approx(49.0, 1e-5) + assert ( + _thermo.calc_entropy( + 2 * 15.999, + degeneracy=degeneracy, + moments=[0, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreq, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(49.0, 1e-5) + ) # N2 i = (constants.hbar ** 2 / (2.0 * constants.k * 2.88)) / ( @@ -471,13 +500,17 @@ def test_entropy_ideal_diatomic_gases(): ) symmetry_number = 2 vibfreq = 3374 * constants.k * constants.centi / (constants.h * constants.c) - assert _thermo.calc_entropy( - 2 * 14.007, - moments=[0, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreq, - temperature=temperature, - ) / constants.calorie == pytest.approx(45.7, 1e-2) + assert ( + _thermo.calc_entropy( + 2 * 14.007, + moments=[0, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreq, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(45.7, 1e-2) + ) # Cl2 i = (constants.hbar ** 2 / (2.0 * constants.k * 0.351)) / ( @@ -485,13 +518,17 @@ def test_entropy_ideal_diatomic_gases(): ) symmetry_number = 2 vibfreq = 808 * constants.k * constants.centi / (constants.h * constants.c) - assert _thermo.calc_entropy( - 2 * 35.45, - moments=[0, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreq, - temperature=temperature, - ) / constants.calorie == pytest.approx(53.3, 1e-2) + assert ( + _thermo.calc_entropy( + 2 * 35.45, + moments=[0, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreq, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(53.3, 1e-2) + ) # HCl i = (constants.hbar ** 2 / (2.0 * constants.k * 15.02)) / ( @@ -556,12 +593,15 @@ def test_internal_energy_ideal_diatomic_gases(): constants.atomic_mass * constants.angstrom ** 2 ) vibfreq = 2256 * constants.k * constants.centi / (constants.h * constants.c) - assert _thermo.calc_internal_energy( - degeneracy=degeneracy, - moments=[0, i, i], - vibfreqs=vibfreq, - temperature=temperature, - ) == pytest.approx(15580.08, 2e-5) + assert ( + _thermo.calc_internal_energy( + degeneracy=degeneracy, + moments=[0, i, i], + vibfreqs=vibfreq, + temperature=temperature, + ) + == pytest.approx(15580.08, 2e-5) + ) # N2 i = (constants.hbar ** 2 / (2.0 * constants.k * 2.88)) / ( @@ -641,13 +681,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [12.011, 15.999, 15.999], - moments=[0, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(51.0, 1e-2) + assert ( + _thermo.calc_entropy( + [12.011, 15.999, 15.999], + moments=[0, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(51.0, 1e-2) + ) # NH3 ia = (constants.hbar ** 2 / (2.0 * constants.k * 13.6)) / ( @@ -663,13 +707,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [14.007, 1.008, 1.008, 1.008], - moments=[ia, ia, ib], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(46.0, 1e-2) + assert ( + _thermo.calc_entropy( + [14.007, 1.008, 1.008, 1.008], + moments=[ia, ia, ib], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(46.0, 1e-2) + ) # NO2 ia = (constants.hbar ** 2 / (2.0 * constants.k * 11.5)) / ( @@ -688,14 +736,18 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [14.007, 15.999, 15.999], - degeneracy=2, - moments=[ia, ib, ic], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(57.5, 1e-2) + assert ( + _thermo.calc_entropy( + [14.007, 15.999, 15.999], + degeneracy=2, + moments=[ia, ib, ic], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(57.5, 1e-2) + ) # ClO2 ia = (constants.hbar ** 2 / (2.0 * constants.k * 2.50)) / ( @@ -714,13 +766,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [35.45, 15.999, 15.999], - moments=[ia, ib, ic], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(59.6, 1e-2) + assert ( + _thermo.calc_entropy( + [35.45, 15.999, 15.999], + moments=[ia, ib, ic], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(59.6, 1e-2) + ) # CH4 i = (constants.hbar ** 2 / (2.0 * constants.k * 7.54)) / ( @@ -733,13 +789,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [12.011, 1.008, 1.008, 1.008, 1.008], - moments=[i, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(44.5, 1e-3) + assert ( + _thermo.calc_entropy( + [12.011, 1.008, 1.008, 1.008, 1.008], + moments=[i, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(44.5, 1e-3) + ) # CH3Cl ia = (constants.hbar ** 2 / (2.0 * constants.k * 7.32)) / ( @@ -755,13 +815,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [12.011, 1.008, 1.008, 1.008, 35.45], - moments=[ia, ib, ib], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(56.0, 1e-3) + assert ( + _thermo.calc_entropy( + [12.011, 1.008, 1.008, 1.008, 35.45], + moments=[ia, ib, ib], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(56.0, 1e-3) + ) # CCl4 i = (constants.hbar ** 2 / (2.0 * constants.k * 0.0823)) / ( @@ -774,13 +838,17 @@ def test_entropy_ideal_polyatomic_gases(): * constants.centi / (constants.h * constants.c) ) - assert _thermo.calc_entropy( - [12.011, 35.45, 35.45, 35.45, 35.45], - moments=[i, i, i], - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(73.9, 1e-2) + assert ( + _thermo.calc_entropy( + [12.011, 35.45, 35.45, 35.45, 35.45], + moments=[i, i, i], + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(73.9, 1e-2) + ) # C6H6 data = logfiles["symmetries"]["benzene"] @@ -789,13 +857,17 @@ def test_entropy_ideal_polyatomic_gases(): assert point_group == "D6h" symmetry_number = coords.symmetry_number(point_group) vibfreqs = np.asanyarray(data.vibfreqs) - assert _thermo.calc_entropy( - data.atommasses, - moments=moments, - symmetry_number=symmetry_number, - vibfreqs=vibfreqs, - temperature=temperature, - ) / constants.calorie == pytest.approx(64.4, 1e-2) + assert ( + _thermo.calc_entropy( + data.atommasses, + moments=moments, + symmetry_number=symmetry_number, + vibfreqs=vibfreqs, + temperature=temperature, + ) + / constants.calorie + == pytest.approx(64.4, 1e-2) + ) def test_internal_energy_ideal_polyatomic_gases(): diff --git a/tests/test_thermo_solv.py b/tests/test_thermo_solv.py index 99d24a50..4bef71d2 100644 --- a/tests/test_thermo_solv.py +++ b/tests/test_thermo_solv.py @@ -245,20 +245,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(144.80408548676766, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(94.56871145467743, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(37.36, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(94.56871145467743, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(37.36, 5e-2) + ) # CH3OH data = logfiles["symmetries"]["methanol"] @@ -277,20 +283,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(151.98582061379608, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(105.02817010903456, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(45.85, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(105.02817010903456, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(45.85, 1e-2) + ) # C2H5OH data = logfiles["symmetries"]["ethanol"] @@ -309,20 +321,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(156.51420201431782, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(111.58706012673835, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(51.01, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(111.58706012673835, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(51.01, 5e-2) + ) # 1-C3H7OH data = logfiles["symmetries"]["1-propanol"] @@ -341,20 +359,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(159.8292158120477, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(116.44404809399771, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(55.70, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(116.44404809399771, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(55.70, 1e-2) + ) # 2-C3H7OH data = logfiles["symmetries"]["2-propanol"] @@ -373,20 +397,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(159.8292158120477, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(116.44717525933929, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(46.81, 1.9e-1) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(116.44717525933929, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(46.81, 1.9e-1) + ) # 1-C4H9OH data = logfiles["symmetries"]["1-butanol"] @@ -405,20 +435,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(162.4455600896596, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(120.30330699244473, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(59.90, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(120.30330699244473, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(59.90, 5e-2) + ) # 2-C4H9OH data = logfiles["symmetries"]["2-butanol"] @@ -437,20 +473,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(162.4455600896596, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(120.30491171022815, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(51.64, 1.5e-1) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(120.30491171022815, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(51.64, 1.5e-1) + ) # i-C4H9OH data = logfiles["symmetries"]["2-methyl-2-propanol"] @@ -469,20 +511,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(162.4455600896596, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(120.29352768299235, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(58.71, 6e-3) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(120.29352768299235, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(58.71, 6e-3) + ) # HCOOH data = logfiles["symmetries"]["formic-acid"] @@ -501,20 +549,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(156.50228474338718, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(109.8726286196741, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(51.45, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(109.8726286196741, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(51.45, 5e-2) + ) # CH3COOH data = logfiles["symmetries"]["acetic-acid"] @@ -533,20 +587,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(159.820081168819, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(115.13015825195785, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(56.52, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(115.13015825195785, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(56.52, 5e-2) + ) # CH3CN data = logfiles["symmetries"]["acetonitrile"] @@ -565,20 +625,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(155.0765105631046, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(109.28222352094771, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(51.25, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(109.28222352094771, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(51.25, 5e-2) + ) # CH3NO2 data = logfiles["symmetries"]["nitromethane"] @@ -597,20 +663,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(160.02360092304738, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(114.90481716308736, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(56.34, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(114.90481716308736, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(56.34, 5e-2) + ) # Acetone data = logfiles["symmetries"]["acetone"] @@ -629,20 +701,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(159.4036577560442, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(115.54256726917262, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(55.01, 5e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(115.54256726917262, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(55.01, 5e-2) + ) # DMSO data = logfiles["symmetries"]["dimethyl-sulfoxide"] @@ -661,20 +739,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(163.10201307782876, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(119.86466911598932, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(60.73, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(119.86466911598932, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(60.73, 1e-2) + ) # THF data = logfiles["symmetries"]["tetrahydrofuran"] @@ -693,20 +777,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(162.10165626567044, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(119.25508474102487, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(57.82, 2e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(119.25508474102487, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(57.82, 2e-2) + ) # Benzene data = logfiles["symmetries"]["benzene"] @@ -725,20 +815,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(163.09961840530607, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(120.42382713494072, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(74.42, 2e-1) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(120.42382713494072, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(74.42, 2e-1) + ) # CCl4 data = logfiles["symmetries"]["tetrachloromethane"] @@ -757,20 +853,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(171.5508534254953, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(129.19786258624222, 5e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(61.39, 2e-1) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(129.19786258624222, 5e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(61.39, 2e-1) + ) # C5H12 data = logfiles["symmetries"]["n-pentane"] @@ -789,20 +891,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(162.10926422571157, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(120.50548449806315, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(58.84, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(120.50548449806315, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(58.84, 1e-2) + ) # C6H14 data = logfiles["symmetries"]["n-hexane"] @@ -821,20 +929,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(164.3249077891098, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(123.65659036939897, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(61.98, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(123.65659036939897, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(61.98, 1e-2) + ) # cyc-C6H12 data = logfiles["symmetries"]["cyclohexane-chair"] @@ -853,20 +967,26 @@ def test_translational_entropy_liquid_phase(): assert _thermo.calc_trans_entropy( data.atommasses, data.atomnos, data.atomcoords ) == pytest.approx(164.02968518741582, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="garza", - ) == pytest.approx(122.79118854674996, 1e-2) - assert _thermo.calc_trans_entropy( - data.atommasses, - data.atomnos, - data.atomcoords, - environment="water", - method="izato", - ) == pytest.approx(59.83, 1e-2) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="garza", + ) + == pytest.approx(122.79118854674996, 1e-2) + ) + assert ( + _thermo.calc_trans_entropy( + data.atommasses, + data.atomnos, + data.atomcoords, + environment="water", + method="izato", + ) + == pytest.approx(59.83, 1e-2) + ) def test_sackur_tetrode_given_free_volumes(): @@ -995,22 +1115,37 @@ def test_change_reference_state_works_for_gas_to_liquid_standard_states(): # different reference pressures temperature = 298.15 - assert temperature * _thermo.change_reference_state( - 1.0 / constants.liter, - 1.0 / _thermo.molar_volume(temperature, constants.atm), - temperature=temperature, - ) / constants.kcal == pytest.approx(1.89, 1e-2) - assert temperature * _thermo.change_reference_state( - 1.0 / constants.liter, - 1.0 / _thermo.molar_volume(temperature, constants.bar), - temperature=temperature, - ) / constants.kcal == pytest.approx(1.90, 1e-2) + assert ( + temperature + * _thermo.change_reference_state( + 1.0 / constants.liter, + 1.0 / _thermo.molar_volume(temperature, constants.atm), + temperature=temperature, + ) + / constants.kcal + == pytest.approx(1.89, 1e-2) + ) + assert ( + temperature + * _thermo.change_reference_state( + 1.0 / constants.liter, + 1.0 / _thermo.molar_volume(temperature, constants.bar), + temperature=temperature, + ) + / constants.kcal + == pytest.approx(1.90, 1e-2) + ) # volumes instead of concentrations temperature = 298.15 - assert temperature * _thermo.change_reference_state( - constants.liter, - _thermo.molar_volume(temperature, constants.atm), - sign=-1, - temperature=temperature, - ) / constants.kcal == pytest.approx(1.89, 1e-2) + assert ( + temperature + * _thermo.change_reference_state( + constants.liter, + _thermo.molar_volume(temperature, constants.atm), + sign=-1, + temperature=temperature, + ) + / constants.kcal + == pytest.approx(1.89, 1e-2) + )