def setUp(self):
        ## IR bases
        # impose excitation limit to IR bases
        filterFunc = create_ir_ket_filter('<=', 1)
        Bases.set_filter('IR', filterFunc)  # set IR filter to class Bases

        # instantiation t1u(4) bases
        t1u_4 = Bases(*InfraredKet('t1u', 4, excitation_limit=2))
        gu_5 = Bases(*InfraredKet('gu', 5, excitation_limit=2))
        hu_6 = Bases(*InfraredKet('hu', 6, excitation_limit=2))

        ## JT bases
        # valid Alpha-J-P combinations which are taken into account
        from irsim.database import DIC_REDUCED_MATRIX_ELEMENT as DIC_RME
        from itertools import chain
        #cmbs = set(chain(*DIC_RME))
        cmbs = {(1, 1, 1), (1, 2, -1)}  # {(Alpha, J, P), (Alpha, J, P)}

        # set Alpha-J-P combinations
        JahnTellerKet.set_alpha_j_p_combinations(cmbs)

        # instantiation jt bases
        jt = Bases(JahnTellerKet())

        # impose excitation limit to IR bases
        filterFunc = create_ir_ket_filter('==', 1)
        Bases.set_filter('IR', filterFunc)  # set IR filter to class Bases

        ## product bases
        self.bases = Bases(t1u_4, gu_5, hu_6, jt)

        # import PSI dictionary
        from irsim.database import DIC_PSI
        self.DIC_PSI = DIC_PSI

        # set PSI dictionary
        IrreducibleRepresentation.set_psi(self.DIC_PSI)
    def setUp(self):
        ## IR bases
        # impose excitation limit to IR bases
        filterFunc = create_ir_ket_filter('<=', 2)
        Bases.set_filter('IR', filterFunc)  # set IR filter to class Bases

        # instantiation t1u(4) bases
        self.t1u_4 = Bases(*InfraredKet('t1u', 4, excitation_limit=2))

        ## JT bases
        # define valid Alpha-J-P combinations
        cmbs = {(1, 1, 1), (1, 2, -1)}  # (Alpha, J, P)

        # set Alpha-J-P combinations
        JahnTellerKet.set_alpha_j_p_combinations(cmbs)

        # instantiation jt bases
        self.jt = Bases(JahnTellerKet())

        ## product bases
        self.bases = Bases(self.t1u_4, self.jt)
    def test_calculation(self):
        # ket
        ket0 = self.bases[0]  # |t1u(4)_x> == 0
        ket1 = self.bases[48]  # |t1u(4)_x> == 1
        ket2 = self.bases[72]  # |t1u(4)_x> == 2

        from copy import deepcopy
        initket0 = deepcopy(ket0)
        initket1 = deepcopy(ket1)
        initket2 = deepcopy(ket2)

        # creation annihilation opearator
        cre = CreationOperator('t1u', 4, 'x')
        ann = AnnihilationOperator('t1u', 4, 'x')

        # define IR frequency dictionary
        DIC_IR_FREQ = {
            ('t1u', 4): 0.00629777152672,
        }

        # set IR frequency data to PositionalOperator class
        PositionalOperator.set_ir_frequency(DIC_IR_FREQ)

        # positional operator
        #q = PositionalOperator('t1u', 4, 'x')
        q = PositionalOperator('t1u', 4)

        # define IR frequency dictionary
        DIC_Q_MTRX = {
            ('hg', 't1', 't1', 1, 'theta'):
            np.sqrt(1 / 6) * np.array([[-1, 0, 0], [0, -1, 0], [0, 0, 2]]),
        }

        # set quadratic matrix data to QuadraticOperator class
        QuadraticOperator.set_quadratic_matrix(DIC_Q_MTRX)

        # set IR filter
        filterFunc = create_ir_ket_filter('<=', 2)
        QuadraticOperator.set_filter('IR', filterFunc)

        # quadratic operator
        Q = QuadraticOperator(q, ('hg', 't1', 't1', 1), q, 'theta')

        # constant
        OMEGA = DIC_IR_FREQ[('t1u', 4)]
        CONST = np.sqrt(q.HBAR / (2 * OMEGA))

        # Q|IR: x=0, y=0, z=0,  JT: (Alpha=1, J=1, M=-1, P=+1)>
        Q_ket0 = sorted(Q(ket0), key=lambda ket: ket.qval)
        qval = [ket.qval for ket in Q_ket0]
        ans = [
            (0, 0, 2, (1, 1, -1, 1)),
            (0, 2, 0, (1, 1, -1, 1)),
            (2, 0, 0, (1, 1, -1, 1)),
        ]
        self.assertEqual(qval, ans)
        weight = [ket.weight for ket in Q_ket0]
        ans = [
            CONST**2 * np.sqrt(2) * np.sqrt(1 / 6) * 2,
            CONST**2 * np.sqrt(2) * np.sqrt(1 / 6) * -1,
            CONST**2 * np.sqrt(2) * np.sqrt(1 / 6) * -1,
        ]
        for w, a in zip(weight, ans):
            dd = get_integer_digit(w)
            self.assertAlmostEqual(w, a, delta=10**(-15 + dd))

        # Q|IR: x=1, y=0, z=0, JT: (Alpha=1, J=1, M=-1, P=+1)>
        Q_ket1 = sorted(Q(ket1), key=lambda ket: ket.qval)
        qval = [ket.qval for ket in Q_ket1]
        ans = [
            (1, 0, 0, (1, 1, -1, 1)),
        ]
        self.assertEqual(qval, ans)
        weight = [ket.weight for ket in Q_ket1]
        ans = [
            -np.sqrt(6) * (1 / 3) * CONST**2,
        ]
        for w, a in zip(weight, ans):
            dd = get_integer_digit(w)
            self.assertAlmostEqual(w, a, delta=10**(-15 + dd))

        # check destroy
        self.assertEqual(ket0.qval, initket0.qval)
        self.assertEqual(ket0.weight, initket0.weight)
        self.assertEqual(ket1.qval, initket1.qval)
        self.assertEqual(ket1.weight, initket1.weight)
        self.assertEqual(ket2.qval, initket2.qval)
        self.assertEqual(ket2.weight, initket2.weight)
