Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Initial work on Broombridge v.0.3 #533

Draft
wants to merge 70 commits into
base: feature/broombridge-v0.3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
4ed1278
Started work on updating to BB 0.3.
cgranade Feb 25, 2022
f94dcb3
Added v0.3 support to qdk-chem convert.
cgranade Feb 26, 2022
8c78dff
Merge branch 'main' into cgranade/broombridge-0.3
cgranade Feb 28, 2022
d3908f1
--from → --format
cgranade Feb 28, 2022
36cb0f9
Merge branch 'cgranade/broombridge-0.3' of https://github.com/microso…
cgranade Feb 28, 2022
ba071be
Fix formulas in PurifiedMixedState(WithData) (#534)
tcNickolas Mar 3, 2022
45f7fa9
Fixed the SDK version. (#536)
kuzminrobin Mar 9, 2022
845decf
Fix #511 for fixed point amplitude amplification (#525)
msoeken Mar 9, 2022
ab0f491
Fix overestimation in MachineLearning.NQubitsRequired (#282)
PhysSong Mar 9, 2022
947a552
Chunks: Add check that chunk size is positive (#540)
tcNickolas Mar 11, 2022
76b7276
Fixes #444 (#537)
msoeken Mar 14, 2022
c360e77
Add --flatten option.
cgranade Mar 15, 2022
ce280af
Adopt .NET6 + VS2022 in Quantum Development Kit (#542)
ricardo-espinoza Mar 17, 2022
dd2c4ca
Update CI build settings to use .NET6 (#543)
tcNickolas Mar 21, 2022
fbbc600
Fixes #367 (#541)
msoeken Mar 22, 2022
daa7e59
Improve code quality in MachineLearning library (#539)
msoeken Mar 22, 2022
4422ad5
Add note: SignedLittleEndian uses two's complement (#544)
tcNickolas Mar 30, 2022
7d0f9f7
Some code simplification in amplitude amplification test. (#545)
msoeken Mar 30, 2022
9c209c2
Updating projects and other components to build 0.24.201332 (#548)
ricardo-espinoza Apr 1, 2022
2a892a9
add gh-sync workflow (#547)
IsraelMiles Apr 1, 2022
9ea44b5
API review March 2022 (#535)
msoeken Apr 4, 2022
c246868
Implements #442 (#552)
msoeken Apr 7, 2022
53fb767
Fix #546. (#553)
msoeken Apr 8, 2022
30d1abd
Fix documentation for Padded function. (#556)
msoeken Apr 9, 2022
e838b63
Fixes #560 (#562)
msoeken Apr 13, 2022
c8f8d67
prevent race condition by enforcing concurrency cancellation on issue…
IsraelMiles Apr 14, 2022
abe71cc
Fixes #563. (#564)
msoeken Apr 14, 2022
eee471f
Removed C# test driver. (#566)
msoeken Apr 20, 2022
17b2c48
Implements #465 (#568)
msoeken Apr 20, 2022
bd99e82
Refactor and remove duplicate internal operation. (#569)
msoeken Apr 21, 2022
488fb7c
Fixes #570. (#572)
msoeken Apr 21, 2022
74a3d27
Fixes #571. (#573)
msoeken Apr 21, 2022
aeedcdd
Add DevSkim scanning (#576)
anjbur Apr 23, 2022
b798477
API review April 2022 (#561)
msoeken May 4, 2022
049ad52
Fixes #580. (#581)
msoeken May 5, 2022
ad3a6f1
Implements #549. (#574)
msoeken Apr 21, 2022
7b5cfc4
Implements #555 (#557)
msoeken Apr 21, 2022
81fe6de
Implements fixed-point conversion functions (#575)
msoeken Apr 22, 2022
690d742
Feature branch cleanup (#582)
msoeken May 8, 2022
025a812
Creating global.json (#586)
anpaz May 14, 2022
dda0153
Microsoft mandatory file (#587)
microsoft-github-policy-service[bot] May 23, 2022
0730cda
Updated to the latest QDK. (#591)
kuzminrobin May 25, 2022
5f9ba1c
API review May 2022 (#584)
msoeken Jun 6, 2022
d46f8b8
improve diagnostics message when swapping array elements (#597)
filipw Jun 13, 2022
2117bf2
Improves MultiplexOperations implementation (#599)
msoeken Jul 5, 2022
3496411
API review June 2022 (#596)
msoeken Jul 7, 2022
131a8e7
Add functions for smallest and largest representable fixed point (#606)
msoeken Jul 18, 2022
0ac7ac1
ApplyWindowed (#603)
adrianleh Jul 20, 2022
3f66179
Updating QDK version to 0.25.222597. (#609)
ricardo-espinoza Jul 27, 2022
59438bf
API review July 2022 (#608)
msoeken Aug 19, 2022
5f0a6f8
Merge branch 'main' into cgranade/broombridge-0.3
cgranade Aug 19, 2022
2991f67
lookup table code (#611)
rajkk1 Aug 23, 2022
676894d
Update magic.
cgranade Aug 26, 2022
3d0aea9
Revise ApplyFunctionWithLookupTable (#617)
msoeken Aug 30, 2022
df7cc1f
Temporarily disable test not compatible with 0.3.
Aug 30, 2022
d43cb35
Add exemption file for Central Feed Services onboarding (#621)
ricardo-espinoza Sep 1, 2022
c0b8517
Fix documentation (#615)
remilvus Sep 2, 2022
9cbc6b1
Add `$schema` to `cgmanifest.json` (#620)
JamieMagee Sep 2, 2022
49a14a4
Update test to bb 0.3, remove test made irrelevant by serialization r…
cgranade Sep 2, 2022
48541da
Fixes outdated example (#623)
RufusJWB Sep 7, 2022
eecc1b6
Disable test for loading old version.
cgranade Sep 9, 2022
f29e03e
Updating QDK version to 0.25.228311 - August 2022 Release (#626)
DmitryVasilevsky Sep 10, 2022
76dd668
Added example how to use PrepareArbitraryStateCP (#627)
RufusJWB Sep 23, 2022
2083e1a
Use trivial symmetry for orbital → fermion transform.
cgranade Sep 30, 2022
b80054e
Update license text for NetMQ (#632)
ricardo-espinoza Oct 5, 2022
05a50fd
Updating Notice.txt for all components (#633)
ricardo-espinoza Oct 6, 2022
60bc2f9
Updating QDK version to 0.26.233415. (#634)
ricardo-espinoza Oct 10, 2022
4558a7c
Gulow/broombridge 0.3 (#637)
guanghaolow Oct 20, 2022
8ca3a7a
Merge from main
guanghaolow Oct 20, 2022
0b82e62
Propgage symmetry when adding otbital integral terms to Hamiltonian.
guanghaolow Oct 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/devskim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: DevSkim

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
schedule:
# set schedule to run at 2AM PT on Saturdays
- cron: '0 9 * * Sat'

jobs:
lint:
name: DevSkim
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1

- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: devskim-results.sarif
38 changes: 38 additions & 0 deletions .github/workflows/gh-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Sync GitHub with ADO

on:
issues:
types: [closed, edited, deleted, reopened, assigned, unassigned, labeled, unlabeled]
issue_comment:

concurrency:
group: ${{ github.event.issue.number }}
cancel-in-progress: true

jobs:
sync-issues:
name: Run gh-sync from GitHub action
if: ${{ github.event.label.name == 'tracking' || contains(github.event.issue.labels.*.name, 'tracking') }}
runs-on: ubuntu-latest
steps:
- name: Login to Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- id: AzureKeyVault
uses: Azure/get-keyvault-secrets@v1
with:
keyvault: 'kv-qdk-build'
secrets: 'ghSyncBuildPAT'

- name: 'Trigger gh-sync'
uses: microsoft/gh-sync@main
with:
ado-organization-url: ${{ secrets.ADO_URL }}
ado-project: ${{ secrets.ADO_PROJECT }}
ado-area-path: ${{ secrets.ADO_AREA_PATH }}
github-repo: 'microsoft/QuantumLibraries'
issue-number: ${{ github.event.issue.number }}
ado-token: ${{ steps.AzureKeyVault.outputs.ghSyncBuildPAT }}
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .sscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cfs": ["CFS0012", "CFS0013"]
}
2 changes: 1 addition & 1 deletion Build/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $artifacts = @{
".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll",
".\Chemistry\src\Jupyter\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Jupyter.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"
".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\net6.0\qdk-chem.dll"
) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) };
}

Expand Down
2 changes: 1 addition & 1 deletion Build/props/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.13.201118141-beta" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.26.233415" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down
4 changes: 2 additions & 2 deletions Build/steps.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
steps:

- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.300'
displayName: 'Use .NET Core SDK 6.0.x'
inputs:
packageType: sdk
version: '3.1.300'
version: '6.0.x'


- task: UsePythonVersion@0
Expand Down
29 changes: 19 additions & 10 deletions Chemistry.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{561759D2-4D2D-4EE3-9565-9AAEC4A7D64B}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -24,23 +24,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard", "Standard\src\St
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BroombridgeExamples", "BroombridgeExamples", "{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\H2O-6_fourfold_v0.3.yaml = Chemistry\tests\TestData\Broombridge\H2O-6_fourfold_v0.3.yaml
Chemistry\tests\TestData\Broombridge\H2O-6_trivial_v0.3.yaml = Chemistry\tests\TestData\Broombridge\H2O-6_trivial_v0.3.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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metapackage", "Chemistry\src\Metapackage\Metapackage.csproj", "{E8268248-FC5B-4F4E-82FF-5C8CC40950BB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metapackage", "Chemistry\src\Metapackage\Metapackage.csproj", "{E8268248-FC5B-4F4E-82FF-5C8CC40950BB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chemistry", "Chemistry", "{43A9F607-5884-4CB9-A455-01E98F5532E2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{812F2D11-792D-4305-8427-01B632A92299}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools", "Chemistry\src\Tools\Tools.csproj", "{3EF5845F-B348-4DC9-A905-23A6FB9AB421}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tools", "Chemistry\src\Tools\Tools.csproj", "{3EF5845F-B348-4DC9-A905-23A6FB9AB421}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModelTests", "Chemistry\tests\DataModelTests\DataModelTests.csproj", "{B86DDA60-44F0-4C05-837E-CEA84DBCADF7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -80,6 +84,10 @@ Global
{3EF5845F-B348-4DC9-A905-23A6FB9AB421}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EF5845F-B348-4DC9-A905-23A6FB9AB421}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EF5845F-B348-4DC9-A905-23A6FB9AB421}.Release|Any CPU.Build.0 = Release|Any CPU
{B86DDA60-44F0-4C05-837E-CEA84DBCADF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B86DDA60-44F0-4C05-837E-CEA84DBCADF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B86DDA60-44F0-4C05-837E-CEA84DBCADF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B86DDA60-44F0-4C05-837E-CEA84DBCADF7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -93,6 +101,7 @@ Global
{E8268248-FC5B-4F4E-82FF-5C8CC40950BB} = {F561BE56-63D8-4C33-A3B3-CF2685BC7A5C}
{812F2D11-792D-4305-8427-01B632A92299} = {43A9F607-5884-4CB9-A455-01E98F5532E2}
{3EF5845F-B348-4DC9-A905-23A6FB9AB421} = {812F2D11-792D-4305-8427-01B632A92299}
{B86DDA60-44F0-4C05-837E-CEA84DBCADF7} = {595D5855-8820-48D7-B5E1-9C88215A866A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6869E5BF-551A-40F1-9B6B-D1B27A5676CB}
Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/DataModel/DataModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="8.1.2" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
</ItemGroup>
Expand Down
90 changes: 66 additions & 24 deletions Chemistry/src/DataModel/OrbitalIntegral/OrbitalIntegral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ public enum Convention
Dirac, Mulliken
}

// NB [Design note]: this intentionally duplicates the corresponding
// enum in the V0_3 class, allowing forward versions
// to add or modify permutation symmetries without
// retroactively changing the definition of V0_3.
public enum PermutationSymmetry
{
Eightfold,
Fourfold,
Trivial
}

/// <summary>
/// Indices of orbitals in the overlap integral.
/// </summary>
Expand All @@ -34,28 +45,35 @@ public enum Convention
/// </summary>
public double Coefficient;

/// <summary>
/// Symmetry of the orbital overlap integral.
/// </summary>
public PermutationSymmetry Symmetry = PermutationSymmetry.Eightfold;

/// <summary>
/// Parameterless constructors. Sets this as an empty OrbitalIntegral with coefficient 0.0
/// </summary>
public OrbitalIntegral() : this(0.0)
{
}

public OrbitalIntegral(double coefficient)
/// <param name="coefficient">coefficient of orbital integral.</param>
/// <param name="symmetry">Convention of symmetry of orbital indices.</param>
public OrbitalIntegral(double coefficient, PermutationSymmetry symmetry = PermutationSymmetry.Eightfold) : this(new int[] { }, coefficient, symmetry)
{
OrbitalIndices = new int[] { };
Coefficient = coefficient;
}

/// <summary>
/// Constructor for orbital integral object.
/// </summary>
/// <param name="orbitalIndices">Array of orbital indices in Dirac notation.</param>
/// <param name="coefficient">coefficient of orbital integral.</param>
public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient = 0.0)
/// <param name="symmetry">Convention of symmetry of orbital indices.</param>
public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient = 0.0, PermutationSymmetry symmetry = PermutationSymmetry.Eightfold)
{
OrbitalIndices = orbitalIndices.ToArray();
Coefficient = coefficient;
Symmetry = symmetry;
}

/// <summary>
Expand All @@ -64,10 +82,12 @@ public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient = 0.0
/// <param name="orbitalIndices">Array of orbital indices.</param>
/// <param name="coefficient">coefficient of orbital integral.</param>
/// <param name="convention">Convention for ordering of orbital indices.</param>
public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient, Convention convention = Convention.Mulliken)
/// <param name="symmetry">Convention of symmetry of orbital indices.</param>
public OrbitalIntegral(IEnumerable<int> orbitalIndices, double coefficient, PermutationSymmetry symmetry, Convention convention = Convention.Mulliken)
{
OrbitalIndices = ConvertIndices(orbitalIndices, convention, Convention.Dirac);
Coefficient = coefficient;
Symmetry = symmetry;
}

public TermType.OrbitalIntegral TermType
Expand Down Expand Up @@ -107,6 +127,40 @@ public void ResetSign()
/// <returns>Length of orbital indices.</returns>
public int Length => OrbitalIndices.Length;

private static int[][] EnumerateTwoBodyPermutations(PermutationSymmetry symmetry, int i, int j, int k, int l) =>
symmetry switch
{
// In Mulliken notation,
// (ij|kl) = (ij|lk) = (ji|kl) = (ji|lk) =
// (kl|ij) = (lk|ij) = (kl|ji) = (lk|ji)
// Orbital indices are in Dirac notation.
PermutationSymmetry.Eightfold => new int[][]
{
new int[] { i, j, k, l }, // 0123
new int[] { j, i, l, k }, // 1032
new int[] { k, l, i, j }, // 2301
new int[] { l, k, j, i }, // 3210
new int[] { i, k, j, l }, // 0213
new int[] { k, i, l, j }, // 2031
new int[] { j, l, i, k }, // 1302
new int[] { l, j, k, i } // 3120
},
// In Mulliken notation,
// (ij|kl) = (ji|lk) = (kl|ij) = (lk|ji)
// Orbital indices are in Dirac notation.
PermutationSymmetry.Fourfold => new int[][]
{
new int[] { i, j, k, l }, // Identity
new int[] { l, k, j, i }, // Complex conjugation
new int[] { j, i, l, k }, // Change of variables
new int[] { k, l, i, j }, // Complex conjugation & Change of variables
},
PermutationSymmetry.Trivial => new int[][]
{
new int[] { i, j, k, l }
},
_ => throw new Exception($"Permutation symmetry {symmetry} is not valid for two-body permutations.")
};

/// <summary>
/// Enumerates over all orbital integrals with the same coefficient
Expand All @@ -128,25 +182,13 @@ public OrbitalIntegral[] EnumerateOrbitalSymmetries()
new int[] {i, j},
new int[] {j, i}
};
return symmetries.Distinct(new ArrayEqualityComparer<int>()).Select(o => new OrbitalIntegral(o, coefficient)).ToArray();
return symmetries.Distinct(new ArrayEqualityComparer<int>()).Select(o => new OrbitalIntegral(o, coefficient, Symmetry)).ToArray();
}
else if (OrbitalIndices.Length == 4)
{
var i = OrbitalIndices[0];
var j = OrbitalIndices[1];
var k = OrbitalIndices[2];
var l = OrbitalIndices[3];
var symmetries = new int[][] {
new int[] { i, j, k, l }, // 0123
new int[] { j, i, l, k }, // 1032
new int[] { k, l, i, j }, // 2301
new int[] { l, k, j, i }, // 3210
new int[] { i, k, j, l }, // 0213
new int[] { k, i, l, j }, // 2031
new int[] { j, l, i, k }, // 1302
new int[] { l, j, k, i } // 3120
};
return symmetries.Distinct(new ArrayEqualityComparer<int>()).Select(o => new OrbitalIntegral(o, coefficient)).ToArray();
return EnumerateTwoBodyPermutations(Symmetry, OrbitalIndices[0], OrbitalIndices[1], OrbitalIndices[2], OrbitalIndices[3])
.Distinct(new ArrayEqualityComparer<int>())
.Select(o => new OrbitalIntegral(o, coefficient, Symmetry)).ToArray();
}
else
{
Expand All @@ -160,7 +202,7 @@ public OrbitalIntegral[] EnumerateOrbitalSymmetries()
public OrbitalIntegral Clone()
{
var newArray = OrbitalIndices.Clone<int>();
return new OrbitalIntegral(newArray, Coefficient);
return new OrbitalIntegral(newArray, Coefficient, Symmetry);
}

/// <summary>
Expand All @@ -172,14 +214,14 @@ public OrbitalIntegral ToCanonicalForm()
{
var symmetries = EnumerateOrbitalSymmetries().Select(o => o.OrbitalIndices).ToList();
symmetries.Sort(new ArrayLexicographicComparer<int>());
return new OrbitalIntegral(symmetries.First(), Coefficient);
return new OrbitalIntegral(symmetries.First(), Coefficient, Symmetry);
}

/// <summary>
/// Checks of this orbital integral has indices sorted in canonical order.
/// </summary>
/// <returns>Returns <see cref="bool"/> if the orbital integral indices are canonically sorted
/// and <see cref="false"/> otherwise.
/// and <c>false</c> otherwise.
/// </returns>
public bool IsInCanonicalOrder()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Microsoft.Quantum.Chemistry.OrbitalIntegrals
/// </summary>
public static partial class Extensions
{

/// <summary>
/// Method for constructing a fermion Hamiltonian from an orbital integral Hamiltonian.
/// </summary>
Expand All @@ -34,7 +33,7 @@ public static partial class Extensions
var nOrbitals = sourceHamiltonian.SystemIndices.Max() + 1;
var hamiltonian = new FermionHamiltonian();
Func<OrbitalIntegral, double, IEnumerable<(HermitianFermionTerm, DoubleCoeff)>> conversion =
(orb, coeff) => new OrbitalIntegral(orb.OrbitalIndices, coeff).ToHermitianFermionTerms(nOrbitals, indexConvention)
(orb, coeff) => new OrbitalIntegral(orb.OrbitalIndices, coeff, orb.Symmetry).ToHermitianFermionTerms(nOrbitals, indexConvention)
.Select(o => (o.Item1, o.Item2.ToDoubleCoeff()));

foreach (var termType in sourceHamiltonian.Terms)
Expand All @@ -49,7 +48,6 @@ public static partial class Extensions
return hamiltonian;
}


/// <summary>
/// Creates all fermion terms generated by all symmetries of an orbital integral.
/// </summary>
Expand Down Expand Up @@ -95,7 +93,9 @@ public static partial class Extensions
{
// One-electron orbital integral symmetries
// ij = ji
var pqSpinOrbitals = orbitalIntegral.EnumerateOrbitalSymmetries().EnumerateSpinOrbitals();
var pqSpinOrbitals = orbitalIntegral
.EnumerateOrbitalSymmetries()
.EnumerateSpinOrbitals();

var coefficient = orbitalIntegral.Coefficient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public OrbitalIntegralHamiltonian(IEnumerable<OrbitalIntegral> terms) : base()
/// <param name="orbitalIntegral">Orbital integral to add to Hamiltonian.</param>
public void Add(OrbitalIntegral orbitalIntegral)
{
Add(new OrbitalIntegral(orbitalIntegral.OrbitalIndices), orbitalIntegral.Coefficient);
Add(new OrbitalIntegral(orbitalIntegral.OrbitalIndices, symmetry: orbitalIntegral.Symmetry), orbitalIntegral.Coefficient);
}

/// <summary>
Expand Down