void NormTerms() { var hamiltonian = new OrbitalIntegralHamiltonian(); hamiltonian.AddRange(orbitalIntegrals.Select(o => (o, o.Coefficient.ToDoubleCoeff()))); var oneNorm = hamiltonian.Norm(); hamiltonian.AddRange(orbitalIntegrals.Select(o => (o, o.Coefficient.ToDoubleCoeff()))); Assert.Equal(oneNorm * 2.0, hamiltonian.Norm()); hamiltonian.AddRange(orbitalIntegrals.Select(o => (o, o.Coefficient.ToDoubleCoeff()))); Assert.Equal(oneNorm * 3.0, hamiltonian.Norm()); hamiltonian.AddRange(orbitalIntegrals.Select(o => (o, o.Coefficient.ToDoubleCoeff()))); Assert.Equal(oneNorm * 4.0, hamiltonian.Norm()); }
public void JsonEncoding() { var filename = "Broombridge/broombridge_v0.2.yaml"; Data broombridge = Deserializers.DeserializeBroombridge(filename); var problemData = broombridge.ProblemDescriptions.First(); OrbitalIntegralHamiltonian original = problemData.OrbitalIntegralHamiltonian; var json = JsonConvert.SerializeObject(original); File.WriteAllText("oribital.original.json", json); var serialized = JsonConvert.DeserializeObject <OrbitalIntegralHamiltonian>(json); File.WriteAllText("orbital.serialized.json", JsonConvert.SerializeObject(serialized)); Assert.Equal(original.SystemIndices.Count, serialized.SystemIndices.Count); Assert.Equal(original.Terms.Count, serialized.Terms.Count); Assert.Equal(original.Norm(), serialized.Norm()); Assert.Equal(original.ToString(), serialized.ToString()); }