diff --git a/python/anyon_braiding_simulator/Model.py b/python/anyon_braiding_simulator/Model.py index 63fbcdd..1e94d0f 100644 --- a/python/anyon_braiding_simulator/Model.py +++ b/python/anyon_braiding_simulator/Model.py @@ -121,3 +121,63 @@ def getFMatrix(self, a: str, b: str, c: str, d: str) -> np.ndarray: raise ValueError('invalid anyon name') return self._f_mtx[anyondict[a]][anyondict[b]][anyondict[c]][anyondict[d]] + + def getFInv(self, a: str, b: str, c: str, d: str) -> np.ndarray: + """ + Parameters + ---------- + a : str + name of anyon corresponding to first lower index + b : str + name of anyon corresponding to second lower index + c : str + name of anyon corresponding to third lower index + d : str + name of anyon corresponding to upper index + + Only the following strings are accepted as parameters: + vacuum, sigma, psi + + Requires that all anyons used as parameters are contained with the + given model + + For details on notation, c.f.r. On classification of modular tensor + categories by Rowell, Stong, and Wang + https://www.arxiv.org/abs/0712.1377 + + Returns + ------- + the Inverse F-matrix corresponding to the set of indices in the model + """ + + return np.linalg.inv(self.getFMatrix(a,b,c,d)) + + def getFInvRF(self, a: str, b: str, c: str, d: str) -> np.ndarray: + """ + Parameters + ---------- + a : str + name of anyon corresponding to first lower index + b : str + name of anyon corresponding to second lower index + c : str + name of anyon corresponding to third lower index + d : str + name of anyon corresponding to upper index + + Only the following strings are accepted as parameters: + vacuum, sigma, psi + + Requires that all anyons used as parameters are contained with the + given model + + For details on notation, c.f.r. On classification of modular tensor + categories by Rowell, Stong, and Wang + https://www.arxiv.org/abs/0712.1377 + + Returns + ------- + the matrix product of (F^-1)RF corresponding to the set of indices in the model + """ + + return self.getFInv(a,b,c,d) @ self._r_mtx @ self.getFMatrix(a,b,c,d) diff --git a/python/tests/test_model.py b/python/tests/test_model.py index 3353753..a2e025f 100644 --- a/python/tests/test_model.py +++ b/python/tests/test_model.py @@ -38,3 +38,35 @@ def test_f_matrix(initialize_ising): assert np.equal(ising.getFMatrix('psi', 'psi', 'psi', 'vacuum'), np.identity(2)).all() assert np.equal(ising.getFMatrix('psi', 'vacuum', 'psi', 'psi'), np.identity(2)).all() assert np.equal(ising.getFMatrix('psi', 'psi', 'psi', 'psi'), np.identity(2)).all() + +@pytest.mark.model +def test_f_inverse(initialize_ising): + ising = initialize_ising + + # check F with all sigma subscripts cancels with inverse + assert np.isclose(ising.getFMatrix('sigma', 'sigma', 'sigma', 'sigma') @ ising.getFInv('sigma', 'sigma', 'sigma', 'sigma'), np.identity(2)).all() + assert np.isclose(ising.getFInv('sigma', 'sigma', 'sigma', 'sigma') @ ising.getFMatrix('sigma', 'sigma', 'sigma', 'sigma'), np.identity(2)).all() + + # check other non identity matrices + assert np.isclose(ising.getFMatrix('psi', 'sigma', 'sigma', 'vacuum') @ ising.getFInv('psi', 'sigma', 'sigma', 'vacuum'), np.identity(2)).all() + assert np.isclose(ising.getFInv('psi', 'sigma', 'sigma', 'vacuum') @ ising.getFMatrix('psi', 'sigma', 'sigma', 'vacuum'), np.identity(2)).all() + + assert np.isclose(ising.getFMatrix('sigma', 'sigma', 'psi', 'psi') @ ising.getFInv('sigma', 'sigma', 'psi', 'psi'), np.identity(2)).all() + assert np.isclose(ising.getFInv('sigma', 'sigma', 'psi', 'psi') @ ising.getFMatrix('sigma', 'sigma', 'psi', 'psi'), np.identity(2)).all() + + # check identity matrices + assert np.isclose(ising.getFMatrix('psi', 'psi', 'psi', 'vacuum') @ ising.getFInv('psi', 'psi', 'psi', 'vacuum'), np.identity(2)).all() + assert np.isclose(ising.getFInv('psi', 'psi', 'psi', 'vacuum') @ ising.getFMatrix('psi', 'psi', 'psi', 'vacuum'), np.identity(2)).all() + +@pytest.mark.model +def test_FinvRF(initialize_ising): + ising = initialize_ising + + # check F with all sigma subscripts + assert np.isclose(ising.getFInvRF('sigma', 'sigma', 'sigma', 'sigma'), np.linalg.inv(ising.getFMatrix('sigma', 'sigma', 'sigma', 'sigma')) @ ising._r_mtx @ ising.getFMatrix('sigma', 'sigma', 'sigma', 'sigma')).all() + + # check other non identity matrices + assert np.isclose(ising.getFInvRF('psi', 'sigma', 'sigma', 'vacuum'), np.linalg.inv(ising.getFMatrix('psi', 'sigma', 'sigma', 'vacuum')) @ ising._r_mtx @ ising.getFMatrix('psi', 'sigma', 'sigma', 'vacuum')).all() + + # check identity matrices + assert np.isclose(ising.getFInvRF('psi', 'psi', 'psi', 'vacuum'), np.linalg.inv(ising.getFMatrix('psi', 'psi', 'psi', 'vacuum')) @ ising._r_mtx @ ising.getFMatrix('psi', 'psi', 'psi', 'vacuum')).all() \ No newline at end of file