-- a p shell: 6 spin-orbitals, spin down on the even indices, spin up on the odd ones NF = 6 NB = 0 IndexDn = {0, 2, 4} IndexUp = {1, 3, 5} OppSx = NewOperator("Sx", NF, IndexUp, IndexDn) OppSz = NewOperator("Sz", NF, IndexUp, IndexDn) OppLx = NewOperator("Lx", NF, IndexUp, IndexDn) OppLz = NewOperator("Lz", NF, IndexUp, IndexDn) -- define an Hamiltonian (in this case a magnetic field of 6 tesla in the z direction) H = 6 * EnergyUnits.Tesla.value * (2*OppSz + OppLz) -- define a transition operator (in this case a pulsed magnetic field of 20 tesla in the x direction) T = 20 * EnergyUnits.Tesla.value * (2*OppSx + OppLx) -- define a ground-state (in this case a p electron with spin and angular momentum down) psigrd = NewWavefunction(NF, NB, {{"100000", 1}}) -- calculate < psigrd | T^dag 1/(w-H+i*G/2+E0) T | psigrd > -- with E0 = -- spectri is optional spec, spectri = CreateSpectra(H, T, psigrd,{{"NE",20}}) -- the real and imaginary part on a fixed energy grid print(spec) -- the response function: for a small space a list of poles (energies relative to E0, and -- residues), otherwise a tri-diagonal matrix (a continued fraction) print(spectri)