class TestInfraredKet(unittest.TestCase): '''test class of ir_ket.py''' 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)) def test_keys(self): assert self.t1u_4.keys == [ ( 'IR', 't1u', 4, 'x', ), ( 'IR', 't1u', 4, 'y', ), ( 'IR', 't1u', 4, 'z', ), ] def test_hash(self): assert self.t1u_4.get_index_from_qval((0, 0, 0)) == 0 assert self.t1u_4.get_index_from_qval((0, 0, 1)) == 1 assert self.t1u_4.get_index_from_qval((1, 1, 0)) == 8 assert self.t1u_4.get_index_from_qval((2, 0, 0)) == 9 def test_set_over_the_intermediate_limit_value(self): '''Raise ValueError if given qval is over the intermediate limit. intermediate limit === excitation limit + 1''' # check instantiation error with self.assertRaises(ValueError): t1u_4_x = InfraredKet('t1u', 4, 'x', qval=4, excitation_limit=2) # check dynamical set error t1u_4_x = InfraredKet('t1u', 4, 'x', qval=0, excitation_limit=2) with self.assertRaises(ValueError): t1u_4_x.qval = 4
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 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): import itertools import os import sys sys.path.append(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..', '..', '..')) from irsim.core import Bases from irsim.quantum_basis import JahnTellerKet from collections import namedtuple self.JTstate = namedtuple('JTstate', 'Alpha, J, M, P') # extract valid Alpha-J-P combinations cmbs = {(1,1,1), (1,2,-1)} # (Alpha, J, P) #from irsim.database.CONSTANT import DIC_RME #cmbs = set(itertools.chain(*DIC_RME)) # set Alpha-J-P combinations JahnTellerKet.set_alpha_j_p_combinations(cmbs) # instantiation jt bases self.jt = Bases(JahnTellerKet())
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 jt = Bases(JahnTellerKet())
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))
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