/// <summary>
        /// Converts the raw problem description in V0_2 Broombridge into
        /// in internal data format.
        /// </summary>
        /// <param name="problem">Problem description to be converted</param>
        /// <returns>The internal problem description data structure.</returns>
        public static ProblemDescription ProcessRawProblemDescription(Broombridge.V0_2.ProblemDescription problem)
        {
            var problemDescription = new ProblemDescription
            {
                EnergyOffset = problem.EnergyOffset.Value + problem.CoulombRepulsion.Value,
                NElectrons   = problem.NElectrons,
                NOrbitals    = problem.NOrbitals,
                OrbitalIntegralHamiltonian = V0_2.ToOrbitalIntegralHamiltonian(problem),
                Wavefunctions = new Dictionary <string, FermionWavefunction <SpinOrbital> >()
            };

            foreach (var initialState in problem.InitialStates)
            {
                var finalState = new FermionWavefunction <SpinOrbital>();

                var(method, energy, outputState) = V0_2.ToWavefunction(initialState);

                var setMethod = V0_2.ParseInitialStateMethod(initialState.Method);
                var setEnergy = energy;

                if (setMethod == StateType.SparseMultiConfigurational)
                {
                    var mcfData = (SparseMultiCFWavefunction <SpinOrbital>)outputState;

                    finalState = new FermionWavefunction <SpinOrbital>(
                        mcfData.Excitations
                        .Select(o => (
                                    o.Key.ToIndices().ToArray(),
                                    o.Value.Real
                                    )));
                }
                else if (setMethod == StateType.UnitaryCoupledCluster)
                {
                    var uccData = (UnitaryCCWavefunction <SpinOrbital>)outputState;

                    var reference = uccData.Reference;

                    var excitations = uccData.Excitations;

                    finalState = new FermionWavefunction <SpinOrbital>(
                        reference.ToIndices(),
                        excitations
                        .Select(o => (
                                    o.Key.ToIndices().ToArray(),
                                    o.Value.Real
                                    ))
                        );
                }
                else
                {
                    throw new System.ArgumentException($"Wavefunction type {setMethod} not recognized");
                }

                finalState.Method = setMethod;
                finalState.Energy = setEnergy;

                problemDescription.Wavefunctions.Add(initialState.Label, finalState);
            }
            return(problemDescription);
        }
        public static IEnumerable <ElectronicStructureProblem> Deserialize(TextReader reader)
        {
            var data = Deserializers.DeserializeBroombridge(reader);

            return(data
                   .Raw
                   .ProblemDescriptions
                   .Select(
                       problem => new ElectronicStructureProblem
            {
                BasisSet = problem.BasisSet?.FromBroombridgeV0_1(),
                CoulombRepulsion = problem.CoulombRepulsion.FromBroombridgeV0_1(),
                Geometry = problem.Geometry?.FromBroombridgeV0_1(),
                EnergyOffset = problem.EnergyOffset.FromBroombridgeV0_1(),
                FciEnergy = problem.FciEnergy?.FromBroombridgeV0_1(),
                InitialStates = problem.InitialStates?.FromBroombridgeV0_2(),
                Metadata = problem.Metadata,
                NElectrons = problem.NElectrons,
                NOrbitals = problem.NOrbitals,
                OrbitalIntegralHamiltonian = V0_2.ToOrbitalIntegralHamiltonian(problem),
                ScfEnergy = problem.ScfEnergy?.FromBroombridgeV0_1(),
                ScfEnergyOffset = problem.ScfEnergyOffset?.FromBroombridgeV0_1()
            }
                       ));
        }
Esempio n. 3
0
        public static ProblemDescription ProcessRawProblemDescription(Broombridge.V0_2.ProblemDescription problem)
        {
            var problemDescription = new ProblemDescription
            {
                EnergyOffset = problem.EnergyOffset.Value + problem.CoulombRepulsion.Value,
                NElectrons   = problem.NElectrons,
                NOrbitals    = problem.NOrbitals,
                OrbitalIntegralHamiltonian = V0_2.ToOrbitalIntegralHamiltonian(problem),
                Wavefunctions = problem.InitialStates?.FromBroombridgeV0_2() ?? new Dictionary <string, FermionWavefunction <SpinOrbital> >()
            };

            return(problemDescription);
        }