From bc90243967071cf96135a739488edb926198f878 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 9 Nov 2024 23:22:40 +0000 Subject: [PATCH 01/11] refactor: Improve code readability and reducing code duplications - Using tuples to reperesent the non-diagonal elements via dictionary --- tanabesugano/matrices.py | 1801 ++++++++++++++++---------------------- 1 file changed, 733 insertions(+), 1068 deletions(-) diff --git a/tanabesugano/matrices.py b/tanabesugano/matrices.py index d37cf92..47d7821 100644 --- a/tanabesugano/matrices.py +++ b/tanabesugano/matrices.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Dict +from typing import Dict, List, Tuple try: @@ -31,7 +31,7 @@ class LigandFieldTheory: """Parent class for ligand field theory configurations.""" def __init__(self, Dq: float, B: float, C: float) -> None: - """Initializes the configuration with given parameters. + """Initialize the configuration with given parameters. Args: dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -65,6 +65,20 @@ def solver(self) -> Dict[str, Float64Array]: msg = "Subclasses should implement this method." raise NotImplementedError(msg) + def construct_matrix( + self, + diag_elements: List[float], + off_diag_elements: Dict[Tuple[int, int], float] + ) -> Float64Array: + """Constructs a symmetric matrix from diagonal and off-diagonal elements.""" + size = len(diag_elements) + matrix = np.zeros((size, size)) + np.fill_diagonal(matrix, diag_elements) + for (i, j), value in off_diag_elements.items(): + matrix[i, j] = value + matrix[j, i] = value # Assuming the matrix is symmetric + return matrix + class d2(LigandFieldTheory): """Class representing the d2 configuration in ligand field theory. @@ -82,55 +96,49 @@ def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3801.0) -> None super().__init__(Dq, B, C) def A_1_1_states(self) -> Float64Array: - """Calculate the A_1_1 states.""" - # Diagonal elements - AA = -8 * self.Dq + 10 * self.B + 5 * self.C - BB = +12 * self.Dq + 8 * self.B + 4 * self.C - - # Non-diagonal elements - AB = BA = _sqrt6 * (2 * self.B + self.C) - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -8 * self.Dq + 10 * self.B + 5 * self.C, + +12 * self.Dq + 8 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): _sqrt6 * (2 * self.B + self.C) + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_states(self) -> Float64Array: - """Calculate the E_1 states.""" - # Diagonal elements - AA = -8 * self.Dq + self.B + 2 * self.C - BB = +12 * self.Dq + 2 * self.C - - # Non-diagonal elements - AB = BA = -_2sqrt3 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -8 * self.Dq + self.B + 2 * self.C, + +12 * self.Dq + 2 * self.C + ] + off_diag_elements = { + (0, 1): -_2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self) -> Float64Array: """Calculate the T_1_2 states.""" - # Diagonal elements - AA = -8 * self.Dq + self.B + 2 * self.C - BB = +2 * self.Dq + 2 * self.C - - # Non-diagonal elements - AB = BA = +_2sqrt3 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -8 * self.Dq + self.B + 2 * self.C, + +2 * self.Dq + 2 * self.C + ] + off_diag_elements = { + (0, 1): +_2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_1_states(self) -> Float64Array: """Calculate the T_3_1 states.""" - # Diagonal elements - AA = -8 * self.Dq - 5 * self.B - BB = +2 * self.Dq + 4 * self.B - - # Non-diagonal elements - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -8 * self.Dq - 5 * self.B, + +2 * self.Dq + 4 * self.B + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def solver(self) -> Dict[str, Float64Array]: @@ -180,111 +188,81 @@ def __init__(self, Dq: float = 0.0, B: float = 918.0, C: float = 4133.0) -> None def T_2_2_states(self) -> Float64Array: """Calculate the T_2_2 states.""" - # Diagonal elements - AA = -12 * self.Dq + 5 * self.C - BB = -2 * self.Dq - 6 * self.B + 3 * self.C - CC = -2 * self.Dq + 4 * self.B + 3 * self.C - DD = +8 * self.Dq + 6 * self.B + 5 * self.C - EE = +8 * self.Dq - 2 * self.B + 3 * self.C - - # Non-diagonal elements - AB = BA = -_3sqrt3 * self.B - AC = CA = -5 * _sqrt3 * self.B - AD = DA = 4 * self.B + 2 * self.C - AE = EA = 2 * self.B - - BC = CB = 3 * self.B - BD = DB = -_3sqrt3 * self.B - BE = EB = -_3sqrt3 * self.B - - CD = DC = -_sqrt3 * self.B - CE = EC = +_sqrt3 * self.B - - DE = ED = 10 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + -12 * self.Dq + 5 * self.C, + -2 * self.Dq - 6 * self.B + 3 * self.C, + -2 * self.Dq + 4 * self.B + 3 * self.C, + +8 * self.Dq + 6 * self.B + 5 * self.C, + +8 * self.Dq - 2 * self.B + 3 * self.C + ] + off_diag_elements = { + (0, 1): -_3sqrt3 * self.B, + (0, 2): -5 * _sqrt3 * self.B, + (0, 3): 4 * self.B + 2 * self.C, + (0, 4): 2 * self.B, + (1, 2): 3 * self.B, + (1, 3): -_3sqrt3 * self.B, + (1, 4): -_3sqrt3 * self.B, + (2, 3): -_sqrt3 * self.B, + (2, 4): +_sqrt3 * self.B, + (3, 4): 10 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_2_1_states(self) -> Float64Array: """Calculate the T_2_1 states.""" - # Diagonal elements - AA = -12 * self.Dq - 6 * self.B + 3 * self.C - BB = -2 * self.Dq + 3 * self.C - CC = -2 * self.Dq - 6 * self.B + 3 * self.C - DD = +8 * self.Dq - 6 * self.B + 3 * self.C - EE = +8 * self.Dq - 2 * self.B + 3 * self.C - - # Non-diagonal elements - AB = BA = -3 * self.B - AC = CA = +3 * self.B - AD = DA = 0.0 - AE = EA = -_2sqrt3 * self.B - - BC = CB = -3 * self.B - BD = DB = +3 * self.B - BE = EB = _3sqrt3 * self.B - - CD = DC = -3 * self.B - CE = EC = -_sqrt3 * self.B - - DE = ED = _2sqrt3 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + -12 * self.Dq - 6 * self.B + 3 * self.C, + -2 * self.Dq + 3 * self.C, + -2 * self.Dq - 6 * self.B + 3 * self.C, + +8 * self.Dq - 6 * self.B + 3 * self.C, + +8 * self.Dq - 2 * self.B + 3 * self.C + ] + off_diag_elements = { + (0, 1): -3 * self.B, + (0, 2): +3 * self.B, + (0, 3): 0.0, + (0, 4): -_2sqrt3 * self.B, + (1, 2): -3 * self.B, + (1, 3): +3 * self.B, + (1, 4): _3sqrt3 * self.B, + (2, 3): -3 * self.B, + (2, 4): -_sqrt3 * self.B, + (3, 4): _2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_2_states(self) -> Float64Array: """Calculate the E_2 states.""" - # Diagonal elements - AA = -12 * self.Dq - 6 * self.B + 3 * self.C - BB = -2 * self.Dq + 8 * self.B + 6 * self.C - CC = -2 * self.Dq - 1 * self.B + 3 * self.C - DD = +18 * self.Dq - 8 * self.B + 4 * self.C - - # Non-diagonal elements - AB = BA = -6 * _sqrt2 * self.B - AC = CA = -_3sqrt2 * self.B - AD = DA = 0.0 - - BC = CB = 10 * self.B - BD = DB = +_sqrt3 * (2 * self.B + self.C) - - CD = DC = _2sqrt3 * self.B - - states = np.array( - [[AA, AB, AC, AD], [BA, BB, BC, BD], [CA, CB, CC, CD], [DA, DB, DC, DD]], - ) - + diag_elements = [ + -12 * self.Dq - 6 * self.B + 3 * self.C, + -2 * self.Dq + 8 * self.B + 6 * self.C, + -2 * self.Dq - 1 * self.B + 3 * self.C, + +18 * self.Dq - 8 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): -6 * _sqrt2 * self.B, + (0, 2): -_3sqrt2 * self.B, + (0, 3): 0.0, + (1, 2): 10 * self.B, + (1, 3): +_sqrt3 * (2 * self.B + self.C), + (2, 3): _2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_1_states(self) -> Float64Array: """Calculate the T_4_1 states.""" - # Diagonal elements - AA = -2 * self.Dq - 3 * self.B - BB = +8 * self.Dq - 12 * self.B - - # Non-diagonal elements - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -2 * self.Dq - 3 * self.B, + +8 * self.Dq - 12 * self.B + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def solver(self) -> Dict[str, Float64Array]: @@ -336,284 +314,207 @@ def __init__(self, Dq: float = 0.0, B: float = 965.0, C: float = 4449.0) -> None super().__init__(Dq, B, C) def T_3_1_states(self) -> Float64Array: - """Calculatee the T_3_1 states.""" - # Diagonal elements - AA = -16 * self.Dq - 15 * self.B + 5 * self.C - BB = -6 * self.Dq - 11 * self.B + 4 * self.C - CC = -6 * self.Dq - 3 * self.B + 6 * self.C - DD = +4 * self.Dq - self.B + 6 * self.C - EE = +4 * self.Dq - 9 * self.B + 4 * self.C - FF = +4 * self.Dq - 11 * self.B + 4 * self.C - GG = +14 * self.Dq - 16 * self.B + 5 * self.C - - # Non-diagonal elements - AB = BA = -_sqrt6 * self.B - AC = CA = -_3sqrt2 * self.B - AD = DA = _sqrt2 * (2 * self.B + self.C) - AE = EA = -_2sqrt2 * self.B - AF = FA = 0.0 - AG = GA = 0.0 - - BC = CB = 5 * _sqrt3 * self.B - BD = DB = _sqrt3 * self.B - BE = EB = -_sqrt3 * self.B - BF = FB = 3 * self.B - BG = GB = _sqrt6 * self.B - - CD = DC = -3 * self.B - CE = EC = -3 * self.B - CF = FC = 5 * _sqrt3 * self.B - CG = GC = _sqrt2 * (self.B + self.C) - - DE = ED = -10 * self.B - DF = FD = 0.0 - DG = GD = _3sqrt2 * self.B - - EF = FE = -2 * _sqrt3 * self.B - EG = GE = -_3sqrt2 * self.B - - FG = GF = _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG], - [BA, BB, BC, BD, BE, BF, BG], - [CA, CB, CC, CD, CE, CF, CG], - [DA, DB, DC, DD, DE, DF, DG], - [EA, EB, EC, ED, EE, EF, EG], - [FA, FB, FC, FD, FE, FF, FG], - [GA, GB, GC, GD, GE, GF, GG], - ], - ) - + """Calculate the T_3_1 states.""" + diag_elements = [ + -16 * self.Dq - 15 * self.B + 5 * self.C, + -6 * self.Dq - 11 * self.B + 4 * self.C, + -6 * self.Dq - 3 * self.B + 6 * self.C, + +4 * self.Dq - self.B + 6 * self.C, + +4 * self.Dq - 9 * self.B + 4 * self.C, + +4 * self.Dq - 11 * self.B + 4 * self.C, + +14 * self.Dq - 16 * self.B + 5 * self.C + ] + off_diag_elements = { + (0, 1): -_sqrt6 * self.B, + (0, 2): -_3sqrt2 * self.B, + (0, 3): _sqrt2 * (2 * self.B + self.C), + (0, 4): -_2sqrt2 * self.B, + (0, 5): 0.0, + (0, 6): 0.0, + (1, 2): 5 * _sqrt3 * self.B, + (1, 3): _sqrt3 * self.B, + (1, 4): -_sqrt3 * self.B, + (1, 5): 3 * self.B, + (1, 6): _sqrt6 * self.B, + (2, 3): -3 * self.B, + (2, 4): -3 * self.B, + (2, 5): 5 * _sqrt3 * self.B, + (2, 6): _sqrt2 * (self.B + self.C), + (3, 4): -10 * self.B, + (3, 5): 0.0, + (3, 6): _3sqrt2 * self.B, + (4, 5): -2 * _sqrt3 * self.B, + (4, 6): -_3sqrt2 * self.B, + (5, 6): _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self) -> Float64Array: """Calculate the T_1_2 states.""" - # Diagonal elements - AA = -16 * self.Dq - 9 * self.B + 7 * self.C - BB = -6 * self.Dq - 9 * self.B + 6 * self.C - CC = -6 * self.Dq + 3 * self.B + 8 * self.C - DD = +4 * self.Dq - 9 * self.B + 6 * self.C - EE = +4 * self.Dq - 3 * self.B + 6 * self.C - FF = +4 * self.Dq + 5 * self.B + 8 * self.C - GG = +14 * self.Dq + 7 * self.C - - # Non-diagonal elements - AB = BA = _3sqrt2 * self.B - AC = CA = -5 * _sqrt6 * self.B - AD = DA = 0.0 - AE = EA = -_2sqrt2 * self.B - AF = FA = _sqrt2 * (2 * self.B + self.C) - AG = GA = 0.0 - - BC = CB = -5 * _sqrt3 * self.B - BD = DB = 3 * self.B - BE = EB = -3 * self.B - BF = FB = -3 * self.B - BG = GB = -_sqrt6 * self.B - - CD = DC = -3 * _sqrt3 * self.B - CE = EC = 5 * _sqrt3 * self.B - CF = FC = -5 * _sqrt3 * self.B - CG = GC = _sqrt2 * (3 * self.B + self.C) - - DE = ED = -6 * self.B - DF = FD = 0.0 - DG = GD = -_3sqrt6 * self.B - - EF = FE = -10 * self.B - EG = GE = _sqrt6 * self.B - - FG = GF = _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG], - [BA, BB, BC, BD, BE, BF, BG], - [CA, CB, CC, CD, CE, CF, CG], - [DA, DB, DC, DD, DE, DF, DG], - [EA, EB, EC, ED, EE, EF, EG], - [FA, FB, FC, FD, FE, FF, FG], - [GA, GB, GC, GD, GE, GF, GG], - ], - ) - + diag_elements = [ + -16 * self.Dq - 9 * self.B + 7 * self.C, + -6 * self.Dq - 9 * self.B + 6 * self.C, + -6 * self.Dq + 3 * self.B + 8 * self.C, + +4 * self.Dq - 9 * self.B + 6 * self.C, + +4 * self.Dq - 3 * self.B + 6 * self.C, + +4 * self.Dq + 5 * self.B + 8 * self.C, + +14 * self.Dq + 7 * self.C + ] + off_diag_elements = { + (0, 1): _3sqrt2 * self.B, + (0, 2): -5 * _sqrt6 * self.B, + (0, 3): 0.0, + (0, 4): -_2sqrt2 * self.B, + (0, 5): _sqrt2 * (2 * self.B + self.C), + (0, 6): 0.0, + (1, 2): -5 * _sqrt3 * self.B, + (1, 3): 3 * self.B, + (1, 4): -3 * self.B, + (1, 5): -3 * self.B, + (1, 6): -_sqrt6 * self.B, + (2, 3): -3 * _sqrt3 * self.B, + (2, 4): 5 * _sqrt3 * self.B, + (2, 5): -5 * _sqrt3 * self.B, + (2, 6): _sqrt2 * (3 * self.B + self.C), + (3, 4): -6 * self.B, + (3, 5): 0.0, + (3, 6): -_3sqrt6 * self.B, + (4, 5): -10 * self.B, + (4, 6): _sqrt6 * self.B, + (5, 6): _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_1_1_states(self) -> Float64Array: """Calculate the A_1_1 states.""" - # Diagonal elements - AA = -16 * self.Dq + 10 * self.C - BB = -6 * self.Dq + 6 * self.C - CC = +4 * self.Dq + 14 * self.B + 11 * self.C - DD = +4 * self.Dq - 3 * self.B + 6 * self.C - EE = +24 * self.Dq - 16 * self.B + 8 * self.C - - # Non-diagonal elements - AB = BA = -12 * _sqrt2 * self.B - AC = CA = _sqrt2 * (4 * self.B + 2 * self.C) - AD = DA = _2sqrt2 * self.B - AE = EA = 0.0 - - BC = CB = -12 * self.B - BD = DB = -6 * self.B - BE = EB = 0.0 - - CD = DC = 20 * self.B - CE = EC = _sqrt6 * (2 * self.B + self.C) - - DE = ED = 2 * _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + -16 * self.Dq + 10 * self.C, + -6 * self.Dq + 6 * self.C, + +4 * self.Dq + 14 * self.B + 11 * self.C, + +4 * self.Dq - 3 * self.B + 6 * self.C, + +24 * self.Dq - 16 * self.B + 8 * self.C + ] + off_diag_elements = { + (0, 1): -12 * _sqrt2 * self.B, + (0, 2): _sqrt2 * (4 * self.B + 2 * self.C), + (0, 3): _2sqrt2 * self.B, + (0, 4): 0.0, + (1, 2): -12 * self.B, + (1, 3): -6 * self.B, + (1, 4): 0.0, + (2, 3): 20 * self.B, + (2, 4): _sqrt6 * (2 * self.B + self.C), + (3, 4): 2 * _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_1_states(self) -> Float64Array: """Calculate the E_1_1 states.""" - # Diagonal elements - AA = -16 * self.Dq - 9 * self.B + 7 * self.C - BB = -6 * self.Dq - 6 * self.B + 6 * self.C - CC = +4 * self.Dq + 5 * self.B + 8 * self.C - DD = +4 * self.Dq + 6 * self.B + 9 * self.C - EE = +4 * self.Dq - 3 * self.B + 6 * self.C - - # Non-diagonal elements - AB = BA = 6 * self.B - AC = CA = _sqrt2 * (2 * self.B + self.C) - AD = DA = -2 * self.B - AE = EA = -4 * self.B - - BC = CB = -_3sqrt2 * self.B - BD = DB = -12 * self.B - BE = EB = 0.0 - - CD = DC = 10 * _sqrt2 * self.B - CE = EC = -10 * _sqrt2 * self.B - - DE = ED = 0.0 - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + -16 * self.Dq - 9 * self.B + 7 * self.C, + -6 * self.Dq - 6 * self.B + 6 * self.C, + +4 * self.Dq + 5 * self.B + 8 * self.C, + +4 * self.Dq + 6 * self.B + 9 * self.C, + +4 * self.Dq - 3 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): 6 * self.B, + (0, 2): _sqrt2 * (2 * self.B + self.C), + (0, 3): -2 * self.B, + (0, 4): -4 * self.B, + (1, 2): -_3sqrt2 * self.B, + (1, 3): -12 * self.B, + (1, 4): 0.0, + (2, 3): 10 * _sqrt2 * self.B, + (2, 4): -10 * _sqrt2 * self.B, + (3, 4): 0.0 + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_2_states(self) -> Float64Array: """Calculate the T_3_2 states.""" - # Diagonal elements - AA = -6 * self.Dq - 9 * self.B + 4 * self.C - BB = -6 * self.Dq - 5 * self.B + 6 * self.C - CC = +4 * self.Dq - 13 * self.B + 4 * self.C - DD = +4 * self.Dq - 9 * self.B + 4 * self.C - EE = +14 * self.Dq - 8 * self.B + 5 * self.C - - # Non-diagonal elements - AB = BA = -5 * _sqrt3 * self.B - AC = CA = _sqrt6 * self.B - AD = DA = _sqrt3 * self.B - AE = EA = -_sqrt6 * self.B - - BC = CB = -_3sqrt2 * self.B - BD = DB = 3 * self.B - BE = EB = _sqrt2 * (3 * self.B + self.C) - - CD = DC = -2 * _sqrt2 * self.B - CE = EC = -6 * self.B - - DE = ED = _3sqrt2 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + -6 * self.Dq - 9 * self.B + 4 * self.C, + -6 * self.Dq - 5 * self.B + 6 * self.C, + +4 * self.Dq - 13 * self.B + 4 * self.C, + +4 * self.Dq - 9 * self.B + 4 * self.C, + +14 * self.Dq - 8 * self.B + 5 * self.C + ] + off_diag_elements = { + (0, 1): -5 * _sqrt3 * self.B, + (0, 2): _sqrt6 * self.B, + (0, 3): _sqrt3 * self.B, + (0, 4): -_sqrt6 * self.B, + (1, 2): -_3sqrt2 * self.B, + (1, 3): 3 * self.B, + (1, 4): _sqrt2 * (3 * self.B + self.C), + (2, 3): -2 * _sqrt2 * self.B, + (2, 4): -6 * self.B, + (3, 4): _3sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_1_states(self) -> Float64Array: """Calculate the T_1_1 states.""" - # Diagonal elements - AA = -6 * self.Dq - 3 * self.B + 6 * self.C - BB = -6 * self.Dq - 3 * self.B + 8 * self.C - CC = +4 * self.Dq - 3 * self.B + 6 * self.C - DD = +14 * self.Dq - 16 * self.B + 7 * self.C - - # Non-diagonal elements - AB = BA = 5 * _sqrt3 * self.B - AC = CA = 3 * self.B - AD = DA = _sqrt6 * self.B - - BC = CB = -5 * _sqrt3 * self.B - BD = DB = _sqrt2 * (self.B + self.C) - - CD = DC = -_sqrt6 * self.B - - states = np.array( - [[AA, AB, AC, AD], [BA, BB, BC, BD], [CA, CB, CC, CD], [DA, DB, DC, DD]], - ) - + diag_elements = [ + -6 * self.Dq - 3 * self.B + 6 * self.C, + -6 * self.Dq - 3 * self.B + 8 * self.C, + +4 * self.Dq - 3 * self.B + 6 * self.C, + +14 * self.Dq - 16 * self.B + 7 * self.C + ] + off_diag_elements = { + (0, 1): 5 * _sqrt3 * self.B, + (0, 2): 3 * self.B, + (0, 3): _sqrt6 * self.B, + (1, 2): -5 * _sqrt3 * self.B, + (1, 3): _sqrt2 * (self.B + self.C), + (2, 3): -_sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_3_1_states(self) -> Float64Array: """Calculate the E_3_1 states.""" - # Diagonal elements - AA = -6 * self.Dq - 13 * self.B + 4 * self.C - BB = -6 * self.Dq - 10 * self.B + 4 * self.C - CC = +4 * self.Dq - 11 * self.B + 4 * self.C - - # Non-diagonal elements - AB = BA = -4 * self.B - AC = CA = 0.0 - - BC = CB = -_3sqrt2 * self.B - - states = np.array([[AA, AB, AC], [BA, BB, BC], [CA, CB, CC]]) - + diag_elements = [ + -6 * self.Dq - 13 * self.B + 4 * self.C, + -6 * self.Dq - 10 * self.B + 4 * self.C, + +4 * self.Dq - 11 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): -4 * self.B, + (0, 2): 0.0, + (1, 2): -_3sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_3_2_states(self) -> Float64Array: """Calculate the A_3_2 states.""" - # Diagonal elements - AA = -6 * self.Dq - 8 * self.B + 4 * self.C - BB = +4 * self.Dq - 2 * self.B + 7 * self.C - - # Non-diagonal elements - AB = BA = -12 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -6 * self.Dq - 8 * self.B + 4 * self.C, + +4 * self.Dq - 2 * self.B + 7 * self.C + ] + off_diag_elements = { + (0, 1): -12 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_1_2_states(self) -> Float64Array: """Calculate the A_1_2 states.""" - # Diagonal elements - AA = -6 * self.Dq - 12 * self.B + 6 * self.C - BB = +4 * self.Dq - 3 * self.B + 6 * self.C - - # Non-diagonal elements - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -6 * self.Dq - 12 * self.B + 6 * self.C, + +4 * self.Dq - 3 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def solver(self) -> Dict[str, Float64Array]: @@ -688,309 +589,224 @@ def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3850.0) -> None def T_2_2_states(self) -> Float64Array: """Calculate the T_2_2 states.""" - # diagonal elements - - AA = -20 * self.Dq - 20 * self.B + 10 * self.C - BB = -10 * self.Dq - 8 * self.B + 9 * self.C - CC = -10 * self.Dq - 18 * self.B + 9 * self.C - DD = -16 * self.B + 8 * self.C - EE = -12 * self.B + 8 * self.C - FF = +2 * self.B + 12 * self.C - GG = -6 * self.B + 10 * self.C - HH = +10 * self.Dq - 18 * self.B + 9 * self.C - II = +10 * self.Dq - 8 * self.B + 9 * self.C - JJ = +20 * self.Dq - 20 * self.B + 10 * self.C - - # non diagonal elements - - AB = BA = _3sqrt6 * self.B - AC = CA = _sqrt6 * self.B - AD = DA = 0.0 - AE = EA = -2 * _sqrt3 * self.B - AF = FA = 4 * self.B + 2 * self.C - AG = GA = 2 * self.B - AH = HA = 0.0 - AI = IA = 0.0 - AJ = JA = 0.0 - - BC = CB = 3 * self.B - BD = DB = _sqrt6 / 2.0 * self.B - BE = EB = -_3sqrt2 / 2.0 * self.B - BF = FB = _3sqrt6 / 2.0 * self.B - BG = GB = _3sqrt6 / 2.0 * self.B - BH = HB = 0.0 - BI = IB = 4 * self.B + self.C - BJ = JB = 0.0 - - CD = DC = _3sqrt6 / 2.0 * self.B - CE = EC = -_3sqrt2 / 2.0 * self.B - CF = FC = +5 * _sqrt6 / 2.0 * self.B - CG = GC = -5 * _sqrt6 / 2.0 * self.B - CH = HC = self.C - CI = IC = 0.0 - CJ = JC = 0.0 - - DE = ED = 2 * _sqrt3 * self.B - DF = FD = 0.0 - DG = GD = 0.0 - DH = HD = -_3sqrt6 / 2.0 * self.B - DI = ID = -_sqrt6 / 2.0 * self.B - DJ = JD = 0.0 - - EF = FE = -10 * _sqrt3 * self.B - EG = GE = 0.0 - EH = HE = _3sqrt2 / 2.0 * self.B - EI = IE = _3sqrt2 / 2.0 * self.B - EJ = JE = -2 * _sqrt3 * self.B - - FG = GF = 0.0 - FH = HF = -5 * _sqrt6 / 2.0 * self.B - FI = IF = -_3sqrt6 / 2.0 * self.B - FJ = JF = 4 * self.B + 2 * self.C - - GH = HG = -5 * _sqrt6 / 2.0 * self.B - GI = IG = _3sqrt6 / 2.0 * self.B - GJ = JG = -2.0 * self.B - - HI = IH = 3 * self.B - HJ = JH = -_sqrt6 * self.B - - IJ = JI = -_3sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ], - [BA, BB, BC, BD, BE, BF, BG, BH, BI, BJ], - [CA, CB, CC, CD, CE, CF, CG, CH, CI, CJ], - [DA, DB, DC, DD, DE, DF, DG, DH, DI, DJ], - [EA, EB, EC, ED, EE, EF, EG, EH, EI, EJ], - [FA, FB, FC, FD, FE, FF, FG, FH, FI, FJ], - [GA, GB, GC, GD, GE, GF, GG, GH, GI, GJ], - [HA, HB, HC, HD, HE, HF, HG, HH, HI, HJ], - [IA, IB, IC, ID, IE, IF, IG, IH, II, IJ], - [JA, JB, JC, JD, JE, JF, JG, JH, JI, JJ], - ], - ) - + diag_elements = [ + -20 * self.Dq - 20 * self.B + 10 * self.C, + -10 * self.Dq - 8 * self.B + 9 * self.C, + -10 * self.Dq - 18 * self.B + 9 * self.C, + -16 * self.B + 8 * self.C, + -12 * self.B + 8 * self.C, + +2 * self.B + 12 * self.C, + -6 * self.B + 10 * self.C, + +10 * self.Dq - 18 * self.B + 9 * self.C, + +10 * self.Dq - 8 * self.B + 9 * self.C, + +20 * self.Dq - 20 * self.B + 10 * self.C + ] + off_diag_elements = { + (0, 1): _3sqrt6 * self.B, + (0, 2): _sqrt6 * self.B, + (0, 3): 0.0, + (0, 4): -2 * _sqrt3 * self.B, + (0, 5): 4 * self.B + 2 * self.C, + (0, 6): 2 * self.B, + (0, 7): 0.0, + (0, 8): 0.0, + (0, 9): 0.0, + (1, 2): 3 * self.B, + (1, 3): _sqrt6 / 2.0 * self.B, + (1, 4): -_3sqrt2 / 2.0 * self.B, + (1, 5): _3sqrt6 / 2.0 * self.B, + (1, 6): _3sqrt6 / 2.0 * self.B, + (1, 7): 0.0, + (1, 8): 4 * self.B + self.C, + (1, 9): 0.0, + (2, 3): _3sqrt6 / 2.0 * self.B, + (2, 4): -_3sqrt2 / 2.0 * self.B, + (2, 5): +5 * _sqrt6 / 2.0 * self.B, + (2, 6): -5 * _sqrt6 / 2.0 * self.B, + (2, 7): self.C, + (2, 8): 0.0, + (2, 9): 0.0, + (3, 4): 2 * _sqrt3 * self.B, + (3, 5): 0.0, + (3, 6): 0.0, + (3, 7): -_3sqrt6 / 2.0 * self.B, + (3, 8): -_sqrt6 / 2.0 * self.B, + (3, 9): 0.0, + (4, 5): -10 * _sqrt3 * self.B, + (4, 6): 0.0, + (4, 7): _3sqrt2 / 2.0 * self.B, + (4, 8): _3sqrt2 / 2.0 * self.B, + (4, 9): -2 * _sqrt3 * self.B, + (5, 6): 0.0, + (5, 7): -5 * _sqrt6 / 2.0 * self.B, + (5, 8): -_3sqrt6 / 2.0 * self.B, + (5, 9): 4 * self.B + 2 * self.C, + (6, 7): -5 * _sqrt6 / 2.0 * self.B, + (6, 8): _3sqrt6 / 2.0 * self.B, + (6, 9): -2.0 * self.B, + (7, 8): 3 * self.B, + (7, 9): -_sqrt6 * self.B, + (8, 9): -_3sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_2_1_states(self) -> Float64Array: """Calculate the T_2_1 states.""" - # diagonal elements - - AA = -10 * self.Dq - 22 * self.B + 9 * self.C - BB = -10 * self.Dq - 8 * self.B + 9 * self.C - CC = -4 * self.B + 10 * self.C - DD = -12 * self.B + 8 * self.C - EE = -10 * self.B + 10 * self.C - FF = -6 * self.B + 10 * self.C - GG = +10 * self.Dq - 8 * self.B + 9 * self.C - HH = +10 * self.Dq - 22 * self.B + 9 * self.C - - # non diagonal elements - - AB = BA = -3 * self.B - AC = CA = -_3sqrt2 / 2.0 * self.B - AD = DA = _3sqrt2 / 2.0 * self.B - AE = EA = -_3sqrt2 / 2.0 * self.B - AF = FA = -_3sqrt6 / 2.0 * self.B - AG = GA = 0.0 - AH = HA = self.C - - BC = CB = _3sqrt2 / 2.0 * self.B - BD = DB = _3sqrt2 / 2.0 * self.B - BE = EB = 15 * _sqrt2 / 2.0 * self.B - BF = FB = 5 * _sqrt6 / 2.0 * self.B - BG = GB = 4 * self.B + self.C - BH = HB = 0.0 - - CD = DC = 0.0 - CE = EC = 0.0 - CF = FC = 10 * _sqrt3 * self.B - CG = GC = _3sqrt2 / 2.0 * self.B - CH = HC = -_3sqrt2 / 2.0 * self.B - - DE = ED = 0.0 - DF = FD = 0.0 - DG = GD = -_3sqrt2 / 2.0 * self.B - DH = HD = -_3sqrt2 / 2.0 * self.B - - EF = FE = 2 * _sqrt3 * self.B - EG = GE = 15 * _sqrt2 / 2.0 * self.B - EH = HE = -_3sqrt2 / 2.0 * self.B - - FG = GF = 5 * _sqrt6 / 2.0 * self.B - FH = HF = -_3sqrt6 / 2.0 * self.B - - GH = HG = -3 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG, AH], - [BA, BB, BC, BD, BE, BF, BG, BH], - [CA, CB, CC, CD, CE, CF, CG, CH], - [DA, DB, DC, DD, DE, DF, DG, DH], - [EA, EB, EC, ED, EE, EF, EG, EH], - [FA, FB, FC, FD, FE, FF, FG, FH], - [GA, GB, GC, GD, GE, GF, GG, GH], - [HA, HB, HC, HD, HE, HF, HG, HH], - ], - ) - + diag_elements = [ + -10 * self.Dq - 22 * self.B + 9 * self.C, + -10 * self.Dq - 8 * self.B + 9 * self.C, + -4 * self.B + 10 * self.C, + -12 * self.B + 8 * self.C, + -10 * self.B + 10 * self.C, + -6 * self.B + 10 * self.C, + +10 * self.Dq - 8 * self.B + 9 * self.C, + +10 * self.Dq - 22 * self.B + 9 * self.C + ] + off_diag_elements = { + (0, 1): -3 * self.B, + (0, 2): -_3sqrt2 / 2.0 * self.B, + (0, 3): _3sqrt2 / 2.0 * self.B, + (0, 4): -_3sqrt2 / 2.0 * self.B, + (0, 5): -_3sqrt6 / 2.0 * self.B, + (0, 6): 0.0, + (0, 7): self.C, + (1, 2): _3sqrt2 / 2.0 * self.B, + (1, 3): _3sqrt2 / 2.0 * self.B, + (1, 4): 15 * _sqrt2 / 2.0 * self.B, + (1, 5): 5 * _sqrt6 / 2.0 * self.B, + (1, 6): 4 * self.B + self.C, + (1, 7): 0.0, + (2, 3): 0.0, + (2, 4): 0.0, + (2, 5): 10 * _sqrt3 * self.B, + (2, 6): _3sqrt2 / 2.0 * self.B, + (2, 7): -_3sqrt2 / 2.0 * self.B, + (3, 4): 0.0, + (3, 5): 0.0, + (3, 6): -_3sqrt2 / 2.0 * self.B, + (3, 7): -_3sqrt2 / 2.0 * self.B, + (4, 5): 2 * _sqrt3 * self.B, + (4, 6): 15 * _sqrt2 / 2.0 * self.B, + (4, 7): -_3sqrt2 / 2.0 * self.B, + (5, 6): 5 * _sqrt6 / 2.0 * self.B, + (5, 7): -_3sqrt6 / 2.0 * self.B, + (6, 7): -3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_2_states(self) -> Float64Array: """Calculate the E_2 states.""" - # diagonal elements - - AA = -10 * self.Dq - 4 * self.B + 12 * self.C - BB = -10 * self.Dq - 13 * self.B + 9 * self.C - CC = -4 * self.B + 10 * self.C - DD = -16 * self.B + 8 * self.C - EE = -12 * self.B + 8 * self.C - FF = +10 * self.Dq - 13 * self.B + 9 * self.C - GG = +10 * self.Dq - 4 * self.B + 12 * self.C - - # non diagonal elements - - AB = BA = 10 * self.B - AC = CA = 6 * self.B - AD = DA = 6 * _sqrt3 * self.B - AE = EA = 6 * _sqrt2 * self.B - AF = FA = -2 * self.B - AG = GA = 4 * self.B + 2 * self.C - - BC = CB = -3 * self.B - BD = DB = 3 * _sqrt3 * self.B - BE = EB = 0.0 - BF = FB = 2 * self.B + self.C - BG = GB = 2 * self.B - - CD = DC = 0.0 - CE = EC = 0.0 - CF = FC = -3 * self.B - CG = GC = -6 * self.B - - DE = ED = 2 * _sqrt6 * self.B - DF = FD = -3 * _sqrt3 * self.B - DG = GD = 6 * _sqrt3 * self.B - - EF = FE = 0.0 - EG = GE = 6 * _sqrt2 * self.B - - FG = GF = -10 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG], - [BA, BB, BC, BD, BE, BF, BG], - [CA, CB, CC, CD, CE, CF, CG], - [DA, DB, DC, DD, DE, DF, DG], - [EA, EB, EC, ED, EE, EF, EG], - [FA, FB, FC, FD, FE, FF, FG], - [GA, GB, GC, GD, GE, GF, GG], - ], - ) - + diag_elements = [ + -10 * self.Dq - 4 * self.B + 12 * self.C, + -10 * self.Dq - 13 * self.B + 9 * self.C, + -4 * self.B + 10 * self.C, + -16 * self.B + 8 * self.C, + -12 * self.B + 8 * self.C, + +10 * self.Dq - 13 * self.B + 9 * self.C, + +10 * self.Dq - 4 * self.B + 12 * self.C + ] + off_diag_elements = { + (0, 1): 10 * self.B, + (0, 2): 6 * self.B, + (0, 3): 6 * _sqrt3 * self.B, + (0, 4): 6 * _sqrt2 * self.B, + (0, 5): -2 * self.B, + (0, 6): 4 * self.B + 2 * self.C, + (1, 2): -3 * self.B, + (1, 3): 3 * _sqrt3 * self.B, + (1, 4): 0.0, + (1, 5): 2 * self.B + self.C, + (1, 6): 2 * self.B, + (2, 3): 0.0, + (2, 4): 0.0, + (2, 5): -3 * self.B, + (2, 6): -6 * self.B, + (3, 4): 2 * _sqrt6 * self.B, + (3, 5): -3 * _sqrt3 * self.B, + (3, 6): 6 * _sqrt3 * self.B, + (4, 5): 0.0, + (4, 6): 6 * _sqrt2 * self.B, + (5, 6): -10 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_2_1_states(self) -> Float64Array: """Calculate the A_2_1 states.""" - # diagonal elements - - AA = -10 * self.Dq - 3 * self.B + 9 * self.C - BB = -12 * self.B + 8 * self.C - CC = -19 * self.B + 8 * self.C - DD = +10 * self.Dq - 3 * self.B + 9 * self.C - - # non diagonal elements - - AB = BA = -_3sqrt2 * self.B - AC = CA = 0.0 - AD = DA = 6 * self.B + self.C - - BC = CB = -4 * _sqrt3 * self.B - BD = DB = _3sqrt2 * self.B - - CD = DC = 0.0 - - states = np.array( - [[AA, AB, AC, AD], [BA, BB, BC, BD], [CA, CB, CC, CD], [DA, DB, DC, DD]], - ) - + diag_elements = [ + -10 * self.Dq - 3 * self.B + 9 * self.C, + -12 * self.B + 8 * self.C, + -19 * self.B + 8 * self.C, + +10 * self.Dq - 3 * self.B + 9 * self.C + ] + off_diag_elements = { + (0, 1): -_3sqrt2 * self.B, + (0, 2): 0.0, + (0, 3): 6 * self.B + self.C, + (1, 2): -4 * _sqrt3 * self.B, + (1, 3): _3sqrt2 * self.B, + (2, 3): 0.0 + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_2_2_states(self) -> Float64Array: """Calculate the A_2_2 states.""" - # diagonal elements - - AA = -10 * self.Dq - 23 * self.B + 9 * self.C - BB = -12 * self.B + 8 * self.C - CC = +10 * self.Dq - 23 * self.B + 9 * self.C - - # non diagonal elements - - AB = BA = _3sqrt2 * self.B - AC = CA = -2 * self.B + self.C - - BC = CB = -_3sqrt2 * self.B - - states = np.array([[AA, AB, AC], [BA, BB, BC], [CA, CB, CC]]) - + diag_elements = [ + -10 * self.Dq - 23 * self.B + 9 * self.C, + -12 * self.B + 8 * self.C, + +10 * self.Dq - 23 * self.B + 9 * self.C + ] + off_diag_elements = { + (0, 1): _3sqrt2 * self.B, + (0, 2): -2 * self.B + self.C, + (1, 2): -_3sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_1_states(self) -> Float64Array: """Calculate the T_4_1 states.""" - # diagonal elements - - AA = -10 * self.Dq - 25 * self.B + 6 * self.C - BB = -16 * self.B + 7 * self.C - CC = 10 * self.Dq - 25 * self.B + 6 * self.C - - # non diagonal elements - - AB = BA = -_3sqrt2 * self.B - AC = CA = self.C - - BC = CB = -_3sqrt2 * self.B - - states = np.array([[AA, AB, AC], [BA, BB, BC], [CA, CB, CC]]) - + diag_elements = [ + -10 * self.Dq - 25 * self.B + 6 * self.C, + -16 * self.B + 7 * self.C, + 10 * self.Dq - 25 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): -_3sqrt2 * self.B, + (0, 2): self.C, + (1, 2): -_3sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_2_states(self) -> Float64Array: """Calculate the T_4_2 states.""" - # diagonal elements - - AA = -10 * self.Dq - 17 * self.B + 6 * self.C - BB = -22 * self.B + 5 * self.C - CC = +10 * self.Dq - 17 * self.B + 6 * self.C - - # non diagonal elements - - AB = BA = _sqrt6 * self.B - AC = CA = +4 * self.B + self.C - - BC = CB = -_sqrt6 * self.B - - # AB = BC = AC = 0 - states = np.array([[AA, AB, AC], [BA, BB, BC], [CA, CB, CC]]) - + diag_elements = [ + -10 * self.Dq - 17 * self.B + 6 * self.C, + -22 * self.B + 5 * self.C, + +10 * self.Dq - 17 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): _sqrt6 * self.B, + (0, 2): +4 * self.B + self.C, + (1, 2): -_sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_4_states(self) -> Float64Array: """Calculate the E_4 states.""" - # diagonal elements - - AA = -22 * self.B + 5 * self.C - BB = -21 * self.B + 5 * self.C - - # non diagonal elements - - AB = BA = -2 * _sqrt3 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + -22 * self.B + 5 * self.C, + -21 * self.B + 5 * self.C + ] + off_diag_elements = { + (0, 1): -2 * _sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def solver(self) -> Dict[str, Float64Array]: @@ -1064,305 +880,208 @@ def __init__(self, Dq: float = 0.0, B: float = 1065.0, C: float = 5120.0): def T_3_1_states(self) -> Float64Array: """Calculate the T_3_1 states.""" - # - diagonal elements - - AA = +16 * self.Dq - 15 * self.B + 5 * self.C - BB = +6 * self.Dq - 11 * self.B + 4 * self.C - CC = +6 * self.Dq - 3 * self.B + 6 * self.C - DD = -4 * self.Dq - self.B + 6 * self.C - EE = -4 * self.Dq - 9 * self.B + 4 * self.C - FF = -4 * self.Dq - 11 * self.B + 4 * self.C - GG = -14 * self.Dq - 16 * self.B + 5 * self.C - - # non diagonal elements - - AB = BA = -_sqrt6 * self.B - AC = CA = -_3sqrt2 * self.B - AD = DA = _sqrt2 * (2 * self.B + self.C) - AE = EA = -_2sqrt2 * self.B - AF = FA = 0.0 - AG = GA = 0.0 - - BC = CB = 5 * _sqrt3 * self.B - BD = DB = _sqrt3 * self.B - BE = EB = -_sqrt3 * self.B - BF = FB = 3 * self.B - BG = GB = _sqrt6 * self.B - - CD = DC = -3 * self.B - CE = EC = -3 * self.B - CF = FC = 5 * _sqrt3 * self.B - CG = GC = _sqrt2 * (self.B + self.C) - - DE = ED = -10 * self.B - DF = FD = 0.0 - DG = GD = _3sqrt2 * self.B - - EF = FE = -2 * _sqrt3 * self.B - EG = GE = -_3sqrt2 * self.B - - FG = GF = _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG], - [BA, BB, BC, BD, BE, BF, BG], - [CA, CB, CC, CD, CE, CF, CG], - [DA, DB, DC, DD, DE, DF, DG], - [EA, EB, EC, ED, EE, EF, EG], - [FA, FB, FC, FD, FE, FF, FG], - [GA, GB, GC, GD, GE, GF, GG], - ], - ) - + diag_elements = [ + +16 * self.Dq - 15 * self.B + 5 * self.C, + +6 * self.Dq - 11 * self.B + 4 * self.C, + +6 * self.Dq - 3 * self.B + 6 * self.C, + -4 * self.Dq - self.B + 6 * self.C, + -4 * self.Dq - 9 * self.B + 4 * self.C, + -4 * self.Dq - 11 * self.B + 4 * self.C, + -14 * self.Dq - 16 * self.B + 5 * self.C + ] + off_diag_elements = { + (0, 1): -_sqrt6 * self.B, + (0, 2): -_3sqrt2 * self.B, + (0, 3): _sqrt2 * (2 * self.B + self.C), + (0, 4): -_2sqrt2 * self.B, + (0, 5): 0.0, + (0, 6): 0.0, + (1, 2): 5 * _sqrt3 * self.B, + (1, 3): _sqrt3 * self.B, + (1, 4): -_sqrt3 * self.B, + (1, 5): 3 * self.B, + (1, 6): _sqrt6 * self.B, + (2, 3): -3 * self.B, + (2, 4): -3 * self.B, + (2, 5): 5 * _sqrt3 * self.B, + (2, 6): _sqrt2 * (self.B + self.C), + (3, 4): -10 * self.B, + (3, 5): 0.0, + (3, 6): _3sqrt2 * self.B, + (4, 5): -2 * _sqrt3 * self.B, + (4, 6): -_3sqrt2 * self.B, + (5, 6): _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self) -> Float64Array: """Calculate the T_1_2 states.""" - # diagonal elements - - AA = +16 * self.Dq - 9 * self.B + 7 * self.C - BB = +6 * self.Dq - 9 * self.B + 6 * self.C - CC = +6 * self.Dq + 3 * self.B + 8 * self.C - DD = -4 * self.Dq - 9 * self.B + 6 * self.C - EE = -4 * self.Dq - 3 * self.B + 6 * self.C - FF = -4 * self.Dq + 5 * self.B + 8 * self.C - GG = -14 * self.Dq + 7 * self.C - - # non diagonal elements - - AB = BA = _3sqrt2 * self.B - AC = CA = -5 * _sqrt6 * self.B - AD = DA = 0.0 - AE = EA = -_2sqrt2 * self.B - AF = FA = _sqrt2 * (2 * self.B + self.C) - AG = GA = 0.0 - - BC = CB = -5 * _sqrt3 * self.B - BD = DB = 3 * self.B - BE = EB = -3 * self.B - BF = FB = -3 * self.B - BG = GB = -_sqrt6 * self.B - - CD = DC = -3 * _sqrt3 * self.B - CE = EC = 5 * _sqrt3 * self.B - CF = FC = -5 * _sqrt3 * self.B - CG = GC = _sqrt2 * (3 * self.B + self.C) - - DE = ED = -6 * self.B - DF = FD = 0.0 - DG = GD = -_3sqrt6 * self.B - - EF = FE = -10 * self.B - EG = GE = _sqrt6 * self.B - - FG = GF = _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE, AF, AG], - [BA, BB, BC, BD, BE, BF, BG], - [CA, CB, CC, CD, CE, CF, CG], - [DA, DB, DC, DD, DE, DF, DG], - [EA, EB, EC, ED, EE, EF, EG], - [FA, FB, FC, FD, FE, FF, FG], - [GA, GB, GC, GD, GE, GF, GG], - ], - ) - + diag_elements = [ + +16 * self.Dq - 9 * self.B + 7 * self.C, + +6 * self.Dq - 9 * self.B + 6 * self.C, + +6 * self.Dq + 3 * self.B + 8 * self.C, + -4 * self.Dq - 9 * self.B + 6 * self.C, + -4 * self.Dq - 3 * self.B + 6 * self.C, + -4 * self.Dq + 5 * self.B + 8 * self.C, + -14 * self.Dq + 7 * self.C + ] + off_diag_elements = { + (0, 1): _3sqrt2 * self.B, + (0, 2): -5 * _sqrt6 * self.B, + (0, 3): 0.0, + (0, 4): -_2sqrt2 * self.B, + (0, 5): _sqrt2 * (2 * self.B + self.C), + (0, 6): 0.0, + (1, 2): -5 * _sqrt3 * self.B, + (1, 3): 3 * self.B, + (1, 4): -3 * self.B, + (1, 5): -3 * self.B, + (1, 6): -_sqrt6 * self.B, + (2, 3): -3 * _sqrt3 * self.B, + (2, 4): 5 * _sqrt3 * self.B, + (2, 5): -5 * _sqrt3 * self.B, + (2, 6): _sqrt2 * (3 * self.B + self.C), + (3, 4): -6 * self.B, + (3, 5): 0.0, + (3, 6): -_3sqrt6 * self.B, + (4, 5): -10 * self.B, + (4, 6): _sqrt6 * self.B, + (5, 6): _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_1_1_states(self) -> Float64Array: """Calculate the A_1_1 states.""" - # diagonal elements - - AA = +16 * self.Dq + 10 * self.C - BB = +6 * self.Dq + 6 * self.C - CC = -4 * self.Dq + 14 * self.B + 11 * self.C - DD = -4 * self.Dq - 3 * self.B + 6 * self.C - EE = -24 * self.Dq - 16 * self.B + 8 * self.C - - # non diagonal elements - - AB = BA = -12 * _sqrt2 * self.B - AC = CA = _sqrt2 * (4 * self.B + 2 * self.C) - AD = DA = _2sqrt2 * self.B - AE = EA = 0.0 - - BC = CB = -12 * self.B - BD = DB = -6 * self.B - BE = EB = 0.0 - - CD = DC = 20 * self.B - CE = EC = _sqrt6 * (2 * self.B + self.C) - - DE = ED = 2 * _sqrt6 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + +16 * self.Dq + 10 * self.C, + +6 * self.Dq + 6 * self.C, + -4 * self.Dq + 14 * self.B + 11 * self.C, + -4 * self.Dq - 3 * self.B + 6 * self.C, + -24 * self.Dq - 16 * self.B + 8 * self.C + ] + off_diag_elements = { + (0, 1): -12 * _sqrt2 * self.B, + (0, 2): _sqrt2 * (4 * self.B + 2 * self.C), + (0, 3): _2sqrt2 * self.B, + (0, 4): 0.0, + (1, 2): -12 * self.B, + (1, 3): -6 * self.B, + (1, 4): 0.0, + (2, 3): 20 * self.B, + (2, 4): _sqrt6 * (2 * self.B + self.C), + (3, 4): 2 * _sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_1_states(self) -> Float64Array: """Calculate the E_1_1 states.""" - # diagonal elements - - AA = +16 * self.Dq - 9 * self.B + 7 * self.C - BB = +6 * self.Dq - 6 * self.B + 6 * self.C - CC = -4 * self.Dq + 5 * self.B + 8 * self.C - DD = -4 * self.Dq + 6 * self.B + 9 * self.C - EE = -4 * self.Dq - 3 * self.B + 6 * self.C - - # non diagonal elements - - AB = BA = 6 * self.B - AC = CA = _sqrt2 * (2 * self.B + self.C) - AD = DA = -2 * self.B - AE = EA = -4 * self.B - - BC = CB = -_3sqrt2 * self.B - BD = DB = -12 * self.B - BE = EB = 0.0 - - CD = DC = 10 * _sqrt2 * self.B - CE = EC = -10 * _sqrt2 * self.B - - DE = ED = 0.0 - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + +16 * self.Dq - 9 * self.B + 7 * self.C, + +6 * self.Dq - 6 * self.B + 6 * self.C, + -4 * self.Dq + 5 * self.B + 8 * self.C, + -4 * self.Dq + 6 * self.B + 9 * self.C, + -4 * self.Dq - 3 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): 6 * self.B, + (0, 2): _sqrt2 * (2 * self.B + self.C), + (0, 3): -2 * self.B, + (0, 4): -4 * self.B, + (1, 2): -_3sqrt2 * self.B, + (1, 3): -12 * self.B, + (1, 4): 0.0, + (2, 3): 10 * _sqrt2 * self.B, + (2, 4): -10 * _sqrt2 * self.B, + (3, 4): 0.0 + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_2_states(self) -> Float64Array: """Calculate the T_3_2 states.""" - # diagonal elements - - AA = +6 * self.Dq - 9 * self.B + 4 * self.C - BB = +6 * self.Dq - 5 * self.B + 6 * self.C - CC = -4 * self.Dq - 13 * self.B + 4 * self.C - DD = -4 * self.Dq - 9 * self.B + 4 * self.C - EE = -14 * self.Dq - 8 * self.B + 5 * self.C - - # non diagonal elements - - AB = BA = -5 * _sqrt3 * self.B - AC = CA = _sqrt6 * self.B - AD = DA = _sqrt3 * self.B - AE = EA = -_sqrt6 * self.B - - BC = CB = -_3sqrt2 * self.B - BD = DB = 3 * self.B - BE = EB = _sqrt2 * (3 * self.B + self.C) - - CD = DC = -2 * _sqrt2 * self.B - CE = EC = -6 * self.B - - DE = ED = 3 * _sqrt2 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + +6 * self.Dq - 9 * self.B + 4 * self.C, + +6 * self.Dq - 5 * self.B + 6 * self.C, + -4 * self.Dq - 13 * self.B + 4 * self.C, + -4 * self.Dq - 9 * self.B + 4 * self.C, + -14 * self.Dq - 8 * self.B + 5 * self.C + ] + off_diag_elements = { + (0, 1): -5 * _sqrt3 * self.B, + (0, 2): _sqrt6 * self.B, + (0, 3): _sqrt3 * self.B, + (0, 4): -_sqrt6 * self.B, + (1, 2): -_3sqrt2 * self.B, + (1, 3): 3 * self.B, + (1, 4): _sqrt2 * (3 * self.B + self.C), + (2, 3): -2 * _sqrt2 * self.B, + (2, 4): -6 * self.B, + (3, 4): 3 * _sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_1_states(self) -> Float64Array: """Calculate the T_1_1 states.""" - # diagonal elements - - AA = +6 * self.Dq - 3 * self.B + 6 * self.C - BB = +6 * self.Dq - 3 * self.B + 8 * self.C - CC = -4 * self.Dq - 3 * self.B + 6 * self.C - DD = -14 * self.Dq - 16 * self.B + 7 * self.C - - # non diagonal elements - - AB = BA = 5 * _sqrt3 * self.B - AC = CA = 3 * self.B - AD = DA = _sqrt6 * self.B - - BC = CB = -5 * _sqrt3 * self.B - BD = DB = _sqrt2 * (self.B + self.C) - - CD = DC = -_sqrt6 * self.B - - states = np.array( - [[AA, AB, AC, AD], [BA, BB, BC, BD], [CA, CB, CC, CD], [DA, DB, DC, DD]], - ) - + diag_elements = [ + +6 * self.Dq - 3 * self.B + 6 * self.C, + +6 * self.Dq - 3 * self.B + 8 * self.C, + -4 * self.Dq - 3 * self.B + 6 * self.C, + -14 * self.Dq - 16 * self.B + 7 * self.C + ] + off_diag_elements = { + (0, 1): 5 * _sqrt3 * self.B, + (0, 2): 3 * self.B, + (0, 3): _sqrt6 * self.B, + (1, 2): -5 * _sqrt3 * self.B, + (1, 3): _sqrt2 * (self.B + self.C), + (2, 3): -_sqrt6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_3_1_states(self) -> Float64Array: """Calculate the E_3_1 states.""" - # diagonal elements - - AA = +6 * self.Dq - 13 * self.B + 4 * self.C - BB = +6 * self.Dq - 10 * self.B + 4 * self.C - CC = -4 * self.Dq - 11 * self.B + 4 * self.C - - # non diagonal elements - - AB = BA = -4 * self.B - AC = CA = 0.0 - - BC = CB = -_3sqrt2 * self.B - - states = np.array([[AA, AB, AC], [BA, BB, BC], [CA, CB, CC]]) - + diag_elements = [ + +6 * self.Dq - 13 * self.B + 4 * self.C, + +6 * self.Dq - 10 * self.B + 4 * self.C, + -4 * self.Dq - 11 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): -4 * self.B, + (0, 2): 0.0, + (1, 2): -_3sqrt2 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_3_2_states(self) -> Float64Array: """Calculate the A_3_2 states.""" - # diagonal elements - - AA = +6 * self.Dq - 8 * self.B + 4 * self.C - BB = -4 * self.Dq - 2 * self.B + 7 * self.C - - # non diagonal elements - - AB = BA = -12 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +6 * self.Dq - 8 * self.B + 4 * self.C, + -4 * self.Dq - 2 * self.B + 7 * self.C + ] + off_diag_elements = { + (0, 1): -12 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def A_1_2_states(self) -> Float64Array: """Calculate the A_1_2 states.""" - # diagonal elements - - AA = +6 * self.Dq - 12 * self.B + 6 * self.C - BB = -4 * self.Dq - 3 * self.B + 6 * self.C - - # non diagonal elements - - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +6 * self.Dq - 12 * self.B + 6 * self.C, + -4 * self.Dq - 3 * self.B + 6 * self.C + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - - def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. @@ -1437,123 +1156,83 @@ def __init__(self, Dq: float = 0.0, B: float = 971.0, C: float = 4499.0): def T_2_2_states(self): """Calculate the T_2_2 states.""" - # - diagonal elements - - AA = +12 * self.Dq + 5 * self.C - BB = +2 * self.Dq - 6 * self.B + 3 * self.C - CC = +2 * self.Dq + 4 * self.B + 3 * self.C - DD = -8 * self.Dq + 6 * self.B + 5 * self.C - EE = -8 * self.Dq - 2 * self.B + 3 * self.C - - # non diagonal elements - - AB = BA = -_3sqrt3 * self.B - AC = CA = -5 * _sqrt3 * self.B - AD = DA = 4 * self.B + 2 * self.C - AE = EA = 2 * self.B - - BC = CB = 3 * self.B - BD = DB = -_3sqrt3 * self.B - BE = EB = -_3sqrt3 * self.B - - CD = DC = -_sqrt3 * self.B - CE = EC = +_sqrt3 * self.B - - DE = ED = 10 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + +12 * self.Dq + 5 * self.C, + +2 * self.Dq - 6 * self.B + 3 * self.C, + +2 * self.Dq + 4 * self.B + 3 * self.C, + -8 * self.Dq + 6 * self.B + 5 * self.C, + -8 * self.Dq - 2 * self.B + 3 * self.C + ] + off_diag_elements = { + (0, 1): -_3sqrt3 * self.B, + (0, 2): -5 * _sqrt3 * self.B, + (0, 3): 4 * self.B + 2 * self.C, + (0, 4): 2 * self.B, + (1, 2): 3 * self.B, + (1, 3): -_3sqrt3 * self.B, + (1, 4): -_3sqrt3 * self.B, + (2, 3): -_sqrt3 * self.B, + (2, 4): +_sqrt3 * self.B, + (3, 4): 10 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_2_1_states(self): """Calculate the T_2_1 states.""" - # - diagonal elements - - AA = +12 * self.Dq - 6 * self.B + 3 * self.C - BB = +2 * self.Dq + 3 * self.C - CC = +2 * self.Dq - 6 * self.B + 3 * self.C - DD = -8 * self.Dq - 6 * self.B + 3 * self.C - EE = -8 * self.Dq - 2 * self.B + 3 * self.C - - # non diagonal elements - - AB = BA = -3 * self.B - AC = CA = +3 * self.B - AD = DA = 0.0 - AE = EA = -_2sqrt3 * self.B - - BC = CB = -3 * self.B - BD = DB = +3 * self.B - BE = EB = _3sqrt3 * self.B - - CD = DC = -3 * self.B - CE = EC = -_sqrt3 * self.B - - DE = ED = _2sqrt3 * self.B - - states = np.array( - [ - [AA, AB, AC, AD, AE], - [BA, BB, BC, BD, BE], - [CA, CB, CC, CD, CE], - [DA, DB, DC, DD, DE], - [EA, EB, EC, ED, EE], - ], - ) - + diag_elements = [ + +12 * self.Dq - 6 * self.B + 3 * self.C, + +2 * self.Dq + 3 * self.C, + +2 * self.Dq - 6 * self.B + 3 * self.C, + -8 * self.Dq - 6 * self.B + 3 * self.C, + -8 * self.Dq - 2 * self.B + 3 * self.C + ] + off_diag_elements = { + (0, 1): -3 * self.B, + (0, 2): +3 * self.B, + (0, 3): 0.0, + (0, 4): -_2sqrt3 * self.B, + (1, 2): -3 * self.B, + (1, 3): +3 * self.B, + (1, 4): _3sqrt3 * self.B, + (2, 3): -3 * self.B, + (2, 4): -_sqrt3 * self.B, + (3, 4): _2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_2_states(self): """Calculate the E_2 states.""" - # - diagonal elements - - AA = +12 * self.Dq - 6 * self.B + 3 * self.C - BB = +2 * self.Dq + 8 * self.B + 6 * self.C - CC = +2 * self.Dq - 1 * self.B + 3 * self.C - DD = -18 * self.Dq - 8 * self.B + 4 * self.C - - # non diagonal elements - - AB = BA = -6 * _sqrt2 * self.B - AC = CA = -_3sqrt2 * self.B - AD = DA = 0.0 - - BC = CB = 10 * self.B - BD = DB = +_sqrt3 * (2 * self.B + self.C) - - CD = DC = _2sqrt3 * self.B - - states = np.array( - [[AA, AB, AC, AD], [BA, BB, BC, BD], [CA, CB, CC, CD], [DA, DB, DC, DD]], - ) - + diag_elements = [ + +12 * self.Dq - 6 * self.B + 3 * self.C, + +2 * self.Dq + 8 * self.B + 6 * self.C, + +2 * self.Dq - 1 * self.B + 3 * self.C, + -18 * self.Dq - 8 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): -6 * _sqrt2 * self.B, + (0, 2): -_3sqrt2 * self.B, + (0, 3): 0.0, + (1, 2): 10 * self.B, + (1, 3): +_sqrt3 * (2 * self.B + self.C), + (2, 3): _2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_1_states(self): """Calculate the T_4_1 states.""" - # - diagonal elements - - AA = +2 * self.Dq - 3 * self.B - BB = -8 * self.Dq - 12 * self.B - - # non diagonal elements - - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +2 * self.Dq - 3 * self.B, + -8 * self.Dq - 12 * self.B + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - - def solver(self) -> Dict[str, np.ndarray]: """Solve for all states and return a dictionary of results. @@ -1620,66 +1299,52 @@ def __init__(self, Dq: float = 0.0, B: float = 1030.0, C: float = 4850.0): def A_1_1_states(self): """Calculate the A_1_1 states.""" - # - diagonal elements - - AA = +8 * self.Dq + 10 * self.B + 5 * self.C - BB = -12 * self.Dq + 8 * self.B + 4 * self.C - - # non diagonal elements - - AB = BA = _sqrt6 * (2 * self.B + self.C) - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +8 * self.Dq + 10 * self.B + 5 * self.C, + -12 * self.Dq + 8 * self.B + 4 * self.C + ] + off_diag_elements = { + (0, 1): _sqrt6 * (2 * self.B + self.C) + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_states(self): """Calculate the E_1 states.""" - # - diagonal elements - - AA = +8 * self.Dq + self.B + 2 * self.C - BB = -12 * self.Dq + 2 * self.C - - # non diagonal elements - - AB = BA = -_2sqrt3 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +8 * self.Dq + self.B + 2 * self.C, + -12 * self.Dq + 2 * self.C + ] + off_diag_elements = { + (0, 1): -_2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self): """Calculate the T_1_2 states.""" - # - diagonal elements - - AA = +8 * self.Dq + self.B + 2 * self.C - BB = -2 * self.Dq + 2 * self.C - - # non diagonal elements - - AB = BA = +_2sqrt3 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +8 * self.Dq + self.B + 2 * self.C, + -2 * self.Dq + 2 * self.C + ] + off_diag_elements = { + (0, 1): +_2sqrt3 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_1_states(self): """Calculate the T_3_1 states.""" - # - diagonal elements - - AA = +8 * self.Dq - 5 * self.B - BB = -2 * self.Dq + 4 * self.B - - # non diagonal elements - - AB = BA = 6 * self.B - - states = np.array([[AA, AB], [BA, BB]]) - + diag_elements = [ + +8 * self.Dq - 5 * self.B, + -2 * self.Dq + 4 * self.B + ] + off_diag_elements = { + (0, 1): 6 * self.B + } + states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - - def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. From fd2f75c12d6f76caccba283687f90b62fdf6680a Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sun, 10 Nov 2024 05:41:54 +0000 Subject: [PATCH 02/11] feat: Update poetry-core version and add pytest configuration with new tests for LigandFieldTheory --- poetry.lock | 162 ++++++++++++++++++++++++----------------------- pyproject.toml | 9 ++- test_matrices.py | 63 ++++++++++++++++++ 3 files changed, 153 insertions(+), 81 deletions(-) create mode 100644 test_matrices.py diff --git a/poetry.lock b/poetry.lock index a0d16c5..cc91ce0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "black" @@ -763,75 +763,77 @@ files = [ [[package]] name = "numpy" -version = "2.1.2" +version = "2.1.3" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.10" files = [ - {file = "numpy-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:30d53720b726ec36a7f88dc873f0eec8447fbc93d93a8f079dfac2629598d6ee"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8d3ca0a72dd8846eb6f7dfe8f19088060fcb76931ed592d29128e0219652884"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:fc44e3c68ff00fd991b59092a54350e6e4911152682b4782f68070985aa9e648"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:7c1c60328bd964b53f8b835df69ae8198659e2b9302ff9ebb7de4e5a5994db3d"}, - {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cdb606a7478f9ad91c6283e238544451e3a95f30fb5467fbf715964341a8a86"}, - {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d666cb72687559689e9906197e3bec7b736764df6a2e58ee265e360663e9baf7"}, - {file = "numpy-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c6eef7a2dbd0abfb0d9eaf78b73017dbfd0b54051102ff4e6a7b2980d5ac1a03"}, - {file = "numpy-2.1.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:12edb90831ff481f7ef5f6bc6431a9d74dc0e5ff401559a71e5e4611d4f2d466"}, - {file = "numpy-2.1.2-cp310-cp310-win32.whl", hash = "sha256:a65acfdb9c6ebb8368490dbafe83c03c7e277b37e6857f0caeadbbc56e12f4fb"}, - {file = "numpy-2.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:860ec6e63e2c5c2ee5e9121808145c7bf86c96cca9ad396c0bd3e0f2798ccbe2"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b42a1a511c81cc78cbc4539675713bbcf9d9c3913386243ceff0e9429ca892fe"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:faa88bc527d0f097abdc2c663cddf37c05a1c2f113716601555249805cf573f1"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:c82af4b2ddd2ee72d1fc0c6695048d457e00b3582ccde72d8a1c991b808bb20f"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:13602b3174432a35b16c4cfb5de9a12d229727c3dd47a6ce35111f2ebdf66ff4"}, - {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ebec5fd716c5a5b3d8dfcc439be82a8407b7b24b230d0ad28a81b61c2f4659a"}, - {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2b49c3c0804e8ecb05d59af8386ec2f74877f7ca8fd9c1e00be2672e4d399b1"}, - {file = "numpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2cbba4b30bf31ddbe97f1c7205ef976909a93a66bb1583e983adbd155ba72ac2"}, - {file = "numpy-2.1.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8e00ea6fc82e8a804433d3e9cedaa1051a1422cb6e443011590c14d2dea59146"}, - {file = "numpy-2.1.2-cp311-cp311-win32.whl", hash = "sha256:5006b13a06e0b38d561fab5ccc37581f23c9511879be7693bd33c7cd15ca227c"}, - {file = "numpy-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:f1eb068ead09f4994dec71c24b2844f1e4e4e013b9629f812f292f04bd1510d9"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7bf0a4f9f15b32b5ba53147369e94296f5fffb783db5aacc1be15b4bf72f43b"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b1d0fcae4f0949f215d4632be684a539859b295e2d0cb14f78ec231915d644db"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:f751ed0a2f250541e19dfca9f1eafa31a392c71c832b6bb9e113b10d050cb0f1"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:bd33f82e95ba7ad632bc57837ee99dba3d7e006536200c4e9124089e1bf42426"}, - {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b8cde4f11f0a975d1fd59373b32e2f5a562ade7cde4f85b7137f3de8fbb29a0"}, - {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d95f286b8244b3649b477ac066c6906fbb2905f8ac19b170e2175d3d799f4df"}, - {file = "numpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ab4754d432e3ac42d33a269c8567413bdb541689b02d93788af4131018cbf366"}, - {file = "numpy-2.1.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e585c8ae871fd38ac50598f4763d73ec5497b0de9a0ab4ef5b69f01c6a046142"}, - {file = "numpy-2.1.2-cp312-cp312-win32.whl", hash = "sha256:9c6c754df29ce6a89ed23afb25550d1c2d5fdb9901d9c67a16e0b16eaf7e2550"}, - {file = "numpy-2.1.2-cp312-cp312-win_amd64.whl", hash = "sha256:456e3b11cb79ac9946c822a56346ec80275eaf2950314b249b512896c0d2505e"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a84498e0d0a1174f2b3ed769b67b656aa5460c92c9554039e11f20a05650f00d"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4d6ec0d4222e8ffdab1744da2560f07856421b367928026fb540e1945f2eeeaf"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:259ec80d54999cc34cd1eb8ded513cb053c3bf4829152a2e00de2371bd406f5e"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:675c741d4739af2dc20cd6c6a5c4b7355c728167845e3c6b0e824e4e5d36a6c3"}, - {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05b2d4e667895cc55e3ff2b56077e4c8a5604361fc21a042845ea3ad67465aa8"}, - {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43cca367bf94a14aca50b89e9bc2061683116cfe864e56740e083392f533ce7a"}, - {file = "numpy-2.1.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:76322dcdb16fccf2ac56f99048af32259dcc488d9b7e25b51e5eca5147a3fb98"}, - {file = "numpy-2.1.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:32e16a03138cabe0cb28e1007ee82264296ac0983714094380b408097a418cfe"}, - {file = "numpy-2.1.2-cp313-cp313-win32.whl", hash = "sha256:242b39d00e4944431a3cd2db2f5377e15b5785920421993770cddb89992c3f3a"}, - {file = "numpy-2.1.2-cp313-cp313-win_amd64.whl", hash = "sha256:f2ded8d9b6f68cc26f8425eda5d3877b47343e68ca23d0d0846f4d312ecaa445"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2ffef621c14ebb0188a8633348504a35c13680d6da93ab5cb86f4e54b7e922b5"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ad369ed238b1959dfbade9018a740fb9392c5ac4f9b5173f420bd4f37ba1f7a0"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:d82075752f40c0ddf57e6e02673a17f6cb0f8eb3f587f63ca1eaab5594da5b17"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1600068c262af1ca9580a527d43dc9d959b0b1d8e56f8a05d830eea39b7c8af6"}, - {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a26ae94658d3ba3781d5e103ac07a876b3e9b29db53f68ed7df432fd033358a8"}, - {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13311c2db4c5f7609b462bc0f43d3c465424d25c626d95040f073e30f7570e35"}, - {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:2abbf905a0b568706391ec6fa15161fad0fb5d8b68d73c461b3c1bab6064dd62"}, - {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:ef444c57d664d35cac4e18c298c47d7b504c66b17c2ea91312e979fcfbdfb08a"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:bdd407c40483463898b84490770199d5714dcc9dd9b792f6c6caccc523c00952"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:da65fb46d4cbb75cb417cddf6ba5e7582eb7bb0b47db4b99c9fe5787ce5d91f5"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c193d0b0238638e6fc5f10f1b074a6993cb13b0b431f64079a509d63d3aa8b7"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a7d80b2e904faa63068ead63107189164ca443b42dd1930299e0d1cb041cec2e"}, - {file = "numpy-2.1.2.tar.gz", hash = "sha256:13532a088217fa624c99b843eeb54640de23b3414b14aa66d023805eb731066c"}, + {file = "numpy-2.1.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c894b4305373b9c5576d7a12b473702afdf48ce5369c074ba304cc5ad8730dff"}, + {file = "numpy-2.1.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b47fbb433d3260adcd51eb54f92a2ffbc90a4595f8970ee00e064c644ac788f5"}, + {file = "numpy-2.1.3-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:825656d0743699c529c5943554d223c021ff0494ff1442152ce887ef4f7561a1"}, + {file = "numpy-2.1.3-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:6a4825252fcc430a182ac4dee5a505053d262c807f8a924603d411f6718b88fd"}, + {file = "numpy-2.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e711e02f49e176a01d0349d82cb5f05ba4db7d5e7e0defd026328e5cfb3226d3"}, + {file = "numpy-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78574ac2d1a4a02421f25da9559850d59457bac82f2b8d7a44fe83a64f770098"}, + {file = "numpy-2.1.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c7662f0e3673fe4e832fe07b65c50342ea27d989f92c80355658c7f888fcc83c"}, + {file = "numpy-2.1.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:fa2d1337dc61c8dc417fbccf20f6d1e139896a30721b7f1e832b2bb6ef4eb6c4"}, + {file = "numpy-2.1.3-cp310-cp310-win32.whl", hash = "sha256:72dcc4a35a8515d83e76b58fdf8113a5c969ccd505c8a946759b24e3182d1f23"}, + {file = "numpy-2.1.3-cp310-cp310-win_amd64.whl", hash = "sha256:ecc76a9ba2911d8d37ac01de72834d8849e55473457558e12995f4cd53e778e0"}, + {file = "numpy-2.1.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4d1167c53b93f1f5d8a139a742b3c6f4d429b54e74e6b57d0eff40045187b15d"}, + {file = "numpy-2.1.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c80e4a09b3d95b4e1cac08643f1152fa71a0a821a2d4277334c88d54b2219a41"}, + {file = "numpy-2.1.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:576a1c1d25e9e02ed7fa5477f30a127fe56debd53b8d2c89d5578f9857d03ca9"}, + {file = "numpy-2.1.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:973faafebaae4c0aaa1a1ca1ce02434554d67e628b8d805e61f874b84e136b09"}, + {file = "numpy-2.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:762479be47a4863e261a840e8e01608d124ee1361e48b96916f38b119cfda04a"}, + {file = "numpy-2.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc6f24b3d1ecc1eebfbf5d6051faa49af40b03be1aaa781ebdadcbc090b4539b"}, + {file = "numpy-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:17ee83a1f4fef3c94d16dc1802b998668b5419362c8a4f4e8a491de1b41cc3ee"}, + {file = "numpy-2.1.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:15cb89f39fa6d0bdfb600ea24b250e5f1a3df23f901f51c8debaa6a5d122b2f0"}, + {file = "numpy-2.1.3-cp311-cp311-win32.whl", hash = "sha256:d9beb777a78c331580705326d2367488d5bc473b49a9bc3036c154832520aca9"}, + {file = "numpy-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:d89dd2b6da69c4fff5e39c28a382199ddedc3a5be5390115608345dec660b9e2"}, + {file = "numpy-2.1.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f55ba01150f52b1027829b50d70ef1dafd9821ea82905b63936668403c3b471e"}, + {file = "numpy-2.1.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:13138eadd4f4da03074851a698ffa7e405f41a0845a6b1ad135b81596e4e9958"}, + {file = "numpy-2.1.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:a6b46587b14b888e95e4a24d7b13ae91fa22386c199ee7b418f449032b2fa3b8"}, + {file = "numpy-2.1.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:0fa14563cc46422e99daef53d725d0c326e99e468a9320a240affffe87852564"}, + {file = "numpy-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8637dcd2caa676e475503d1f8fdb327bc495554e10838019651b76d17b98e512"}, + {file = "numpy-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2312b2aa89e1f43ecea6da6ea9a810d06aae08321609d8dc0d0eda6d946a541b"}, + {file = "numpy-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a38c19106902bb19351b83802531fea19dee18e5b37b36454f27f11ff956f7fc"}, + {file = "numpy-2.1.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:02135ade8b8a84011cbb67dc44e07c58f28575cf9ecf8ab304e51c05528c19f0"}, + {file = "numpy-2.1.3-cp312-cp312-win32.whl", hash = "sha256:e6988e90fcf617da2b5c78902fe8e668361b43b4fe26dbf2d7b0f8034d4cafb9"}, + {file = "numpy-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:0d30c543f02e84e92c4b1f415b7c6b5326cbe45ee7882b6b77db7195fb971e3a"}, + {file = "numpy-2.1.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:96fe52fcdb9345b7cd82ecd34547fca4321f7656d500eca497eb7ea5a926692f"}, + {file = "numpy-2.1.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f653490b33e9c3a4c1c01d41bc2aef08f9475af51146e4a7710c450cf9761598"}, + {file = "numpy-2.1.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:dc258a761a16daa791081d026f0ed4399b582712e6fc887a95af09df10c5ca57"}, + {file = "numpy-2.1.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:016d0f6f5e77b0f0d45d77387ffa4bb89816b57c835580c3ce8e099ef830befe"}, + {file = "numpy-2.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c181ba05ce8299c7aa3125c27b9c2167bca4a4445b7ce73d5febc411ca692e43"}, + {file = "numpy-2.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5641516794ca9e5f8a4d17bb45446998c6554704d888f86df9b200e66bdcce56"}, + {file = "numpy-2.1.3-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ea4dedd6e394a9c180b33c2c872b92f7ce0f8e7ad93e9585312b0c5a04777a4a"}, + {file = "numpy-2.1.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b0df3635b9c8ef48bd3be5f862cf71b0a4716fa0e702155c45067c6b711ddcef"}, + {file = "numpy-2.1.3-cp313-cp313-win32.whl", hash = "sha256:50ca6aba6e163363f132b5c101ba078b8cbd3fa92c7865fd7d4d62d9779ac29f"}, + {file = "numpy-2.1.3-cp313-cp313-win_amd64.whl", hash = "sha256:747641635d3d44bcb380d950679462fae44f54b131be347d5ec2bce47d3df9ed"}, + {file = "numpy-2.1.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:996bb9399059c5b82f76b53ff8bb686069c05acc94656bb259b1d63d04a9506f"}, + {file = "numpy-2.1.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:45966d859916ad02b779706bb43b954281db43e185015df6eb3323120188f9e4"}, + {file = "numpy-2.1.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:baed7e8d7481bfe0874b566850cb0b85243e982388b7b23348c6db2ee2b2ae8e"}, + {file = "numpy-2.1.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:a9f7f672a3388133335589cfca93ed468509cb7b93ba3105fce780d04a6576a0"}, + {file = "numpy-2.1.3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7aac50327da5d208db2eec22eb11e491e3fe13d22653dce51b0f4109101b408"}, + {file = "numpy-2.1.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4394bc0dbd074b7f9b52024832d16e019decebf86caf909d94f6b3f77a8ee3b6"}, + {file = "numpy-2.1.3-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:50d18c4358a0a8a53f12a8ba9d772ab2d460321e6a93d6064fc22443d189853f"}, + {file = "numpy-2.1.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:14e253bd43fc6b37af4921b10f6add6925878a42a0c5fe83daee390bca80bc17"}, + {file = "numpy-2.1.3-cp313-cp313t-win32.whl", hash = "sha256:08788d27a5fd867a663f6fc753fd7c3ad7e92747efc73c53bca2f19f8bc06f48"}, + {file = "numpy-2.1.3-cp313-cp313t-win_amd64.whl", hash = "sha256:2564fbdf2b99b3f815f2107c1bbc93e2de8ee655a69c261363a1172a79a257d4"}, + {file = "numpy-2.1.3-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:4f2015dfe437dfebbfce7c85c7b53d81ba49e71ba7eadbf1df40c915af75979f"}, + {file = "numpy-2.1.3-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:3522b0dfe983a575e6a9ab3a4a4dfe156c3e428468ff08ce582b9bb6bd1d71d4"}, + {file = "numpy-2.1.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c006b607a865b07cd981ccb218a04fc86b600411d83d6fc261357f1c0966755d"}, + {file = "numpy-2.1.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:e14e26956e6f1696070788252dcdff11b4aca4c3e8bd166e0df1bb8f315a67cb"}, + {file = "numpy-2.1.3.tar.gz", hash = "sha256:aa08e04e08aaf974d4458def539dece0d28146d866a39da5639596f4921fd761"}, ] [[package]] name = "packaging" -version = "24.1" +version = "24.2" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, ] [[package]] @@ -1244,13 +1246,13 @@ files = [ [[package]] name = "rich" -version = "13.9.3" +version = "13.9.4" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.8.0" files = [ - {file = "rich-13.9.3-py3-none-any.whl", hash = "sha256:9836f5096eb2172c9e77df411c1b009bace4193d6a481d534fea75ebba758283"}, - {file = "rich-13.9.3.tar.gz", hash = "sha256:bc1e01b899537598cf02579d2b9f4a415104d3fc439313a7a2c165d76557a08e"}, + {file = "rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"}, + {file = "rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098"}, ] [package.dependencies] @@ -1263,29 +1265,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.7.0" +version = "0.7.3" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.7.0-py3-none-linux_armv6l.whl", hash = "sha256:0cdf20c2b6ff98e37df47b2b0bd3a34aaa155f59a11182c1303cce79be715628"}, - {file = "ruff-0.7.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:496494d350c7fdeb36ca4ef1c9f21d80d182423718782222c29b3e72b3512737"}, - {file = "ruff-0.7.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:214b88498684e20b6b2b8852c01d50f0651f3cc6118dfa113b4def9f14faaf06"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630fce3fefe9844e91ea5bbf7ceadab4f9981f42b704fae011bb8efcaf5d84be"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:211d877674e9373d4bb0f1c80f97a0201c61bcd1e9d045b6e9726adc42c156aa"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:194d6c46c98c73949a106425ed40a576f52291c12bc21399eb8f13a0f7073495"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:82c2579b82b9973a110fab281860403b397c08c403de92de19568f32f7178598"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9af971fe85dcd5eaed8f585ddbc6bdbe8c217fb8fcf510ea6bca5bdfff56040e"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b641c7f16939b7d24b7bfc0be4102c56562a18281f84f635604e8a6989948914"}, - {file = "ruff-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d71672336e46b34e0c90a790afeac8a31954fd42872c1f6adaea1dff76fd44f9"}, - {file = "ruff-0.7.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ab7d98c7eed355166f367597e513a6c82408df4181a937628dbec79abb2a1fe4"}, - {file = "ruff-0.7.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1eb54986f770f49edb14f71d33312d79e00e629a57387382200b1ef12d6a4ef9"}, - {file = "ruff-0.7.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:dc452ba6f2bb9cf8726a84aa877061a2462afe9ae0ea1d411c53d226661c601d"}, - {file = "ruff-0.7.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:4b406c2dce5be9bad59f2de26139a86017a517e6bcd2688da515481c05a2cb11"}, - {file = "ruff-0.7.0-py3-none-win32.whl", hash = "sha256:f6c968509f767776f524a8430426539587d5ec5c662f6addb6aa25bc2e8195ec"}, - {file = "ruff-0.7.0-py3-none-win_amd64.whl", hash = "sha256:ff4aabfbaaba880e85d394603b9e75d32b0693152e16fa659a3064a85df7fce2"}, - {file = "ruff-0.7.0-py3-none-win_arm64.whl", hash = "sha256:10842f69c245e78d6adec7e1db0a7d9ddc2fff0621d730e61657b64fa36f207e"}, - {file = "ruff-0.7.0.tar.gz", hash = "sha256:47a86360cf62d9cd53ebfb0b5eb0e882193fc191c6d717e8bef4462bc3b9ea2b"}, + {file = "ruff-0.7.3-py3-none-linux_armv6l.whl", hash = "sha256:34f2339dc22687ec7e7002792d1f50712bf84a13d5152e75712ac08be565d344"}, + {file = "ruff-0.7.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:fb397332a1879b9764a3455a0bb1087bda876c2db8aca3a3cbb67b3dbce8cda0"}, + {file = "ruff-0.7.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:37d0b619546103274e7f62643d14e1adcbccb242efda4e4bdb9544d7764782e9"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d59f0c3ee4d1a6787614e7135b72e21024875266101142a09a61439cb6e38a5"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:44eb93c2499a169d49fafd07bc62ac89b1bc800b197e50ff4633aed212569299"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6d0242ce53f3a576c35ee32d907475a8d569944c0407f91d207c8af5be5dae4e"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6b6224af8b5e09772c2ecb8dc9f3f344c1aa48201c7f07e7315367f6dd90ac29"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c50f95a82b94421c964fae4c27c0242890a20fe67d203d127e84fbb8013855f5"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7f3eff9961b5d2644bcf1616c606e93baa2d6b349e8aa8b035f654df252c8c67"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8963cab06d130c4df2fd52c84e9f10d297826d2e8169ae0c798b6221be1d1d2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:61b46049d6edc0e4317fb14b33bd693245281a3007288b68a3f5b74a22a0746d"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:10ebce7696afe4644e8c1a23b3cf8c0f2193a310c18387c06e583ae9ef284de2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3f36d56326b3aef8eeee150b700e519880d1aab92f471eefdef656fd57492aa2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5d024301109a0007b78d57ab0ba190087b43dce852e552734ebf0b0b85e4fb16"}, + {file = "ruff-0.7.3-py3-none-win32.whl", hash = "sha256:4ba81a5f0c5478aa61674c5a2194de8b02652f17addf8dfc40c8937e6e7d79fc"}, + {file = "ruff-0.7.3-py3-none-win_amd64.whl", hash = "sha256:588a9ff2fecf01025ed065fe28809cd5a53b43505f48b69a1ac7707b1b7e4088"}, + {file = "ruff-0.7.3-py3-none-win_arm64.whl", hash = "sha256:1713e2c5545863cdbfe2cbce21f69ffaf37b813bfd1fb3b90dc9a6f1963f5a8c"}, + {file = "ruff-0.7.3.tar.gz", hash = "sha256:e1d1ba2e40b6e71a61b063354d04be669ab0d39c352461f3d789cac68b54a313"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index e60e049..0d6317b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ exclude = ["test/**/*.py", "example/**", "ts-diagrams/**"] ruff = "^0.7.0" [build-system] -requires = ["poetry-core>=1.0.0"] +requires = ["poetry-core>=1.1.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] @@ -84,3 +84,10 @@ lines-between-types = 1 lines-after-imports = 2 known-third-party = ["poetry.core"] required-imports = ["from __future__ import annotations"] + +[tool.pytest.ini_options] +markers = """ + xfail: mark test as expecting to fail + skip: mark test as skipped +""" +addopts = "-v --cov=tanabesugano" diff --git a/test_matrices.py b/test_matrices.py new file mode 100644 index 0000000..e09b822 --- /dev/null +++ b/test_matrices.py @@ -0,0 +1,63 @@ + +import pytest +import numpy as np +from tanabesugano.matrices import LigandFieldTheory + +# Define a type alias for clarity +Float64Array = np.ndarray + +@pytest.fixture +def ligand_field_theory(): + # Arrange + # Create a fixture for the LigandFieldTheory instance + return LigandFieldTheory(Dq=1000.0, B=800.0, C=4000.0) + +@pytest.mark.parametrize( + "matrix, expected_eigenvalues", + [ + (np.array([[1, 0], [0, 1]], dtype=np.float64), np.array([1, 1], dtype=np.float64)), + (np.array([[2, 1], [1, 2]], dtype=np.float64), np.array([1, 3], dtype=np.float64)), + (np.array([[0, 0], [0, 0]], dtype=np.float64), np.array([0, 0], dtype=np.float64)), + ], + ids=["identity_matrix", "symmetric_matrix", "zero_matrix"] +) +def test_eigensolver(ligand_field_theory, matrix, expected_eigenvalues): + # Act + eigenvalues = ligand_field_theory.eigensolver(matrix) + + # Assert + np.testing.assert_array_almost_equal(eigenvalues, expected_eigenvalues) + +@pytest.mark.parametrize( + "diag_elements, off_diag_elements, expected_matrix", + [ + ([1, 2], {(0, 1): 0.5}, np.array([[1, 0.5], [0.5, 2]], dtype=np.float64)), + ([3, 4, 5], {(0, 2): 1.0, (1, 2): 0.5}, np.array([[3, 0, 1], [0, 4, 0.5], [1, 0.5, 5]], dtype=np.float64)), + ([0, 0], {}, np.array([[0, 0], [0, 0]], dtype=np.float64)), + ], + ids=["simple_2x2", "complex_3x3", "zero_2x2"] +) +def test_construct_matrix(ligand_field_theory, diag_elements, off_diag_elements, expected_matrix): + # Act + matrix = ligand_field_theory.construct_matrix(diag_elements, off_diag_elements) + + # Assert + np.testing.assert_array_almost_equal(matrix, expected_matrix) + +def test_solver_not_implemented(ligand_field_theory): + # Act & Assert + with pytest.raises(NotImplementedError, match="Subclasses should implement this method."): + ligand_field_theory.solver() + +@pytest.mark.parametrize( + "matrix", + [ + np.array([[1, 2], [3, 4]], dtype=np.float64), # Non-symmetric matrix + np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float64), # Non-square matrix + ], + ids=["non_symmetric_matrix", "non_square_matrix"] +) +def test_eigensolver_invalid_input(ligand_field_theory, matrix): + # Act & Assert + with pytest.raises(ValueError): + ligand_field_theory.eigensolver(matrix) From d92a0095931098eb0752bf34088be0919acb94f6 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sun, 10 Nov 2024 05:45:17 +0000 Subject: [PATCH 03/11] test: Mark eigensolver_invalid_input test as expected failure due to unimplemented functionality --- test_matrices.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test_matrices.py b/test_matrices.py index e09b822..9bee48f 100644 --- a/test_matrices.py +++ b/test_matrices.py @@ -57,6 +57,7 @@ def test_solver_not_implemented(ligand_field_theory): ], ids=["non_symmetric_matrix", "non_square_matrix"] ) +@pytest.mark.xfail(reason="Functionality not implemented yet") def test_eigensolver_invalid_input(ligand_field_theory, matrix): # Act & Assert with pytest.raises(ValueError): From 2a9a19950b117561901db7b58b1b0b2e186716c0 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 04:53:04 +0100 Subject: [PATCH 04/11] chore: :card_file_box: Moving test file --- test_matrices.py => tanabesugano/test/test_matrices.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test_matrices.py => tanabesugano/test/test_matrices.py (100%) diff --git a/test_matrices.py b/tanabesugano/test/test_matrices.py similarity index 100% rename from test_matrices.py rename to tanabesugano/test/test_matrices.py From 10eb8b4751fee22ddc0393772d5cff6aa84f8abe Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 04:59:10 +0100 Subject: [PATCH 05/11] chore: Clean up configuration files and update changelog formatting --- .github/dependabot.yml | 1 - .github/workflows/docker-image.yml | 2 +- CHANGELOG.md | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bf11320..91abb11 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,4 +9,3 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" - diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 25f3ebc..b5674f7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,4 +15,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Build the Docker image - run: docker build . --file Dockerfile --tag tanabesugano:$(date +%s) \ No newline at end of file + run: docker build . --file Dockerfile --tag tanabesugano:$(date +%s) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64aac6d..6a1aebe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,4 @@ * Add `poetry` for dependecy mangament * `setup.py` depends now on the `project.toml` * Modified the `GitHub-Actions` -* Introduced `TanabeSugano` batch for extending analysis of correlation matrices \ No newline at end of file +* Introduced `TanabeSugano` batch for extending analysis of correlation matrices From af5d424694be185b244cd6116d1d5a9032785830 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 17:23:00 +0100 Subject: [PATCH 06/11] refactor: Improve test readability by formatting and organizing parameterized tests --- tanabesugano/test/test_matrices.py | 41 ++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tanabesugano/test/test_matrices.py b/tanabesugano/test/test_matrices.py index 9bee48f..5790639 100644 --- a/tanabesugano/test/test_matrices.py +++ b/tanabesugano/test/test_matrices.py @@ -1,4 +1,3 @@ - import pytest import numpy as np from tanabesugano.matrices import LigandFieldTheory @@ -6,20 +5,31 @@ # Define a type alias for clarity Float64Array = np.ndarray + @pytest.fixture def ligand_field_theory(): # Arrange # Create a fixture for the LigandFieldTheory instance return LigandFieldTheory(Dq=1000.0, B=800.0, C=4000.0) + @pytest.mark.parametrize( "matrix, expected_eigenvalues", [ - (np.array([[1, 0], [0, 1]], dtype=np.float64), np.array([1, 1], dtype=np.float64)), - (np.array([[2, 1], [1, 2]], dtype=np.float64), np.array([1, 3], dtype=np.float64)), - (np.array([[0, 0], [0, 0]], dtype=np.float64), np.array([0, 0], dtype=np.float64)), + ( + np.array([[1, 0], [0, 1]], dtype=np.float64), + np.array([1, 1], dtype=np.float64), + ), + ( + np.array([[2, 1], [1, 2]], dtype=np.float64), + np.array([1, 3], dtype=np.float64), + ), + ( + np.array([[0, 0], [0, 0]], dtype=np.float64), + np.array([0, 0], dtype=np.float64), + ), ], - ids=["identity_matrix", "symmetric_matrix", "zero_matrix"] + ids=["identity_matrix", "symmetric_matrix", "zero_matrix"], ) def test_eigensolver(ligand_field_theory, matrix, expected_eigenvalues): # Act @@ -28,34 +38,45 @@ def test_eigensolver(ligand_field_theory, matrix, expected_eigenvalues): # Assert np.testing.assert_array_almost_equal(eigenvalues, expected_eigenvalues) + @pytest.mark.parametrize( "diag_elements, off_diag_elements, expected_matrix", [ ([1, 2], {(0, 1): 0.5}, np.array([[1, 0.5], [0.5, 2]], dtype=np.float64)), - ([3, 4, 5], {(0, 2): 1.0, (1, 2): 0.5}, np.array([[3, 0, 1], [0, 4, 0.5], [1, 0.5, 5]], dtype=np.float64)), + ( + [3, 4, 5], + {(0, 2): 1.0, (1, 2): 0.5}, + np.array([[3, 0, 1], [0, 4, 0.5], [1, 0.5, 5]], dtype=np.float64), + ), ([0, 0], {}, np.array([[0, 0], [0, 0]], dtype=np.float64)), ], - ids=["simple_2x2", "complex_3x3", "zero_2x2"] + ids=["simple_2x2", "complex_3x3", "zero_2x2"], ) -def test_construct_matrix(ligand_field_theory, diag_elements, off_diag_elements, expected_matrix): +def test_construct_matrix( + ligand_field_theory, diag_elements, off_diag_elements, expected_matrix +): # Act matrix = ligand_field_theory.construct_matrix(diag_elements, off_diag_elements) # Assert np.testing.assert_array_almost_equal(matrix, expected_matrix) + def test_solver_not_implemented(ligand_field_theory): # Act & Assert - with pytest.raises(NotImplementedError, match="Subclasses should implement this method."): + with pytest.raises( + NotImplementedError, match="Subclasses should implement this method." + ): ligand_field_theory.solver() + @pytest.mark.parametrize( "matrix", [ np.array([[1, 2], [3, 4]], dtype=np.float64), # Non-symmetric matrix np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float64), # Non-square matrix ], - ids=["non_symmetric_matrix", "non_square_matrix"] + ids=["non_symmetric_matrix", "non_square_matrix"], ) @pytest.mark.xfail(reason="Functionality not implemented yet") def test_eigensolver_invalid_input(ligand_field_theory, matrix): From 03db49cbd31f6e49d4080366bb64727aa47b09f7 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 17:24:55 +0100 Subject: [PATCH 07/11] style: Format code for improved readability by adjusting line breaks and spacing --- tanabesugano/__init__.py | 1 + tanabesugano/batch.py | 8 +- tanabesugano/cmd.py | 20 ++- tanabesugano/matrices.py | 233 ++++++++++++-------------------- tanabesugano/test/test_front.py | 6 +- tanabesugano/tools.py | 3 +- 6 files changed, 115 insertions(+), 156 deletions(-) diff --git a/tanabesugano/__init__.py b/tanabesugano/__init__.py index 7a69a1d..73a40da 100644 --- a/tanabesugano/__init__.py +++ b/tanabesugano/__init__.py @@ -1,4 +1,5 @@ """tanabesugano: A Python package for Tanabe-Sugano diagrams.""" + from __future__ import annotations diff --git a/tanabesugano/batch.py b/tanabesugano/batch.py index 3b3fcb1..9e1cd1d 100644 --- a/tanabesugano/batch.py +++ b/tanabesugano/batch.py @@ -33,14 +33,18 @@ def __init__( "The range of `B` is based on the three values: start, stop, steps!", ) self.B = np.linspace( - B[0], B[1], int(B[2]), + B[0], + B[1], + int(B[2]), ) # Racah-Parameter B in wavenumbers if len(C) != 3: raise KeyError( "The range of `C` is based on the three values: start, stop, steps!", ) self.C = np.linspace( - C[0], C[1], int(C[2]), + C[0], + C[1], + int(C[2]), ) # Racah-Parameter C in wavenumbers if slater: diff --git a/tanabesugano/cmd.py b/tanabesugano/cmd.py index 3f1af2f..825c08b 100644 --- a/tanabesugano/cmd.py +++ b/tanabesugano/cmd.py @@ -103,7 +103,9 @@ def plot(self) -> None: ls="--", ) self.label_plot( - "DD excitations -Diagram", r"$dd-state-energy\,(1/cm)$", r"$10Dq\,(1/cm)$", + "DD excitations -Diagram", + r"$dd-state-energy\,(1/cm)$", + r"$10Dq\,(1/cm)$", ) plt.show() @@ -128,8 +130,7 @@ def savetxt(self) -> None: ).to_csv(Path(f"{self.title_DD}.csv"), index=False) def calculation(self) -> None: - """Is filling the self.result with the iTS states of over-iterated energy range - """ + """Is filling the self.result with the iTS states of over-iterated energy range""" result = [] for dq in self.df["Energy"]: if self.d_count == 2: # d2 @@ -197,8 +198,7 @@ def subsplit_states(states: dict) -> dict: return rearranged_states def ci_cut(self, dq_ci: float = None) -> None: - """Extracting the atomic-termsymbols for a specific dq depending on the oxidation state - """ + """Extracting the atomic-termsymbols for a specific dq depending on the oxidation state""" if self.d_count == 2: # d2 states = matrices.d2(Dq=dq_ci / 10.0, B=self.B, C=self.C).solver() self.ts_print(states, dq_ci=dq_ci) @@ -366,7 +366,10 @@ def cmd_line() -> None: parser = argparse.ArgumentParser(description=description) parser.add_argument( - "-d", type=int, default=6, help="Number of unpaired electrons (default d5)", + "-d", + type=int, + default=6, + help="Number of unpaired electrons (default d5)", ) parser.add_argument( "-Dq", @@ -398,7 +401,10 @@ def cmd_line() -> None: "1.)", ) parser.add_argument( - "-n", type=int, default=500, help="Number of roots (default nroots = 500)", + "-n", + type=int, + default=500, + help="Number of roots (default nroots = 500)", ) parser.add_argument( "-ndisp", diff --git a/tanabesugano/matrices.py b/tanabesugano/matrices.py index 47d7821..d583f8c 100644 --- a/tanabesugano/matrices.py +++ b/tanabesugano/matrices.py @@ -68,7 +68,7 @@ def solver(self) -> Dict[str, Float64Array]: def construct_matrix( self, diag_elements: List[float], - off_diag_elements: Dict[Tuple[int, int], float] + off_diag_elements: Dict[Tuple[int, int], float], ) -> Float64Array: """Constructs a symmetric matrix from diagonal and off-diagonal elements.""" size = len(diag_elements) @@ -81,8 +81,7 @@ def construct_matrix( class d2(LigandFieldTheory): - """Class representing the d2 configuration in ligand field theory. - """ + """Class representing the d2 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3801.0) -> None: """Initializes the d2 configuration with given parameters. @@ -98,46 +97,29 @@ def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3801.0) -> None def A_1_1_states(self) -> Float64Array: diag_elements = [ -8 * self.Dq + 10 * self.B + 5 * self.C, - +12 * self.Dq + 8 * self.B + 4 * self.C + +12 * self.Dq + 8 * self.B + 4 * self.C, ] - off_diag_elements = { - (0, 1): _sqrt6 * (2 * self.B + self.C) - } + off_diag_elements = {(0, 1): _sqrt6 * (2 * self.B + self.C)} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_states(self) -> Float64Array: - diag_elements = [ - -8 * self.Dq + self.B + 2 * self.C, - +12 * self.Dq + 2 * self.C - ] - off_diag_elements = { - (0, 1): -_2sqrt3 * self.B - } + diag_elements = [-8 * self.Dq + self.B + 2 * self.C, +12 * self.Dq + 2 * self.C] + off_diag_elements = {(0, 1): -_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self) -> Float64Array: """Calculate the T_1_2 states.""" - diag_elements = [ - -8 * self.Dq + self.B + 2 * self.C, - +2 * self.Dq + 2 * self.C - ] - off_diag_elements = { - (0, 1): +_2sqrt3 * self.B - } + diag_elements = [-8 * self.Dq + self.B + 2 * self.C, +2 * self.Dq + 2 * self.C] + off_diag_elements = {(0, 1): +_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_1_states(self) -> Float64Array: """Calculate the T_3_1 states.""" - diag_elements = [ - -8 * self.Dq - 5 * self.B, - +2 * self.Dq + 4 * self.B - ] - off_diag_elements = { - (0, 1): 6 * self.B - } + diag_elements = [-8 * self.Dq - 5 * self.B, +2 * self.Dq + 4 * self.B] + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -193,7 +175,7 @@ def T_2_2_states(self) -> Float64Array: -2 * self.Dq - 6 * self.B + 3 * self.C, -2 * self.Dq + 4 * self.B + 3 * self.C, +8 * self.Dq + 6 * self.B + 5 * self.C, - +8 * self.Dq - 2 * self.B + 3 * self.C + +8 * self.Dq - 2 * self.B + 3 * self.C, ] off_diag_elements = { (0, 1): -_3sqrt3 * self.B, @@ -205,7 +187,7 @@ def T_2_2_states(self) -> Float64Array: (1, 4): -_3sqrt3 * self.B, (2, 3): -_sqrt3 * self.B, (2, 4): +_sqrt3 * self.B, - (3, 4): 10 * self.B + (3, 4): 10 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -217,7 +199,7 @@ def T_2_1_states(self) -> Float64Array: -2 * self.Dq + 3 * self.C, -2 * self.Dq - 6 * self.B + 3 * self.C, +8 * self.Dq - 6 * self.B + 3 * self.C, - +8 * self.Dq - 2 * self.B + 3 * self.C + +8 * self.Dq - 2 * self.B + 3 * self.C, ] off_diag_elements = { (0, 1): -3 * self.B, @@ -229,7 +211,7 @@ def T_2_1_states(self) -> Float64Array: (1, 4): _3sqrt3 * self.B, (2, 3): -3 * self.B, (2, 4): -_sqrt3 * self.B, - (3, 4): _2sqrt3 * self.B + (3, 4): _2sqrt3 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -240,7 +222,7 @@ def E_2_states(self) -> Float64Array: -12 * self.Dq - 6 * self.B + 3 * self.C, -2 * self.Dq + 8 * self.B + 6 * self.C, -2 * self.Dq - 1 * self.B + 3 * self.C, - +18 * self.Dq - 8 * self.B + 4 * self.C + +18 * self.Dq - 8 * self.B + 4 * self.C, ] off_diag_elements = { (0, 1): -6 * _sqrt2 * self.B, @@ -248,20 +230,15 @@ def E_2_states(self) -> Float64Array: (0, 3): 0.0, (1, 2): 10 * self.B, (1, 3): +_sqrt3 * (2 * self.B + self.C), - (2, 3): _2sqrt3 * self.B + (2, 3): _2sqrt3 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_1_states(self) -> Float64Array: """Calculate the T_4_1 states.""" - diag_elements = [ - -2 * self.Dq - 3 * self.B, - +8 * self.Dq - 12 * self.B - ] - off_diag_elements = { - (0, 1): 6 * self.B - } + diag_elements = [-2 * self.Dq - 3 * self.B, +8 * self.Dq - 12 * self.B] + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -322,7 +299,7 @@ def T_3_1_states(self) -> Float64Array: +4 * self.Dq - self.B + 6 * self.C, +4 * self.Dq - 9 * self.B + 4 * self.C, +4 * self.Dq - 11 * self.B + 4 * self.C, - +14 * self.Dq - 16 * self.B + 5 * self.C + +14 * self.Dq - 16 * self.B + 5 * self.C, ] off_diag_elements = { (0, 1): -_sqrt6 * self.B, @@ -345,7 +322,7 @@ def T_3_1_states(self) -> Float64Array: (3, 6): _3sqrt2 * self.B, (4, 5): -2 * _sqrt3 * self.B, (4, 6): -_3sqrt2 * self.B, - (5, 6): _sqrt6 * self.B + (5, 6): _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -359,7 +336,7 @@ def T_1_2_states(self) -> Float64Array: +4 * self.Dq - 9 * self.B + 6 * self.C, +4 * self.Dq - 3 * self.B + 6 * self.C, +4 * self.Dq + 5 * self.B + 8 * self.C, - +14 * self.Dq + 7 * self.C + +14 * self.Dq + 7 * self.C, ] off_diag_elements = { (0, 1): _3sqrt2 * self.B, @@ -382,7 +359,7 @@ def T_1_2_states(self) -> Float64Array: (3, 6): -_3sqrt6 * self.B, (4, 5): -10 * self.B, (4, 6): _sqrt6 * self.B, - (5, 6): _sqrt6 * self.B + (5, 6): _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -394,7 +371,7 @@ def A_1_1_states(self) -> Float64Array: -6 * self.Dq + 6 * self.C, +4 * self.Dq + 14 * self.B + 11 * self.C, +4 * self.Dq - 3 * self.B + 6 * self.C, - +24 * self.Dq - 16 * self.B + 8 * self.C + +24 * self.Dq - 16 * self.B + 8 * self.C, ] off_diag_elements = { (0, 1): -12 * _sqrt2 * self.B, @@ -406,7 +383,7 @@ def A_1_1_states(self) -> Float64Array: (1, 4): 0.0, (2, 3): 20 * self.B, (2, 4): _sqrt6 * (2 * self.B + self.C), - (3, 4): 2 * _sqrt6 * self.B + (3, 4): 2 * _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -418,7 +395,7 @@ def E_1_1_states(self) -> Float64Array: -6 * self.Dq - 6 * self.B + 6 * self.C, +4 * self.Dq + 5 * self.B + 8 * self.C, +4 * self.Dq + 6 * self.B + 9 * self.C, - +4 * self.Dq - 3 * self.B + 6 * self.C + +4 * self.Dq - 3 * self.B + 6 * self.C, ] off_diag_elements = { (0, 1): 6 * self.B, @@ -430,7 +407,7 @@ def E_1_1_states(self) -> Float64Array: (1, 4): 0.0, (2, 3): 10 * _sqrt2 * self.B, (2, 4): -10 * _sqrt2 * self.B, - (3, 4): 0.0 + (3, 4): 0.0, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -442,7 +419,7 @@ def T_3_2_states(self) -> Float64Array: -6 * self.Dq - 5 * self.B + 6 * self.C, +4 * self.Dq - 13 * self.B + 4 * self.C, +4 * self.Dq - 9 * self.B + 4 * self.C, - +14 * self.Dq - 8 * self.B + 5 * self.C + +14 * self.Dq - 8 * self.B + 5 * self.C, ] off_diag_elements = { (0, 1): -5 * _sqrt3 * self.B, @@ -454,7 +431,7 @@ def T_3_2_states(self) -> Float64Array: (1, 4): _sqrt2 * (3 * self.B + self.C), (2, 3): -2 * _sqrt2 * self.B, (2, 4): -6 * self.B, - (3, 4): _3sqrt2 * self.B + (3, 4): _3sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -465,7 +442,7 @@ def T_1_1_states(self) -> Float64Array: -6 * self.Dq - 3 * self.B + 6 * self.C, -6 * self.Dq - 3 * self.B + 8 * self.C, +4 * self.Dq - 3 * self.B + 6 * self.C, - +14 * self.Dq - 16 * self.B + 7 * self.C + +14 * self.Dq - 16 * self.B + 7 * self.C, ] off_diag_elements = { (0, 1): 5 * _sqrt3 * self.B, @@ -473,7 +450,7 @@ def T_1_1_states(self) -> Float64Array: (0, 3): _sqrt6 * self.B, (1, 2): -5 * _sqrt3 * self.B, (1, 3): _sqrt2 * (self.B + self.C), - (2, 3): -_sqrt6 * self.B + (2, 3): -_sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -483,12 +460,12 @@ def E_3_1_states(self) -> Float64Array: diag_elements = [ -6 * self.Dq - 13 * self.B + 4 * self.C, -6 * self.Dq - 10 * self.B + 4 * self.C, - +4 * self.Dq - 11 * self.B + 4 * self.C + +4 * self.Dq - 11 * self.B + 4 * self.C, ] off_diag_elements = { (0, 1): -4 * self.B, (0, 2): 0.0, - (1, 2): -_3sqrt2 * self.B + (1, 2): -_3sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -497,11 +474,9 @@ def A_3_2_states(self) -> Float64Array: """Calculate the A_3_2 states.""" diag_elements = [ -6 * self.Dq - 8 * self.B + 4 * self.C, - +4 * self.Dq - 2 * self.B + 7 * self.C + +4 * self.Dq - 2 * self.B + 7 * self.C, ] - off_diag_elements = { - (0, 1): -12 * self.B - } + off_diag_elements = {(0, 1): -12 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -509,11 +484,9 @@ def A_1_2_states(self) -> Float64Array: """Calculate the A_1_2 states.""" diag_elements = [ -6 * self.Dq - 12 * self.B + 6 * self.C, - +4 * self.Dq - 3 * self.B + 6 * self.C + +4 * self.Dq - 3 * self.B + 6 * self.C, ] - off_diag_elements = { - (0, 1): 6 * self.B - } + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -599,7 +572,7 @@ def T_2_2_states(self) -> Float64Array: -6 * self.B + 10 * self.C, +10 * self.Dq - 18 * self.B + 9 * self.C, +10 * self.Dq - 8 * self.B + 9 * self.C, - +20 * self.Dq - 20 * self.B + 10 * self.C + +20 * self.Dq - 20 * self.B + 10 * self.C, ] off_diag_elements = { (0, 1): _3sqrt6 * self.B, @@ -646,7 +619,7 @@ def T_2_2_states(self) -> Float64Array: (6, 9): -2.0 * self.B, (7, 8): 3 * self.B, (7, 9): -_sqrt6 * self.B, - (8, 9): -_3sqrt6 * self.B + (8, 9): -_3sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -661,7 +634,7 @@ def T_2_1_states(self) -> Float64Array: -10 * self.B + 10 * self.C, -6 * self.B + 10 * self.C, +10 * self.Dq - 8 * self.B + 9 * self.C, - +10 * self.Dq - 22 * self.B + 9 * self.C + +10 * self.Dq - 22 * self.B + 9 * self.C, ] off_diag_elements = { (0, 1): -3 * self.B, @@ -691,7 +664,7 @@ def T_2_1_states(self) -> Float64Array: (4, 7): -_3sqrt2 / 2.0 * self.B, (5, 6): 5 * _sqrt6 / 2.0 * self.B, (5, 7): -_3sqrt6 / 2.0 * self.B, - (6, 7): -3 * self.B + (6, 7): -3 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -705,7 +678,7 @@ def E_2_states(self) -> Float64Array: -16 * self.B + 8 * self.C, -12 * self.B + 8 * self.C, +10 * self.Dq - 13 * self.B + 9 * self.C, - +10 * self.Dq - 4 * self.B + 12 * self.C + +10 * self.Dq - 4 * self.B + 12 * self.C, ] off_diag_elements = { (0, 1): 10 * self.B, @@ -728,7 +701,7 @@ def E_2_states(self) -> Float64Array: (3, 6): 6 * _sqrt3 * self.B, (4, 5): 0.0, (4, 6): 6 * _sqrt2 * self.B, - (5, 6): -10 * self.B + (5, 6): -10 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -739,7 +712,7 @@ def A_2_1_states(self) -> Float64Array: -10 * self.Dq - 3 * self.B + 9 * self.C, -12 * self.B + 8 * self.C, -19 * self.B + 8 * self.C, - +10 * self.Dq - 3 * self.B + 9 * self.C + +10 * self.Dq - 3 * self.B + 9 * self.C, ] off_diag_elements = { (0, 1): -_3sqrt2 * self.B, @@ -747,7 +720,7 @@ def A_2_1_states(self) -> Float64Array: (0, 3): 6 * self.B + self.C, (1, 2): -4 * _sqrt3 * self.B, (1, 3): _3sqrt2 * self.B, - (2, 3): 0.0 + (2, 3): 0.0, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -757,12 +730,12 @@ def A_2_2_states(self) -> Float64Array: diag_elements = [ -10 * self.Dq - 23 * self.B + 9 * self.C, -12 * self.B + 8 * self.C, - +10 * self.Dq - 23 * self.B + 9 * self.C + +10 * self.Dq - 23 * self.B + 9 * self.C, ] off_diag_elements = { (0, 1): _3sqrt2 * self.B, (0, 2): -2 * self.B + self.C, - (1, 2): -_3sqrt2 * self.B + (1, 2): -_3sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -772,12 +745,12 @@ def T_4_1_states(self) -> Float64Array: diag_elements = [ -10 * self.Dq - 25 * self.B + 6 * self.C, -16 * self.B + 7 * self.C, - 10 * self.Dq - 25 * self.B + 6 * self.C + 10 * self.Dq - 25 * self.B + 6 * self.C, ] off_diag_elements = { (0, 1): -_3sqrt2 * self.B, (0, 2): self.C, - (1, 2): -_3sqrt2 * self.B + (1, 2): -_3sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -787,25 +760,20 @@ def T_4_2_states(self) -> Float64Array: diag_elements = [ -10 * self.Dq - 17 * self.B + 6 * self.C, -22 * self.B + 5 * self.C, - +10 * self.Dq - 17 * self.B + 6 * self.C + +10 * self.Dq - 17 * self.B + 6 * self.C, ] off_diag_elements = { (0, 1): _sqrt6 * self.B, (0, 2): +4 * self.B + self.C, - (1, 2): -_sqrt6 * self.B + (1, 2): -_sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_4_states(self) -> Float64Array: """Calculate the E_4 states.""" - diag_elements = [ - -22 * self.B + 5 * self.C, - -21 * self.B + 5 * self.C - ] - off_diag_elements = { - (0, 1): -2 * _sqrt3 * self.B - } + diag_elements = [-22 * self.B + 5 * self.C, -21 * self.B + 5 * self.C] + off_diag_elements = {(0, 1): -2 * _sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -820,7 +788,8 @@ def solver(self) -> Dict[str, Float64Array]: GS = -35 * self.B A_6_1 = np.array( - [0.0], dtype=float, + [0.0], + dtype=float, ) # Starting value is -35. * B, but has to set to zero per definition E_4 = self.E_4_states() - GS A_4_1 = np.array([-25 * self.B + 5 * self.C]) - GS @@ -887,7 +856,7 @@ def T_3_1_states(self) -> Float64Array: -4 * self.Dq - self.B + 6 * self.C, -4 * self.Dq - 9 * self.B + 4 * self.C, -4 * self.Dq - 11 * self.B + 4 * self.C, - -14 * self.Dq - 16 * self.B + 5 * self.C + -14 * self.Dq - 16 * self.B + 5 * self.C, ] off_diag_elements = { (0, 1): -_sqrt6 * self.B, @@ -910,7 +879,7 @@ def T_3_1_states(self) -> Float64Array: (3, 6): _3sqrt2 * self.B, (4, 5): -2 * _sqrt3 * self.B, (4, 6): -_3sqrt2 * self.B, - (5, 6): _sqrt6 * self.B + (5, 6): _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -924,7 +893,7 @@ def T_1_2_states(self) -> Float64Array: -4 * self.Dq - 9 * self.B + 6 * self.C, -4 * self.Dq - 3 * self.B + 6 * self.C, -4 * self.Dq + 5 * self.B + 8 * self.C, - -14 * self.Dq + 7 * self.C + -14 * self.Dq + 7 * self.C, ] off_diag_elements = { (0, 1): _3sqrt2 * self.B, @@ -947,7 +916,7 @@ def T_1_2_states(self) -> Float64Array: (3, 6): -_3sqrt6 * self.B, (4, 5): -10 * self.B, (4, 6): _sqrt6 * self.B, - (5, 6): _sqrt6 * self.B + (5, 6): _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -959,7 +928,7 @@ def A_1_1_states(self) -> Float64Array: +6 * self.Dq + 6 * self.C, -4 * self.Dq + 14 * self.B + 11 * self.C, -4 * self.Dq - 3 * self.B + 6 * self.C, - -24 * self.Dq - 16 * self.B + 8 * self.C + -24 * self.Dq - 16 * self.B + 8 * self.C, ] off_diag_elements = { (0, 1): -12 * _sqrt2 * self.B, @@ -971,7 +940,7 @@ def A_1_1_states(self) -> Float64Array: (1, 4): 0.0, (2, 3): 20 * self.B, (2, 4): _sqrt6 * (2 * self.B + self.C), - (3, 4): 2 * _sqrt6 * self.B + (3, 4): 2 * _sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -983,7 +952,7 @@ def E_1_1_states(self) -> Float64Array: +6 * self.Dq - 6 * self.B + 6 * self.C, -4 * self.Dq + 5 * self.B + 8 * self.C, -4 * self.Dq + 6 * self.B + 9 * self.C, - -4 * self.Dq - 3 * self.B + 6 * self.C + -4 * self.Dq - 3 * self.B + 6 * self.C, ] off_diag_elements = { (0, 1): 6 * self.B, @@ -995,7 +964,7 @@ def E_1_1_states(self) -> Float64Array: (1, 4): 0.0, (2, 3): 10 * _sqrt2 * self.B, (2, 4): -10 * _sqrt2 * self.B, - (3, 4): 0.0 + (3, 4): 0.0, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1007,7 +976,7 @@ def T_3_2_states(self) -> Float64Array: +6 * self.Dq - 5 * self.B + 6 * self.C, -4 * self.Dq - 13 * self.B + 4 * self.C, -4 * self.Dq - 9 * self.B + 4 * self.C, - -14 * self.Dq - 8 * self.B + 5 * self.C + -14 * self.Dq - 8 * self.B + 5 * self.C, ] off_diag_elements = { (0, 1): -5 * _sqrt3 * self.B, @@ -1019,7 +988,7 @@ def T_3_2_states(self) -> Float64Array: (1, 4): _sqrt2 * (3 * self.B + self.C), (2, 3): -2 * _sqrt2 * self.B, (2, 4): -6 * self.B, - (3, 4): 3 * _sqrt2 * self.B + (3, 4): 3 * _sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1030,7 +999,7 @@ def T_1_1_states(self) -> Float64Array: +6 * self.Dq - 3 * self.B + 6 * self.C, +6 * self.Dq - 3 * self.B + 8 * self.C, -4 * self.Dq - 3 * self.B + 6 * self.C, - -14 * self.Dq - 16 * self.B + 7 * self.C + -14 * self.Dq - 16 * self.B + 7 * self.C, ] off_diag_elements = { (0, 1): 5 * _sqrt3 * self.B, @@ -1038,7 +1007,7 @@ def T_1_1_states(self) -> Float64Array: (0, 3): _sqrt6 * self.B, (1, 2): -5 * _sqrt3 * self.B, (1, 3): _sqrt2 * (self.B + self.C), - (2, 3): -_sqrt6 * self.B + (2, 3): -_sqrt6 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1048,12 +1017,12 @@ def E_3_1_states(self) -> Float64Array: diag_elements = [ +6 * self.Dq - 13 * self.B + 4 * self.C, +6 * self.Dq - 10 * self.B + 4 * self.C, - -4 * self.Dq - 11 * self.B + 4 * self.C + -4 * self.Dq - 11 * self.B + 4 * self.C, ] off_diag_elements = { (0, 1): -4 * self.B, (0, 2): 0.0, - (1, 2): -_3sqrt2 * self.B + (1, 2): -_3sqrt2 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1062,11 +1031,9 @@ def A_3_2_states(self) -> Float64Array: """Calculate the A_3_2 states.""" diag_elements = [ +6 * self.Dq - 8 * self.B + 4 * self.C, - -4 * self.Dq - 2 * self.B + 7 * self.C + -4 * self.Dq - 2 * self.B + 7 * self.C, ] - off_diag_elements = { - (0, 1): -12 * self.B - } + off_diag_elements = {(0, 1): -12 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1074,11 +1041,9 @@ def A_1_2_states(self) -> Float64Array: """Calculate the A_1_2 states.""" diag_elements = [ +6 * self.Dq - 12 * self.B + 6 * self.C, - -4 * self.Dq - 3 * self.B + 6 * self.C + -4 * self.Dq - 3 * self.B + 6 * self.C, ] - off_diag_elements = { - (0, 1): 6 * self.B - } + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1161,7 +1126,7 @@ def T_2_2_states(self): +2 * self.Dq - 6 * self.B + 3 * self.C, +2 * self.Dq + 4 * self.B + 3 * self.C, -8 * self.Dq + 6 * self.B + 5 * self.C, - -8 * self.Dq - 2 * self.B + 3 * self.C + -8 * self.Dq - 2 * self.B + 3 * self.C, ] off_diag_elements = { (0, 1): -_3sqrt3 * self.B, @@ -1173,7 +1138,7 @@ def T_2_2_states(self): (1, 4): -_3sqrt3 * self.B, (2, 3): -_sqrt3 * self.B, (2, 4): +_sqrt3 * self.B, - (3, 4): 10 * self.B + (3, 4): 10 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1185,7 +1150,7 @@ def T_2_1_states(self): +2 * self.Dq + 3 * self.C, +2 * self.Dq - 6 * self.B + 3 * self.C, -8 * self.Dq - 6 * self.B + 3 * self.C, - -8 * self.Dq - 2 * self.B + 3 * self.C + -8 * self.Dq - 2 * self.B + 3 * self.C, ] off_diag_elements = { (0, 1): -3 * self.B, @@ -1197,7 +1162,7 @@ def T_2_1_states(self): (1, 4): _3sqrt3 * self.B, (2, 3): -3 * self.B, (2, 4): -_sqrt3 * self.B, - (3, 4): _2sqrt3 * self.B + (3, 4): _2sqrt3 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1208,7 +1173,7 @@ def E_2_states(self): +12 * self.Dq - 6 * self.B + 3 * self.C, +2 * self.Dq + 8 * self.B + 6 * self.C, +2 * self.Dq - 1 * self.B + 3 * self.C, - -18 * self.Dq - 8 * self.B + 4 * self.C + -18 * self.Dq - 8 * self.B + 4 * self.C, ] off_diag_elements = { (0, 1): -6 * _sqrt2 * self.B, @@ -1216,20 +1181,15 @@ def E_2_states(self): (0, 3): 0.0, (1, 2): 10 * self.B, (1, 3): +_sqrt3 * (2 * self.B + self.C), - (2, 3): _2sqrt3 * self.B + (2, 3): _2sqrt3 * self.B, } states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_4_1_states(self): """Calculate the T_4_1 states.""" - diag_elements = [ - +2 * self.Dq - 3 * self.B, - -8 * self.Dq - 12 * self.B - ] - off_diag_elements = { - (0, 1): 6 * self.B - } + diag_elements = [+2 * self.Dq - 3 * self.B, -8 * self.Dq - 12 * self.B] + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) @@ -1301,47 +1261,30 @@ def A_1_1_states(self): """Calculate the A_1_1 states.""" diag_elements = [ +8 * self.Dq + 10 * self.B + 5 * self.C, - -12 * self.Dq + 8 * self.B + 4 * self.C + -12 * self.Dq + 8 * self.B + 4 * self.C, ] - off_diag_elements = { - (0, 1): _sqrt6 * (2 * self.B + self.C) - } + off_diag_elements = {(0, 1): _sqrt6 * (2 * self.B + self.C)} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def E_1_states(self): """Calculate the E_1 states.""" - diag_elements = [ - +8 * self.Dq + self.B + 2 * self.C, - -12 * self.Dq + 2 * self.C - ] - off_diag_elements = { - (0, 1): -_2sqrt3 * self.B - } + diag_elements = [+8 * self.Dq + self.B + 2 * self.C, -12 * self.Dq + 2 * self.C] + off_diag_elements = {(0, 1): -_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_1_2_states(self): """Calculate the T_1_2 states.""" - diag_elements = [ - +8 * self.Dq + self.B + 2 * self.C, - -2 * self.Dq + 2 * self.C - ] - off_diag_elements = { - (0, 1): +_2sqrt3 * self.B - } + diag_elements = [+8 * self.Dq + self.B + 2 * self.C, -2 * self.Dq + 2 * self.C] + off_diag_elements = {(0, 1): +_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) def T_3_1_states(self): """Calculate the T_3_1 states.""" - diag_elements = [ - +8 * self.Dq - 5 * self.B, - -2 * self.Dq + 4 * self.B - ] - off_diag_elements = { - (0, 1): 6 * self.B - } + diag_elements = [+8 * self.Dq - 5 * self.B, -2 * self.Dq + 4 * self.B] + off_diag_elements = {(0, 1): 6 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) diff --git a/tanabesugano/test/test_front.py b/tanabesugano/test/test_front.py index 3698143..37cac70 100644 --- a/tanabesugano/test/test_front.py +++ b/tanabesugano/test/test_front.py @@ -7,7 +7,11 @@ def test_frontapp(): return frontapp.CMDmain( - Dq=4000.0, B=400.0, C=3600.0, nroots=100, d_count=5, + Dq=4000.0, + B=400.0, + C=3600.0, + nroots=100, + d_count=5, ).calculation() diff --git a/tanabesugano/tools.py b/tanabesugano/tools.py index f62c1a9..214fb73 100644 --- a/tanabesugano/tools.py +++ b/tanabesugano/tools.py @@ -7,7 +7,8 @@ def racah( - F2: Union[float, np.array], F4: Union[float, np.array], + F2: Union[float, np.array], + F4: Union[float, np.array], ) -> Union[Tuple[float, float], Tuple[np.array, np.array]]: """Transform the Slater-Condon-Parameter to Racah-Parameter. From 820d0b16db292a01b1a1424e89efff666da6475e Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 18:03:51 +0100 Subject: [PATCH 08/11] fix: Correct comment from 'd3' to 'd2' for clarity in batch processing logic --- tanabesugano/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tanabesugano/batch.py b/tanabesugano/batch.py index 9e1cd1d..9259079 100644 --- a/tanabesugano/batch.py +++ b/tanabesugano/batch.py @@ -67,7 +67,7 @@ def calculation(self) -> None: for _Dq in self.Dq: for _B in self.B: for _C in self.C: - if self.d_count == 2: # d3 + if self.d_count == 2: # d2 states = matrices.d2(Dq=_Dq, B=_B, C=_C).solver() self.result.append( { From cafd6d70c9e74638c2e79eaa26b5c6685429b692 Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 18:03:59 +0100 Subject: [PATCH 09/11] chore: Update pyproject.toml for improved dependency formatting and linting rules --- pyproject.toml | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0d6317b..67e941c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,28 +38,28 @@ classifiers = [ include = ["LICENSE"] exclude = ["test/**/*.py", "example/**", "ts-diagrams/**"] - [tool.poetry.dependencies] - python = ">=3.9,<4.0" - pandas = ">=1.2.4,<4.0.0" - numpy = [ - { version = "^1.24.4", python = ">=3.8,<3.9" }, - { version = "^1.26.4", python = ">=3.9,<3.10" }, - { version = "^2.0.2", python = ">=3.10,<3.13" }, - ] - matplotlib = "^3.4.2" - prettytable = ">=2.1,<4.0" - plotly = { version = "^5.13.1", optional = true } - update = "^0.0.1" +[tool.poetry.dependencies] +python = ">=3.9,<4.0" +pandas = ">=1.2.4,<4.0.0" +numpy = [ + { version = "^1.24.4", python = ">=3.8,<3.9" }, + { version = "^1.26.4", python = ">=3.9,<3.10" }, + { version = "^2.0.2", python = ">=3.10,<3.13" }, +] +matplotlib = "^3.4.2" +prettytable = ">=2.1,<4.0" +plotly = { version = "^5.13.1", optional = true } +update = "^0.0.1" - [tool.poetry.group.dev.dependencies] - pytest = ">=7.2,<9.0" - pytest-clarity = "^1.0.1" - pytest-cov = ">=4,<6" - flake8 = ">=6,<8" - black = ">=22.12,<25.0" - isort = "^5.11.4" - pytest-console-scripts = "^1.3.1" - ruff = "^0.7.0" +[tool.poetry.group.dev.dependencies] +pytest = ">=7.2,<9.0" +pytest-clarity = "^1.0.1" +pytest-cov = ">=4,<6" +flake8 = ">=6,<8" +black = ">=22.12,<25.0" +isort = "^5.11.4" +pytest-console-scripts = "^1.3.1" +ruff = "^0.7.0" [build-system] requires = ["poetry-core>=1.1.0"] @@ -73,10 +73,13 @@ plotly = ["plotly"] [tool.ruff] lint.select = ["ALL"] -lint.ignore = ["N806"] +lint.ignore = ["UP006", "UP007", "N801", "N802", "N803", "N806"] target-version = "py38" src = ["tanabesugano"] +[tool.ruff.lint.per-file-ignores] +"tanabesugano/test/*" = ["PT006", "ANN001", "ANN201", "D103", "PLR2004", "S101"] + [tool.ruff.lint.isort] known-first-party = ["umf"] force-single-line = true From 1afe0241f1a1e71172e55fd07e9ba9d4ab297b5b Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 18:04:10 +0100 Subject: [PATCH 10/11] refactor: Enhance type hinting and improve code readability in tools and test files --- tanabesugano/matrices.py | 61 +++++++++++++++++------------- tanabesugano/test/test_matrices.py | 10 +++-- tanabesugano/test/test_num.py | 21 +++++++--- tanabesugano/tools.py | 14 +++++-- 4 files changed, 66 insertions(+), 40 deletions(-) diff --git a/tanabesugano/matrices.py b/tanabesugano/matrices.py index d583f8c..236cb6d 100644 --- a/tanabesugano/matrices.py +++ b/tanabesugano/matrices.py @@ -1,6 +1,8 @@ from __future__ import annotations -from typing import Dict, List, Tuple +from typing import Dict +from typing import List +from typing import Tuple try: @@ -34,9 +36,9 @@ def __init__(self, Dq: float, B: float, C: float) -> None: """Initialize the configuration with given parameters. Args: - dq (float): Crystal field splitting in wavenumbers (cm-1). - b (float): Racah parameter B in wavenumbers (cm-1). - c (float): Racah parameter C in wavenumbers (cm-1). + Dq (float): Crystal field splitting in wavenumbers (cm-1). + B (float): Racah parameter B in wavenumbers (cm-1). + C (float): Racah parameter C in wavenumbers (cm-1). """ self.Dq = np.float64(Dq) @@ -70,7 +72,7 @@ def construct_matrix( diag_elements: List[float], off_diag_elements: Dict[Tuple[int, int], float], ) -> Float64Array: - """Constructs a symmetric matrix from diagonal and off-diagonal elements.""" + """Construct a symmetric matrix from diagonal and off-diagonal elements.""" size = len(diag_elements) matrix = np.zeros((size, size)) np.fill_diagonal(matrix, diag_elements) @@ -84,7 +86,7 @@ class d2(LigandFieldTheory): """Class representing the d2 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3801.0) -> None: - """Initializes the d2 configuration with given parameters. + """Initialize the d2 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -158,7 +160,7 @@ class d3(LigandFieldTheory): """Class representing the d3 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 918.0, C: float = 4133.0) -> None: - """Initializes the d3 configuration with given parameters. + """Initialize the d3 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -280,7 +282,7 @@ class d4(LigandFieldTheory): """Class representing the d4 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 965.0, C: float = 4449.0) -> None: - """Initializes the d4 configuration with given parameters. + """Initialize the d4 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -494,7 +496,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states @@ -550,7 +553,7 @@ class d5(LigandFieldTheory): """Class representing the d5 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3850.0) -> None: - """Initializes the d5 configuration with given parameters. + """Initialize the d5 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -781,7 +784,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states @@ -837,7 +841,7 @@ class d6(LigandFieldTheory): """Class representing the d6 configuration in ligand field theory.""" def __init__(self, Dq: float = 0.0, B: float = 1065.0, C: float = 5120.0): - """Initializes the d6 configuration with given parameters. + """Initialize the d6 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -1051,7 +1055,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ GS = np.array([-4 * self.Dq - 21 * self.B]) @@ -1108,8 +1113,8 @@ def solver(self) -> Dict[str, Float64Array]: class d7(LigandFieldTheory): """Class for d7 configuration.""" - def __init__(self, Dq: float = 0.0, B: float = 971.0, C: float = 4499.0): - """Initializes the d7 configuration with given parameters. + def __init__(self, Dq: float = 0.0, B: float = 971.0, C: float = 4499.0) -> None: + """Initialize the d7 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -1119,7 +1124,7 @@ def __init__(self, Dq: float = 0.0, B: float = 971.0, C: float = 4499.0): """ super().__init__(Dq, B, C) - def T_2_2_states(self): + def T_2_2_states(self) -> Float64Array: """Calculate the T_2_2 states.""" diag_elements = [ +12 * self.Dq + 5 * self.C, @@ -1143,7 +1148,7 @@ def T_2_2_states(self): states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def T_2_1_states(self): + def T_2_1_states(self) -> Float64Array: """Calculate the T_2_1 states.""" diag_elements = [ +12 * self.Dq - 6 * self.B + 3 * self.C, @@ -1167,7 +1172,7 @@ def T_2_1_states(self): states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def E_2_states(self): + def E_2_states(self) -> Float64Array: """Calculate the E_2 states.""" diag_elements = [ +12 * self.Dq - 6 * self.B + 3 * self.C, @@ -1186,7 +1191,7 @@ def E_2_states(self): states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def T_4_1_states(self): + def T_4_1_states(self) -> Float64Array: """Calculate the T_4_1 states.""" diag_elements = [+2 * self.Dq - 3 * self.B, -8 * self.Dq - 12 * self.B] off_diag_elements = {(0, 1): 6 * self.B} @@ -1197,7 +1202,8 @@ def solver(self) -> Dict[str, np.ndarray]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, np.ndarray]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, np.ndarray]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states @@ -1246,8 +1252,8 @@ def solver(self) -> Dict[str, np.ndarray]: class d8(LigandFieldTheory): - def __init__(self, Dq: float = 0.0, B: float = 1030.0, C: float = 4850.0): - """Initializes the d8 configuration with given parameters. + def __init__(self, Dq: float = 0.0, B: float = 1030.0, C: float = 4850.0) -> None: + """Initialize the d8 configuration with given parameters. Args: Dq (float): Crystal field splitting in wavenumbers (cm-1). @@ -1257,7 +1263,7 @@ def __init__(self, Dq: float = 0.0, B: float = 1030.0, C: float = 4850.0): """ super().__init__(Dq, B, C) - def A_1_1_states(self): + def A_1_1_states(self) -> Float64Array: """Calculate the A_1_1 states.""" diag_elements = [ +8 * self.Dq + 10 * self.B + 5 * self.C, @@ -1267,21 +1273,21 @@ def A_1_1_states(self): states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def E_1_states(self): + def E_1_states(self) -> Float64Array: """Calculate the E_1 states.""" diag_elements = [+8 * self.Dq + self.B + 2 * self.C, -12 * self.Dq + 2 * self.C] off_diag_elements = {(0, 1): -_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def T_1_2_states(self): + def T_1_2_states(self) -> Float64Array: """Calculate the T_1_2 states.""" diag_elements = [+8 * self.Dq + self.B + 2 * self.C, -2 * self.Dq + 2 * self.C] off_diag_elements = {(0, 1): +_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) return self.eigensolver(states) - def T_3_1_states(self): + def T_3_1_states(self) -> Float64Array: """Calculate the T_3_1 states.""" diag_elements = [+8 * self.Dq - 5 * self.B, -2 * self.Dq + 4 * self.B] off_diag_elements = {(0, 1): 6 * self.B} @@ -1292,7 +1298,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states diff --git a/tanabesugano/test/test_matrices.py b/tanabesugano/test/test_matrices.py index 5790639..3106f35 100644 --- a/tanabesugano/test/test_matrices.py +++ b/tanabesugano/test/test_matrices.py @@ -1,7 +1,11 @@ -import pytest +from __future__ import annotations + import numpy as np +import pytest + from tanabesugano.matrices import LigandFieldTheory + # Define a type alias for clarity Float64Array = np.ndarray @@ -53,7 +57,7 @@ def test_eigensolver(ligand_field_theory, matrix, expected_eigenvalues): ids=["simple_2x2", "complex_3x3", "zero_2x2"], ) def test_construct_matrix( - ligand_field_theory, diag_elements, off_diag_elements, expected_matrix + ligand_field_theory, diag_elements, off_diag_elements, expected_matrix, ): # Act matrix = ligand_field_theory.construct_matrix(diag_elements, off_diag_elements) @@ -65,7 +69,7 @@ def test_construct_matrix( def test_solver_not_implemented(ligand_field_theory): # Act & Assert with pytest.raises( - NotImplementedError, match="Subclasses should implement this method." + NotImplementedError, match="Subclasses should implement this method.", ): ligand_field_theory.solver() diff --git a/tanabesugano/test/test_num.py b/tanabesugano/test/test_num.py index 994aebf..f628d89 100644 --- a/tanabesugano/test/test_num.py +++ b/tanabesugano/test/test_num.py @@ -1,12 +1,16 @@ from __future__ import annotations +import stat import numpy as np from tanabesugano import matrices -def state_check(x): +def state_check(x) -> int: for i in np.linspace(0, 1500, 30): + if x == 2: + states = matrices.d2(Dq=i).solver() + return len(states) if x == 3: states = matrices.d3(Dq=i).solver() return len(states) @@ -22,23 +26,28 @@ def state_check(x): if x == 7: states = matrices.d7(Dq=i).solver() return len(states) + if x == 8: + states = matrices.d8(Dq=i).solver() + return len(states) +def test_answer_d2() -> None: + assert state_check(2) == 7 -def test_answer_d3(): +def test_answer_d3() -> None: assert state_check(3) == 8 -def test_answer_d4(): +def test_answer_d4() -> None: assert state_check(4) == 12 -def test_answer_d5(): +def test_answer_d5() -> None: assert state_check(5) == 11 -def test_answer_d6(): +def test_answer_d6() -> None: assert state_check(6) == 12 -def test_answer_d7(): +def test_answer_d7() -> None: assert state_check(7) == 8 diff --git a/tanabesugano/tools.py b/tanabesugano/tools.py index 214fb73..d58a9fd 100644 --- a/tanabesugano/tools.py +++ b/tanabesugano/tools.py @@ -1,9 +1,12 @@ from __future__ import annotations +from typing import TYPE_CHECKING from typing import Tuple from typing import Union -import numpy as np + +if TYPE_CHECKING: + import numpy as np def racah( @@ -16,11 +19,14 @@ def racah( eV will be converted to wavenumbers Args: - F2 (Union[float, np.array]): Slater-Condon-Pramater `F2` as float-value or array. - F4 (Union[float, np.array]): Slater-Condon-Pramater `F4` as float-value or array. + F2 (Union[float, np.array]): Slater-Condon-Pramater `F2` as float-value or + array. + F4 (Union[float, np.array]): Slater-Condon-Pramater `F4` as float-value or + array. Returns: - Union[Tuple[float, float], Tuple[np.array, np.array]]: Return the racah parameters. + Union[Tuple[float, float], Tuple[np.array, np.array]]: Return the racah + parameters. """ eVcm = 8065.54 From b6a59fd97f87073ab29c6d0a89a26f7535db88ca Mon Sep 17 00:00:00 2001 From: Anselm Hahn Date: Sat, 16 Nov 2024 18:22:48 +0100 Subject: [PATCH 11/11] style: Improve docstring formatting and add missing method descriptions in matrices.py --- tanabesugano/matrices.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tanabesugano/matrices.py b/tanabesugano/matrices.py index 236cb6d..87b7b0e 100644 --- a/tanabesugano/matrices.py +++ b/tanabesugano/matrices.py @@ -49,10 +49,12 @@ def eigensolver(self, matrix: Float64Array) -> Float64Array: """Solve for the eigenvalues of the given matrix. Args: - matrix (Float64Array): 2-dimensional square array representing the TS matrix of the ligand field Hamiltonian. + matrix (Float64Array): 2-dimensional square array representing the TS matrix + of the ligand field Hamiltonian. Returns: - Float64Array: 1-dimensional array of eigenvalues of the diagonalized ligand field Hamiltonian. + Float64Array: 1-dimensional array of eigenvalues of the diagonalized ligand + field Hamiltonian. """ return eigh(matrix)[0] @@ -61,7 +63,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ msg = "Subclasses should implement this method." @@ -97,6 +100,7 @@ def __init__(self, Dq: float = 0.0, B: float = 860.0, C: float = 3801.0) -> None super().__init__(Dq, B, C) def A_1_1_states(self) -> Float64Array: + """Calculate the A_1_1 states.""" diag_elements = [ -8 * self.Dq + 10 * self.B + 5 * self.C, +12 * self.Dq + 8 * self.B + 4 * self.C, @@ -106,6 +110,7 @@ def A_1_1_states(self) -> Float64Array: return self.eigensolver(states) def E_1_states(self) -> Float64Array: + """Calculate the E_1 states.""" diag_elements = [-8 * self.Dq + self.B + 2 * self.C, +12 * self.Dq + 2 * self.C] off_diag_elements = {(0, 1): -_2sqrt3 * self.B} states = self.construct_matrix(diag_elements, off_diag_elements) @@ -129,7 +134,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states @@ -248,7 +254,8 @@ def solver(self) -> Dict[str, Float64Array]: """Solve for all states and return a dictionary of results. Returns: - Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and eigenvalues as values. + Dict[str, Float64Array]: Dictionary with atomic term symbols as keys and + eigenvalues as values. """ # Ligand field independent states @@ -840,7 +847,7 @@ def solver(self) -> Dict[str, Float64Array]: class d6(LigandFieldTheory): """Class representing the d6 configuration in ligand field theory.""" - def __init__(self, Dq: float = 0.0, B: float = 1065.0, C: float = 5120.0): + def __init__(self, Dq: float = 0.0, B: float = 1065.0, C: float = 5120.0) -> None: """Initialize the d6 configuration with given parameters. Args: @@ -1208,11 +1215,11 @@ def solver(self) -> Dict[str, np.ndarray]: """ # Ligand field independent states - # Ligandfield multi depnedent state become GS + # Ligandfield multi dependent state become GS T_4_1 = self.T_4_1_states() - # Ligendfield single depentent states + # Ligendfield single dependent states GS = T_4_1[0] @@ -1252,6 +1259,7 @@ def solver(self) -> Dict[str, np.ndarray]: class d8(LigandFieldTheory): + """Class for d8 configuration.""" def __init__(self, Dq: float = 0.0, B: float = 1030.0, C: float = 4850.0) -> None: """Initialize the d8 configuration with given parameters.