Ejemplo n.º 4
0
    is_symmetric,
    is_diagonalized,
    diagonalize_helmitian_operator,
)
from irsim.file_handler import (
    create_diagonalization_save_directory_name as create_dir_name, )

if __name__ == '__main__':
    ### BASES

    ## IR bases
    IR_LIMIT = 1
    INEQUALITY = '<='

    # impose excitation limit to IR bases
    filterFunc = create_ir_ket_filter('<=', IR_LIMIT)
    Bases.set_filter('IR', filterFunc)  # set IR filter to class Bases

    # instantiation ir bases
    t1u_4 = Bases(*InfraredKet('t1u', 4, excitation_limit=IR_LIMIT))
    gu_5 = Bases(*InfraredKet('gu', 5, excitation_limit=IR_LIMIT))
    hu_6 = Bases(*InfraredKet('hu', 6, excitation_limit=IR_LIMIT))

    ## JT bases
    # valid Alpha-J-P combinations which are taken into account
    cmbs = {(1, 1, 1), (1, 2, -1)}  # {(Alpha, J, P), (Alpha, J, P)}

    # set Alpha-J-P combinations
    JahnTellerKet.set_alpha_j_p_combinations(cmbs)

    # instantiation jt bases
    def test_calculation(self):
        # ket
        ket0 = self.bases[0]  # |t1u(4)_x> == 0
        ket1 = self.bases[1]  # |t1u(4)_x> == 1
        ket2 = self.bases[72]  # |t1u(4)_x> == 2

        from copy import deepcopy
        initket0 = deepcopy(ket0)
        initket1 = deepcopy(ket1)
        initket2 = deepcopy(ket2)

        # define IR frequency dictionary
        DIC_IR_FREQ = {
            ('t1u', 4): 0.00629777152672,
        }

        # set IR frequency data to PositionalOperator class
        PositionalOperator.set_ir_frequency(DIC_IR_FREQ)

        # positional operator
        q = PositionalOperator('t1u', 4)

        # define quadratic matrix dictionary
        from irsim.database import DIC_QUADRATIC_MATRIX as DIC_Q_MTRX

        # set quadratic matrix data to QuadraticOperator class
        QuadraticOperator.set_quadratic_matrix(DIC_Q_MTRX)

        # set IR filter
        filterFunc = create_ir_ket_filter('<=', 2)
        QuadraticOperator.set_filter('IR', filterFunc)

        # quadratic operator
        Q = QuadraticOperator(q, ('hg', 't1', 't1', 1), q)
        #Q = QuadraticOperator(q, ('hg', 't1', 't1', 1), q, 'theta')

        # set coupling constant dictionary to HamiltonianCoupling class
        DIC_COUP_CONST = {
            (('t1u', 4), ('t1u', 4), 1): -0.000000713859624,
        }
        HamiltonianCouplingOperator.set_coupling_constant(DIC_COUP_CONST)

        # set coupling constant dictionary
        from irsim.database.COUPLING_MATRIX import DIC_COUPLING_MATRIX as DIC_COUP_MTRX
        HamiltonianCouplingOperator.set_coupling_matrix(DIC_COUP_MTRX)

        # set reduced matrix element dictionary
        from irsim.database import DIC_REDUCED_MATRIX_ELEMENT as DIC_RME
        HamiltonianCouplingOperator.set_reduced_matrix_element(DIC_RME)
        #print(HamiltonianCoupling.DIC_MATRIX_RME)

        h_coup = HamiltonianCouplingOperator(Q)

        # constant
        OMEGA = DIC_IR_FREQ[('t1u', 4)]
        W = DIC_COUP_CONST[(('t1u', 4), ('t1u', 4), 1)]
        XI = DIC_RME[((1, 1, 1), (1, 2, -1))]
        CONST = (1 / 2) * (np.sqrt(q.HBAR / (2 * OMEGA)))**2 * W * XI

        # h_coup|IR: x=0, y=0, z=0,  JT: (Alpha=1, J=1, M=-1, P=+1)>
        h_1coup_ket0 = sorted(h_coup(ket0), key=lambda ket: ket.qval)
        qval = [ket.qval for ket in h_1coup_ket0]
        ans = [
            (0, 0, 2, (1, 2, 0, -1)),
            (0, 1, 1, (1, 2, -2, -1)),
            (0, 1, 1, (1, 2, -1, -1)),
            (0, 2, 0, (1, 2, 0, -1)),
            (1, 0, 1, (1, 2, 2, -1)),
            (1, 1, 0, (1, 2, 1, -1)),
        ]
        self.assertEqual(qval, ans)
        weight = [ket.weight for ket in h_1coup_ket0]
        ans = [
            +2 / np.sqrt(3) * CONST * 0.547722557505166,
            +np.sqrt(2) * CONST * (-0.547722557505166),
            +np.sqrt(2) * CONST * (-0.316227766016838),
            -2 * CONST * 0.316227766016838,
            +np.sqrt(2) * CONST * (0.316227766016838),
            +np.sqrt(2) * CONST * (-0.316227766016838),
        ]
        for w, a in zip(weight, ans):
            dd = get_integer_digit(w)
            self.assertAlmostEqual(w, a, delta=10**(-15 + dd))

        # cache check
        # h_coup|IR: x=0, y=0, z=0,  JT: (Alpha=1, J=1, M=0, P=+1)>
        ket1.weight = 0.5
        h_1coup_ket1 = sorted(h_coup(ket1), key=lambda ket: ket.qval)
        # h_coup|IR: x=0, y=0, z=0,  JT: (Alpha=1, J=1, M=-1, P=+1)>
        h_1coup_ket0 = sorted(h_coup(ket0), key=lambda ket: ket.qval)
        qval = [ket.qval for ket in h_1coup_ket0]
        ans = [
            (0, 0, 2, (1, 2, 0, -1)),
            (0, 1, 1, (1, 2, -2, -1)),
            (0, 1, 1, (1, 2, -1, -1)),
            (0, 2, 0, (1, 2, 0, -1)),
            (1, 0, 1, (1, 2, 2, -1)),
            (1, 1, 0, (1, 2, 1, -1)),
        ]
        self.assertEqual(qval, ans)
        weight = [ket.weight for ket in h_1coup_ket0]
        ans = [
            +2 / np.sqrt(3) * CONST * 0.547722557505166,
            +np.sqrt(2) * CONST * (-0.547722557505166),
            +np.sqrt(2) * CONST * (-0.316227766016838),
            -2 * CONST * 0.316227766016838,
            +np.sqrt(2) * CONST * (0.316227766016838),
            +np.sqrt(2) * CONST * (-0.316227766016838),
        ]
        for w, a in zip(weight, ans):
            dd = get_integer_digit(w)
            self.assertAlmostEqual(w, a, delta=10**(-15 + dd))
        ket1.weight = 1

        # check destroy
        self.assertEqual(ket0.qval, initket0.qval)
        self.assertEqual(ket0.weight, initket0.weight)
        self.assertEqual(ket1.qval, initket1.qval)
        self.assertEqual(ket1.weight, initket1.weight)
        self.assertEqual(ket2.qval, initket2.qval)
        self.assertEqual(ket2.weight, initket2.weight)
