Differences
This shows you the differences between two versions of the page.
documentation:tutorials:introduction_to_quanty:expectation_values [2016/10/07 20:28] – created Maurits W. Haverkort | documentation:tutorials:introduction_to_quanty:expectation_values [2016/10/10 09:41] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{indexmenu_n> | ||
+ | ====== Expectation values ====== | ||
+ | ### | ||
+ | The fifth example discusses expectation values. | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | <code Quanty Expectation_values.Quanty> | ||
+ | -- Using operators and wavefunctions as explained in | ||
+ | -- the Operators and Wavefunctions example we can do | ||
+ | -- simple calculations of expectation values | ||
+ | |||
+ | -- Define the basis: | ||
+ | -- For a p-shell we would like the have 6 | ||
+ | -- spinorbitals, | ||
+ | -- spin up ml=-1, | ||
+ | -- spin down with ml=-1, ml=0, ml=1 | ||
+ | NF=6 | ||
+ | NB=0 | ||
+ | IndexDn={0, | ||
+ | IndexUp={1, | ||
+ | |||
+ | -- Define 6 one electron wave functions | ||
+ | psi0=NewWavefunction(NF, | ||
+ | psi0.Name = "psi(1 -1 1/2 -1/2)" | ||
+ | psi1=NewWavefunction(NF, | ||
+ | psi1.Name = " | ||
+ | psi2=NewWavefunction(NF, | ||
+ | psi2.Name = " | ||
+ | psi3=NewWavefunction(NF, | ||
+ | psi3.Name = "psi(1 -1 1/2 1/2)" | ||
+ | psi4=NewWavefunction(NF, | ||
+ | psi4.Name = " | ||
+ | psi5=NewWavefunction(NF, | ||
+ | psi5.Name = " | ||
+ | |||
+ | -- Define spin and angular momentum operators | ||
+ | OppSx | ||
+ | OppSy | ||
+ | OppSz | ||
+ | OppSsqr =NewOperator(" | ||
+ | OppSplus=NewOperator(" | ||
+ | OppSmin =NewOperator(" | ||
+ | |||
+ | OppLx | ||
+ | OppLy | ||
+ | OppLz | ||
+ | OppLsqr =NewOperator(" | ||
+ | OppLplus=NewOperator(" | ||
+ | OppLmin =NewOperator(" | ||
+ | |||
+ | OppJx | ||
+ | OppJy | ||
+ | OppJz | ||
+ | OppJsqr =NewOperator(" | ||
+ | OppJplus=NewOperator(" | ||
+ | OppJmin =NewOperator(" | ||
+ | |||
+ | Oppldots=NewOperator(" | ||
+ | |||
+ | -- We can look at expectation values by multiplying | ||
+ | -- a wavefunction with an operator with a | ||
+ | -- wavefunction | ||
+ | ExpLz = psi0 * OppLz * psi0 | ||
+ | print(" | ||
+ | ExpSz = psi0 * OppSz * psi0 | ||
+ | print(" | ||
+ | print("" | ||
+ | |||
+ | -- A print of the operator gives the operator in | ||
+ | -- second quantization. knowing a basis of | ||
+ | -- wavefunctions we can also look at a matrix | ||
+ | -- representation of the operators. To simplify | ||
+ | -- loops we first create a table of the functions | ||
+ | psiList={psi0, | ||
+ | |||
+ | -- print the Sz operator | ||
+ | print(" | ||
+ | for i = 1, 6 do | ||
+ | for j = 1, 6 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | print("" | ||
+ | |||
+ | -- print the Lz operator | ||
+ | print(" | ||
+ | for i = 1, 6 do | ||
+ | for j = 1, 6 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | print("" | ||
+ | |||
+ | -- the Lz and Sz operators are represented by | ||
+ | -- diagonal matrices. This is so while our basis | ||
+ | -- states are chosen (created) to be eigen states | ||
+ | -- of Lz and Sz. If one looks at other operators | ||
+ | -- this is different. | ||
+ | print(" | ||
+ | psiList={psi0, | ||
+ | for i = 1, 6 do | ||
+ | for j = 1, 6 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | |||
+ | -- The matrix form of the operators depends on the | ||
+ | -- basis states we take. For two electrons we need | ||
+ | -- to define 15 two particle states in the p-shell. | ||
+ | print("" | ||
+ | print(" | ||
+ | psi0 =NewWavefunction(NF, | ||
+ | psi1 =NewWavefunction(NF, | ||
+ | psi2 =NewWavefunction(NF, | ||
+ | psi3 =NewWavefunction(NF, | ||
+ | psi4 =NewWavefunction(NF, | ||
+ | psi5 =NewWavefunction(NF, | ||
+ | psi6 =NewWavefunction(NF, | ||
+ | psi7 =NewWavefunction(NF, | ||
+ | psi8 =NewWavefunction(NF, | ||
+ | psi9 =NewWavefunction(NF, | ||
+ | psi10=NewWavefunction(NF, | ||
+ | psi11=NewWavefunction(NF, | ||
+ | psi12=NewWavefunction(NF, | ||
+ | psi13=NewWavefunction(NF, | ||
+ | psi14=NewWavefunction(NF, | ||
+ | |||
+ | -- The operator in terms of creation and | ||
+ | -- annihilation operators is still the same | ||
+ | -- and can thus be used to calculate expectation | ||
+ | -- values | ||
+ | print("" | ||
+ | ExpLz = psi0 * OppLz * psi0 | ||
+ | print(" | ||
+ | ExpSz = psi0 * OppSz * psi0 | ||
+ | print(" | ||
+ | print("" | ||
+ | |||
+ | -- to simplify loops we first create a table of the | ||
+ | -- functions | ||
+ | psiList = {psi0, psi1, psi2, psi3, psi4, psi5, psi6, psi7, psi8, psi9, psi10, psi11, psi12, psi13, psi14} | ||
+ | |||
+ | -- print the Sz operator | ||
+ | print(" | ||
+ | for i = 1, 15 do | ||
+ | for j = 1, 15 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | print("" | ||
+ | |||
+ | -- print the Lz operator | ||
+ | print(" | ||
+ | for i = 1, 15 do | ||
+ | for j = 1, 15 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | print("" | ||
+ | |||
+ | -- print the Ssqr operator | ||
+ | print(" | ||
+ | for i = 1, 15 do | ||
+ | for j = 1, 15 do | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | print("" | ||
+ | </ | ||
+ | ### | ||
+ | |||
+ | ### | ||
+ | The output is: | ||
+ | <file Quanty_Output Expectation_values.out> | ||
+ | The expectation value for psi0 is given as <psi0 | Lz | psi0> | ||
+ | The expectation value for psi0 is given as <psi0 | Sz | psi0> | ||
+ | |||
+ | The Sz operator on a basis of psi0 to psi5 looks like: | ||
+ | -0.50 0.00 0.00 0.00 0.00 0.00 | ||
+ | 0.00 -0.50 0.00 0.00 0.00 0.00 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | The Lz operator on a basis of psi0 to psi5 looks like: | ||
+ | -1.00 0.00 0.00 0.00 0.00 0.00 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | The spin orbit coupling operator l.s on a basis of psi0 to psi5 looks like: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | ========== Two electrons in the p-shell ========== | ||
+ | |||
+ | The expectation value for psi0 is given as <psi0 | Lz | psi0> = -2 | ||
+ | The expectation value for psi0 is given as <psi0 | Sz | psi0> = 0 | ||
+ | |||
+ | The Sz operator on a basis of psi0 to psi14 looks like: | ||
+ | | ||
+ | 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | The Lz operator on a basis of psi0 to psi14 looks like: | ||
+ | -2.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
+ | 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | The S^2 operator on a basis of psi0 to psi14 looks like: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | ### | ||
+ | |||
+ | |||
+ | ===== Table of contents ===== | ||
+ | {{indexmenu> |