public void IsInCanonicalOrderTest(bool pass, int nOrbitals, int[] ca, int[] idx) { var ladderOperators = ca.Zip(idx, (a, b) => (a == 0 ? RaisingLowering.d : RaisingLowering.u, (int)b)).ToLadderSequence(); var tmp = new HermitianFermionTerm(ladderOperators); Assert.True(tmp.IsInCanonicalOrder()); }
public void UniqueIndicesTests(int norbitals, int[] idx, int uniqueIndices) { var coefficient = 1.0; var HermitianFermionTerm = new HermitianFermionTerm(idx.ToLadderSequence()); Assert.True(HermitianFermionTerm.UniqueIndices() == uniqueIndices); }
public void SerializeHermitianFermionTerm() { HermitianFermionTerm term0 = new HermitianFermionTerm(new[] { 1, 2, 3, 4 }); string json = JsonConvert.SerializeObject(term0, Formatting.None); HermitianFermionTerm term1 = new HermitianFermionTerm(JsonConvert.DeserializeObject <LadderSequence <int> >(json)); Debug.WriteLine(@json); }
public void EmptyHermitianFermionTerm() { var term = new HermitianFermionTerm(new LadderSequence <int>()); var term2 = new HermitianFermionTerm(new LadderSequence <int>()); Dictionary <HermitianFermionTerm, double> dictionary = new Dictionary <HermitianFermionTerm, double>(); dictionary.Add(term, 0.5); Assert.Equal(0.5, dictionary[term2]); }
public void GetFermionTermTypeTests(int norbitals, int[] idx, int type) { var tmp = new TermType.Fermion[] { Identity, PP, PQ, PQQP, PQQR, PQRS }; var fermionTerm = new HermitianFermionTerm(idx.ToLadderSequence()); var fermionTermType = fermionTerm.TermType; Assert.True(fermionTermType == tmp[type]); }
void CheckKeyPresence() { var hamiltonian = GenerateTestHamiltonian(); var check = new HermitianFermionTerm(new[] { 0, 2, 2, 0 }.ToLadderSequence()); hamiltonian.Add(check, 100.0.ToDoubleCoeff()); var sourceDict = hamiltonian.Terms[TermType.Fermion.PQQP]; var check2 = new HermitianFermionTerm(new[] { 0, 2, 2, 0 }.ToLadderSequence()); var coeff = sourceDict[check2]; Assert.Equal(101.0, coeff.Value); Assert.Equal(101.0, hamiltonian.Terms[TermType.Fermion.PQQP][check].Value); // Check using GetTerm method. Assert.Equal(101.0, hamiltonian.GetTerm(new HermitianFermionTerm(check)).Value); }
public void Inheritance() { var term = new NormalOrderedSequence <int>(new LadderSequence <int>()); var term2 = new HermitianFermionTerm(term); }