Ejemplo n.º 6
0
    def setUp(self):
        filterFunc = create_ir_ket_filter('<=', 2)
        Bases.set_filter('IR', filterFunc)  # set IR filter to class Bases

        # instantiation t1u(4) bases
        self.t1u_4 = Bases(*InfraredKet('t1u', 4, excitation_limit=2))
Ejemplo n.º 7
0
    def setUp(self):
        ### BASES
        ## IR bases
        IR_LIMIT = 0
        # impose excitation limit to IR bases
        filterFunc = create_ir_ket_filter('<=', IR_LIMIT)
        Bases.set_filter('IR', filterFunc) # set IR filter to class Bases

        # instantiation ir bases
        t1u_4 = Bases(*InfraredKet('t1u', 4, excitation_limit = IR_LIMIT))
        gu_5 = Bases(*InfraredKet('gu', 5, excitation_limit = IR_LIMIT))
        hu_6 = Bases(*InfraredKet('hu', 6, excitation_limit = IR_LIMIT))


        ## JT bases
        # valid Alpha-J-P combinations which are taken into account
        cmbs = {(1,0,1), (1,2,-1)} # {(Alpha, J, P), (Alpha, J, P)}

        # set Alpha-J-P combinations
        JahnTellerKet.set_alpha_j_p_combinations(cmbs)

        # instantiation jt bases
        jt = Bases(JahnTellerKet())


        ## product bases
        # set filter 
        #filterFunc = create_ir_ket_filter('<=', IR_LIMIT)
        filterFunc = create_ir_ket_filter('==', IR_LIMIT)
        Bases.set_filter('IR', filterFunc) # set IR filter to class Bases

        # instantiation product bases
        #bases = Bases(t1u_4, gu_5, hu_6, jt)
        bases = Bases(t1u_4, jt)



        ### QUANTUM OPERATOR
        ## positional operator
        # fetch IR frequency data
        from irsim.database import DIC_IR_FREQUENCY as DIC_IR_FREQ

        # set IR frequency data to PositionalOperator class
        q.set_ir_frequency(DIC_IR_FREQ)


        ## quadratic operator
        # fetch IR frequency data
        from irsim.database import DIC_QUADRATIC_MATRIX as DIC_Q_MTRX

        # set quadratic matrix data to QuadraticOperator class
        Q.set_quadratic_matrix(DIC_Q_MTRX)

        # set IR filter to class QuadraticOperator
        filterFunc = create_ir_ket_filter('<=', IR_LIMIT)
        Q.set_filter('IR', filterFunc)


        ## hamiltonian coupling operator
        # fetch coupling constant data
        from irsim.database import DIC_COUPLING_CONSTANT as DIC_COUP_CONST

        # set coupling constant data to HamiltonianCouplingOperator
        H_coupling.set_coupling_constant(DIC_COUP_CONST)

        from irsim.database.COUPLING_MATRIX import DIC_COUPLING_MATRIX as DIC_COUP_MTRX

        # set coupling constant dictionary to HamiltonianCouplingOperator
        H_coupling.set_coupling_matrix(DIC_COUP_MTRX)

        # set reduced matrix element dictionary to HamiltonianCouplingOperator
        from irsim.database import DIC_REDUCED_MATRIX_ELEMENT as DIC_RME

        H_coupling.set_reduced_matrix_element(DIC_RME)

        # instantiation
        h_coupling = H_coupling(
                Q(q('t1u',4), ('hg', 't1', 't1', 1), q('t1u',4)),
#                Q(q('gu',5), ('hg', 'g', 'g', 1), q('gu',5)),
#                Q(q('hu',6), ('hg', 'h', 'h', 1), q('hu',6)),
#                Q(q('hu',6), ('hg', 'h', 'h', 2), q('hu',6)),
#                Q(q('t1u',4), ('hg', 't1', 'g', 1), q('gu',5)),
#                Q(q('t1u',4), ('hg', 't1', 'h', 1), q('hu',6)),
#                Q(q('gu',5), ('hg', 'g', 'h', 1), q('hu',6)),
#                Q(q('gu',5), ('hg', 'g', 'h', 2), q('hu',6)),
                )


        ## hamiltonian infrared operator
        # set ir frequency data
        H_IR.set_ir_frequency(DIC_IR_FREQ)

        # instantiation
        h_ir = H_IR()


        ## hamiltonian jahn-teller operator
        # fetch & convert jt eigen energy data to Python dictionary
        #from irsim.database import import_vibronic_energy_levels
        from irsim.database import DIC_VIBRONIC_ENERGY_LEVEL

        # set jt eigen energy data to HamiltonianJahnTellerOperator
        H_JT.set_jt_eigen_energy(DIC_VIBRONIC_ENERGY_LEVEL)

        # instantiation
        h_jt = H_JT()


        #################################
        ## create total Hamiltonian
        H = h_ir + h_jt + h_coupling
        #################################

        self.bases = bases
        self.H = H