Chemistry data conversion tool (#280)
This commit is contained in:
Родитель
13b49100ae
Коммит
fc24b3ef5f
|
@ -15,6 +15,7 @@
|
|||
".\Numerics\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Numerics.dll",
|
||||
".\MachineLearning\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.MachineLearning.dll",
|
||||
".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll",
|
||||
".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll"
|
||||
".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll",
|
||||
".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\qdk-chem.dll"
|
||||
) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot ".." $_) };
|
||||
} | Write-Output;
|
||||
|
|
|
@ -37,6 +37,9 @@ Pack-One '../Numerics/src/Numerics.csproj'
|
|||
Write-Host "##[info]Pack chemistry magics library"
|
||||
Pack-One '../Chemistry/src/Jupyter/Jupyter.csproj'
|
||||
|
||||
Write-Host "##[info]Pack chemistry tool"
|
||||
Pack-One '../Chemistry/src/Tools/Tools.csproj'
|
||||
|
||||
if (-not $all_ok) {
|
||||
throw "At least one test failed execution. Check the logs."
|
||||
}
|
||||
|
|
|
@ -31,11 +31,8 @@ Test-One '../Chemistry/tests/ChemistryTests/QSharpTests.csproj'
|
|||
Write-Host "##[info]Testing Chemistry/tests/SystemTests/SystemTests.csproj"
|
||||
Test-One '../Chemistry/tests/SystemTests/SystemTests.csproj'
|
||||
|
||||
Write-Host "##[info]Testing Chemistry/tests/DataModelTests/CSharpTests.csproj"
|
||||
Test-One '../Chemistry/tests/DataModelTests/CSharpTests.csproj'
|
||||
|
||||
Write-Host "##[info]Testing Chemistry/tests/SerializationTests/SerializationTests.csproj"
|
||||
Test-One '../Chemistry/tests/SerializationTests/SerializationTests.csproj'
|
||||
Write-Host "##[info]Testing Chemistry/tests/DataModelTests/DataModelTests.csproj"
|
||||
Test-One '../Chemistry/tests/DataModelTests/DataModelTests.csproj'
|
||||
|
||||
Write-Host "##[info]Testing Chemistry/tests/JupyterTests/JupyterTests.csproj"
|
||||
Test-One '../Chemistry/tests/JupyterTests/JupyterTests.csproj'
|
||||
|
|
|
@ -18,26 +18,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{595D5855
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemTests", "Chemistry\tests\SystemTests\SystemTests.csproj", "{E9688DB1-CECC-407E-A192-90CC07FC48CA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpTests", "Chemistry\tests\DataModelTests\CSharpTests.csproj", "{56296CAB-76A9-4595-B5DB-DC8290B9B991}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModelTests", "Chemistry\tests\DataModelTests\DataModelTests.csproj", "{56296CAB-76A9-4595-B5DB-DC8290B9B991}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSharpTests", "Chemistry\tests\ChemistryTests\QSharpTests.csproj", "{F723F015-C78C-46A2-BB9D-CD2FD3D1DDCD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard", "Standard\src\Standard.csproj", "{4EE69CC7-1158-49A2-A28F-9443B06D4A32}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SerializationTests", "Chemistry\tests\SerializationTests\SerializationTests.csproj", "{364D11CE-AB4E-4727-ADA7-EFF3DCD92096}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BroombridgeExamples", "BroombridgeExamples", "{F25F3396-EDE5-4A9F-A428-643EB138F00F}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestData\Broombridge", "TestData\Broombridge", "{F25F3396-EDE5-4A9F-A428-643EB138F00F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Chemistry\tests\BroombridgeExamples\broombridge_v0.1.yaml = Chemistry\tests\BroombridgeExamples\broombridge_v0.1.yaml
|
||||
Chemistry\tests\BroombridgeExamples\broombridge_v0.2.yaml = Chemistry\tests\BroombridgeExamples\broombridge_v0.2.yaml
|
||||
Chemistry\tests\BroombridgeExamples\hydrogen_0.1.yaml = Chemistry\tests\BroombridgeExamples\hydrogen_0.1.yaml
|
||||
Chemistry\tests\BroombridgeExamples\hydrogen_0.2.yaml = Chemistry\tests\BroombridgeExamples\hydrogen_0.2.yaml
|
||||
Chemistry\tests\BroombridgeExamples\LiH_0.1.yaml = Chemistry\tests\BroombridgeExamples\LiH_0.1.yaml
|
||||
Chemistry\tests\BroombridgeExamples\LiH_0.2.yaml = Chemistry\tests\BroombridgeExamples\LiH_0.2.yaml
|
||||
Chemistry\tests\TestData\Broombridge\broombridge_v0.1.yaml = Chemistry\tests\TestData\Broombridge\broombridge_v0.1.yaml
|
||||
Chemistry\tests\TestData\Broombridge\broombridge_v0.2.yaml = Chemistry\tests\TestData\Broombridge\broombridge_v0.2.yaml
|
||||
Chemistry\tests\TestData\Broombridge\hydrogen_0.1.yaml = Chemistry\tests\TestData\Broombridge\hydrogen_0.1.yaml
|
||||
Chemistry\tests\TestData\Broombridge\hydrogen_0.2.yaml = Chemistry\tests\TestData\Broombridge\hydrogen_0.2.yaml
|
||||
Chemistry\tests\TestData\Broombridge\LiH_0.1.yaml = Chemistry\tests\TestData\Broombridge\LiH_0.1.yaml
|
||||
Chemistry\tests\TestData\Broombridge\LiH_0.2.yaml = Chemistry\tests\TestData\Broombridge\LiH_0.2.yaml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplesTests", "Chemistry\tests\SamplesTests\SamplesTests.csproj", "{2A0E61DB-7187-4359-B5C7-C30FCB1D6800}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chemistry", "Chemistry", "{9DBAD085-1238-4575-B4D4-6D693FD659AD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A6FCF729-0408-4884-8D8D-D4BD5CB951A9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools", "Chemistry\src\Tools\Tools.csproj", "{196C66C9-6FE3-41C8-A04A-748A42699C23}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -68,14 +72,14 @@ Global
|
|||
{4EE69CC7-1158-49A2-A28F-9443B06D4A32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4EE69CC7-1158-49A2-A28F-9443B06D4A32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4EE69CC7-1158-49A2-A28F-9443B06D4A32}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{364D11CE-AB4E-4727-ADA7-EFF3DCD92096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{364D11CE-AB4E-4727-ADA7-EFF3DCD92096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{364D11CE-AB4E-4727-ADA7-EFF3DCD92096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{364D11CE-AB4E-4727-ADA7-EFF3DCD92096}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2A0E61DB-7187-4359-B5C7-C30FCB1D6800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A0E61DB-7187-4359-B5C7-C30FCB1D6800}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A0E61DB-7187-4359-B5C7-C30FCB1D6800}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A0E61DB-7187-4359-B5C7-C30FCB1D6800}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{196C66C9-6FE3-41C8-A04A-748A42699C23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{196C66C9-6FE3-41C8-A04A-748A42699C23}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{196C66C9-6FE3-41C8-A04A-748A42699C23}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{196C66C9-6FE3-41C8-A04A-748A42699C23}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -86,8 +90,9 @@ Global
|
|||
{E9688DB1-CECC-407E-A192-90CC07FC48CA} = {595D5855-8820-48D7-B5E1-9C88215A866A}
|
||||
{56296CAB-76A9-4595-B5DB-DC8290B9B991} = {595D5855-8820-48D7-B5E1-9C88215A866A}
|
||||
{F723F015-C78C-46A2-BB9D-CD2FD3D1DDCD} = {595D5855-8820-48D7-B5E1-9C88215A866A}
|
||||
{364D11CE-AB4E-4727-ADA7-EFF3DCD92096} = {595D5855-8820-48D7-B5E1-9C88215A866A}
|
||||
{2A0E61DB-7187-4359-B5C7-C30FCB1D6800} = {595D5855-8820-48D7-B5E1-9C88215A866A}
|
||||
{A6FCF729-0408-4884-8D8D-D4BD5CB951A9} = {9DBAD085-1238-4575-B4D4-6D693FD659AD}
|
||||
{196C66C9-6FE3-41C8-A04A-748A42699C23} = {A6FCF729-0408-4884-8D8D-D4BD5CB951A9}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6869E5BF-551A-40F1-9B6B-D1B27A5676CB}
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Broombridge
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerable item for Broombridge version numbers.
|
||||
/// </summary>
|
||||
public enum VersionNumber
|
||||
{
|
||||
NotRecognized = -1, v0_1 = 0, v0_2 = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge deserializers
|
||||
/// </summary>
|
||||
public static class Deserializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Dictionary from version number strings to version number types.
|
||||
/// </summary>
|
||||
internal static Dictionary<string, VersionNumber> VersionNumberDict = new Dictionary<string, VersionNumber>()
|
||||
{
|
||||
// https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
|
||||
{"0.1", VersionNumber.v0_1 },
|
||||
{"broombridge-0.1.schema", VersionNumber.v0_1 },
|
||||
// TODO: URL of 0.2 schema.
|
||||
{"0.2", VersionNumber.v0_2 },
|
||||
{"broombridge-0.2.schema", VersionNumber.v0_2 }
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns version number of Broombridge file.
|
||||
/// </summary>
|
||||
/// <param name="filename">Broombridge file address.</param>
|
||||
/// <returns>Version number of Broombridge file</returns>
|
||||
public static VersionNumber GetVersionNumber(string filename)
|
||||
{
|
||||
using (var reader = File.OpenText(filename))
|
||||
{
|
||||
var deserializer = new DeserializerBuilder().Build();
|
||||
var data = deserializer.Deserialize<Dictionary<string, object>>(reader);
|
||||
var schema = data["$schema"] as string;
|
||||
VersionNumber versionNumber = VersionNumber.NotRecognized;
|
||||
if(schema != null)
|
||||
{
|
||||
foreach (var kv in VersionNumberDict)
|
||||
{
|
||||
if (schema.Contains(kv.Key))
|
||||
{
|
||||
versionNumber = kv.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return versionNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns Broombridge deserialized into the current version data structure.
|
||||
/// Data structure is automatically updated to the current Broombridge version.
|
||||
/// </summary>
|
||||
/// <param name="filename">Broombridge file address.</param>
|
||||
/// <returns>Deserializer Broombridge data strauture.</returns>
|
||||
public static Data DeserializeBroombridge(string filename)
|
||||
{
|
||||
VersionNumber versionNumber = GetVersionNumber(filename);
|
||||
var output = new V0_2.Data();
|
||||
if (versionNumber == VersionNumber.v0_1)
|
||||
{
|
||||
output = DataStructures.Update(Deserialize<V0_1.Data>(filename));
|
||||
}
|
||||
else if (versionNumber == VersionNumber.v0_2)
|
||||
{
|
||||
output = Deserialize<V0_2.Data>(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.InvalidOperationException("Unrecognized Broombridge version number.");
|
||||
}
|
||||
return new Data(output);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generic deserializer from a file into a data structure of type `TData`.
|
||||
/// </summary>
|
||||
/// <typeparam name="TData">Type of data to be deserialized.</typeparam>
|
||||
/// <param name="filename">Path to data to be deserialized.</param>
|
||||
/// <returns></returns>
|
||||
public static TData Deserialize<TData>(string filename)
|
||||
{
|
||||
using (var reader = File.OpenText(filename))
|
||||
{
|
||||
return new DeserializerBuilder()
|
||||
.Build()
|
||||
.Deserialize<TData>(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge serializers
|
||||
/// </summary>
|
||||
public static class Serializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Broombridge serializer
|
||||
/// </summary>
|
||||
/// <param name="filename">Broombridge filename to serialize</param>
|
||||
/// <returns>Serialized Broombridge</returns>
|
||||
public static void SerializeBroombridgev0_2(V0_2.Data data, string filename)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var serializer = new Serializer();
|
||||
stringBuilder.AppendLine(serializer.Serialize(data));
|
||||
Console.WriteLine(stringBuilder);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.1.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry
|
||||
{
|
||||
using System;
|
||||
|
@ -60,6 +62,14 @@ namespace Microsoft.Quantum.Chemistry
|
|||
}
|
||||
|
||||
|
||||
internal static TValue GetValueOrDefault<TKey, TValue>(
|
||||
this Dictionary<TKey, TValue> dictionary, TKey key,
|
||||
TValue defaultValue = default
|
||||
) =>
|
||||
dictionary.TryGetValue(key, out var value)
|
||||
? value
|
||||
: defaultValue;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -218,6 +228,28 @@ namespace Microsoft.Quantum.Chemistry
|
|||
/// <param name="array">Input array to clone.</param>
|
||||
/// <returns>Clone of the input array.</returns>
|
||||
public static TValue[] Clone<TValue>(this TValue[] array) => array.Select(el => el).ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Searches base types of a given type to find the type that immediately derives from
|
||||
/// <see href="System.Object" />.
|
||||
/// </summary>
|
||||
internal static Type GetBasestType(this Type t) =>
|
||||
(t.BaseType == typeof(object) || t == typeof(object)) ? t : GetBasestType(t.BaseType);
|
||||
|
||||
internal static int[] ToZeroBasedIndices(this IEnumerable<int> indices) =>
|
||||
indices.Select(idx => idx - 1).ToArray();
|
||||
|
||||
internal static int[] ToOneBasedIndices(this IEnumerable<int> indices) =>
|
||||
indices.Select(idx => idx + 1).ToArray();
|
||||
|
||||
internal static IEnumerable<TOutput> SelectMaybe<TInput, TOutput>(
|
||||
this IEnumerable<TInput> source, Func<TInput, TOutput?> selector
|
||||
)
|
||||
where TOutput : class =>
|
||||
source.Select(selector).Where(output => output != null).Select(item => item!);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
/// <summary>
|
||||
/// Method for collecting all distinct system (orbital) indices.
|
||||
/// </summary>
|
||||
/// <param name="orbitalIntegral">Collate orbital indices from this orbital integral.</param>
|
||||
/// <param name="index">Collate orbital indices from this orbital integral.</param>
|
||||
public override void AddToSystemIndices(HermitianFermionTerm index)
|
||||
{
|
||||
foreach (var idx in index.Sequence)
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
/// Index-ordered, where are raising(lowering) operators are in ascending(descending) order.
|
||||
/// </description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public class FermionTerm : IndexOrderedSequence<int>
|
||||
{
|
||||
|
@ -44,7 +45,11 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
/// Construct instance from a normal-ordered sequence of ladder operators.
|
||||
/// </summary>
|
||||
/// <param name="ladderOperators">Normal-ordered sequence of ladder operators.</param>
|
||||
public FermionTerm(IEnumerable<FermionOperator> ladderOperators, int setSign = 1 ) : base(ladderOperators, setSign) { }
|
||||
/// <param name="coefficient">
|
||||
/// Coefficient as the sign (<c>-1</c> or <c>+1</c>) of a ladder operator.
|
||||
/// </param>
|
||||
public FermionTerm(IEnumerable<FermionOperator> ladderOperators, int coefficient = 1)
|
||||
: base(ladderOperators, coefficient) { }
|
||||
#endregion
|
||||
|
||||
// This exists as a convenience function for creating fermion terms in samples.
|
||||
|
@ -87,6 +92,3 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ using System.Linq;
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.LadderOperators;
|
||||
using Microsoft.Quantum.Chemistry;
|
||||
using Microsoft.Quantum.Chemistry;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Fermion
|
||||
{
|
||||
|
@ -32,6 +30,7 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
/// Hermitian, and is assumed to be implicitly summed with its Hermitian conjugate if not explicitly Hermitian.
|
||||
/// </description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public class HermitianFermionTerm : FermionTerm, ITermIndex<TermType.Fermion, HermitianFermionTerm>
|
||||
{
|
||||
|
@ -53,7 +52,12 @@ namespace Microsoft.Quantum.Chemistry.Fermion
|
|||
/// Constructs a Hermitian fermion term from a normal-ordered sequence of ladder operators.
|
||||
/// </summary>
|
||||
/// <param name="ladderOperators">Hermitian normal-ordered sequence of ladder operators.</param>
|
||||
public HermitianFermionTerm(IEnumerable<FermionOperator> ladderOperators, int setSign = 1) : base(ladderOperators, setSign) {
|
||||
/// <param name="coefficient">
|
||||
/// Coefficient as the sign (<c>-1</c> or <c>+1</c>) of a ladder operator.
|
||||
/// </param>
|
||||
public HermitianFermionTerm(IEnumerable<FermionOperator> ladderOperators, int coefficient = 1)
|
||||
: base(ladderOperators, coefficient)
|
||||
{
|
||||
NormalizeToCanonicalOrder();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Quantum.Chemistry.OrbitalIntegrals;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.LadderOperators;
|
||||
|
||||
// Main idea: We do not want to implement a general technique to serialize everything.
|
||||
// We will create wrapper classes around the specific objects we want to serialize.
|
||||
|
||||
|
||||
// Serialize Ladder operators: Int and SpinOrbital type.
|
||||
// Serialize Hamiltonian: Fermion type.
|
||||
|
||||
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Json
|
||||
{
|
||||
|
||||
internal static class TypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Searches base types of a given type to find the type that immediately derives from
|
||||
/// <see href="System.Object" />.
|
||||
/// </summary>
|
||||
internal static Type GetBasestType(this Type t) =>
|
||||
(t.BaseType == typeof(object) || t == typeof(object)) ? t : GetBasestType(t.BaseType);
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,11 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
/// Constructs an instance from a normal-ordered sequence of ladder operators.
|
||||
/// </summary>
|
||||
/// <param name="ladderOperators">Normal-ordered sequence of ladder operators.</param>
|
||||
public IndexOrderedSequence(IEnumerable<LadderOperator<TIndex>> ladderOperators, int setSign = 1) : base(ladderOperators, setSign)
|
||||
/// <param name="coefficient">
|
||||
/// Coefficient as the sign (<c>-1</c> or <c>+1</c>) of a ladder operator.
|
||||
/// </param>
|
||||
public IndexOrderedSequence(IEnumerable<LadderOperator<TIndex>> ladderOperators, int coefficient = 1)
|
||||
: base(ladderOperators, coefficient)
|
||||
{
|
||||
NormalizeToIndexOrder();
|
||||
}
|
||||
|
|
|
@ -85,22 +85,27 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct instance from sequence of ladder operators.
|
||||
/// Construct instance from sequence of ladder operators.
|
||||
/// </summary>
|
||||
/// <param name="setSequence">Sequence of ladder operators.</param>
|
||||
public LadderSequence(IEnumerable<LadderOperator<TIndex>> setSequence, int setCoefficient = 1)
|
||||
/// <param name="coefficient">
|
||||
/// Coefficient as the sign (<c>-1</c> or <c>+1</c>) of a ladder operator.
|
||||
/// </param>
|
||||
public LadderSequence(IEnumerable<LadderOperator<TIndex>> setSequence, int coefficient = 1)
|
||||
{
|
||||
Sequence = setSequence.ToList();
|
||||
Coefficient = setCoefficient;
|
||||
Coefficient = coefficient;
|
||||
}
|
||||
|
||||
// This exists as a convenience function for creating fermion terms in samples.
|
||||
/// <summary>
|
||||
/// Implicit operator for creating a Ladder operator.
|
||||
/// Implicit operator for creating a Ladder operator.
|
||||
/// </summary>
|
||||
/// <param name="setOperator">Tuple where the first parameter
|
||||
/// is the raising or lowering index, and the second parameter
|
||||
/// is the position index of the ladder operator.</param>
|
||||
/// <param name="setSequence">
|
||||
/// Tuple where the first parameter
|
||||
/// is the raising or lowering index, and the second parameter
|
||||
/// is the position index of the ladder operator.
|
||||
/// </param>
|
||||
public static implicit operator LadderSequence<TIndex>((RaisingLowering, TIndex)[] setSequence)
|
||||
{
|
||||
return new LadderSequence<TIndex>(setSequence.Select(o => new LadderOperator<TIndex>(o)));
|
||||
|
@ -128,14 +133,13 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
{
|
||||
throw new System.ArgumentException(
|
||||
$"Number of terms provided is `{length}` and must be of even length."
|
||||
);
|
||||
);
|
||||
}
|
||||
LadderOperator<TIndex> GetLadderOperator(TIndex index, int position)
|
||||
{
|
||||
var ladderOperatorData = (position < length / 2 ? RaisingLowering.u : RaisingLowering.d, index);
|
||||
return new LadderOperator<TIndex>(ladderOperatorData);
|
||||
}
|
||||
Sequence = indices.Select(GetLadderOperator).ToList();
|
||||
Sequence = indices.Select(
|
||||
(index, position) => new LadderOperator<TIndex>(
|
||||
position < length / 2 ? RaisingLowering.u : RaisingLowering.d, index
|
||||
)
|
||||
).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -147,7 +151,10 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
/// Returns <c>true</c> this condition is satisfied.
|
||||
/// Returns <c>false</c> otherwise.
|
||||
/// </returns>
|
||||
public bool IsInNormalOrder() => Sequence.Count() == 0 ? true : Sequence.Select(o => (int)o.Type).IsInAscendingOrder();
|
||||
public bool IsInNormalOrder() =>
|
||||
Sequence.Count() == 0 ||
|
||||
Sequence.Select(o => (int)o.Type).IsInAscendingOrder();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -168,11 +175,11 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
/// <summary>
|
||||
/// Concatenates two Fermion terms.
|
||||
/// </summary>
|
||||
/// <param name="left">Left <see cref="LadderSequence"/> <c>x</c>.</param>
|
||||
/// <param name="right">Right <see cref="LadderSequence"/> <c>y</c>.</param>
|
||||
/// <param name="left">Left <see cref="LadderSequence{TIndex}"/> <c>x</c>.</param>
|
||||
/// <param name="right">Right <see cref="LadderSequence{TIndex}"/> <c>y</c>.</param>
|
||||
/// <returns>
|
||||
/// Returns new <see cref="LadderSequence"/> <c>xy</c> where coefficients and
|
||||
/// LadderOperatorSequences are multipled together.
|
||||
/// Returns new <see cref="LadderSequence{TIndex}"/> <c>xy</c> where coefficients and
|
||||
/// LadderOperatorSequences are multipled together.
|
||||
/// </returns>
|
||||
// TODO: May decide to overload the * operator.
|
||||
public LadderSequence<TIndex> Multiply(
|
||||
|
@ -181,8 +188,8 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
=> new LadderSequence<TIndex>(left.Sequence.Concat(right.Sequence), left.Coefficient * right.Coefficient);
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of unique system indices across all <see cref="LadderOperator"/> terms
|
||||
/// in a <see cref="LadderSequence"/>
|
||||
/// Counts the number of unique system indices across all <see cref="LadderOperator{TIndex}"/> terms
|
||||
/// in a <see cref="LadderSequence{TIndex}"/>
|
||||
/// </summary>
|
||||
/// <returns>Number of unique system indices.</returns>
|
||||
public int UniqueIndices() => Sequence.Select(o => o.Index).Distinct().Count();
|
||||
|
@ -269,6 +276,3 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,12 @@ namespace Microsoft.Quantum.Chemistry.LadderOperators
|
|||
/// Construct instance from a normal-ordered sequence of ladder operators.
|
||||
/// </summary>
|
||||
/// <param name="ladderOperators">Normal-ordered sequence of ladder operators.</param>
|
||||
public NormalOrderedSequence(IEnumerable<LadderOperator<TIndex>> ladderOperators, int setSign = 1) : base(ladderOperators, setSign) => ThrowExceptionIfNotInNormalOrder();
|
||||
/// <param name="coefficient">
|
||||
/// Coefficient as the sign (<c>-1</c> or <c>+1</c>) of a ladder operator.
|
||||
/// </param>
|
||||
public NormalOrderedSequence(IEnumerable<LadderOperator<TIndex>> ladderOperators, int coefficient = 1)
|
||||
: base(ladderOperators, coefficient) =>
|
||||
ThrowExceptionIfNotInNormalOrder();
|
||||
#endregion
|
||||
|
||||
#region Ordering testers
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Quantum.Chemistry;
|
||||
using Microsoft.Quantum.Chemistry.LadderOperators;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.OrbitalIntegrals
|
||||
{
|
||||
|
||||
internal static class IndexConventionConversions
|
||||
{
|
||||
internal static int[] ConvertIndices(
|
||||
IEnumerable<int> indices,
|
||||
OrbitalIntegral.Convention from,
|
||||
OrbitalIntegral.Convention to
|
||||
) =>
|
||||
(from, to) switch
|
||||
{
|
||||
(OrbitalIntegral.Convention.Mulliken, OrbitalIntegral.Convention.Dirac) =>
|
||||
ConvertMullikenToDirac(indices),
|
||||
(OrbitalIntegral.Convention.Dirac, OrbitalIntegral.Convention.Mulliken) =>
|
||||
ConvertDiracToMulliken(indices),
|
||||
_ when from == to => indices.ToArray(),
|
||||
_ => throw new ArgumentException($"Conversion from {from} to {to} not currently supported.")
|
||||
};
|
||||
|
||||
private static int[] ConvertMullikenToDirac(IEnumerable<int> indices) =>
|
||||
indices.Count() switch
|
||||
{
|
||||
2 => indices.Select(o => o).ToArray(),
|
||||
4 => new int[]
|
||||
{
|
||||
indices.ElementAt(0),
|
||||
indices.ElementAt(2),
|
||||
indices.ElementAt(3),
|
||||
indices.ElementAt(1)
|
||||
},
|
||||
_ => throw new System.ArgumentException(
|
||||
$"Got indices [{String.Join(", ", indices)}], but Mulliken convention for not 2 or 4 indices is not defined."
|
||||
)
|
||||
};
|
||||
|
||||
private static int[] ConvertDiracToMulliken(IEnumerable<int> indices) =>
|
||||
indices.Count() switch
|
||||
{
|
||||
2 => indices.Select(o => o).ToArray(),
|
||||
4 => new int[]
|
||||
{
|
||||
indices.ElementAt(0),
|
||||
indices.ElementAt(3),
|
||||
indices.ElementAt(1),
|
||||
indices.ElementAt(2)
|
||||
},
|
||||
_ => throw new System.ArgumentException(
|
||||
$"Got indices [{String.Join(", ", indices)}], but Dirac convention for not 2 or 4 indices is not defined."
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,8 @@ using System.Collections.Generic;
|
|||
using Microsoft.Quantum.Chemistry;
|
||||
using Microsoft.Quantum.Chemistry.LadderOperators;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.OrbitalIntegrals.IndexConventionConversions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.OrbitalIntegrals
|
||||
{
|
||||
using static Microsoft.Quantum.Chemistry.Extensions;
|
||||
|
@ -64,31 +66,8 @@ namespace Microsoft.Quantum.Chemistry.OrbitalIntegrals
|
|||
/// <param name="convention">Convention for ordering of orbital indices.</param>
|
||||
public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient, Convention convention = Convention.Mulliken)
|
||||
{
|
||||
if (convention == Convention.Mulliken)
|
||||
{
|
||||
if (orbitalIndices.Count() == 2)
|
||||
{
|
||||
OrbitalIndices = orbitalIndices.Select(o => o).ToArray();
|
||||
}
|
||||
else if (orbitalIndices.Count() == 4)
|
||||
{
|
||||
var p = orbitalIndices.ElementAt(0);
|
||||
var q = orbitalIndices.ElementAt(2);
|
||||
var r = orbitalIndices.ElementAt(3);
|
||||
var s = orbitalIndices.ElementAt(1);
|
||||
OrbitalIndices = new int[] { p, q, r, s };
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.ArgumentException("Mulliken convention for not 2 or 4 indices is not defined.");
|
||||
}
|
||||
Coefficient = coefficient;
|
||||
}
|
||||
else
|
||||
{
|
||||
OrbitalIndices = orbitalIndices.ToArray();
|
||||
Coefficient = coefficient;
|
||||
}
|
||||
OrbitalIndices = ConvertIndices(orbitalIndices, convention, Convention.Dirac);
|
||||
Coefficient = coefficient;
|
||||
}
|
||||
|
||||
public TermType.OrbitalIntegral TermType
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace Microsoft.Quantum.Chemistry.OrbitalIntegrals
|
|||
SystemIndices.Add(idx);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
using Microsoft.Quantum.Chemistry.Fermion;
|
||||
using Microsoft.Quantum.Chemistry.OrbitalIntegrals;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry
|
||||
{
|
||||
|
||||
public static class QuantityExtensions
|
||||
{
|
||||
public static Quantity<TValue> WithUnits<TValue>(this TValue value, string units) =>
|
||||
new Quantity<TValue>
|
||||
{
|
||||
Units = units,
|
||||
Value = value
|
||||
};
|
||||
}
|
||||
|
||||
public interface IHasUnits
|
||||
{
|
||||
public string Units { get; set; }
|
||||
}
|
||||
|
||||
public interface IHasMetadata
|
||||
{
|
||||
public Dictionary<string, object> Metadata { get; set; }
|
||||
}
|
||||
|
||||
public struct Quantity<TValue> : IHasUnits
|
||||
{
|
||||
public string Units { get ; set; }
|
||||
public TValue Value { get; set; }
|
||||
}
|
||||
|
||||
public struct BoundedQuantity<TValue> : IHasUnits
|
||||
where TValue : struct
|
||||
{
|
||||
public string Units { get ; set; }
|
||||
public TValue? Value { get; set; }
|
||||
public TValue Lower { get; set; }
|
||||
public TValue Upper { get; set; }
|
||||
}
|
||||
|
||||
public struct BasisSet
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public struct Geometry : IHasUnits
|
||||
{
|
||||
public string Units { get ; set; }
|
||||
public string CoordinateSystem { get; set; }
|
||||
|
||||
public string Symmetry { get; set; }
|
||||
|
||||
public List<Dictionary<string, object>> Atoms { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents an electronic structure problem.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This type is agnostic with respect to serialization formats, and is a proper subset of
|
||||
/// all currently supported formats such that all current serialization formats should correctly
|
||||
/// serialize and deserialize to this type.
|
||||
///
|
||||
/// Fields and properties that can be missing are explicitly marked as nullable.
|
||||
/// </remarks>
|
||||
public class ElectronicStructureProblem : IHasMetadata
|
||||
{
|
||||
#region Metadata
|
||||
|
||||
/// <summary>
|
||||
/// Represents any additional metadata about this electronic structure problem.
|
||||
/// </summary>
|
||||
public Dictionary<string, object> Metadata { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
public Quantity<double> EnergyOffset { get; set; }
|
||||
public Quantity<double> CoulombRepulsion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The self-consistent field energy for this electronic structure problem.
|
||||
/// If no energy SCF is provided or known, may be <c>null</c>.
|
||||
/// </summary>
|
||||
public Quantity<double>? ScfEnergy { get; set; }
|
||||
public Quantity<double>? ScfEnergyOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full configuration interaction energy for this electronic structure problem.
|
||||
/// If the FCI energy is known only to be bounded with in an interval,
|
||||
/// the <see cref="BoundedQuantity{TValue}.Value" /> property may be <c>null</c>,
|
||||
/// while if not even a bound is known, this property itself may be <c>null</c>.
|
||||
/// </summary>
|
||||
public BoundedQuantity<double>? FciEnergy { get; set; }
|
||||
|
||||
public BasisSet? BasisSet { get; set; }
|
||||
|
||||
public int NOrbitals { get; set; }
|
||||
public int NElectrons { get; set; }
|
||||
|
||||
public Geometry? Geometry { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Hamiltonian represented by orbital integrals.
|
||||
/// </summary>
|
||||
public OrbitalIntegralHamiltonian OrbitalIntegralHamiltonian { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional collection of trial wavefunctions.
|
||||
/// </summary>
|
||||
public Dictionary<string, FermionWavefunction<SpinOrbital>>? InitialStates { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.Quantum.Chemistry.Tests.CSharp" + SigningConstants.PUBLIC_KEY)]
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -20,6 +20,10 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
/// <summary>
|
||||
/// Latest Broombridge format.
|
||||
/// </summary>
|
||||
[Obsolete(
|
||||
"Please use collections of ElectronicStructureProblem instead.",
|
||||
error: false
|
||||
)]
|
||||
public class Data
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -71,6 +75,10 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
/// <summary>
|
||||
/// Electronic structure problem instance.
|
||||
/// </summary>
|
||||
[Obsolete(
|
||||
"Please use ElectronicStructureProblem instead.",
|
||||
error: false
|
||||
)]
|
||||
public struct ProblemDescription
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -112,55 +120,8 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
NElectrons = problem.NElectrons,
|
||||
NOrbitals = problem.NOrbitals,
|
||||
OrbitalIntegralHamiltonian = V0_2.ToOrbitalIntegralHamiltonian(problem),
|
||||
Wavefunctions = new Dictionary<string, FermionWavefunction<SpinOrbital>>()
|
||||
Wavefunctions = problem.InitialStates?.FromBroombridgeV0_2() ?? 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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -14,14 +16,120 @@ using YamlDotNet.Serialization;
|
|||
using Microsoft.Quantum.Chemistry.OrbitalIntegrals;
|
||||
using Microsoft.Quantum.Chemistry.LadderOperators;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.OrbitalIntegrals.IndexConventionConversions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Broombridge
|
||||
{
|
||||
|
||||
internal static class BroombridgeExtensionsV0_1
|
||||
{
|
||||
|
||||
internal static Broombridge.V0_1.SimpleQuantity ToBroombridgeV0_1(this Quantity<double> quantity) =>
|
||||
new Broombridge.V0_1.SimpleQuantity
|
||||
{
|
||||
Units = quantity.Units,
|
||||
Value = quantity.Value
|
||||
};
|
||||
|
||||
internal static Broombridge.V0_1.BoundedQuantity ToBroombridgeV0_1(this BoundedQuantity<double> quantity) =>
|
||||
new Broombridge.V0_1.BoundedQuantity
|
||||
{
|
||||
Units = quantity.Units,
|
||||
Value = quantity.Value,
|
||||
Lower = quantity.Lower,
|
||||
Upper = quantity.Upper
|
||||
};
|
||||
|
||||
internal static Quantity<double> FromBroombridgeV0_1(this Broombridge.V0_1.SimpleQuantity quantity) =>
|
||||
new Quantity<double>
|
||||
{
|
||||
Units = quantity.Units,
|
||||
Value = quantity.Value
|
||||
};
|
||||
|
||||
internal static BoundedQuantity<double> FromBroombridgeV0_1(this Broombridge.V0_1.BoundedQuantity quantity) =>
|
||||
new BoundedQuantity<double>
|
||||
{
|
||||
Units = quantity.Units,
|
||||
Value = quantity.Value,
|
||||
Lower = quantity.Lower,
|
||||
Upper = quantity.Upper
|
||||
};
|
||||
|
||||
internal static BasisSet FromBroombridgeV0_1(this Broombridge.V0_1.BasisSet basisSet) =>
|
||||
new BasisSet
|
||||
{
|
||||
Name = basisSet.Name,
|
||||
Type = basisSet.Type
|
||||
};
|
||||
|
||||
|
||||
|
||||
internal static Geometry FromBroombridgeV0_1(this Broombridge.V0_1.Geometry geometry) =>
|
||||
new Geometry
|
||||
{
|
||||
Atoms = geometry.Atoms,
|
||||
CoordinateSystem = geometry.CoordinateSystem,
|
||||
Symmetry = geometry.Symmetry,
|
||||
Units = geometry.Units
|
||||
};
|
||||
|
||||
internal static V0_1.Geometry ToBroombridgeV0_1(this Geometry geometry) =>
|
||||
new V0_1.Geometry
|
||||
{
|
||||
Atoms = geometry.Atoms,
|
||||
CoordinateSystem = geometry.CoordinateSystem,
|
||||
Symmetry = geometry.Symmetry,
|
||||
Units = geometry.Units
|
||||
};
|
||||
|
||||
internal static V0_1.ArrayQuantity<long, double> ToBroombridgeV0_1(
|
||||
this Dictionary<OrbitalIntegrals.OrbitalIntegral, DoubleCoeff> terms
|
||||
) =>
|
||||
new V0_1.ArrayQuantity<long, double>()
|
||||
{
|
||||
Format = "sparse",
|
||||
Units = "hartree",
|
||||
Values = terms.Select(term => (
|
||||
ConvertIndices(
|
||||
term
|
||||
.Key
|
||||
.ToCanonicalForm()
|
||||
.OrbitalIndices,
|
||||
OrbitalIntegral.Convention.Dirac,
|
||||
OrbitalIntegral.Convention.Mulliken
|
||||
)
|
||||
.ToOneBasedIndices()
|
||||
.Select(idx => (long)idx)
|
||||
.ToArray(),
|
||||
term.Value.Value
|
||||
)).ToList()
|
||||
};
|
||||
|
||||
internal static V0_1.HamiltonianData ToBroombridgeV0_1(this OrbitalIntegralHamiltonian hamiltonian) =>
|
||||
new V0_1.HamiltonianData
|
||||
{
|
||||
OneElectronIntegrals = hamiltonian
|
||||
.Terms[TermType.OrbitalIntegral.OneBody]
|
||||
.ToBroombridgeV0_1(),
|
||||
TwoElectronIntegrals = hamiltonian
|
||||
.Terms[TermType.OrbitalIntegral.TwoBody]
|
||||
.ToBroombridgeV0_1()
|
||||
};
|
||||
|
||||
internal static V0_1.IntegralSet ToBroombridgeV0_1(this ElectronicStructureProblem problem) =>
|
||||
throw new NotImplementedException("Not yet implemented.");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge v0.1 format
|
||||
/// </summary>
|
||||
#region Broombridge v0.1 format
|
||||
public static class V0_1
|
||||
{
|
||||
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.1.schema.json";
|
||||
|
||||
public struct Data
|
||||
{
|
||||
|
||||
|
@ -51,7 +159,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
public Dictionary<string, object> Metadata { get; set; }
|
||||
|
||||
[YamlMember(Alias = "basis_set", ApplyNamingConventions = false)]
|
||||
public BasisSet BasisSet { get; set; }
|
||||
public BasisSet? BasisSet { get; set; }
|
||||
|
||||
[YamlMember(Alias = "geometry", ApplyNamingConventions = false)]
|
||||
public Geometry Geometry { get; set; }
|
||||
|
@ -80,10 +188,6 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
[YamlMember(Alias = "hamiltonian", ApplyNamingConventions = false)]
|
||||
public HamiltonianData Hamiltonian { get; set; }
|
||||
|
||||
// FIXME: actually specify what initial_state_suggestions looks like.
|
||||
//[YamlMember(Alias = "initial_state_suggestions", ApplyNamingConventions = false)]
|
||||
//public List<Dictionary<string, object>> InitialStateSuggestions { get; set; }
|
||||
|
||||
[YamlMember(Alias = "initial_state_suggestions", ApplyNamingConventions = false)]
|
||||
public List<SuggestedState> SuggestedState { get; set; }
|
||||
}
|
||||
|
@ -141,19 +245,12 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
Value = dict[kind];
|
||||
|
||||
switch (kind.ToLowerInvariant())
|
||||
Kind = kind.ToLowerInvariant() switch
|
||||
{
|
||||
case "arxiv":
|
||||
Kind = BibliographyKind.arXiv;
|
||||
break;
|
||||
case "doi":
|
||||
Kind = BibliographyKind.DOI;
|
||||
break;
|
||||
default:
|
||||
Kind = BibliographyKind.URL;
|
||||
break;
|
||||
|
||||
}
|
||||
"arxiv" => BibliographyKind.arXiv,
|
||||
"doi" => BibliographyKind.DOI,
|
||||
_ => BibliographyKind.URL
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -170,7 +267,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
}
|
||||
}
|
||||
|
||||
public struct BasisSet
|
||||
public class BasisSet
|
||||
{
|
||||
[YamlMember(Alias = "type", ApplyNamingConventions = false)]
|
||||
public string Type { get; set; }
|
||||
|
@ -181,7 +278,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
public class HasUnits
|
||||
{
|
||||
[YamlMember(Alias = "units", ApplyNamingConventions = false)]
|
||||
[YamlMember(Alias = "units", ApplyNamingConventions = false, DefaultValuesHandling = DefaultValuesHandling.Preserve)]
|
||||
// FIXME: make this an enum of allowed units.
|
||||
public string Units { get; set; }
|
||||
}
|
||||
|
@ -204,7 +301,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
[YamlMember(Alias = "particle_hole_representation", ApplyNamingConventions = false)]
|
||||
// TODO: Placeholder object for ParticleHoleRepresentation, which we do not
|
||||
// yet support.
|
||||
public ArrayQuantity<object, object> ParticleHoleRepresentation { get; set; }
|
||||
public ArrayQuantity<object, object>? ParticleHoleRepresentation { get; set; }
|
||||
|
||||
[YamlMember(Alias = "one_electron_integrals", ApplyNamingConventions = false)]
|
||||
public ArrayQuantity<long, double> OneElectronIntegrals { get; set; }
|
||||
|
@ -216,7 +313,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
public class SimpleQuantity : HasUnits
|
||||
{
|
||||
[YamlMember(Alias = "value", ApplyNamingConventions = false)]
|
||||
[YamlMember(Alias = "value", ApplyNamingConventions = false, SerializeAs = typeof(double))]
|
||||
public double Value { get; set; }
|
||||
}
|
||||
|
||||
|
@ -319,4 +416,4 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -31,6 +33,127 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
using HamiltonianData = V0_1.HamiltonianData;
|
||||
using BoundedQuantity = V0_1.BoundedQuantity;
|
||||
|
||||
internal static class BroombridgeExtensionsV0_2
|
||||
{
|
||||
// NB: V0_2 and V0_1 use the same format for quantities.
|
||||
internal static Broombridge.V0_1.SimpleQuantity ToBroombridgeV0_2(this Quantity<double> quantity) =>
|
||||
quantity.ToBroombridgeV0_1();
|
||||
|
||||
internal static Broombridge.V0_1.BoundedQuantity ToBroombridgeV0_2(this BoundedQuantity<double> quantity) =>
|
||||
quantity.ToBroombridgeV0_1();
|
||||
|
||||
// NB: Broombridge v0.2 uses the same serialization format
|
||||
// for Geometry as 0.1.
|
||||
internal static V0_1.Geometry ToBroombridgeV0_2(
|
||||
this Microsoft.Quantum.Chemistry.Geometry geometry
|
||||
) =>
|
||||
geometry.ToBroombridgeV0_1();
|
||||
|
||||
internal static V0_2.ProblemDescription ToBroombridgeV0_2(
|
||||
this ElectronicStructureProblem problem
|
||||
) => new V0_2.ProblemDescription
|
||||
{
|
||||
BasisSet = problem.BasisSet != null
|
||||
? new V0_1.BasisSet
|
||||
{
|
||||
Name = problem.BasisSet?.Name,
|
||||
Type = problem.BasisSet?.Type
|
||||
}
|
||||
: null,
|
||||
CoulombRepulsion = problem.CoulombRepulsion.ToBroombridgeV0_2(),
|
||||
EnergyOffset = problem.EnergyOffset.ToBroombridgeV0_2(),
|
||||
FciEnergy = problem.FciEnergy?.ToBroombridgeV0_2(),
|
||||
Geometry = problem.Geometry?.ToBroombridgeV0_2(),
|
||||
Hamiltonian = problem.OrbitalIntegralHamiltonian.ToBroombridgeV0_1(),
|
||||
InitialStates = problem.InitialStates?.ToBroombridgeV0_2(),
|
||||
Metadata = problem.Metadata,
|
||||
NElectrons = problem.NElectrons,
|
||||
NOrbitals = problem.NOrbitals,
|
||||
ScfEnergy = problem.ScfEnergy?.ToBroombridgeV0_2(),
|
||||
ScfEnergyOffset = problem.ScfEnergyOffset?.ToBroombridgeV0_2()
|
||||
};
|
||||
|
||||
internal static List<V0_2.State> ToBroombridgeV0_2(
|
||||
this Dictionary<string, FermionWavefunction<SpinOrbital>> states
|
||||
) =>
|
||||
states
|
||||
.Select(state => new V0_2.State
|
||||
{
|
||||
Label = state.Key,
|
||||
Energy = new SimpleQuantity
|
||||
{
|
||||
Value = state.Value.Energy,
|
||||
Units = "hartree" // FIXME
|
||||
},
|
||||
Method = state.Value.Method switch
|
||||
{
|
||||
StateType.SingleConfigurational => V0_2.UpdaterStrings.SingleConfigurational,
|
||||
StateType.SparseMultiConfigurational => V0_2.UpdaterStrings.SparseMultiConfigurational,
|
||||
StateType.UnitaryCoupledCluster => V0_2.UpdaterStrings.UnitaryCoupledCluster,
|
||||
_ => "default"
|
||||
}
|
||||
// FIXME: add Superposition and ClusterOperator.
|
||||
})
|
||||
.ToList();
|
||||
|
||||
internal static Dictionary<string, Fermion.FermionWavefunction<OrbitalIntegrals.SpinOrbital>>
|
||||
FromBroombridgeV0_2(
|
||||
this IEnumerable<V0_2.State> initialStates
|
||||
)
|
||||
{
|
||||
var wavefunctions = new Dictionary<string, Fermion.FermionWavefunction<OrbitalIntegrals.SpinOrbital>>();
|
||||
foreach (var initialState in initialStates ?? new List<V0_2.State>())
|
||||
{
|
||||
|
||||
var (method, energy, outputState) = V0_2.ToWavefunction(initialState);
|
||||
var finalState = new FermionWavefunction<SpinOrbital>()
|
||||
{
|
||||
Energy = energy
|
||||
};
|
||||
|
||||
var setMethod = V0_2.ParseInitialStateMethod(initialState.Method);
|
||||
|
||||
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;
|
||||
|
||||
wavefunctions.Add(initialState.Label, finalState);
|
||||
}
|
||||
return wavefunctions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge v0.2 format.
|
||||
|
@ -44,14 +167,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
#region Broombridge v0.2 format
|
||||
public static class V0_2
|
||||
{
|
||||
// Lower-case invariant dictionary key comparer.
|
||||
private static Dictionary<string, StateType> StateTypeDictionary = new Dictionary<string, StateType>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "single_configurational", StateType.SingleConfigurational },
|
||||
{ "sparse_multi_configurational", StateType.SparseMultiConfigurational },
|
||||
{ "unitary_coupled_cluster", StateType.UnitaryCoupledCluster }
|
||||
};
|
||||
|
||||
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json";
|
||||
internal static class UpdaterStrings
|
||||
{
|
||||
public const string SingleConfigurational = "single_configurational";
|
||||
|
@ -60,9 +176,21 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
public const string VersionNumber = "0.2";
|
||||
}
|
||||
|
||||
// Lower-case invariant dictionary key comparer.
|
||||
private static Dictionary<string, StateType> StateTypeDictionary = new Dictionary<string, StateType>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[UpdaterStrings.SingleConfigurational] = StateType.SingleConfigurational,
|
||||
[UpdaterStrings.SparseMultiConfigurational] = StateType.SparseMultiConfigurational,
|
||||
[UpdaterStrings.UnitaryCoupledCluster] = StateType.UnitaryCoupledCluster
|
||||
};
|
||||
|
||||
// Root of Broombridge data structure
|
||||
public struct Data
|
||||
{
|
||||
public static readonly Format DefaultFormat = new Broombridge.V0_1.Format
|
||||
{
|
||||
Version = "0.2"
|
||||
};
|
||||
|
||||
[YamlMember(Alias = "$schema", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "$schema")]
|
||||
|
@ -94,11 +222,11 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
[YamlMember(Alias = "basis_set", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "basis_set")]
|
||||
public BasisSet BasisSet { get; set; }
|
||||
public BasisSet? BasisSet { get; set; }
|
||||
|
||||
[YamlMember(Alias = "geometry", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "geometry")]
|
||||
public Geometry Geometry { get; set; }
|
||||
public Geometry? Geometry { get; set; }
|
||||
|
||||
[YamlMember(Alias = "coulomb_repulsion", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "coulomb_repulsion")]
|
||||
|
@ -106,15 +234,15 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
[YamlMember(Alias = "scf_energy", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "scf_energy")]
|
||||
public SimpleQuantity ScfEnergy { get; set; }
|
||||
public SimpleQuantity? ScfEnergy { get; set; }
|
||||
|
||||
[YamlMember(Alias = "scf_energy_offset", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "scf_energy_offset")]
|
||||
public SimpleQuantity ScfEnergyOffset { get; set; }
|
||||
public SimpleQuantity? ScfEnergyOffset { get; set; }
|
||||
|
||||
[YamlMember(Alias = "fci_energy", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "fci_energy")]
|
||||
public BoundedQuantity FciEnergy { get; set; }
|
||||
public BoundedQuantity? FciEnergy { get; set; }
|
||||
|
||||
[YamlMember(Alias = "n_orbitals", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "n_orbitals")]
|
||||
|
@ -134,7 +262,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
|
||||
[YamlMember(Alias = "initial_state_suggestions", ApplyNamingConventions = false)]
|
||||
[JsonProperty(PropertyName = "initial_state_suggestions")]
|
||||
public List<State> InitialStates { get; set; }
|
||||
public List<State>? InitialStates { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,7 +332,9 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
/// <param name="state">String in method field.</param>
|
||||
/// <returns>The initial state preparation algorithm described by the given method.</returns>
|
||||
internal static StateType ParseInitialStateMethod(string state) =>
|
||||
StateTypeDictionary.ContainsKey(state) ? StateTypeDictionary[state] : StateType.Default;
|
||||
StateTypeDictionary.ContainsKey(state)
|
||||
? StateTypeDictionary[state]
|
||||
: StateType.Default;
|
||||
|
||||
|
||||
// Parses MCF wavefunction.
|
||||
|
@ -278,7 +408,7 @@ namespace Microsoft.Quantum.Chemistry.Broombridge
|
|||
internal static (StateType, double, object) ToWavefunction(V0_2.State state)
|
||||
{
|
||||
StateType method = ParseInitialStateMethod(state.Method);
|
||||
double energy = state.Energy != null ? state.Energy.Value : 0.0;
|
||||
var energy = state.Energy?.Value ?? 0.0;
|
||||
List<List<string>> superposition = state.Superposition ?? new List<List<string>>();
|
||||
ClusterOperator clusterOperator = state.ClusterOperator;
|
||||
object outputState;
|
|
@ -0,0 +1,270 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Core.Events;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Broombridge
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerable item for Broombridge version numbers.
|
||||
/// </summary>
|
||||
public enum VersionNumber
|
||||
{
|
||||
NotRecognized = -1, v0_1 = 0, v0_2 = 1
|
||||
}
|
||||
|
||||
public static class BroombridgeSerializer
|
||||
{
|
||||
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()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static void Serialize(TextWriter writer, IEnumerable<ElectronicStructureProblem> problems)
|
||||
{
|
||||
Serializers.SerializeBroombridgev0_2(
|
||||
new Broombridge.V0_2.Data
|
||||
{
|
||||
// TODO: fix additional properties by converting IEnumerable<ESP> to
|
||||
// new problem collection class.
|
||||
Bibliography = null,
|
||||
Format = new V0_1.Format
|
||||
{
|
||||
Version = "0.2"
|
||||
},
|
||||
Generator = new V0_1.Generator
|
||||
{
|
||||
Source = "qdk-chem",
|
||||
Version = typeof(BroombridgeSerializer).Assembly.GetName().Version.ToString()
|
||||
},
|
||||
Schema = V0_2.SchemaUrl,
|
||||
ProblemDescriptions = problems
|
||||
.Select(
|
||||
problem => problem.ToBroombridgeV0_2()
|
||||
)
|
||||
.ToList()
|
||||
},
|
||||
writer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge deserializers
|
||||
/// </summary>
|
||||
[Obsolete(
|
||||
"Please use BroombridgeSerializer instead.",
|
||||
false
|
||||
)]
|
||||
public static class Deserializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Dictionary from version number strings to version number types.
|
||||
/// </summary>
|
||||
internal static Dictionary<string, VersionNumber> VersionNumberDict = new Dictionary<string, VersionNumber>()
|
||||
{
|
||||
// https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
|
||||
["0.1"] = VersionNumber.v0_1,
|
||||
["broombridge-0.1.schema"] = VersionNumber.v0_1,
|
||||
// TODO: URL of 0.2 schema.
|
||||
["0.2"] = VersionNumber.v0_2,
|
||||
["broombridge-0.2.schema"] = VersionNumber.v0_2
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns version number of a Broombridge file.
|
||||
/// </summary>
|
||||
/// <param name="filename">Path to a Broombridge file.</param>
|
||||
/// <returns>Version number of Broombridge file</returns>
|
||||
public static VersionNumber GetVersionNumber(string filename)
|
||||
{
|
||||
using var reader = File.OpenText(filename);
|
||||
return GetVersionNumber(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns version number of a Broombridge file.
|
||||
/// </summary>
|
||||
/// <param name="reader">Stream for reading Broombridge data.</param>
|
||||
/// <returns>Version number of Broombridge file</returns>
|
||||
public static VersionNumber GetVersionNumber(TextReader reader)
|
||||
{
|
||||
var deserializer = new DeserializerBuilder().Build();
|
||||
var data = deserializer.Deserialize<Dictionary<string, object>>(reader);
|
||||
var schema = data["$schema"] as string;
|
||||
VersionNumber versionNumber = VersionNumber.NotRecognized;
|
||||
if(schema != null)
|
||||
{
|
||||
foreach (var kv in VersionNumberDict)
|
||||
{
|
||||
if (schema.Contains(kv.Key))
|
||||
{
|
||||
versionNumber = kv.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns Broombridge deserialized into the current version data structure.
|
||||
/// Data structure is automatically updated to the current Broombridge version.
|
||||
/// </summary>
|
||||
/// <param name="reader">Stream for reading Broombridge data.</param>
|
||||
/// <returns>Deserializer Broombridge data structure.</returns>
|
||||
public static Data DeserializeBroombridge(TextReader reader)
|
||||
{
|
||||
// We'll need the stream twice: once to get the version of
|
||||
// Broombridge used to serialize the data,
|
||||
// and again to actually deserialize once we know the right
|
||||
// version. Since we can't actually duplicate the stream,
|
||||
// we'll read into memory first, then use a string reader
|
||||
// in both cases.
|
||||
var rawData = reader.ReadToEnd();
|
||||
var versionNumber = GetVersionNumber(new StringReader(rawData));
|
||||
var stringReader = new StringReader(rawData);
|
||||
return new Data(
|
||||
versionNumber switch
|
||||
{
|
||||
VersionNumber.v0_1 => DataStructures.Update(
|
||||
Deserialize<V0_1.Data>(stringReader)
|
||||
),
|
||||
VersionNumber.v0_2 => Deserialize<V0_2.Data>(stringReader),
|
||||
_ => throw new System.InvalidOperationException(
|
||||
"Unrecognized Broombridge version number."
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Broombridge deserialized into the current version data structure.
|
||||
/// Data structure is automatically updated to the current Broombridge version.
|
||||
/// </summary>
|
||||
/// <param name="filename">Path to a Broombridge file.</param>
|
||||
/// <returns>Deserializer Broombridge data structure.</returns>
|
||||
public static Data DeserializeBroombridge(string filename)
|
||||
{
|
||||
using var reader = File.OpenText(filename);
|
||||
return DeserializeBroombridge(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generic deserializer from a file into a data structure of type `TData`.
|
||||
/// </summary>
|
||||
/// <typeparam name="TData">Type of data to be deserialized.</typeparam>
|
||||
/// <param name="reader">Stream for reading Broombridge data.</param>
|
||||
/// <returns></returns>
|
||||
public static TData Deserialize<TData>(TextReader reader) =>
|
||||
new DeserializerBuilder()
|
||||
.Build()
|
||||
.Deserialize<TData>(reader);
|
||||
|
||||
/// <summary>
|
||||
/// Generic deserializer from a file into a data structure of type `TData`.
|
||||
/// </summary>
|
||||
/// <typeparam name="TData">Type of data to be deserialized.</typeparam>
|
||||
/// <param name="filename">Path to data to be deserialized.</param>
|
||||
/// <returns></returns>
|
||||
public static TData Deserialize<TData>(string filename)
|
||||
{
|
||||
using var reader = File.OpenText(filename);
|
||||
return Deserialize<TData>(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broombridge serializers
|
||||
/// </summary>
|
||||
public static class Serializers
|
||||
{
|
||||
/// <summary>
|
||||
/// Broombridge serializer
|
||||
/// </summary>
|
||||
/// <param name="filename">Broombridge filename to serialize</param>
|
||||
/// <returns>Serialized Broombridge</returns>
|
||||
internal static void SerializeBroombridgev0_2(V0_2.Data data, string filename)
|
||||
{
|
||||
using var writer = new StreamWriter(File.OpenWrite(filename));
|
||||
var stringBuilder = new StringBuilder();
|
||||
var serializer = new Serializer();
|
||||
stringBuilder.AppendLine(serializer.Serialize(data));
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// Broombridge serializer
|
||||
/// </summary>
|
||||
/// <param name="filename">Broombridge filename to serialize</param>
|
||||
/// <returns>Serialized Broombridge</returns>
|
||||
internal static void SerializeBroombridgev0_2(V0_2.Data data, TextWriter writer)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var serializer =
|
||||
new SerializerBuilder()
|
||||
.ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
|
||||
.WithTypeConverter(new DoubleYamlConverter())
|
||||
.Build();
|
||||
writer.WriteLine(serializer.Serialize(data));
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// YAML type converter used to ensure that the double value <c>0</c>
|
||||
/// in <c>"G17"</c> converts to <c>0.0</c> to help assist compatability
|
||||
/// with dynamically typed languages.
|
||||
/// </summary>
|
||||
internal class DoubleYamlConverter : IYamlTypeConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool Accepts(Type type) => type == typeof(double);
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ReadYaml(IParser parser, Type type) =>
|
||||
Double.TryParse(parser.Consume<Scalar>()?.Value, out var value)
|
||||
? value as object
|
||||
: null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void WriteYaml(IEmitter emitter, object value, Type type) =>
|
||||
emitter.Emit(new Scalar(
|
||||
null, null,
|
||||
((double)value) == 0
|
||||
? "0.0"
|
||||
: ((double)value).ToString("G17"),
|
||||
ScalarStyle.Any, true, false
|
||||
));
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ using YamlDotNet.Serialization;
|
|||
namespace Microsoft.Quantum.Chemistry.Broombridge
|
||||
{
|
||||
|
||||
public static partial class DataStructures
|
||||
internal static partial class DataStructures
|
||||
{
|
||||
|
||||
/// <summary>
|
|
@ -0,0 +1,11 @@
|
|||
# Broombridge Serialization Design
|
||||
|
||||
The C# files in this folder implement serialization and deserialization for Broombridge files, using the YamlDotNet package.
|
||||
In particular, the data model used for loading from and saving to YAML is implemented by the `BroombridgeDataStructuresv0.1.cs` and `BroombridgeDataStructuresv0.2.cs` files.
|
||||
These files define internal classes for use with YamlDotNet, and that then get converted into instances of the public `ElectronicStructureProblem` classes.
|
||||
For compatibility with earlier versions of Broombridge, these files include full data models for historical Broombridge versions; where newer versions have not modified data structures, data models for later versions may have properties whose types are associated with earlier versions.
|
||||
For instance, the `basis_set` property in Broombridge 0.2 is the same as it was in 0.1, such that the 0.2 `ProblemDescription` class has a `BasisSet` property whose type is `V0_1.BasisSet`.
|
||||
|
||||
> **NOTE**: These classes are designed for internal use only, but are marked as `public` to make them available to Python interoperability.
|
||||
|
||||
This separation prevents users from depending on the exact details of how electronic structure problems are represented in each version of Broombridge, focusing instead on the _logical_ structure of problems once deserialized.
|
|
@ -0,0 +1,160 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.Quantum.Simulation.Core;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.OrbitalIntegrals;
|
||||
using static Microsoft.Quantum.Chemistry.OrbitalIntegrals.IndexConventionConversions;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry
|
||||
{
|
||||
/// <summary>
|
||||
/// Serialization and deserialization support for FCIDUMP
|
||||
/// formatted problem descriptions.
|
||||
/// </summary>
|
||||
public static class FciDumpSerializer
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an FCIDUMP-formatted problem description.
|
||||
/// </summary>
|
||||
/// <param name="reader">A stream for reading FCIDUMP data.</param>
|
||||
/// <returns>
|
||||
/// An electronic structure problem deserialized from the file.
|
||||
/// </returns>
|
||||
public static IEnumerable<ElectronicStructureProblem> Deserialize(TextReader reader)
|
||||
{
|
||||
// FCIDUMP files begin with a FORTRAN-formatted namelist, delimited
|
||||
// by &FCI and &END. We start by extracting that namelist.
|
||||
var allText = reader.ReadToEnd();
|
||||
var lines = Regex.Split(allText, "\r\n|\r|\n");
|
||||
if (lines == null)
|
||||
{
|
||||
throw new IOException("Expected a non-empty FCIDUMP file.");
|
||||
}
|
||||
var header = System.String.Join("\n", lines.TakeWhile(line => line.Trim() != "&END")).Trim();
|
||||
var body = lines!.SkipWhile(line => line.Trim() != "&END").Skip(1).ToList();
|
||||
|
||||
// Make sure that the header starts with &FCI, as expected.
|
||||
if (!header.StartsWith("&FCI"))
|
||||
{
|
||||
throw new IOException("FCIDUMP file did not start with \"&FCI\" as expected.");
|
||||
}
|
||||
|
||||
// Split out the &FCI and &END lines, turn the rest into a dictionary of namelist items.
|
||||
var namelist = Regex.Matches(
|
||||
header
|
||||
.Replace("&FCI", "")
|
||||
.Replace("&END", ""),
|
||||
pattern: "\\s*(?<identifier>\\w+)\\s*=\\s*(?<value>[^=]+),\\s*"
|
||||
)
|
||||
.ToDictionary(
|
||||
match => match.Groups["identifier"].Value,
|
||||
match => match.Groups["value"].Value
|
||||
);
|
||||
|
||||
var hamiltonian = new OrbitalIntegralHamiltonian();
|
||||
var arrayData = body
|
||||
.Select(line => line.Trim())
|
||||
.Where(line => line.Length > 0)
|
||||
.Select(
|
||||
line => line.Split(" ", StringSplitOptions.RemoveEmptyEntries)
|
||||
)
|
||||
.Select(
|
||||
row => (
|
||||
Double.Parse(row[0]),
|
||||
row[1..].Select(Int32.Parse).Where(idx => idx != 0).ToZeroBasedIndices()
|
||||
)
|
||||
);
|
||||
var (coulomb, _) = arrayData.Where(item => item.Item2.Length == 0).Single();
|
||||
hamiltonian.Add(arrayData
|
||||
.Where(row => row.Item2.Length > 0)
|
||||
.SelectMaybe(
|
||||
row => row.Item2.Length % 2 == 0
|
||||
? new OrbitalIntegral(
|
||||
row.Item2, row.Item1, OrbitalIntegral.Convention.Mulliken
|
||||
).ToCanonicalForm()
|
||||
: null
|
||||
)
|
||||
.Distinct()
|
||||
);
|
||||
|
||||
// The identity term in deserialized Hamiltonians is the sum of the
|
||||
// Coloumb repulsion and the energy offset. Since only the former
|
||||
// exists in FCIDUMP, we set the identity term accordingly.
|
||||
hamiltonian.Add(new OrbitalIntegral(), coulomb);
|
||||
|
||||
return new List<ElectronicStructureProblem>
|
||||
{
|
||||
new ElectronicStructureProblem
|
||||
{
|
||||
EnergyOffset = 0.0.WithUnits("hartree"),
|
||||
CoulombRepulsion = coulomb.WithUnits("hartree"),
|
||||
Metadata = new Dictionary<string, object>
|
||||
{
|
||||
["Comment"] = "Imported from FCIDUMP"
|
||||
},
|
||||
NElectrons = Int32.Parse(namelist["NELEC"]),
|
||||
NOrbitals = Int32.Parse(namelist["NORB"]),
|
||||
OrbitalIntegralHamiltonian = hamiltonian
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void Serialize(TextWriter writer, IEnumerable<ElectronicStructureProblem> problems)
|
||||
{
|
||||
var problem = problems.Single();
|
||||
|
||||
// Start by writing the header.
|
||||
writer.WriteLine($"&FCI NORB={problem.NOrbitals},NELEC={problem.NElectrons},");
|
||||
// Assume global phase symmetry for now.
|
||||
writer.WriteLine($" ORBSYM={String.Join("", Enumerable.Range(0, problem.NOrbitals).Select(idx => "1,"))}");
|
||||
writer.WriteLine($" ISYM=1,");
|
||||
writer.WriteLine("&END");
|
||||
|
||||
(string, double) FormatTerm(KeyValuePair<OrbitalIntegral, DoubleCoeff> term) =>
|
||||
(
|
||||
String.Join(" ",
|
||||
ConvertIndices(
|
||||
term.Key.OrbitalIndices,
|
||||
OrbitalIntegral.Convention.Dirac,
|
||||
OrbitalIntegral.Convention.Mulliken
|
||||
)
|
||||
.ToOneBasedIndices()
|
||||
),
|
||||
term.Value
|
||||
);
|
||||
|
||||
foreach (var (indices, value) in problem
|
||||
.OrbitalIntegralHamiltonian
|
||||
.Terms[TermType.OrbitalIntegral.TwoBody]
|
||||
.Select(FormatTerm))
|
||||
{
|
||||
writer.WriteLine($"{value} {indices}");
|
||||
}
|
||||
// Next write out all one-body terms, using trailing zeros to indicate one-body.
|
||||
foreach (var (indices, value) in problem
|
||||
.OrbitalIntegralHamiltonian
|
||||
.Terms[TermType.OrbitalIntegral.OneBody]
|
||||
.Select(FormatTerm))
|
||||
{
|
||||
writer.WriteLine($"{value} {indices} 0 0");
|
||||
}
|
||||
// Finish by writing out the identity term.
|
||||
var identityTerm = problem
|
||||
.OrbitalIntegralHamiltonian
|
||||
.Terms.GetValueOrDefault(TermType.OrbitalIntegral.Identity, null)
|
||||
?.Select(term => term.Value.Value)
|
||||
?.SingleOrDefault() ?? 0.0
|
||||
+ problem.EnergyOffset.Value;
|
||||
writer.WriteLine($"{identityTerm} 0 0 0 0");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.Quantum.Simulation.Core;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -8,59 +10,30 @@ using System.Linq;
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.OrbitalIntegrals;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry
|
||||
{
|
||||
/// <summary>
|
||||
/// Methods for loading Hamiltonian data from standard formats
|
||||
/// into a <see cref="FermionHamiltonian"/>.
|
||||
/// </summary>
|
||||
public class LiQuiD
|
||||
{
|
||||
public struct ProblemDescription
|
||||
{
|
||||
public int NOrbitals { get; set; }
|
||||
public int NElectrons { get; set; }
|
||||
public double CoulombRepulsion { get; set; }
|
||||
public string MiscellaneousInformation { get; set; }
|
||||
public OrbitalIntegralHamiltonian OrbitalIntegralHamiltonian { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a Hamiltonian from integral data represented
|
||||
/// in LIQ𝑈𝑖|⟩ format.
|
||||
/// Please see the <a href="https://stationq.github.io/Liquid/docs/LIQUiD.pdf">
|
||||
/// LIQ𝑈𝑖|⟩ documentation</a> for further details about the
|
||||
/// format parsed by this method.
|
||||
/// </summary>
|
||||
/// <param name="filename">The name of the file to be loaded.</param>
|
||||
/// <returns>
|
||||
/// List of electronic structure problem deserialized from the file.
|
||||
/// </returns>
|
||||
public static IEnumerable<ProblemDescription> Deserialize(string filename)
|
||||
|
||||
public static class LiQuiDSerializer
|
||||
{
|
||||
public static IEnumerable<ElectronicStructureProblem> Deserialize(TextReader reader)
|
||||
{
|
||||
var name = filename;
|
||||
var allText = System.IO.File.ReadAllText(filename, System.Text.Encoding.ASCII);
|
||||
var allText = reader.ReadToEnd();
|
||||
string[] delimiters = { "tst" };
|
||||
var lines = allText.Split(delimiters, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
var hamiltonians = lines.Select(o => DeserializeSingle(o));
|
||||
var hamiltonians = lines.Select(DeserializeSingleProblem);
|
||||
return hamiltonians;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a Hamiltonian from integral data represented
|
||||
/// in LIQ𝑈𝑖|⟩ format.
|
||||
/// Please see the <a href="https://stationq.github.io/Liquid/docs/LIQUiD.pdf">
|
||||
/// LIQ𝑈𝑖|⟩ documentation</a> for further details about the
|
||||
/// format parsed by this method.
|
||||
/// </summary>
|
||||
/// <param name="lines">Sequence of text describing terms of Hamiltonian.</param>
|
||||
/// <returns>
|
||||
/// Single electronic structure problem deserialized from the file.
|
||||
/// </returns>
|
||||
public static ProblemDescription DeserializeSingle(string line)
|
||||
internal static ElectronicStructureProblem DeserializeSingleProblem(string line)
|
||||
{
|
||||
var problem = new LiQuiD.ProblemDescription();
|
||||
var problem = new ElectronicStructureProblem()
|
||||
{
|
||||
Metadata = new Dictionary<string, object>()
|
||||
};
|
||||
|
||||
var regexMiscellaneous = new Regex(@"((info=(?<info>[^\s]*)))");
|
||||
var regexnuc = new Regex(@"nuc=(?<nuc>-?\s*\d*.\d*)");
|
||||
|
@ -77,7 +50,7 @@ namespace Microsoft.Quantum.Chemistry
|
|||
Match stringMisc = regexMiscellaneous.Match(line);
|
||||
if (stringMisc.Success)
|
||||
{
|
||||
problem.MiscellaneousInformation = stringMisc.Groups["info"].ToString();
|
||||
problem.Metadata["misc_info"] = stringMisc.Groups["info"].ToString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,10 +152,65 @@ namespace Microsoft.Quantum.Chemistry
|
|||
|
||||
problem.OrbitalIntegralHamiltonian = hamiltonian;
|
||||
problem.NOrbitals = System.Convert.ToInt32 ( nOrbitals);
|
||||
problem.CoulombRepulsion = coulombRepulsion;
|
||||
problem.CoulombRepulsion = coulombRepulsion.WithUnits("hartree");
|
||||
|
||||
return problem;
|
||||
}
|
||||
|
||||
public static void Serialize(TextWriter writer, IEnumerable<ElectronicStructureProblem> problems)
|
||||
{
|
||||
throw new NotImplementedException("Serialization to LiQuiD is not yet implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Methods for loading Hamiltonian data from standard formats
|
||||
/// into a <see cref="FermionHamiltonian"/>.
|
||||
/// </summary>
|
||||
[Obsolete(
|
||||
"Please use LiQuiDSerializer instead.",
|
||||
false
|
||||
)]
|
||||
|
||||
public class LiQuiD
|
||||
{
|
||||
public struct ProblemDescription
|
||||
{
|
||||
public int NOrbitals { get; set; }
|
||||
public int NElectrons { get; set; }
|
||||
public double CoulombRepulsion { get; set; }
|
||||
public string MiscellaneousInformation { get; set; }
|
||||
public OrbitalIntegralHamiltonian OrbitalIntegralHamiltonian { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a Hamiltonian from integral data represented
|
||||
/// in LIQ𝑈𝑖|⟩ format.
|
||||
/// Please see the <a href="https://stationq.github.io/Liquid/docs/LIQUiD.pdf">
|
||||
/// LIQ𝑈𝑖|⟩ documentation</a> for further details about the
|
||||
/// format parsed by this method.
|
||||
/// </summary>
|
||||
/// <param name="filename">The name of the file to be loaded.</param>
|
||||
/// <returns>
|
||||
/// List of electronic structure problem deserialized from the file.
|
||||
/// </returns>
|
||||
public static IEnumerable<ProblemDescription> Deserialize(string filename)
|
||||
{
|
||||
var name = filename;
|
||||
using var reader = File.OpenText(filename);
|
||||
return LiQuiDSerializer
|
||||
.Deserialize(reader)
|
||||
.Select(problem => new ProblemDescription
|
||||
{
|
||||
CoulombRepulsion = problem.CoulombRepulsion.Value,
|
||||
MiscellaneousInformation = problem.Metadata.GetValueOrDefault("misc_info", "").ToString(),
|
||||
NElectrons = problem.NElectrons,
|
||||
NOrbitals = problem.NOrbitals,
|
||||
OrbitalIntegralHamiltonian = problem.OrbitalIntegralHamiltonian
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry
|
||||
{
|
||||
public enum SerializationFormat
|
||||
{
|
||||
Broombridge,
|
||||
LiQuiD,
|
||||
FciDump
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
|
@ -16,7 +16,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2005.1133-beta" />
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.403" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
using Broombridge = Microsoft.Quantum.Chemistry.Broombridge;
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tools
|
||||
{
|
||||
|
||||
public static class Convert
|
||||
{
|
||||
public static Command CreateCommand() =>
|
||||
new Command("convert")
|
||||
{
|
||||
new Argument<FileInfo>(
|
||||
"path",
|
||||
"Input data to be loaded, or - to load from stdin."
|
||||
),
|
||||
new Option<SerializationFormat>(
|
||||
"--from",
|
||||
"Format to use in loading problem description data."
|
||||
),
|
||||
new Option<SerializationFormat>(
|
||||
"--to",
|
||||
"Format to use in writing problem description data."
|
||||
),
|
||||
new Option<FileInfo?>(
|
||||
"--out",
|
||||
"Path to write output to. Data will be written to stdout by default."
|
||||
)
|
||||
}
|
||||
.WithDescription(
|
||||
"Converts between various problem description formats. " +
|
||||
"Note that not all data is supported by all formats, such that data may be lost " +
|
||||
"when converting to formats other than Broombridge."
|
||||
)
|
||||
.WithHandler<FileInfo, SerializationFormat, SerializationFormat, FileInfo?>(
|
||||
(path, from, to, @out) =>
|
||||
{
|
||||
using var reader =
|
||||
path.Name == "-"
|
||||
? System.Console.In
|
||||
: File.OpenText(path.FullName);
|
||||
using var writer =
|
||||
@out == null
|
||||
? System.Console.Out
|
||||
: new StreamWriter(File.OpenWrite(@out.FullName));
|
||||
ConvertProblemDescription(reader, from, writer, to);
|
||||
}
|
||||
);
|
||||
|
||||
public static void ConvertProblemDescription(
|
||||
TextReader reader, SerializationFormat from,
|
||||
TextWriter writer, SerializationFormat to
|
||||
)
|
||||
{
|
||||
// Our strategy will be to load whatever our source data is into an
|
||||
// in-memory instance of Broombridge, then re-export that to
|
||||
// the destination format.
|
||||
// In doing so, we'll use the latest version of Broombridge
|
||||
// to represent data between loading and saving.
|
||||
var data = Load(reader, from);
|
||||
Save(data, writer, to);
|
||||
}
|
||||
|
||||
internal static IEnumerable<ElectronicStructureProblem> Load(TextReader reader, SerializationFormat from) =>
|
||||
(from switch
|
||||
{
|
||||
SerializationFormat.Broombridge =>
|
||||
BroombridgeSerializer.Deserialize(reader),
|
||||
SerializationFormat.LiQuiD =>
|
||||
LiQuiDSerializer.Deserialize(reader),
|
||||
SerializationFormat.FciDump =>
|
||||
FciDumpSerializer.Deserialize(reader),
|
||||
_ => throw new ArgumentException($"Invalid format {from}.")
|
||||
})
|
||||
.ToList();
|
||||
|
||||
internal static void Save(IEnumerable<ElectronicStructureProblem> data, TextWriter writer, SerializationFormat to)
|
||||
{
|
||||
switch (to)
|
||||
{
|
||||
case SerializationFormat.Broombridge:
|
||||
// Check if the data has any nontrivial initial state suggestions, since
|
||||
// those are currently unsupported for export.
|
||||
if (data.Any(problem => (problem.InitialStates?.Count ?? 0) > 0))
|
||||
{
|
||||
Console.Error.WriteLine("[WARNING] Serialization of initial states is not currently supported.");
|
||||
}
|
||||
BroombridgeSerializer.Serialize(writer, data);
|
||||
return;
|
||||
case SerializationFormat.LiQuiD:
|
||||
throw new NotSupportedException("Not yet implemented.");
|
||||
return;
|
||||
case SerializationFormat.FciDump:
|
||||
FciDumpSerializer.Serialize(
|
||||
writer, data
|
||||
);
|
||||
return;
|
||||
default:
|
||||
throw new ArgumentException($"Invalid format {to}.");
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Broombridge = Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tools
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static Command WithHandler(this Command command, ICommandHandler handler)
|
||||
{
|
||||
command.Handler = handler;
|
||||
return command;
|
||||
}
|
||||
|
||||
public static Command WithHandler<T1>(this Command command, Action<T1> handler) =>
|
||||
command.WithHandler(CommandHandler.Create<T1>(handler));
|
||||
|
||||
public static Command WithHandler<T1, T2>(this Command command, Action<T1, T2> handler) =>
|
||||
command.WithHandler(CommandHandler.Create<T1, T2>(handler));
|
||||
|
||||
public static Command WithHandler<T1, T2, T3>(this Command command, Action<T1, T2, T3> handler) =>
|
||||
command.WithHandler(CommandHandler.Create<T1, T2, T3>(handler));
|
||||
|
||||
public static Command WithHandler<T1, T2, T3, T4>(this Command command, Action<T1, T2, T3, T4> handler) =>
|
||||
command.WithHandler(CommandHandler.Create<T1, T2, T3, T4>(handler));
|
||||
|
||||
public static Command WithHandler<T1, T2, T3, T4, T5>(this Command command, Action<T1, T2, T3, T4, T5> handler) =>
|
||||
command.WithHandler(CommandHandler.Create<T1, T2, T3, T4, T5>(handler));
|
||||
|
||||
public static Command WithDescription(this Command command, string description)
|
||||
{
|
||||
command.Description = description;
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
using Broombridge = Microsoft.Quantum.Chemistry.Broombridge;
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tools
|
||||
{
|
||||
|
||||
public static class Normalize
|
||||
{
|
||||
public static Command CreateCommand() =>
|
||||
new Command("normalize")
|
||||
{
|
||||
new Argument<FileInfo>(
|
||||
"path",
|
||||
"Input data to be loaded, or - to load from stdin."
|
||||
),
|
||||
new Option<SerializationFormat>(
|
||||
"--format",
|
||||
"Format to use in reading and writing problem description data."
|
||||
),
|
||||
new Option<FileInfo?>(
|
||||
"--out",
|
||||
"Path to write output to. Data will be written to stdout by default."
|
||||
)
|
||||
}
|
||||
.WithDescription(
|
||||
"Normalizes the problem description data in a given problem description file" +
|
||||
"by loading and then saving the data in a given format."
|
||||
)
|
||||
.WithHandler<FileInfo, SerializationFormat, FileInfo?>(
|
||||
(path, format, @out) =>
|
||||
{
|
||||
using var reader =
|
||||
path.Name == "-"
|
||||
? System.Console.In
|
||||
: File.OpenText(path.FullName);
|
||||
using var writer =
|
||||
@out == null
|
||||
? System.Console.Out
|
||||
: new StreamWriter(File.OpenWrite(@out.FullName));
|
||||
// Reuse logic from the convert command, but with the from
|
||||
// and to format as the same.
|
||||
Convert.ConvertProblemDescription(reader, format, writer, format);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tools
|
||||
{
|
||||
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static Command CreateRootCommand() =>
|
||||
new RootCommand
|
||||
{
|
||||
Convert.CreateCommand(),
|
||||
Normalize.CreateCommand()
|
||||
}
|
||||
.WithDescription("Tools for working with quantum chemistry data.");
|
||||
|
||||
public static async Task<int> Main(string[] args) =>
|
||||
await CreateRootCommand().InvokeAsync(args);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
# Quantum Development Kit Chemistry Command-Line Tools
|
||||
|
||||
This project provides command-line tools for working with quantum chemistry data and the Quantum Development Kit chemistry library.
|
||||
|
||||
## Installing the Quantum Development Kit Chemistry Tools
|
||||
|
||||
The Quantum Development Kit chemistry command-line tools are distributed as a .NET Core SDK Global Tool, and thus can be installed using the `dotnet` command:
|
||||
|
||||
```
|
||||
$ dotnet tool install --global Microsoft.Quantum.Chemistry.Tools
|
||||
```
|
||||
|
||||
> ⚠ NOTE: If you want to use a pre-release version of the Microsoft.Quantum.Chemistry.Tools package, you'll need to [configure the Quantum Development Kit prerelease feed](https://github.com/microsoft/QuantumLibraries#optional-using-prerelease-versions) before proceeding.
|
||||
> Once you have the prerelease feed configured, you can install the Microsoft.Quantum.Chemistry.Tools package by providing an explicit version:
|
||||
> ```
|
||||
> $ dotnet tool install --global Microsoft.Quantum.Chemistry.Tools --version "<version>"
|
||||
> ```
|
||||
> where `<version>` should be replaced by the specific prerelease version that you would like to install.
|
||||
|
||||
Once installed, you can run the Quantum Development Kit chemistry command-line tools with the `qdk-chem` command:
|
||||
|
||||
```
|
||||
$ qdk-chem convert --from fcidump --to broombridge lih.fcidump --out lih.yaml
|
||||
```
|
||||
|
||||
For help, use the `--help` option:
|
||||
|
||||
```
|
||||
$ qdk-chem --help
|
||||
$ qdk-chem convert --help
|
||||
```
|
||||
|
||||
## Building from Source
|
||||
|
||||
Instead of installing the tools, you can also run `qdk-chem` directly from this project using the .NET Core SDK:
|
||||
|
||||
```
|
||||
$ dotnet run -- convert --from fcidump --to broombridge lih.fcidump --out lih.yaml
|
||||
```
|
||||
|
||||
Note that the `--` argument is used to separate arguments recognized by the .NET Core SDK from the arguments to the `qdk-chem` tool.
|
||||
|
||||
## Converting Chemistry Data with `qdk-chem`
|
||||
|
||||
The `qdk-chem convert` subcommand can be used to convert between the various chemistry data formats supported by the Quantum Development Kit.
|
||||
|
||||
> We strongly recommend the use of [Broombridge](https://docs.microsoft.com/quantum/libraries/chemistry/schema/broombridge) to represent quantum chemistry problems, and provide `qdk-chem convert` to make it easier to work with and prepare Broombridge-formatted data.
|
||||
|
||||
The source and destination formats can be specified by the `--from` and `--to` options, respectively.
|
||||
By default, `qdk-chem` will write its output to the console; use the `--out` option to write directly to an output file.
|
||||
If you want to provide the source file to be converted using stdin, pass `-` as the name of the file to read from:
|
||||
|
||||
```
|
||||
$ echo lih.fcidump | qdk-chem convert --from fcidump --to broombridge - --out lih.yaml
|
||||
```
|
|
@ -0,0 +1,46 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>Microsoft.Quantum.Chemistry.Tools</RootNamespace>
|
||||
<AssemblyName>qdk-chem</AssemblyName>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>0162</NoWarn>
|
||||
<Authors>Microsoft</Authors>
|
||||
<Description>Tools for working with quantum chemistry data.</Description>
|
||||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<PackageReleaseNotes>See: https://docs.microsoft.com/quantum/relnotes/</PackageReleaseNotes>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/microsoft/quantumlibraries</PackageProjectUrl>
|
||||
<PackageIconUrl>https://secure.gravatar.com/avatar/bd1f02955b2853ba0a3b1cdc2434e8ec.png</PackageIconUrl>
|
||||
<PackageTags>Quantum Q# Qsharp</PackageTags>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>qdk-chem</ToolCommandName>
|
||||
<PackageId>Microsoft.Quantum.Chemistry.Tools</PackageId>
|
||||
<ContentTargetFolders>\</ContentTargetFolders>
|
||||
<ApplicationIcon />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Runtime\Runtime.csproj" />
|
||||
<ProjectReference Include="..\DataModel\DataModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0-dev-00039" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20253.1" />
|
||||
<PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.20253.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<Import Project="..\..\..\Build\props\tests.props" />
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>Microsoft.Quantum.Chemistry.Tests.CSharp</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -27,15 +28,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\BroombridgeExamples\broombridge_v0.1.yaml" Link="Broombridge\broombridge_v0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\BroombridgeExamples\broombridge_v0.2.yaml" Link="Broombridge\broombridge_v0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -46,4 +39,23 @@
|
|||
<ProjectReference Include="..\..\src\Runtime\Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\src\DataModel\DataModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Serialization test data -->
|
||||
<ItemGroup>
|
||||
<!-- Broombridge v0.1 and v0.2 examples -->
|
||||
<None Include="..\TestData\Broombridge\broombridge_v0.1.yaml" Link="Broombridge\broombridge_v0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\TestData\Broombridge\broombridge_v0.2.yaml" Link="Broombridge\broombridge_v0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\TestData\Broombridge\LiH_0.1.yaml" Link="Broombridge\LiH_0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
<!-- FCIDUMP examples -->
|
||||
<None Include="..\TestData\FciDump\h2_anorccmb.fcidump" Link="FciDump\h2_anorccmb.fcidump">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,125 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tests
|
||||
{
|
||||
internal static class Extensions
|
||||
{
|
||||
internal static void AssertThat(Action what) =>
|
||||
what();
|
||||
|
||||
internal static void AssertThat(IEnumerable<Action> whats)
|
||||
{
|
||||
var exceptions = new List<Exception>();
|
||||
foreach (var what in whats)
|
||||
{
|
||||
try
|
||||
{
|
||||
what();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (exceptions.Count == 1)
|
||||
{
|
||||
throw exceptions.Single();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AggregateException(exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
internal static Action HasUnits<T>(this Quantity<T> quantity, string units) =>
|
||||
() => Assert.Equal(quantity.Units, units);
|
||||
|
||||
internal static IEnumerable<Action> IsEqualTo(this ElectronicStructureProblem expected, ElectronicStructureProblem actual)
|
||||
{
|
||||
// NB: This does not yet check all metadata, as some metadata does not yet roundtrip
|
||||
// correctly. See https://github.com/microsoft/QuantumLibraries/issues/279 for an
|
||||
// example and for discussion.
|
||||
yield return () =>
|
||||
actual.CoulombRepulsion.Value.Should().Be(
|
||||
expected.CoulombRepulsion.Value,
|
||||
because: "Coulomb repulsion should match"
|
||||
);
|
||||
yield return () =>
|
||||
actual.EnergyOffset.Value.Should().Be(
|
||||
expected.EnergyOffset.Value,
|
||||
because: "energy offset should match"
|
||||
);
|
||||
yield return () =>
|
||||
actual.NElectrons.Should().Be(
|
||||
expected.NElectrons,
|
||||
because: "# of electrons should match"
|
||||
);
|
||||
yield return () =>
|
||||
actual.NOrbitals.Should().Be(
|
||||
expected.NOrbitals,
|
||||
because: "# of orbitals should match"
|
||||
);
|
||||
// yield return () =>
|
||||
// actual.OrbitalIntegralHamiltonian.Terms.Should().ContainKeys(
|
||||
// expected.OrbitalIntegralHamiltonian.Terms.Keys
|
||||
// ).And.HaveCount(
|
||||
// expected.OrbitalIntegralHamiltonian.Terms.Count,
|
||||
// because: "# of kinds of terms should match"
|
||||
// );
|
||||
|
||||
var onlyInActual =
|
||||
actual.OrbitalIntegralHamiltonian.Terms.Keys
|
||||
.Except(expected.OrbitalIntegralHamiltonian.Terms.Keys);
|
||||
|
||||
// Make sure that any keys that are only in the actual
|
||||
// problem are trivial.
|
||||
foreach (var termType in onlyInActual)
|
||||
{
|
||||
var term = actual.OrbitalIntegralHamiltonian.Terms[termType];
|
||||
// Make sure that any terms, if present, have coefficient zero.
|
||||
yield return () => term.Values.Should().OnlyContain(item => item.Value == 0.0);
|
||||
}
|
||||
|
||||
// Check the actual terms themselves.
|
||||
foreach (var termType in expected.OrbitalIntegralHamiltonian.Terms.Keys)
|
||||
{
|
||||
yield return () =>
|
||||
actual.OrbitalIntegralHamiltonian.Terms[termType].Count.Should().Be(
|
||||
expected.OrbitalIntegralHamiltonian.Terms[termType].Count,
|
||||
because: $"# of terms of type {termType} should match"
|
||||
);
|
||||
|
||||
// Now that we've checked that the count is correct, we can check
|
||||
// each individual term.
|
||||
foreach (var index in expected.OrbitalIntegralHamiltonian.Terms[termType])
|
||||
{
|
||||
yield return () =>
|
||||
actual.OrbitalIntegralHamiltonian.Terms[termType][index.Key].Should().Be(
|
||||
index.Value,
|
||||
$"term with index {index.Key} of type {termType} should match"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,8 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.Extensions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tests
|
||||
{
|
||||
public class ComparerTests
|
||||
|
@ -29,12 +31,12 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
[Fact]
|
||||
public void CompareIntArrayTest()
|
||||
{
|
||||
Assert.Equal(0, Extensions.CompareArray(new Int64[] { 1, 2, 3, 4 }, new Int64[] { 1, 2, 3, 4 }));
|
||||
Assert.Equal(1, Extensions.CompareArray(new Int64[] { 1, 2, 3, 4 }, new Int64[] { 1, 2, 3, 3 }));
|
||||
Assert.Equal(-1, Extensions.CompareArray(new Int64[] { 1, 2, 3, 3 }, new Int64[] { 1, 2, 3, 4 }));
|
||||
Assert.Equal(0, Extensions.CompareArray(new Int64[] { 2, 2, 2, 2 }, new Int64[] { 2, 2, 2, 2 }));
|
||||
Assert.Equal(1, Extensions.CompareArray(new Int64[] { 2, 2, 3, 4 }, new Int64[] { 1, 2, 10, 3 }));
|
||||
Assert.Equal(-1, Extensions.CompareArray(new Int64[] { 1, 3, 3, 3 }, new Int64[] { 10, 2, 3, 4 }));
|
||||
Assert.Equal(0, CompareArray(new Int64[] { 1, 2, 3, 4 }, new Int64[] { 1, 2, 3, 4 }));
|
||||
Assert.Equal(1, CompareArray(new Int64[] { 1, 2, 3, 4 }, new Int64[] { 1, 2, 3, 3 }));
|
||||
Assert.Equal(-1, CompareArray(new Int64[] { 1, 2, 3, 3 }, new Int64[] { 1, 2, 3, 4 }));
|
||||
Assert.Equal(0, CompareArray(new Int64[] { 2, 2, 2, 2 }, new Int64[] { 2, 2, 2, 2 }));
|
||||
Assert.Equal(1, CompareArray(new Int64[] { 2, 2, 3, 4 }, new Int64[] { 1, 2, 10, 3 }));
|
||||
Assert.Equal(-1, CompareArray(new Int64[] { 1, 3, 3, 3 }, new Int64[] { 10, 2, 3, 4 }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -48,4 +50,4 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -38,23 +40,37 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
}
|
||||
}
|
||||
|
||||
public class Broombridgev0_2Tests
|
||||
public class BroombridgeV0_2Fixture
|
||||
{
|
||||
static string filename = "Broombridge/broombridge_v0.2.yaml";
|
||||
static V0_2.Data broombridge = Deserializers.Deserialize<V0_2.Data>(filename);
|
||||
public string Filename = "Broombridge/broombridge_v0.2.yaml";
|
||||
internal V0_2.Data DeserializedData;
|
||||
|
||||
public BroombridgeV0_2Fixture()
|
||||
{
|
||||
DeserializedData = Deserializers.Deserialize<V0_2.Data>(Filename);
|
||||
}
|
||||
}
|
||||
|
||||
public class Broombridgev0_2Tests : IClassFixture<BroombridgeV0_2Fixture>
|
||||
{
|
||||
BroombridgeV0_2Fixture fixture;
|
||||
public Broombridgev0_2Tests(BroombridgeV0_2Fixture fixture)
|
||||
{
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Version()
|
||||
{
|
||||
Assert.Equal("0.2", broombridge.Format.Version);
|
||||
Assert.NotEqual("", broombridge.Format.Version);
|
||||
Assert.Equal("0.2", fixture.DeserializedData.Format.Version);
|
||||
Assert.NotEqual("", fixture.DeserializedData.Format.Version);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnitaryCoupledCluster()
|
||||
{
|
||||
var state = broombridge.ProblemDescriptions.Single().InitialStates.ElementAt(3);
|
||||
var state = fixture.DeserializedData.ProblemDescriptions.Single().InitialStates.ElementAt(3);
|
||||
|
||||
Assert.Equal("UCCSD |G>", state.Label);
|
||||
|
||||
|
@ -84,7 +100,7 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
[Fact]
|
||||
public void CheckNullUnitaryCoupledCluster()
|
||||
{
|
||||
var broombridge_internal = Deserializers.DeserializeBroombridge(filename).ProblemDescriptions.Single();
|
||||
var broombridge_internal = Deserializers.DeserializeBroombridge(fixture.Filename).ProblemDescriptions.Single();
|
||||
|
||||
Assert.Contains("UCCSD nullTwo", broombridge_internal.Wavefunctions.Keys);
|
||||
Assert.Contains("UCCSD nullOne", broombridge_internal.Wavefunctions.Keys);
|
||||
|
@ -97,7 +113,7 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
var broombridge_v0_1 = Deserializers.Deserialize<V0_1.Data>(filename);
|
||||
var broombridge_v0_2 = DataStructures.Update(broombridge_v0_1);
|
||||
|
||||
Broombridge.Serializers.SerializeBroombridgev0_2(broombridge_v0_2, "");
|
||||
Broombridge.Serializers.SerializeBroombridgev0_2(broombridge_v0_2, System.Console.Out);
|
||||
|
||||
}
|
||||
|
||||
|
@ -120,4 +136,4 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
Assert.Equal(original.Schema, serialized.Schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Xunit;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.Tests.Extensions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tests
|
||||
{
|
||||
public class FciDumpTests : IClassFixture<FciDumpDataFixture>
|
||||
{
|
||||
FciDumpDataFixture fixture;
|
||||
public FciDumpTests(FciDumpDataFixture fixture)
|
||||
{
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnergyOffsetIsZero()
|
||||
{
|
||||
Assert.Equal(fixture.problem.EnergyOffset.Value, 0.0);
|
||||
AssertThat(fixture.problem.EnergyOffset.HasUnits("hartree"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CoulombRepulsionIsCorrect()
|
||||
{
|
||||
Assert.Equal(fixture.problem.CoulombRepulsion.Value, 0.71510433906);
|
||||
AssertThat(fixture.problem.CoulombRepulsion.HasUnits("hartree"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NumberOfTermsIsCorrect()
|
||||
{
|
||||
Assert.Equal(fixture.problem.OrbitalIntegralHamiltonian.Terms[TermType.OrbitalIntegral.OneBody].Count, 2);
|
||||
Assert.Equal(fixture.problem.OrbitalIntegralHamiltonian.Terms[TermType.OrbitalIntegral.TwoBody].Count, 4);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Xunit;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.Tests.Extensions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tests
|
||||
{
|
||||
|
||||
public class IntegrationTests : IClassFixture<FciDumpDataFixture>
|
||||
{
|
||||
FciDumpDataFixture fixture;
|
||||
public IntegrationTests(FciDumpDataFixture fixture)
|
||||
{
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundtripFcidumpIsCorrect()
|
||||
{
|
||||
// Start by converting the Fcidump data deserialized
|
||||
// in the test fixture out to Broombridge.
|
||||
using var writer = new StringWriter();
|
||||
BroombridgeSerializer.Serialize(writer, new [] { fixture.problem });
|
||||
|
||||
// Now deserialize back from Broombridge.
|
||||
using var reader = new StringReader(writer.ToString());
|
||||
var roundtripData = BroombridgeSerializer.Deserialize(reader).Single();
|
||||
|
||||
// Next, check that the resulting problem is the same.
|
||||
AssertThat(fixture.problem.IsEqualTo(roundtripData));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,7 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
{
|
||||
//var test = terms.Item1;
|
||||
//string[] lines, FermionTermType termType, FermionTerm[] terms
|
||||
var hamiltonian = LiQuiD.DeserializeSingle(line).OrbitalIntegralHamiltonian;
|
||||
var hamiltonian = LiQuiDSerializer.DeserializeSingleProblem(line).OrbitalIntegralHamiltonian;
|
||||
Assert.True(hamiltonian.Terms.ContainsKey(termType));
|
||||
// Check that expected terms are found
|
||||
|
|
@ -15,6 +15,7 @@ using Microsoft.Quantum.Chemistry.LadderOperators;
|
|||
using Microsoft.Quantum.Chemistry;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace SerializationTests
|
||||
{
|
||||
|
@ -83,7 +84,7 @@ namespace SerializationTests
|
|||
}
|
||||
|
||||
// Lithium Hydride filename.
|
||||
static string filename = "LiH_0.1.yaml";
|
||||
static string filename = Path.Join("Broombridge", "LiH_0.1.yaml");
|
||||
|
||||
[Fact]
|
||||
public void SerializeEmptyHamiltonian()
|
|
@ -20,7 +20,9 @@ namespace Microsoft.Quantum.Chemistry.Tests
|
|||
{
|
||||
public FermionWavefunction<int> MakeWavefunction(string wavefunctionLabel = "UCCSD |G>")
|
||||
{
|
||||
var data = Broombridge.Deserializers.DeserializeBroombridge("broombridge_v0.2.yaml");
|
||||
var data = Broombridge.Deserializers.DeserializeBroombridge(
|
||||
Path.Join("Broombridge", "broombridge_v0.2.yaml"
|
||||
));
|
||||
return data.ProblemDescriptions.First().Wavefunctions[wavefunctionLabel].ToIndexing(IndexConvention.UpDown);
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Quantum.Chemistry.Broombridge;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Xunit;
|
||||
|
||||
using static Microsoft.Quantum.Chemistry.Tests.Extensions;
|
||||
|
||||
namespace Microsoft.Quantum.Chemistry.Tests
|
||||
{
|
||||
public class FciDumpDataFixture
|
||||
{
|
||||
public ElectronicStructureProblem problem;
|
||||
|
||||
public FciDumpDataFixture()
|
||||
{
|
||||
using var reader = File.OpenText(
|
||||
Path.Join(
|
||||
"FciDump", "h2_anorccmb.fcidump"
|
||||
)
|
||||
);
|
||||
problem = FciDumpSerializer.Deserialize(reader).Single();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\BroombridgeExamples\broombridge_v0.2.yaml" Link="broombridge_v0.2.yaml">
|
||||
<None Include="..\TestData\Broombridge\broombridge_v0.2.yaml" Link="broombridge_v0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\BroombridgeExamples\LiH_0.2.yaml" Link="Molecules\LiH_0.2.yaml">
|
||||
<None Include="..\TestData\Broombridge\LiH_0.2.yaml" Link="Molecules\LiH_0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\LiQuiDExamples\B_sto6g.dat" Link="Molecules\B_sto6g.dat">
|
||||
<None Include="..\TestData\LiQuiD\B_sto6g.dat" Link="Molecules\B_sto6g.dat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\BroombridgeExamples\broombridge_v0.2.yaml" Link="broombridge_v0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\BroombridgeExamples\LiH_0.1.yaml" Link="LiH_0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\DataModel\DataModel.csproj" />
|
||||
<ProjectReference Include="..\..\src\Runtime\Runtime.csproj" />
|
||||
<ProjectReference Include="..\DataModelTests\CSharpTests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<Import Project="..\..\..\Build\props\tests.props" />
|
||||
|
||||
|
@ -14,16 +14,16 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\BroombridgeExamples\hydrogen_0.1.yaml" Link="Molecules\MolecularHydrogen\hydrogen_0.1.yaml">
|
||||
<None Include="..\TestData\Broombridge\hydrogen_0.1.yaml" Link="Molecules\MolecularHydrogen\hydrogen_0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\BroombridgeExamples\hydrogen_0.2.yaml" Link="Molecules\MolecularHydrogen\hydrogen_0.2.yaml">
|
||||
<None Include="..\TestData\Broombridge\hydrogen_0.2.yaml" Link="Molecules\MolecularHydrogen\hydrogen_0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\BroombridgeExamples\LiH_0.1.yaml" Link="Molecules\LithiumHydride\LiH_0.1.yaml">
|
||||
<None Include="..\TestData\Broombridge\LiH_0.1.yaml" Link="Molecules\LithiumHydride\LiH_0.1.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\BroombridgeExamples\LiH_0.2.yaml" Link="Molecules\LithiumHydride\LiH_0.2.yaml">
|
||||
<None Include="..\TestData\Broombridge\LiH_0.2.yaml" Link="Molecules\LithiumHydride\LiH_0.2.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# © Microsoft
|
||||
# MIT license
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
# Generated by nwchem version v...
|
||||
"$schema": https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
|
||||
format: # required
|
||||
|
@ -247,4 +247,4 @@ integral_sets:
|
|||
label : "|F>"
|
||||
superposition:
|
||||
# ?
|
||||
- [1.0, "(6b)+","(2a)","|E>"]
|
||||
- [1.0, "(6b)+","(2a)","|E>"]
|
|
@ -1,5 +1,5 @@
|
|||
# © Microsoft
|
||||
# MIT license
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
# Generated by nwchem version v...
|
||||
"$schema": https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.2.schema.json
|
||||
format:
|
|
@ -0,0 +1,13 @@
|
|||
# FCIDUMP Examples #
|
||||
|
||||
Example FCIDUMP files to test the FCIDUMP-BroomBridge file converter.
|
||||
|
||||
## File Descriptions ##
|
||||
- **[ethylene_ccpvdz.fcidump](ethylene_ccpvdz.fcidump)**:
|
||||
Ethylene molecule in cc-pVDZ basis, 10 orbitals and 16 electrons.
|
||||
- **[h2o_ccpvdz.fcidump](h2o_ccpvdz.fcidump)**:
|
||||
Water molecule in cc-pVDZ basis, 9 orbitals and 10 electrons.
|
||||
- **[h2_anorccmb.fcidump](h2_anorccmb.fcidump)**:
|
||||
Hydrogen molecule in ANO-RCC minimal basis, 2 orbitals and 2 electrons.
|
||||
|
||||
All FCIDUMP files are generated from OpenMolcas, and are covered under MIT license.
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,461 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
# H2 molecule using 6-31G basis, containing 2 electrons 4 orbitals
|
||||
$schema: https://raw.githubusercontent.com/Microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json
|
||||
format:
|
||||
version: '0.2'
|
||||
problem_description:
|
||||
- coulomb_repulsion:
|
||||
units: hartree
|
||||
value: 0.26458860546
|
||||
energy_offset:
|
||||
units: hartree
|
||||
value: 0.0
|
||||
hamiltonian:
|
||||
one_electron_integrals:
|
||||
format: sparse
|
||||
units: hartree
|
||||
values:
|
||||
- - 1
|
||||
- 1
|
||||
- -0.8018330653330913
|
||||
- - 2
|
||||
- 2
|
||||
- -0.6808848190171333
|
||||
- - 3
|
||||
- 1
|
||||
- -0.07439133632145523
|
||||
- - 3
|
||||
- 2
|
||||
- -1.500133985855629e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 0.2029981654021328
|
||||
- - 4
|
||||
- 2
|
||||
- -0.1202291206839734
|
||||
- - 4
|
||||
- 3
|
||||
- 1.047618484027786e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 0.2650102486850815
|
||||
two_electron_integrals:
|
||||
format: sparse
|
||||
index_convention: mulliken
|
||||
units: hartree
|
||||
values:
|
||||
- - 1
|
||||
- 1
|
||||
- 1
|
||||
- 1
|
||||
- 0.4228062775109397
|
||||
- - 1
|
||||
- 1
|
||||
- 2
|
||||
- 2
|
||||
- 0.4105346883667327
|
||||
- - 1
|
||||
- 1
|
||||
- 3
|
||||
- 1
|
||||
- 0.0743913697375054
|
||||
- - 1
|
||||
- 1
|
||||
- 3
|
||||
- 2
|
||||
- 1.199377475849302e-15
|
||||
- - 1
|
||||
- 1
|
||||
- 3
|
||||
- 3
|
||||
- 0.4373591832451234
|
||||
- - 1
|
||||
- 1
|
||||
- 4
|
||||
- 2
|
||||
- 0.09313324623964918
|
||||
- - 1
|
||||
- 1
|
||||
- 4
|
||||
- 4
|
||||
- 0.4152149451059131
|
||||
- - 2
|
||||
- 1
|
||||
- 2
|
||||
- 1
|
||||
- 0.1637626609092841
|
||||
- - 2
|
||||
- 1
|
||||
- 3
|
||||
- 2
|
||||
- 0.08569005654145083
|
||||
- - 2
|
||||
- 1
|
||||
- 3
|
||||
- 3
|
||||
- 4.527088606898575e-15
|
||||
- - 2
|
||||
- 1
|
||||
- 4
|
||||
- 1
|
||||
- 0.06603737686743057
|
||||
- - 2
|
||||
- 1
|
||||
- 4
|
||||
- 2
|
||||
- -1.15100188191536e-15
|
||||
- - 2
|
||||
- 1
|
||||
- 4
|
||||
- 3
|
||||
- 0.1803152075799192
|
||||
- - 2
|
||||
- 1
|
||||
- 4
|
||||
- 4
|
||||
- -4.571338852757589e-15
|
||||
- - 2
|
||||
- 2
|
||||
- 1
|
||||
- 1
|
||||
- 0.4105346883667327
|
||||
- - 2
|
||||
- 2
|
||||
- 2
|
||||
- 2
|
||||
- 0.411293475922327
|
||||
- - 2
|
||||
- 2
|
||||
- 3
|
||||
- 1
|
||||
- 0.08342294821430508
|
||||
- - 2
|
||||
- 2
|
||||
- 3
|
||||
- 2
|
||||
- 1.085175988379264e-15
|
||||
- - 2
|
||||
- 2
|
||||
- 3
|
||||
- 3
|
||||
- 0.4327659784044743
|
||||
- - 2
|
||||
- 2
|
||||
- 4
|
||||
- 2
|
||||
- 0.09150097321188448
|
||||
- - 2
|
||||
- 2
|
||||
- 4
|
||||
- 4
|
||||
- 0.4174019952666657
|
||||
- - 3
|
||||
- 1
|
||||
- 1
|
||||
- 1
|
||||
- 0.07439136973750543
|
||||
- - 3
|
||||
- 1
|
||||
- 2
|
||||
- 2
|
||||
- 0.08342294821430513
|
||||
- - 3
|
||||
- 1
|
||||
- 3
|
||||
- 1
|
||||
- 0.07249511734007211
|
||||
- - 3
|
||||
- 1
|
||||
- 3
|
||||
- 2
|
||||
- 1.833283628009839e-15
|
||||
- - 3
|
||||
- 1
|
||||
- 3
|
||||
- 3
|
||||
- 0.1174300285896483
|
||||
- - 3
|
||||
- 1
|
||||
- 4
|
||||
- 2
|
||||
- 0.07166348670614635
|
||||
- - 3
|
||||
- 1
|
||||
- 4
|
||||
- 3
|
||||
- 1.367168151165445e-15
|
||||
- - 3
|
||||
- 1
|
||||
- 4
|
||||
- 4
|
||||
- 0.1129869387217845
|
||||
- - 3
|
||||
- 2
|
||||
- 1
|
||||
- 1
|
||||
- 1.214153487243656e-15
|
||||
- - 3
|
||||
- 2
|
||||
- 2
|
||||
- 1
|
||||
- 0.08569005654145084
|
||||
- - 3
|
||||
- 2
|
||||
- 2
|
||||
- 2
|
||||
- 1.084874403851883e-15
|
||||
- - 3
|
||||
- 2
|
||||
- 3
|
||||
- 1
|
||||
- 1.821057467691201e-15
|
||||
- - 3
|
||||
- 2
|
||||
- 3
|
||||
- 2
|
||||
- 0.08349523983329145
|
||||
- - 3
|
||||
- 2
|
||||
- 3
|
||||
- 3
|
||||
- 4.892381062176435e-15
|
||||
- - 3
|
||||
- 2
|
||||
- 4
|
||||
- 1
|
||||
- 0.0729648630579708
|
||||
- - 3
|
||||
- 2
|
||||
- 4
|
||||
- 3
|
||||
- 0.1239219982051575
|
||||
- - 3
|
||||
- 2
|
||||
- 4
|
||||
- 4
|
||||
- -1.537196050340819e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 1
|
||||
- 1
|
||||
- 0.4373591832451235
|
||||
- - 3
|
||||
- 3
|
||||
- 2
|
||||
- 1
|
||||
- 4.571490279268793e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 2
|
||||
- 2
|
||||
- 0.4327659784044742
|
||||
- - 3
|
||||
- 3
|
||||
- 3
|
||||
- 1
|
||||
- 0.1174300285896483
|
||||
- - 3
|
||||
- 3
|
||||
- 3
|
||||
- 2
|
||||
- 4.76904258940222e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 3
|
||||
- 3
|
||||
- 0.5012410512800376
|
||||
- - 3
|
||||
- 3
|
||||
- 4
|
||||
- 1
|
||||
- 1.246217853822323e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 4
|
||||
- 2
|
||||
- 0.134974881971873
|
||||
- - 3
|
||||
- 3
|
||||
- 4
|
||||
- 3
|
||||
- 5.538737367932461e-15
|
||||
- - 3
|
||||
- 3
|
||||
- 4
|
||||
- 4
|
||||
- 0.4768832880189133
|
||||
- - 4
|
||||
- 1
|
||||
- 2
|
||||
- 1
|
||||
- 0.0660373768674306
|
||||
- - 4
|
||||
- 1
|
||||
- 3
|
||||
- 2
|
||||
- 0.07296486305797081
|
||||
- - 4
|
||||
- 1
|
||||
- 3
|
||||
- 3
|
||||
- 1.216826075596107e-15
|
||||
- - 4
|
||||
- 1
|
||||
- 4
|
||||
- 1
|
||||
- 0.06642119431455176
|
||||
- - 4
|
||||
- 1
|
||||
- 4
|
||||
- 2
|
||||
- -1.810997396936309e-15
|
||||
- - 4
|
||||
- 1
|
||||
- 4
|
||||
- 3
|
||||
- 0.1016918983917669
|
||||
- - 4
|
||||
- 1
|
||||
- 4
|
||||
- 4
|
||||
- -3.892232419394906e-15
|
||||
- - 4
|
||||
- 2
|
||||
- 1
|
||||
- 1
|
||||
- 0.09313324623964919
|
||||
- - 4
|
||||
- 2
|
||||
- 2
|
||||
- 1
|
||||
- -1.122378661427826e-15
|
||||
- - 4
|
||||
- 2
|
||||
- 2
|
||||
- 2
|
||||
- 0.09150097321188454
|
||||
- - 4
|
||||
- 2
|
||||
- 3
|
||||
- 1
|
||||
- 0.07166348670614633
|
||||
- - 4
|
||||
- 2
|
||||
- 3
|
||||
- 3
|
||||
- 0.1349748819718728
|
||||
- - 4
|
||||
- 2
|
||||
- 4
|
||||
- 1
|
||||
- -1.80902543532016e-15
|
||||
- - 4
|
||||
- 2
|
||||
- 4
|
||||
- 2
|
||||
- 0.08076088234734272
|
||||
- - 4
|
||||
- 2
|
||||
- 4
|
||||
- 3
|
||||
- -1.767735174271869e-15
|
||||
- - 4
|
||||
- 2
|
||||
- 4
|
||||
- 4
|
||||
- 0.1227753412517658
|
||||
- - 4
|
||||
- 3
|
||||
- 2
|
||||
- 1
|
||||
- 0.1803152075799192
|
||||
- - 4
|
||||
- 3
|
||||
- 3
|
||||
- 1
|
||||
- 1.24972475147227e-15
|
||||
- - 4
|
||||
- 3
|
||||
- 3
|
||||
- 2
|
||||
- 0.1239219982051575
|
||||
- - 4
|
||||
- 3
|
||||
- 3
|
||||
- 3
|
||||
- 5.417037109493215e-15
|
||||
- - 4
|
||||
- 3
|
||||
- 4
|
||||
- 1
|
||||
- 0.101691898391767
|
||||
- - 4
|
||||
- 3
|
||||
- 4
|
||||
- 2
|
||||
- -1.858411340113457e-15
|
||||
- - 4
|
||||
- 3
|
||||
- 4
|
||||
- 3
|
||||
- 0.2379037613312699
|
||||
- - 4
|
||||
- 3
|
||||
- 4
|
||||
- 4
|
||||
- -6.317291645296597e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 1
|
||||
- 1
|
||||
- 0.4152149451059131
|
||||
- - 4
|
||||
- 4
|
||||
- 2
|
||||
- 1
|
||||
- -4.533320345338483e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 2
|
||||
- 2
|
||||
- 0.4174019952666655
|
||||
- - 4
|
||||
- 4
|
||||
- 3
|
||||
- 1
|
||||
- 0.1129869387217845
|
||||
- - 4
|
||||
- 4
|
||||
- 3
|
||||
- 2
|
||||
- -1.738402489080445e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 3
|
||||
- 3
|
||||
- 0.4768832880189133
|
||||
- - 4
|
||||
- 4
|
||||
- 4
|
||||
- 1
|
||||
- -3.961225479136159e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 4
|
||||
- 2
|
||||
- 0.1227753412517659
|
||||
- - 4
|
||||
- 4
|
||||
- 4
|
||||
- 3
|
||||
- -6.1280640324577e-15
|
||||
- - 4
|
||||
- 4
|
||||
- 4
|
||||
- 4
|
||||
- 0.4607393847909207
|
||||
metadata:
|
||||
molecule_name: h2_631g
|
||||
n_electrons: 2
|
||||
n_orbitals: 4
|
|
@ -0,0 +1,14 @@
|
|||
&FCI NORB= 2,NELEC= 2,MS2= 0,
|
||||
ORBSYM= 1, 1,
|
||||
ISYM=0
|
||||
&END
|
||||
0.60678308648 1 1 1 1
|
||||
0.15821110448 2 1 2 1
|
||||
0.60486756354 2 2 1 1
|
||||
0.64496763778 2 2 2 2
|
||||
-1.2207498577 1 1 0 0
|
||||
-0.52751160572 2 2 0 0
|
||||
0.0000000000 1 0 0 0
|
||||
0.0000000000 2 0 0 0
|
||||
0.71510433906 0 0 0 0
|
||||
|
|
@ -0,0 +1,430 @@
|
|||
&FCI NORB= 9,NELEC= 10,MS2= 0,
|
||||
ORBSYM= 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
ISYM=0
|
||||
&END
|
||||
4.7400019749 1 1 1 1
|
||||
-0.43178754325 2 1 1 1
|
||||
0.63915174574E-01 2 1 2 1
|
||||
1.0452023780 2 2 1 1
|
||||
-0.14376382085E-01 2 2 2 1
|
||||
0.75044870963 2 2 2 2
|
||||
0.18948044917E-01 3 1 3 1
|
||||
0.22799635801E-01 3 2 3 1
|
||||
0.15144621745 3 2 3 2
|
||||
0.86591287632 3 3 1 1
|
||||
-0.63327099573E-02 3 3 2 1
|
||||
0.67300727303 3 3 2 2
|
||||
0.65586240053 3 3 3 3
|
||||
0.13892414992 4 1 1 1
|
||||
-0.17081617489E-01 4 1 2 1
|
||||
0.14088793375E-01 4 1 2 2
|
||||
0.69798875427E-02 4 1 3 3
|
||||
0.29611074795E-01 4 1 4 1
|
||||
-0.93920501392E-01 4 2 1 1
|
||||
0.77017497905E-02 4 2 2 1
|
||||
0.13601143646E-01 4 2 2 2
|
||||
0.13895611119E-01 4 2 3 3
|
||||
0.22711271819E-01 4 2 4 1
|
||||
0.12676492938 4 2 4 2
|
||||
-0.29646418745E-02 4 3 3 1
|
||||
0.18512552735E-01 4 3 3 2
|
||||
0.40862547859E-01 4 3 4 3
|
||||
0.97694908824 4 4 1 1
|
||||
-0.12360062981E-01 4 4 2 1
|
||||
0.67772659272 4 4 2 2
|
||||
0.60020892430 4 4 3 3
|
||||
-0.92562949458E-02 4 4 4 1
|
||||
-0.70670802788E-01 4 4 4 2
|
||||
0.72115287356 4 4 4 4
|
||||
0.30203901200E-01 5 1 5 1
|
||||
0.30098560160E-01 5 2 5 1
|
||||
0.12951608802 5 2 5 2
|
||||
0.29819116047E-01 5 3 5 3
|
||||
-0.94610543192E-02 5 4 5 1
|
||||
-0.30784322823E-01 5 4 5 2
|
||||
0.42598603228E-01 5 4 5 4
|
||||
1.0391148433 5 5 1 1
|
||||
-0.11340594426E-01 5 5 2 1
|
||||
0.71354197515 5 5 2 2
|
||||
0.61768528962 5 5 3 3
|
||||
0.42644500770E-02 5 5 4 1
|
||||
-0.39369149663E-01 5 5 4 2
|
||||
0.66136462711 5 5 4 4
|
||||
0.76066713825 5 5 5 5
|
||||
0.14560454776 6 1 1 1
|
||||
-0.22959141146E-01 6 1 2 1
|
||||
0.18545423125E-02 6 1 2 2
|
||||
0.46796744925E-03 6 1 3 3
|
||||
-0.10537995626E-02 6 1 4 1
|
||||
-0.95753435431E-02 6 1 4 2
|
||||
0.74207272494E-02 6 1 4 4
|
||||
0.30209973121E-02 6 1 5 5
|
||||
0.10324013132E-01 6 1 6 1
|
||||
-0.20988392947 6 2 1 1
|
||||
0.45817145290E-02 6 2 2 1
|
||||
-0.10916344148 6 2 2 2
|
||||
-0.78004581421E-01 6 2 3 3
|
||||
-0.98971204673E-02 6 2 4 1
|
||||
-0.17740985585E-01 6 2 4 2
|
||||
-0.75929596615E-01 6 2 4 4
|
||||
-0.99126077378E-01 6 2 5 5
|
||||
0.93433534156E-03 6 2 6 1
|
||||
0.37230090831E-01 6 2 6 2
|
||||
-0.42744028569E-02 6 3 3 1
|
||||
0.15897247123E-02 6 3 3 2
|
||||
0.57272775544E-02 6 3 4 3
|
||||
0.19721061541E-01 6 3 6 3
|
||||
-0.11611179709 6 4 1 1
|
||||
0.74279404928E-03 6 4 2 1
|
||||
-0.62790033159E-01 6 4 2 2
|
||||
-0.39920585072E-01 6 4 3 3
|
||||
-0.37286617760E-02 6 4 4 1
|
||||
0.48164373710E-02 6 4 4 2
|
||||
-0.61595364181E-01 6 4 4 4
|
||||
-0.58480430575E-01 6 4 5 5
|
||||
0.84601948461E-03 6 4 6 1
|
||||
0.21212673614E-01 6 4 6 2
|
||||
0.21743311271E-01 6 4 6 4
|
||||
-0.78298701846E-02 6 5 5 1
|
||||
-0.22242242507E-01 6 5 5 2
|
||||
-0.98753914307E-03 6 5 5 4
|
||||
0.11539639833E-01 6 5 6 5
|
||||
0.41432513697 6 6 1 1
|
||||
-0.20105349424E-02 6 6 2 1
|
||||
0.36893806162 6 6 2 2
|
||||
0.35837790599 6 6 3 3
|
||||
0.67124995389E-02 6 6 4 1
|
||||
0.29864024671E-01 6 6 4 2
|
||||
0.34243263624 6 6 4 4
|
||||
0.34893628692 6 6 5 5
|
||||
-0.10860666686E-02 6 6 6 1
|
||||
-0.20302523498E-01 6 6 6 2
|
||||
-0.27149692451E-02 6 6 6 4
|
||||
0.30235831553 6 6 6 6
|
||||
0.10996407334E-01 7 1 3 1
|
||||
0.12898847020E-01 7 1 3 2
|
||||
-0.18811717957E-02 7 1 4 3
|
||||
-0.24363426183E-02 7 1 6 3
|
||||
0.63840003010E-02 7 1 7 1
|
||||
0.99861774222E-02 7 2 3 1
|
||||
0.40742533620E-01 7 2 3 2
|
||||
-0.81039851389E-02 7 2 4 3
|
||||
-0.10620706479E-01 7 2 6 3
|
||||
0.57066721343E-02 7 2 7 1
|
||||
0.19970206774E-01 7 2 7 2
|
||||
0.24881933161 7 3 1 1
|
||||
-0.42072255585E-02 7 3 2 1
|
||||
0.12720275303 7 3 2 2
|
||||
0.10687366584 7 3 3 3
|
||||
0.81648785602E-03 7 3 4 1
|
||||
-0.24299432565E-01 7 3 4 2
|
||||
0.11482066163 7 3 4 4
|
||||
0.12389882434 7 3 5 5
|
||||
0.13906023260E-02 7 3 6 1
|
||||
-0.32967236684E-01 7 3 6 2
|
||||
-0.23821750976E-01 7 3 6 4
|
||||
0.13471228665E-01 7 3 6 6
|
||||
0.52507435856E-01 7 3 7 3
|
||||
-0.39642380549E-02 7 4 3 1
|
||||
-0.25482214002E-01 7 4 3 2
|
||||
0.57979409352E-02 7 4 4 3
|
||||
-0.88158570212E-02 7 4 6 3
|
||||
-0.23136094852E-02 7 4 7 1
|
||||
-0.49516935133E-02 7 4 7 2
|
||||
0.13429148433E-01 7 4 7 4
|
||||
0.10830204353E-01 7 5 5 3
|
||||
0.61721474322E-02 7 5 7 5
|
||||
-0.48533721051E-02 7 6 3 1
|
||||
-0.50599732542E-01 7 6 3 2
|
||||
-0.18169012635E-01 7 6 4 3
|
||||
-0.24957111151E-01 7 6 6 3
|
||||
-0.26793779177E-02 7 6 7 1
|
||||
0.62343266339E-03 7 6 7 2
|
||||
0.19216274347E-01 7 6 7 4
|
||||
0.73731220282E-01 7 6 7 6
|
||||
0.40556427361 7 7 1 1
|
||||
-0.22128654928E-02 7 7 2 1
|
||||
0.34907631250 7 7 2 2
|
||||
0.35098155471 7 7 3 3
|
||||
0.17808636641E-02 7 7 4 1
|
||||
0.95774597961E-02 7 7 4 2
|
||||
0.33015042176 7 7 4 4
|
||||
0.33217695996 7 7 5 5
|
||||
0.37986371586E-03 7 7 6 1
|
||||
-0.14868465032E-01 7 7 6 2
|
||||
0.91504470444E-03 7 7 6 4
|
||||
0.29059242057 7 7 6 6
|
||||
0.14565526005E-01 7 7 7 3
|
||||
0.29707209271 7 7 7 7
|
||||
0.10414348730E-01 8 1 3 1
|
||||
0.11894841090E-01 8 1 3 2
|
||||
-0.24418618239E-02 8 1 4 3
|
||||
-0.21148386289E-02 8 1 6 3
|
||||
0.60529523455E-02 8 1 7 1
|
||||
0.53541163046E-02 8 1 7 2
|
||||
-0.24871258813E-02 8 1 7 4
|
||||
-0.24166639597E-02 8 1 7 6
|
||||
0.57706293117E-02 8 1 8 1
|
||||
0.74301048645E-02 8 2 3 1
|
||||
0.50863306599E-02 8 2 3 2
|
||||
-0.33834862500E-01 8 2 4 3
|
||||
-0.10517107287E-01 8 2 6 3
|
||||
0.43396341148E-02 8 2 7 1
|
||||
0.16377332929E-01 8 2 7 2
|
||||
-0.43594394018E-02 8 2 7 4
|
||||
0.93053979876E-02 8 2 7 6
|
||||
0.43510397374E-02 8 2 8 1
|
||||
0.38233868425E-01 8 2 8 2
|
||||
0.16764121992 8 3 1 1
|
||||
-0.49226177301E-02 8 3 2 1
|
||||
0.35237004364E-01 8 3 2 2
|
||||
0.12220303115E-01 8 3 3 3
|
||||
-0.49527925526E-02 8 3 4 1
|
||||
-0.71023399836E-01 8 3 4 2
|
||||
0.56045229346E-01 8 3 4 4
|
||||
0.66071727728E-01 8 3 5 5
|
||||
0.32939403869E-02 8 3 6 1
|
||||
-0.15545260438E-01 8 3 6 2
|
||||
-0.21149512926E-01 8 3 6 4
|
||||
-0.16919886043E-01 8 3 6 6
|
||||
0.42540226214E-01 8 3 7 3
|
||||
-0.64481847814E-02 8 3 7 7
|
||||
0.88956157127E-01 8 3 8 3
|
||||
-0.86620670398E-02 8 4 3 1
|
||||
-0.75451262551E-01 8 4 3 2
|
||||
-0.78175154475E-02 8 4 4 3
|
||||
-0.13170882337E-01 8 4 6 3
|
||||
-0.49483382608E-02 8 4 7 1
|
||||
-0.14125689694E-01 8 4 7 2
|
||||
0.22468344655E-01 8 4 7 4
|
||||
0.32274934577E-01 8 4 7 6
|
||||
-0.48919995635E-02 8 4 8 1
|
||||
0.64266276094E-02 8 4 8 2
|
||||
0.58048251424E-01 8 4 8 4
|
||||
0.11993940436E-01 8 5 5 3
|
||||
0.59621396975E-02 8 5 7 5
|
||||
0.90857641992E-02 8 5 8 5
|
||||
-0.17277226297E-02 8 6 3 1
|
||||
-0.10379882805E-01 8 6 3 2
|
||||
-0.98674472550E-02 8 6 4 3
|
||||
0.10032337715E-03 8 6 6 3
|
||||
-0.96866431553E-03 8 6 7 1
|
||||
-0.25248201788E-03 8 6 7 2
|
||||
0.16048458467E-02 8 6 7 4
|
||||
-0.23711461459E-02 8 6 7 6
|
||||
-0.83417690852E-03 8 6 8 1
|
||||
0.10914406754E-01 8 6 8 2
|
||||
0.88222171242E-02 8 6 8 4
|
||||
0.14456574144E-01 8 6 8 6
|
||||
0.16593393783 8 7 1 1
|
||||
-0.24742776161E-02 8 7 2 1
|
||||
0.10415420266 8 7 2 2
|
||||
0.99053946096E-01 8 7 3 3
|
||||
-0.58315302931E-03 8 7 4 1
|
||||
-0.85356143121E-02 8 7 4 2
|
||||
0.10090556620 8 7 4 4
|
||||
0.96205186898E-01 8 7 5 5
|
||||
0.11311409478E-02 8 7 6 1
|
||||
-0.14976205026E-01 8 7 6 2
|
||||
-0.74214710334E-02 8 7 6 4
|
||||
0.31636296802E-01 8 7 6 6
|
||||
0.25327440747E-01 8 7 7 3
|
||||
0.29069608008E-01 8 7 7 7
|
||||
0.40081689442E-02 8 7 8 3
|
||||
0.30800246317E-01 8 7 8 7
|
||||
0.55324873085 8 8 1 1
|
||||
-0.20371790860E-02 8 8 2 1
|
||||
0.50448589547 8 8 2 2
|
||||
0.51252412615 8 8 3 3
|
||||
0.14984384781E-02 8 8 4 1
|
||||
0.26017981066E-01 8 8 4 2
|
||||
0.47632424958 8 8 4 4
|
||||
0.45736085660 8 8 5 5
|
||||
0.37627570775E-03 8 8 6 1
|
||||
-0.29261711906E-01 8 8 6 2
|
||||
-0.92778659407E-02 8 8 6 4
|
||||
0.33258102439 8 8 6 6
|
||||
0.39984516794E-01 8 8 7 3
|
||||
0.32373863472 8 8 7 7
|
||||
-0.48689057319E-01 8 8 8 3
|
||||
0.75564570211E-01 8 8 8 7
|
||||
0.48718212309 8 8 8 8
|
||||
0.12794192339 9 1 1 1
|
||||
-0.20900819163E-01 9 1 2 1
|
||||
-0.50948773644E-03 9 1 2 2
|
||||
-0.12458610246E-03 9 1 3 3
|
||||
-0.68291408156E-02 9 1 4 1
|
||||
-0.14078292128E-01 9 1 4 2
|
||||
0.95513606317E-02 9 1 4 4
|
||||
0.19141005176E-02 9 1 5 5
|
||||
0.11077479285E-01 9 1 6 1
|
||||
0.28004149365E-02 9 1 6 2
|
||||
0.15654102699E-02 9 1 6 4
|
||||
-0.23222637589E-02 9 1 6 6
|
||||
0.15552201783E-02 9 1 7 3
|
||||
0.25184648242E-03 9 1 7 7
|
||||
0.44658719183E-02 9 1 8 3
|
||||
0.14397950701E-02 9 1 8 7
|
||||
0.43005515374E-03 9 1 8 8
|
||||
0.13023431352E-01 9 1 9 1
|
||||
-0.16798042546 9 2 1 1
|
||||
0.38582651953E-02 9 2 2 1
|
||||
-0.69112114979E-01 9 2 2 2
|
||||
-0.21916995452E-01 9 2 3 3
|
||||
-0.11767864566E-01 9 2 4 1
|
||||
-0.15212323697E-01 9 2 4 2
|
||||
-0.42724661129E-01 9 2 4 4
|
||||
-0.77914032716E-01 9 2 5 5
|
||||
0.18024983123E-02 9 2 6 1
|
||||
0.34806618469E-01 9 2 6 2
|
||||
0.21845150834E-01 9 2 6 4
|
||||
-0.10348256854E-01 9 2 6 6
|
||||
-0.24822400224E-01 9 2 7 3
|
||||
-0.27114461346E-03 9 2 7 7
|
||||
-0.30596479622E-01 9 2 8 3
|
||||
-0.22410871039E-02 9 2 8 7
|
||||
0.20148004635E-01 9 2 8 8
|
||||
0.42180343963E-02 9 2 9 1
|
||||
0.51635203311E-01 9 2 9 2
|
||||
0.74971214903E-03 9 3 3 1
|
||||
0.58694401634E-01 9 3 3 2
|
||||
0.24717869568E-01 9 3 4 3
|
||||
0.25001336112E-01 9 3 6 3
|
||||
0.37965997933E-03 9 3 7 1
|
||||
-0.12825853529E-02 9 3 7 2
|
||||
-0.17428116858E-01 9 3 7 4
|
||||
-0.37695444694E-01 9 3 7 6
|
||||
0.48347964728E-03 9 3 8 1
|
||||
-0.27591081150E-01 9 3 8 2
|
||||
-0.49141502060E-01 9 3 8 4
|
||||
-0.14043142695E-01 9 3 8 6
|
||||
0.72670365036E-01 9 3 9 3
|
||||
-0.16652104581 9 4 1 1
|
||||
0.29935037669E-02 9 4 2 1
|
||||
-0.64814609522E-01 9 4 2 2
|
||||
-0.27729223858E-01 9 4 3 3
|
||||
-0.30893936666E-02 9 4 4 1
|
||||
0.10413331567E-01 9 4 4 2
|
||||
-0.69269183070E-01 9 4 4 4
|
||||
-0.65100011923E-01 9 4 5 5
|
||||
-0.22914949011E-03 9 4 6 1
|
||||
0.26413315645E-01 9 4 6 2
|
||||
0.21721291764E-01 9 4 6 4
|
||||
-0.67149881600E-02 9 4 6 6
|
||||
-0.28329343412E-01 9 4 7 3
|
||||
-0.19054875350E-02 9 4 7 7
|
||||
-0.39023580012E-01 9 4 8 3
|
||||
-0.53606173361E-02 9 4 8 7
|
||||
0.14976879849E-01 9 4 8 8
|
||||
0.33399854895E-03 9 4 9 1
|
||||
0.37177513487E-01 9 4 9 2
|
||||
0.39175212224E-01 9 4 9 4
|
||||
-0.10913894327E-01 9 5 5 1
|
||||
-0.45209593128E-01 9 5 5 2
|
||||
0.23626509143E-02 9 5 5 4
|
||||
0.10809419527E-01 9 5 6 5
|
||||
0.21951654819E-01 9 5 9 5
|
||||
0.17424098705 9 6 1 1
|
||||
-0.24093494176E-02 9 6 2 1
|
||||
0.11392616527 9 6 2 2
|
||||
0.10350183161 9 6 3 3
|
||||
0.68404134301E-02 9 6 4 1
|
||||
0.20171475002E-01 9 6 4 2
|
||||
0.90544702180E-01 9 6 4 4
|
||||
0.96569808692E-01 9 6 5 5
|
||||
-0.97962218306E-03 9 6 6 1
|
||||
-0.23263329568E-01 9 6 6 2
|
||||
-0.12024574838E-01 9 6 6 4
|
||||
0.37407219091E-01 9 6 6 6
|
||||
0.17902393987E-01 9 6 7 3
|
||||
0.35050972539E-01 9 6 7 7
|
||||
-0.11650297121E-01 9 6 8 3
|
||||
0.25465344839E-01 9 6 8 7
|
||||
0.80324259695E-01 9 6 8 8
|
||||
-0.22603003291E-02 9 6 9 1
|
||||
-0.86382453028E-02 9 6 9 2
|
||||
-0.48997166176E-02 9 6 9 4
|
||||
0.39392174145E-01 9 6 9 6
|
||||
-0.19226540590E-02 9 7 3 1
|
||||
-0.16834747369E-01 9 7 3 2
|
||||
-0.11515391228E-01 9 7 4 3
|
||||
-0.36797552753E-02 9 7 6 3
|
||||
-0.10540459511E-02 9 7 7 1
|
||||
-0.31540117430E-03 9 7 7 2
|
||||
0.24773945866E-02 9 7 7 4
|
||||
0.52154671272E-02 9 7 7 6
|
||||
-0.83054153238E-03 9 7 8 1
|
||||
0.97422199205E-02 9 7 8 2
|
||||
0.11720158456E-01 9 7 8 4
|
||||
0.10924705983E-01 9 7 8 6
|
||||
-0.18016682708E-01 9 7 9 3
|
||||
0.13291021450E-01 9 7 9 7
|
||||
-0.44154879743E-02 9 8 3 1
|
||||
-0.81981094856E-01 9 8 3 2
|
||||
-0.45877323035E-01 9 8 4 3
|
||||
-0.30455849900E-01 9 8 6 3
|
||||
-0.23770488006E-02 9 8 7 1
|
||||
0.20605390266E-02 9 8 7 2
|
||||
0.20745007423E-01 9 8 7 4
|
||||
0.62928961977E-01 9 8 7 6
|
||||
-0.19805870184E-02 9 8 8 1
|
||||
0.43611020831E-01 9 8 8 2
|
||||
0.65113441170E-01 9 8 8 4
|
||||
0.21345601798E-01 9 8 8 6
|
||||
-0.89509284131E-01 9 8 9 3
|
||||
0.27193116958E-01 9 8 9 7
|
||||
0.13413575077 9 8 9 8
|
||||
0.57833790333 9 9 1 1
|
||||
-0.25755750376E-02 9 9 2 1
|
||||
0.51476175814 9 9 2 2
|
||||
0.51612775326 9 9 3 3
|
||||
0.11175347418E-01 9 9 4 1
|
||||
0.63368884046E-01 9 9 4 2
|
||||
0.45735029621 9 9 4 4
|
||||
0.46118091564 9 9 5 5
|
||||
-0.21407676725E-02 9 9 6 1
|
||||
-0.39275928750E-01 9 9 6 2
|
||||
-0.95043968446E-02 9 9 6 4
|
||||
0.34752275405 9 9 6 6
|
||||
0.30106529093E-01 9 9 7 3
|
||||
0.33110737388 9 9 7 7
|
||||
-0.68966979402E-01 9 9 8 3
|
||||
0.72158025701E-01 9 9 8 7
|
||||
0.48438534625 9 9 8 8
|
||||
-0.41300956940E-02 9 9 9 1
|
||||
0.10481817475E-01 9 9 9 2
|
||||
0.13881428959E-01 9 9 9 4
|
||||
0.95233828604E-01 9 9 9 6
|
||||
0.52166630727 9 9 9 9
|
||||
-33.005594824 1 1 0 0
|
||||
0.58184013034 2 1 0 0
|
||||
-7.8245650168 2 2 0 0
|
||||
-6.6171813434 3 3 0 0
|
||||
-0.18505807824 4 1 0 0
|
||||
0.26650429509 4 2 0 0
|
||||
-6.8766855802 4 4 0 0
|
||||
-7.0837148768 5 5 0 0
|
||||
-0.18238422934 6 1 0 0
|
||||
0.99625661008 6 2 0 0
|
||||
0.60214600322 6 4 0 0
|
||||
-3.3833273707 6 6 0 0
|
||||
-1.2679896365 7 3 0 0
|
||||
-3.1842134503 7 7 0 0
|
||||
-0.64253347384 8 3 0 0
|
||||
-1.0391046627 8 7 0 0
|
||||
-4.0324229443 8 8 0 0
|
||||
-0.15899999486 9 1 0 0
|
||||
0.69318170748 9 2 0 0
|
||||
0.72263800813 9 4 0 0
|
||||
-1.0541508722 9 6 0 0
|
||||
-4.0211605734 9 9 0 0
|
||||
0.0000000000 1 0 0 0
|
||||
0.0000000000 2 0 0 0
|
||||
0.0000000000 3 0 0 0
|
||||
0.0000000000 4 0 0 0
|
||||
0.0000000000 5 0 0 0
|
||||
0.0000000000 6 0 0 0
|
||||
0.0000000000 7 0 0 0
|
||||
0.0000000000 8 0 0 0
|
||||
0.0000000000 9 0 0 0
|
||||
9.0067748021 0 0 0 0
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<AssemblyName>Microsoft.Quantum.MachineLearning</AssemblyName>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<Import Project="..\..\Build\props\tests.props" />
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2005.1133-beta" />
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.403" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<Import Project="..\..\Build\props\tests.props" />
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
|
@ -30,7 +30,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2005.1133-beta" />
|
||||
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.403" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2005.1133-beta">
|
||||
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.403">
|
||||
|
||||
<Import Project="..\..\Build\props\tests.props" />
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче