From e99a1fd8d75c315f12ff54cbc833f0dd8e9c56d3 Mon Sep 17 00:00:00 2001 From: bartandrews Date: Fri, 8 Nov 2024 10:55:11 +0100 Subject: [PATCH] fix angles in orbital_rotation --- python/ffsim/tenpy/circuits/gates.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/ffsim/tenpy/circuits/gates.py b/python/ffsim/tenpy/circuits/gates.py index bb2b15e57..d4b0b202d 100644 --- a/python/ffsim/tenpy/circuits/gates.py +++ b/python/ffsim/tenpy/circuits/gates.py @@ -8,6 +8,9 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. +import cmath +import math + import numpy as np import scipy as sp import tenpy.linalg.np_conserved as npc @@ -359,9 +362,8 @@ def apply_orbital_rotation( # apply the Givens rotation gates for gate in givens_list: - theta = np.arccos(gate.c) - s = np.conj(gate.s) - phi = np.real(1j * np.log(-s / np.sin(theta))) if theta else 0 + theta = math.acos(gate.c) + phi = cmath.phase(gate.s) - np.pi conj = True if gate.j < gate.i else False apply_gate2( psi,