====== PrintExpectationValues ====== ### PrintExpectationValues(psiList, Hamiltonian, opList, options) (old order) or PrintExpectationValues(psiList, opList, Hamiltonian, extraLists, options) (new order) takes a table of wavefunctions, a table of operators, a Hamiltonian operator, extraLists, and a list of options, and prints out expectation values. Note that restrictions placed on the operators in opList are not currently respected. The Hamiltonian is treated separately here because it is possible to sort the output by energy and/or to print the standard deviation in energy. It can be omitted. The (otpional) extraLists need to be given in pairings of name and list of numbers. They can for example be used to include values that cannot be expressed as Hermitian operators. The Options are also optional. The function prints a header based on the name of the operator (except in the case of the Hamiltonian, where it uses "E"). ### ===== Input ===== * psiList : A list of wavefunctions, or a single wavefunction * opList : A list of operators for which expectation values are to be calculated * Hamiltonian : Giving the Hamiltonian operator here is optional * Extra : Optional Map in form { {string,{num1,num2,...}},...}, which adds extra lists. * Possible Options are: * "colWidth" Positive integer specifying the width of each column. (Default value 8) * "printHeaderEvery" Positive integer specifying how often the header should be printed. (Default value 0, meaning the header is only printed at the beginning) * "printSigma" Bool specifying if the standard deviation shall be printed, useful for checking how close to an energy eigenstate a wavefunction is (needs an specified Hamiltonian for that). If the Hamiltonian has restrictions it takes these into account, allowing to check how far away a wave function is from an eigenstate in a subspace. (Default false) * "sortByEnergy" Bool specifying if the wavefunctions are to be sorted by energy (needs an specified Hamiltonian for that). (Default false) * "zero" Positive real number. Every number whose absolute value is smaller than zero is set to 0 for a more readable output. (Default 1E-10) ===== Output ===== * None ===== Example ===== ==== Input ==== Verbosity(0) orbs = {"1s","2s","2p"} Ind, NF = CreateAtomicIndicesDict(orbs) psiList = {} for key1,orb1 in pairs(orbs) do for key2, orb2 in pairs(orbs) do if key1 == key2 then det1 = DeterminantString(NF, Ind[orb1]) psiList[#psiList + 1] = NewWavefunction(NF, 0, {{det1,1}}) elseif key1 < key2 then det1 = DeterminantString(NF, Ind[orb1]) det2 = DeterminantString(NF, Ind[orb2]) psiList[#psiList + 1] = NewWavefunction(NF, 0, {{det1,math.sqrt(1/2)}, {det2,math.sqrt(1/2)}}) end end end Hamil = NewOperator("Number",NF,Ind["1s"],Ind["1s"],{0.1,0.2}) Hamil = Hamil + NewOperator("Number",NF,Ind["2s"],Ind["2s"],{0.3,0.4}) Hamil = Hamil + NewOperator("Number",NF,Ind["2p"],Ind["2p"],{0.5,0.6,0.7,0.8,0.9,1.0}) Hamil = Hamil + NewOperator("U",NF,Ind["1s_Up"],Ind["1s_Dn"],Ind["2p_Up"],Ind["2p_Dn"],{0.6},{0.7}) Hamil = Hamil + NewOperator("U",NF,Ind["2s_Up"],Ind["2s_Dn"],Ind["2p_Up"],Ind["2p_Dn"],{0.8},{0.9}) Hamil = Hamil + NewOperator("U",NF,Ind["2p_Up"],Ind["2p_Dn"],{0.5,sqrt(2)}) Hamil = Hamil + 1e-5*NewOperator("Lz",NF,Ind["2p_Up"],Ind["2p_Dn"]) Hamil = Hamil - 4 Hamil = Hamil/2 Hamil = Hamil + ConjugateTranspose(Hamil) Hamil.Name = "H" opList = {} opList[#opList + 1] = NewOperator("Number",NF,Ind["1s"],Ind["1s"],{1,1}) opList[#opList].Name = "N_1s" opList[#opList + 1] = NewOperator("Number",NF,Ind["2s"],Ind["2s"],{1,1}) opList[#opList].Name = "N_2s" opList[#opList + 1] = NewOperator("Number",NF,Ind["2p"],Ind["2p"],{1,1,1,1,1,1}) opList[#opList].Name = "N_2p" opList[#opList + 1] = NewOperator("U",NF,Ind["2p_Up"],Ind["2p_Dn"],{1,0}) opList[#opList].Name = "F0_2p" opList[#opList + 1] = NewOperator("U",NF,Ind["2p_Up"],Ind["2p_Dn"],{0,1}) opList[#opList].Name = "F2_2p" opList[#opList + 1] = NewOperator("U",NF,Ind["2p_Up"],Ind["2p_Dn"],{0,1}) opList[#opList].Name = "Operator with a long name" opList[#opList + 1] = NewOperator("U",NF,Ind["2p_Up"],Ind["2p_Dn"],{0,1}) opList[#opList].Name = "An Operator with small lexicographical value" StartRestrictions = {NF,0} StartRestrictions[3] = {DeterminantString(NF, Ind["1s"]),2,2} StartRestrictions[4] = {DeterminantString(NF, Ind["2s"]),2,2} Restrictions = {NF,0} Restrictions[3] = {DeterminantString(NF, Ind["2p"]),0,1} NPsi = 15 psiList = Eigensystem(Hamil,StartRestrictions,NPsi) extraList1 = {"Extra1",{}} extraList2 = {"Extra2",{}} for i = 1, NPsi do extraList1[2][i] = 0.5*i extraList2[2][i] = 5/i end extraLists = {extraList1, extraList2} Options = {{"colWidth",10},{"printHeaderEvery",10},{"printSigma",true},{"sortByEnergy",true},{"zero",1E-7}} print("\n\n\nPrintExpectationValues(psiList,opList):") PrintExpectationValues(psiList,opList) print("\n\n\nPrintExpectationValues(psiList,opList,Hamil):") PrintExpectationValues(psiList,opList,Hamil) print("\n\n\nPrintExpectationValues(psiList,opList,extraLists):") PrintExpectationValues(psiList,opList,extraLists) print("\n\n\nPrintExpectationValues(psiList,opList,Options):") PrintExpectationValues(psiList,opList,Options) print("\n\n\nPrintExpectationValues(psiList,opList,Hamil,extraLists):") PrintExpectationValues(psiList,opList,Hamil,extraLists) print("\n\n\nPrintExpectationValues(psiList,opList,Hamil,Options):") PrintExpectationValues(psiList,opList,Hamil,Options) print("\n\n\nPrintExpectationValues(psiList,opList,Hamil,extraLists,Options):") PrintExpectationValues(psiList,opList,Hamil,extraLists,Options) print("\n\n\nPrintExpectationValues(psiList,opList,-Hamil,extraLists,Options):") PrintExpectationValues(psiList,opList,-Hamil,extraLists,Options) ==== Result ==== PrintExpectationValues(psiList,opList): N_1s N_2s N_2p F0_2p F2_2p Operato An Oper 1 2 2 0 0 0 0 0 2 2 2 1 0 0 0 0 3 2 2 1 0 0 0 0 4 2 2 1 0 0 0 0 5 2 2 1 0 0 0 0 6 2 2 1 0 0 0 0 7 2 2 1 0 0 0 0 8 2 2 2 1 -0.2 -0.2 -0.2 9 2 2 2 1 -0.2 -0.2 -0.2 10 2 2 2 1 -0.2 -0.2 -0.2 11 2 2 2 1 -0.2 -0.2 -0.2 12 2 2 2 1 0.04 0.04 0.04 13 2 2 2 1 -0.2 -0.2 -0.2 14 2 2 2 1 -0.2 -0.2 -0.2 15 2 2 2 1 -0.2 -0.2 -0.2 PrintExpectationValues(psiList,opList,Hamil): E N_1s N_2s N_2p F0_2p F2_2p Operato An Oper 1 -3 2 2 0 0 0 0 0 2 -0.2333 2 2 1 0 0 0 0 3 -0.1333 2 2 1 0 0 0 0 4 -0.0333 2 2 1 0 0 0 0 5 0.06667 2 2 1 0 0 0 0 6 0.16668 2 2 1 0 0 0 0 7 0.26668 2 2 1 0 0 0 0 8 2.95048 2 2 2 1 -0.2 -0.2 -0.2 9 3.05048 2 2 2 1 -0.2 -0.2 -0.2 10 3.15048 2 2 2 1 -0.2 -0.2 -0.2 11 3.15049 2 2 2 1 -0.2 -0.2 -0.2 12 3.18988 2 2 2 1 0.04 0.04 0.04 13 3.25049 2 2 2 1 -0.2 -0.2 -0.2 14 3.35049 2 2 2 1 -0.2 -0.2 -0.2 15 3.3505 2 2 2 1 -0.2 -0.2 -0.2 PrintExpectationValues(psiList,opList,extraLists): N_1s N_2s N_2p F0_2p F2_2p Operato An Oper Extra1 Extra2 1 2 2 0 0 0 0 0 0.5 5 2 2 2 1 0 0 0 0 1 2.5 3 2 2 1 0 0 0 0 1.5 1.66667 4 2 2 1 0 0 0 0 2 1.25 5 2 2 1 0 0 0 0 2.5 1 6 2 2 1 0 0 0 0 3 0.83333 7 2 2 1 0 0 0 0 3.5 0.71429 8 2 2 2 1 -0.2 -0.2 -0.2 4 0.625 9 2 2 2 1 -0.2 -0.2 -0.2 4.5 0.55556 10 2 2 2 1 -0.2 -0.2 -0.2 5 0.5 11 2 2 2 1 -0.2 -0.2 -0.2 5.5 0.45455 12 2 2 2 1 0.04 0.04 0.04 6 0.41667 13 2 2 2 1 -0.2 -0.2 -0.2 6.5 0.38462 14 2 2 2 1 -0.2 -0.2 -0.2 7 0.35714 15 2 2 2 1 -0.2 -0.2 -0.2 7.5 0.33333 PrintExpectationValues(psiList,opList,Options): N_1s N_2s N_2p F0_2p F2_2p Operator An Operat 1 2 2 0 0 0 0 0 2 2 2 1 0 0 0 0 3 2 2 1 0 0 0 0 4 2 2 1 0 0 0 0 5 2 2 1 0 0 0 0 6 2 2 1 0 0 0 0 7 2 2 1 0 0 0 0 8 2 2 2 1 -0.2 -0.2 -0.2 9 2 2 2 1 -0.2 -0.2 -0.2 10 2 2 2 1 -0.2 -0.2 -0.2 N_1s N_2s N_2p F0_2p F2_2p Operator An Operat 11 2 2 2 1 -0.2 -0.2 -0.2 12 2 2 2 1 0.04 0.04 0.04 13 2 2 2 1 -0.2 -0.2 -0.2 14 2 2 2 1 -0.2 -0.2 -0.2 15 2 2 2 1 -0.2 -0.2 -0.2 PrintExpectationValues(psiList,opList,Hamil,extraLists): E N_1s N_2s N_2p F0_2p F2_2p Operato An Oper Extra1 Extra2 1 -3 2 2 0 0 0 0 0 0.5 5 2 -0.2333 2 2 1 0 0 0 0 1 2.5 3 -0.1333 2 2 1 0 0 0 0 1.5 1.66667 4 -0.0333 2 2 1 0 0 0 0 2 1.25 5 0.06667 2 2 1 0 0 0 0 2.5 1 6 0.16668 2 2 1 0 0 0 0 3 0.83333 7 0.26668 2 2 1 0 0 0 0 3.5 0.71429 8 2.95048 2 2 2 1 -0.2 -0.2 -0.2 4 0.625 9 3.05048 2 2 2 1 -0.2 -0.2 -0.2 4.5 0.55556 10 3.15048 2 2 2 1 -0.2 -0.2 -0.2 5 0.5 11 3.15049 2 2 2 1 -0.2 -0.2 -0.2 5.5 0.45455 12 3.18988 2 2 2 1 0.04 0.04 0.04 6 0.41667 13 3.25049 2 2 2 1 -0.2 -0.2 -0.2 6.5 0.38462 14 3.35049 2 2 2 1 -0.2 -0.2 -0.2 7 0.35714 15 3.3505 2 2 2 1 -0.2 -0.2 -0.2 7.5 0.33333 PrintExpectationValues(psiList,opList,Hamil,Options): E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat std-dev 1 -3 2 2 0 0 0 0 0 7.3e-8 2 -0.233343 2 2 1 0 0 0 0 1.2633e-8 3 -0.133343 2 2 1 0 0 0 0 2.2039e-8 4 -0.033333 2 2 1 0 0 0 0 3.0052e-8 5 0.0666667 2 2 1 0 0 0 0 5.4281e-8 6 0.166677 2 2 1 0 0 0 0 3.96e-8 7 0.266677 2 2 1 0 0 0 0 4.8141e-8 8 2.95048 2 2 2 1 -0.2 -0.2 -0.2 5.9605e-8 9 3.05048 2 2 2 1 -0.2 -0.2 -0.2 1.0324e-7 10 3.15048 2 2 2 1 -0.2 -0.2 -0.2 7.3e-8 E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat std-dev 11 3.15049 2 2 2 1 -0.2 -0.2 -0.2 4.2147e-8 12 3.18988 2 2 2 1 0.04 0.04 0.04 7.3e-8 13 3.25049 2 2 2 1 -0.2 -0.2 -0.2 1.3979e-7 14 3.35049 2 2 2 1 -0.2 -0.2 -0.2 0 15 3.3505 2 2 2 1 -0.2 -0.2 -0.2 5.9605e-8 PrintExpectationValues(psiList,opList,Hamil,extraLists,Options): E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat Extra1 Extra2 std-dev 1 -3 2 2 0 0 0 0 0 0.5 5 7.3e-8 2 -0.233343 2 2 1 0 0 0 0 1 2.5 1.2633e-8 3 -0.133343 2 2 1 0 0 0 0 1.5 1.66667 2.2039e-8 4 -0.033333 2 2 1 0 0 0 0 2 1.25 3.0052e-8 5 0.0666667 2 2 1 0 0 0 0 2.5 1 5.4281e-8 6 0.166677 2 2 1 0 0 0 0 3 0.833333 3.96e-8 7 0.266677 2 2 1 0 0 0 0 3.5 0.714286 4.8141e-8 8 2.95048 2 2 2 1 -0.2 -0.2 -0.2 4 0.625 5.9605e-8 9 3.05048 2 2 2 1 -0.2 -0.2 -0.2 4.5 0.555556 1.0324e-7 10 3.15048 2 2 2 1 -0.2 -0.2 -0.2 5 0.5 7.3e-8 E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat Extra1 Extra2 std-dev 11 3.15049 2 2 2 1 -0.2 -0.2 -0.2 5.5 0.454545 4.2147e-8 12 3.18988 2 2 2 1 0.04 0.04 0.04 6 0.416667 7.3e-8 13 3.25049 2 2 2 1 -0.2 -0.2 -0.2 6.5 0.384615 1.3979e-7 14 3.35049 2 2 2 1 -0.2 -0.2 -0.2 7 0.357143 0 15 3.3505 2 2 2 1 -0.2 -0.2 -0.2 7.5 0.333333 5.9605e-8 PrintExpectationValues(psiList,opList,-Hamil,extraLists,Options): E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat Extra1 Extra2 std-dev 1 -3.3505 2 2 2 1 -0.2 -0.2 -0.2 7.5 0.333333 5.9605e-8 2 -3.35049 2 2 2 1 -0.2 -0.2 -0.2 7 0.357143 0 3 -3.25049 2 2 2 1 -0.2 -0.2 -0.2 6.5 0.384615 1.3979e-7 4 -3.18988 2 2 2 1 0.04 0.04 0.04 6 0.416667 7.3e-8 5 -3.15049 2 2 2 1 -0.2 -0.2 -0.2 5.5 0.454545 4.2147e-8 6 -3.15048 2 2 2 1 -0.2 -0.2 -0.2 5 0.5 7.3e-8 7 -3.05048 2 2 2 1 -0.2 -0.2 -0.2 4.5 0.555556 1.0324e-7 8 -2.95048 2 2 2 1 -0.2 -0.2 -0.2 4 0.625 5.9605e-8 9 -0.266677 2 2 1 0 0 0 0 3.5 0.714286 4.8141e-8 10 -0.166677 2 2 1 0 0 0 0 3 0.833333 3.96e-8 E N_1s N_2s N_2p F0_2p F2_2p Operator An Operat Extra1 Extra2 std-dev 11 -0.066667 2 2 1 0 0 0 0 2.5 1 5.4281e-8 12 0.0333333 2 2 1 0 0 0 0 2 1.25 3.0052e-8 13 0.133343 2 2 1 0 0 0 0 1.5 1.66667 2.2039e-8 14 0.233343 2 2 1 0 0 0 0 1 2.5 1.2633e-8 15 3 2 2 0 0 0 0 0 0.5 5 7.3e-8 ===== Table of contents ===== {{indexmenu>.#1}}