From c5abe40afaba92acf34b48f1b0a1b609330efcf3 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt <41597680+ValentinS4t1qbit@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:37:35 -0700 Subject: [PATCH 01/15] Catch up: develop to main (#402) * Removing support for PySCF MINDO3Solver (#401) * Removed MINDO3Solver, and its tests. * Removed pyscf-semiempirical from pip install and automated test environment --- .github/workflows/continuous_integration.yml | 1 - setup.py | 2 +- tangelo/algorithms/__init__.py | 2 +- tangelo/algorithms/classical/__init__.py | 1 - .../classical/semi_empirical_solver.py | 76 ------------------- .../tests/test_semi_empirical_solver.py | 42 ---------- .../oniom/_helpers/helper_classes.py | 7 +- 7 files changed, 5 insertions(+), 126 deletions(-) delete mode 100644 tangelo/algorithms/classical/semi_empirical_solver.py delete mode 100644 tangelo/algorithms/classical/tests/test_semi_empirical_solver.py diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 9b16e3060..d9d3cc993 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -74,7 +74,6 @@ jobs: - name: Install pyscf run: | python -m pip install pyscf - python -m pip install git+https://github.com/pyscf/semiempirical if: always() - name: Install rdkit, openbabel-wheel diff --git a/setup.py b/setup.py index 5ea9687d4..88c824ae5 100755 --- a/setup.py +++ b/setup.py @@ -20,6 +20,6 @@ test_suite="tangelo", install_requires=['h5py', 'bitarray', 'openfermion'], extras_require={ - 'pyscf': ['pyscf'] #'pyscf-semiempirical @ git+https://github.com/pyscf/semiempirical@v0.1.0'], # pyscf-semiempirical PyPI sdist is missing C extension files + 'pyscf': ['pyscf'] } ) diff --git a/tangelo/algorithms/__init__.py b/tangelo/algorithms/__init__.py index 7c97f83ca..6439fb053 100644 --- a/tangelo/algorithms/__init__.py +++ b/tangelo/algorithms/__init__.py @@ -13,5 +13,5 @@ # limitations under the License. from .variational import BuiltInAnsatze, VQESolver, ADAPTSolver, SA_VQESolver, SA_OO_Solver -from .classical import FCISolver, CCSDSolver, MINDO3Solver, MP2Solver +from .classical import FCISolver, CCSDSolver, MP2Solver from .projective import QITESolver diff --git a/tangelo/algorithms/classical/__init__.py b/tangelo/algorithms/classical/__init__.py index e26c67483..e4a34d918 100644 --- a/tangelo/algorithms/classical/__init__.py +++ b/tangelo/algorithms/classical/__init__.py @@ -14,5 +14,4 @@ from .fci_solver import FCISolver from .ccsd_solver import CCSDSolver -from .semi_empirical_solver import MINDO3Solver from .mp2_solver import MP2Solver diff --git a/tangelo/algorithms/classical/semi_empirical_solver.py b/tangelo/algorithms/classical/semi_empirical_solver.py deleted file mode 100644 index 5345843b3..000000000 --- a/tangelo/algorithms/classical/semi_empirical_solver.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright SandboxAQ 2021-2024. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Class performing electronic structure calculation employing the -semi-empirical methods. At first, semi-empirical methods are ways of computing -the total energy of a molecule in a very fast way to optimize its geometry. -Those methods are not ab initio as they employ empirical parameters, as stated -in the name "semi-empirical". They are in fact related to simplified -Hartree-Fock versions with empirical corrections. Differences between them come -from the process chosen to compute the empirical parameters. For example, MINDO3 -inventors used atomization energies to fit their mathematical models. - -They have been introduced in this package for the purpose of computing an -environment energy and inducing constraints on atomic positions. As stand-alone -solvers, they are however a poor choice, as they do not provide an accurate -approximation of energies. - -Here are the semi-empirical method(s) implemented: - - MINDO3 -""" - -from tangelo.helpers.utils import is_package_installed -from tangelo.algorithms.electronic_structure_solver import ElectronicStructureSolver -from tangelo.toolboxes.molecular_computation.integral_solver_pyscf import mol_to_pyscf - - -class MINDO3Solver(ElectronicStructureSolver): - """Uses the MINDO3 method to solve the electronic structure problem, through - pyscf. Only the restricted (RMINDO3) flavor is implemented. - - Args: - molecule (Molecule or SecondQuantizedMolecule): The molecule to - simulate. - - Refs: - - R. C. Bingham, M. J. Dewar, D. H. Lo, J. Am. Chem. Soc., 97, 1285 - (1975). - - D. F. Lewis, Chem. Rev. 86, 1111 (1986). - """ - - def __init__(self, molecule): - if not is_package_installed("pyscf.semiempirical"): - raise ModuleNotFoundError(f"The pyscf.semiempirical module is not available and is required by {self.__class__.__name__}.") - - self.molecule = molecule - - def simulate(self): - """Perform the simulation (energy calculation) for the molecule. - - Returns: - float: RMINDO3 energy. - """ - from pyscf.semiempirical import mindo3 - - solver = mindo3.RMINDO3(mol_to_pyscf(self.molecule)).run(verbose=0) - total_energy = solver.e_tot - - return total_energy - - def get_rdm(self): - """Method must be defined (ElectronicStructureSolver). For - semi-empirical methods, it is not relevant nor defined. - """ - - raise NotImplementedError("Method get_rdm is not relevant for semi-empirical methods.") diff --git a/tangelo/algorithms/classical/tests/test_semi_empirical_solver.py b/tangelo/algorithms/classical/tests/test_semi_empirical_solver.py deleted file mode 100644 index eb04cdd20..000000000 --- a/tangelo/algorithms/classical/tests/test_semi_empirical_solver.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright SandboxAQ 2021-2024. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -from tangelo.helpers.utils import is_package_installed -from tangelo.molecule_library import mol_pyridine - - -class SemiEmpiricalSolverTest(unittest.TestCase): - - @unittest.skipIf(not is_package_installed("pyscf") or not is_package_installed("pyscf.semiempirical"), - "Test Skipped: pyscf.semiempirical module not available \n") - def test_mindo3_energy(self): - """Test MINDO3Solver with pyridine. Validated with: - - MINDO/3-derived geometries and energies of alkylpyridines and the - related N-methylpyridinium cations. Jeffrey I. Seeman, - John C. Schug, and Jimmy W. Viers - The Journal of Organic Chemistry 1983 48 (14), 2399-2407 - DOI: 10.1021/jo00162a021. - """ - from tangelo.algorithms.classical import MINDO3Solver - - solver = MINDO3Solver(mol_pyridine) - energy = solver.simulate() - - self.assertAlmostEqual(energy, -33.04112644117467, places=6) - - -if __name__ == "__main__": - unittest.main() diff --git a/tangelo/problem_decomposition/oniom/_helpers/helper_classes.py b/tangelo/problem_decomposition/oniom/_helpers/helper_classes.py index 080bf59bd..239ff88ec 100644 --- a/tangelo/problem_decomposition/oniom/_helpers/helper_classes.py +++ b/tangelo/problem_decomposition/oniom/_helpers/helper_classes.py @@ -23,7 +23,7 @@ import numpy as np from scipy.spatial.transform import Rotation as R -from tangelo.algorithms import CCSDSolver, FCISolver, VQESolver, MINDO3Solver, ADAPTSolver, QITESolver +from tangelo.algorithms import CCSDSolver, FCISolver, VQESolver, ADAPTSolver, QITESolver from tangelo.problem_decomposition.oniom._helpers.capping_groups import elements, chemical_groups from tangelo.toolboxes.molecular_computation.molecule import SecondQuantizedMolecule, get_default_integral_solver @@ -145,7 +145,7 @@ def __init__(self, solver_low: str = None, options_low: dict = None, solver_high self.solver_high = solver_high.upper() if solver_high is not None else solver_high self.options_high = options_high if options_high is not None else default_solver_options - self.supported_classical_solvers = {"HF": None, "CCSD": CCSDSolver, "FCI": FCISolver, "MINDO3": MINDO3Solver} + self.supported_classical_solvers = {"HF": None, "CCSD": CCSDSolver, "FCI": FCISolver} self.supported_quantum_solvers = {"VQE": VQESolver, "ADAPT": ADAPTSolver, "QITE": QITESolver} # Check if the solvers are implemented in ONIOM. @@ -242,8 +242,7 @@ def get_energy(molecule, solver): # In case of RHF solver (inside SecondQuantizedMolecule object). if isinstance(solver, str): energy = molecule.mf_energy - # The remaining case is for VQESolver, CCSDSolver, FCISolver and - # MINDO3Solver. + # The remaining case is for VQESolver, CCSDSolver, FCISolver. else: energy = solver.simulate() From 079d12bd92c02819e7b95acdf4d8cb2d8b904cdb Mon Sep 17 00:00:00 2001 From: Valentin Senicourt <41597680+ValentinS4t1qbit@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:40:18 -0700 Subject: [PATCH 02/15] Bump main before release (#403) * Removing support for PySCF MINDO3Solver (#401) * Removed MINDO3Solver, and its tests. * Removed pyscf-semiempirical from pip install and automated test environment From 7833982ba8bc90472b724157184c8c6b28978f6e Mon Sep 17 00:00:00 2001 From: Valentin Senicourt <41597680+ValentinS4t1qbit@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:01:04 -0700 Subject: [PATCH 03/15] Update link to docs after trasnfer to SBAQ --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 86efa0556..afb8c7b13 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ Tangelo is an open-source Python package maintained by `SandboxAQ Features  ·  - Docs + Docs  ·  Blog From 7812175d6ea1e77f9402065393d466b042079ef2 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt <41597680+ValentinS4t1qbit@users.noreply.github.com> Date: Sun, 15 Sep 2024 20:50:40 -0400 Subject: [PATCH 04/15] Update link to tutorial --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index afb8c7b13..7805cad44 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ Tangelo is an open-source Python package maintained by `SandboxAQ - Tutorials + Tutorials  ·  Features  ·  From edc02c5b305590734cdf6d191c08e273959a96cf Mon Sep 17 00:00:00 2001 From: paul-abb <136359239+paul-abb@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:36:23 -0500 Subject: [PATCH 05/15] Semgrep scanning Enabling semgrep scanning --- .github/workflows/semgrep.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/semgrep.yml diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 000000000..bdbcae86c --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,39 @@ +# Name of this GitHub Actions workflow. +name: Semgrep +on: + # Scan changed files in PRs (diff-aware scanning): + pull_request: {} + # Scan on-demand through GitHub Actions interface: + workflow_dispatch: {} + # Scan mainline branches if there are changes to .github/workflows/semgrep.yml: + push: + branches: + - main + - semgrep_integration + paths: + - .github/workflows/semgrep.yml + # Schedule the CI job (this method uses cron syntax): + schedule: + - cron: '20 17 * * *' # Sets Semgrep to scan every day at 17:20 UTC. + # It is recommended to change the schedule to a random time. +jobs: + semgrep: + # User definable name of this GitHub Actions job. + name: semgrep/ci + # If you are self-hosting, change the following `runs-on` value: + runs-on: ubuntu-latest + container: + # A Docker image with Semgrep installed. Do not change this. + image: semgrep/semgrep + # Skip any PR created by dependabot to avoid permission issues: + if: (github.actor != 'dependabot[bot]') + steps: + # Fetch project source with GitHub Actions Checkout. Use either v3 or v4. + - uses: actions/checkout@v4 + # Run the "semgrep ci" command on the command line of the docker image. + - run: semgrep ci + env: + # Connect to Semgrep AppSec Platform through your SEMGREP_APP_TOKEN. + # Generate a token from Semgrep AppSec Platform > Settings + # and add it to your GitHub secrets. + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} From 274516c1521796f6dbd38d8f03a2e540622a7864 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 19:26:06 -0800 Subject: [PATCH 06/15] dotnet version updates --- .github/workflows/continuous_integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index d9d3cc993..a54f63fdd 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -50,11 +50,11 @@ jobs: - name: Install Microsoft qsharp/qdk run: | - wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update - sudo apt-get install -y dotnet-sdk-5.0 + sudo apt-get install -y dotnet-sdk-9.0 dotnet tool install -g Microsoft.Quantum.IQSharp $(which dotnet-iqsharp) install --user pip install qsharp From 00e068581b4bc5113d05620f69c1fa36916f62af Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 19:40:41 -0800 Subject: [PATCH 07/15] dotnet version updates --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index a54f63fdd..075b117a5 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -54,7 +54,7 @@ jobs: sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update - sudo apt-get install -y dotnet-sdk-9.0 + sudo apt-get install -y dotnet-sdk-8.0 dotnet tool install -g Microsoft.Quantum.IQSharp $(which dotnet-iqsharp) install --user pip install qsharp From 8d12975340cdc6ed3d67bb01d3b3c2ad33d33a4b Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 19:50:28 -0800 Subject: [PATCH 08/15] updates links --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 188753797..a513e2568 100644 --- a/README.rst +++ b/README.rst @@ -27,13 +27,13 @@ Tangelo is an open-source Python package maintained by `SandboxAQ - Tutorials + Tutorials  ·  Features  ·  Docs  ·  - Blog + Blog ------------- From 023155742556d154786f1b8c8cc3486e5797ca0b Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 19:55:50 -0800 Subject: [PATCH 09/15] update --- .github/workflows/continuous_integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 075b117a5..850bcbdef 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -57,6 +57,7 @@ jobs: sudo apt-get install -y dotnet-sdk-8.0 dotnet tool install -g Microsoft.Quantum.IQSharp $(which dotnet-iqsharp) install --user + echo "YAYAYAYAYAYA" pip install qsharp if: always() From 5fbc5d6b0b2c303bcd1a66efe5a82a380f7478c4 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 19:57:49 -0800 Subject: [PATCH 10/15] update --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 850bcbdef..6d29a1337 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -57,7 +57,7 @@ jobs: sudo apt-get install -y dotnet-sdk-8.0 dotnet tool install -g Microsoft.Quantum.IQSharp $(which dotnet-iqsharp) install --user - echo "YAYAYAYAYAYA" + echo "YAYAYAYAYAYA" pip install qsharp if: always() From e655d81391ba1bc92e47526e0706d161a08c7ea7 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 20:02:17 -0800 Subject: [PATCH 11/15] update --- .github/workflows/continuous_integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 6d29a1337..b278793c8 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -54,8 +54,10 @@ jobs: sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update + echo "YOYOYOYO" sudo apt-get install -y dotnet-sdk-8.0 dotnet tool install -g Microsoft.Quantum.IQSharp + echo "YIYIYIYIYI" $(which dotnet-iqsharp) install --user echo "YAYAYAYAYAYA" pip install qsharp From ac843c7926c3d6860f6d1ca1fe6c967d8e144171 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 20:07:08 -0800 Subject: [PATCH 12/15] update --- .github/workflows/continuous_integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index b278793c8..732fa47b4 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -56,6 +56,9 @@ jobs: sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update echo "YOYOYOYO" sudo apt-get install -y dotnet-sdk-8.0 + echo "YEYEYEYEYE" + sudo apt-get install -y dotnet-runtime-8.0 + echo "BB" dotnet tool install -g Microsoft.Quantum.IQSharp echo "YIYIYIYIYI" $(which dotnet-iqsharp) install --user From 9207ed3b36981b8517aedc88be381517f4b09639 Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 20:11:05 -0800 Subject: [PATCH 13/15] update --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 732fa47b4..294dc7b43 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -57,7 +57,7 @@ jobs: echo "YOYOYOYO" sudo apt-get install -y dotnet-sdk-8.0 echo "YEYEYEYEYE" - sudo apt-get install -y dotnet-runtime-8.0 + sudo apt-get install -y dotnet-runtime-8.0 echo "BB" dotnet tool install -g Microsoft.Quantum.IQSharp echo "YIYIYIYIYI" From a7ea49c6e1bbdf74d0e470758776c4acd9f046fc Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 20:16:39 -0800 Subject: [PATCH 14/15] update --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 294dc7b43..f78656fa8 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -57,7 +57,7 @@ jobs: echo "YOYOYOYO" sudo apt-get install -y dotnet-sdk-8.0 echo "YEYEYEYEYE" - sudo apt-get install -y dotnet-runtime-8.0 + sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-8.0 echo "BB" dotnet tool install -g Microsoft.Quantum.IQSharp echo "YIYIYIYIYI" From ba1ef2eaa87f415cbca667a34110ac792b7330db Mon Sep 17 00:00:00 2001 From: Valentin Senicourt Date: Mon, 6 Jan 2025 20:28:03 -0800 Subject: [PATCH 15/15] update --- .github/workflows/continuous_integration.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index f78656fa8..4abaca203 100755 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -54,13 +54,11 @@ jobs: sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb sudo apt-get update; sudo apt-get install -y apt-transport-https && sudo apt-get update - echo "YOYOYOYO" sudo apt-get install -y dotnet-sdk-8.0 - echo "YEYEYEYEYE" - sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-8.0 echo "BB" dotnet tool install -g Microsoft.Quantum.IQSharp echo "YIYIYIYIYI" + sudo ln -s /usr/share/dotnet/shared /usr/lib/dotnet $(which dotnet-iqsharp) install --user echo "YAYAYAYAYAYA" pip install qsharp