Esempio n. 1
0
        public void SerializeLadderOperatorInt()
        {
            LadderOperator <int> op0 = new LadderOperator <int>(RaisingLowering.u, 5);

            string json = JsonConvert.SerializeObject(op0, Formatting.None);

            Debug.WriteLine(@json);

            LadderOperator <int> op1 = JsonConvert.DeserializeObject <LadderOperator <int> >(json);

            Assert.Equal(op0, op1);
        }
Esempio n. 2
0
        public void SerializeLadderOperatorSpinOrbital()
        {
            LadderOperator <SpinOrbital> op0 = new LadderOperator <SpinOrbital>(RaisingLowering.u, new SpinOrbital(3, Spin.u));

            string json = JsonConvert.SerializeObject(op0, Formatting.None);

            Debug.WriteLine(@json);

            LadderOperator <SpinOrbital> op1 = JsonConvert.DeserializeObject <LadderOperator <SpinOrbital> >(json);

            Assert.Equal(op0, op1);
        }
Esempio n. 3
0
        static void LadderOperator()
        {
            // Let us use the spin orbital created in the previous snippet.
            var spinOrbitalInteger = new SpinOrbital(5, Spin.d).ToInt();

            // We specify either a creation or annihilation operator using
            // the enumerable type `RaisingLowering.u` or `RaisingLowering.d`
            // respectively;
            var creationEnum = RaisingLowering.u;

            // The type representing a creation operator is then initialized
            // as follows. Here, we index these operators with integers.
            // Hence we initialize the generic ladder operator with an
            // integer index type.
            var ladderOperator0 = new LadderOperator <int>(creationEnum, spinOrbitalInteger);

            // An alternate constructor for a LadderOperator instead uses
            // a tuple.
            var ladderOperator1 = new LadderOperator <int>((creationEnum, spinOrbitalInteger));

            Assert.Equal(ladderOperator0, ladderOperator1);
        }