tequila-basic 1.9.4__tar.gz → 1.9.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. {tequila-basic-1.9.4/src/tequila_basic.egg-info → tequila_basic-1.9.6}/PKG-INFO +12 -10
  2. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/README.md +11 -9
  3. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/gates.py +1 -1
  4. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/qasm.py +25 -11
  5. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/qpic.py +1 -1
  6. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/binary_rep.py +1 -1
  7. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/__init__.py +2 -0
  8. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/chemistry_tools.py +146 -19
  9. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/encodings.py +141 -47
  10. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/madness_interface.py +4 -1
  11. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/orbital_optimizer.py +10 -4
  12. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/pyscf_interface.py +1 -0
  13. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/qc_base.py +325 -24
  14. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_api.py +6 -1
  15. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_qiskit.py +14 -6
  16. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/tools/random_generators.py +17 -0
  17. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/version.py +1 -1
  18. {tequila-basic-1.9.4 → tequila_basic-1.9.6/src/tequila_basic.egg-info}/PKG-INFO +12 -10
  19. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_chemistry.py +63 -5
  20. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_chemistry_madness.py +1 -1
  21. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/LICENSE +0 -0
  22. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/MANIFEST.in +0 -0
  23. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/requirements.txt +0 -0
  24. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/setup.cfg +0 -0
  25. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/setup.py +0 -0
  26. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/__init__.py +0 -0
  27. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/__init__.py +0 -0
  28. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/_unary_state_prep_impl.py +0 -0
  29. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/adapt/__init__.py +0 -0
  30. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/adapt/adapt.py +0 -0
  31. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/krylov/__init__.py +0 -0
  32. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/krylov/krylov.py +0 -0
  33. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/robustness/__init__.py +0 -0
  34. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/robustness/helpers.py +0 -0
  35. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/robustness/interval.py +0 -0
  36. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/apps/unary_state_prep.py +0 -0
  37. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/autograd_imports.py +0 -0
  38. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/__init__.py +0 -0
  39. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/_gates_impl.py +0 -0
  40. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/circuit.py +0 -0
  41. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/compiler.py +0 -0
  42. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/gradient.py +0 -0
  43. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/noise.py +0 -0
  44. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/circuit/pyzx.py +0 -0
  45. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/__init__.py +0 -0
  46. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/binary_utils.py +0 -0
  47. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/compile_groups.py +0 -0
  48. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/ev_utils.py +0 -0
  49. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/fermionic_functions.py +0 -0
  50. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/fermionic_methods.py +0 -0
  51. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/grouping/overlapping_methods.py +0 -0
  52. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/hamiltonian/__init__.py +0 -0
  53. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/hamiltonian/paulis.py +0 -0
  54. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/hamiltonian/paulistring.py +0 -0
  55. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/hamiltonian/qubit_hamiltonian.py +0 -0
  56. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/ml/__init__.py +0 -0
  57. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/ml/interface_torch.py +0 -0
  58. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/ml/ml_api.py +0 -0
  59. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/ml/utils_ml.py +0 -0
  60. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/objective/__init__.py +0 -0
  61. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/objective/braket.py +0 -0
  62. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/objective/objective.py +0 -0
  63. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/objective/qtensor.py +0 -0
  64. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/__init__.py +0 -0
  65. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/_containers.py +0 -0
  66. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/optimizer_base.py +0 -0
  67. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/optimizer_gd.py +0 -0
  68. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/optimizer_gpyopt.py +0 -0
  69. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/optimizers/optimizer_scipy.py +0 -0
  70. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/quantumchemistry/psi4_interface.py +0 -0
  71. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/__init__.py +0 -0
  72. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_base.py +0 -0
  73. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_cirq.py +0 -0
  74. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_pyquil.py +0 -0
  75. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_qibo.py +0 -0
  76. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_qlm.py +0 -0
  77. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_qulacs.py +0 -0
  78. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_qulacs_gpu.py +0 -0
  79. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/simulators/simulator_symbolic.py +0 -0
  80. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/tools/__init__.py +0 -0
  81. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/tools/convenience.py +0 -0
  82. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/tools/qng.py +0 -0
  83. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/__init__.py +0 -0
  84. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/bitstrings.py +0 -0
  85. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/exceptions.py +0 -0
  86. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/joined_transformation.py +0 -0
  87. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/keymap.py +0 -0
  88. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/utils/misc.py +0 -0
  89. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/wavefunction/__init__.py +0 -0
  90. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila/wavefunction/qubit_wavefunction.py +0 -0
  91. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila_basic.egg-info/SOURCES.txt +0 -0
  92. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila_basic.egg-info/dependency_links.txt +0 -0
  93. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila_basic.egg-info/requires.txt +0 -0
  94. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/src/tequila_basic.egg-info/top_level.txt +0 -0
  95. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_TrotErr.py +0 -0
  96. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_adapt.py +0 -0
  97. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_array.py +0 -0
  98. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_binary_pauli.py +0 -0
  99. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_binary_utils.py +0 -0
  100. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_bitstrings.py +0 -0
  101. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_braket.py +0 -0
  102. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_chemistry_f12.py +0 -0
  103. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_circuits.py +0 -0
  104. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_fermionic_meas.py +0 -0
  105. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_gd_optimizer.py +0 -0
  106. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_gpyopt.py +0 -0
  107. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_gradient.py +0 -0
  108. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_hamiltonian_arithmetic.py +0 -0
  109. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_krylov.py +0 -0
  110. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_mappings.py +0 -0
  111. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_noise.py +0 -0
  112. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_noise_opt.py +0 -0
  113. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_objectives.py +0 -0
  114. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_pyzx.py +0 -0
  115. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_qasm.py +0 -0
  116. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_qtensor.py +0 -0
  117. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_recompilation_routines.py +0 -0
  118. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_scipy.py +0 -0
  119. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_simulator_backends.py +0 -0
  120. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_symbolic_simulator.py +0 -0
  121. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_torch_interface.py +0 -0
  122. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_unary_state_prep.py +0 -0
  123. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_variable.py +0 -0
  124. {tequila-basic-1.9.4 → tequila_basic-1.9.6}/tests/test_zzz_cleanup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tequila-basic
3
- Version: 1.9.4
3
+ Version: 1.9.6
4
4
  Summary: A High-Level Abstraction Framework for Quantum Algorithms
5
5
  Home-page: https://github.com/tequilahub/tequila
6
6
  Author: Tequila Developers
@@ -32,7 +32,7 @@ Tequila can execute the underlying quantum expectation values on state of the ar
32
32
  - [talks and slides](https://kottmanj.github.io/talks_and_material/)
33
33
 
34
34
  # Installation
35
- Recommended Python version is 3.8-3.9.
35
+ Recommended Python version is 3.9 (3.10).
36
36
  Tequila supports linux, osx and windows. However, not all optional dependencies are supported on windows.
37
37
 
38
38
  ## Install from PyPi
@@ -258,14 +258,18 @@ A.G. Cadavid, I. Montalban, A. Dalal, E. Solano, N.N. Hegade
258
258
  Efficient DCQO Algorithm within the Impulse Regime for Portfolio Optimization
259
259
  [arxiv:2308.15475](https://arxiv.org/abs/2308.15475)
260
260
 
261
+ A. Anand, K. Brown
262
+ Hamiltonians, groups, graphs and ansätze
263
+ [arxiv:2312.17146](https://arxiv.org/abs/2312.17146)
264
+
265
+ P.W.K. Jensen, E.R. Kjellgren, P. Reinholdt, K.M. Ziems, S. Coriani, J. Kongsted, S. Sauer
266
+ Quantum Equation of Motion with Orbital Optimization for Computing Molecular Properties in Near-Term Quantum Computing
267
+ [arxiv:2312.12386](https://arxiv.org/abs/2312.12386)
268
+
261
269
  Let us know, if you want your research project and/or tutorial to be included in this list!
262
270
 
263
271
  # Dependencies
264
- Support for additional optimizers or quantum backends can be activated by intalling them in your environment.
265
- Tequila will then detect them automatically.
266
- Currently those are: [Phoenics](https://github.com/aspuru-guzik-group/phoenics)
267
- and [GPyOpt](https://sheffieldml.github.io/GPyOpt/).
268
- Quantum backends are treated in the same way.
272
+ Support for specific backends (quantum simulators, optimizers, quantum chemistry) can be activated by intalling them in your environment.
269
273
 
270
274
  ## Quantum Backends
271
275
  Currently supported
@@ -285,7 +289,7 @@ Currently supported
285
289
  ### [Psi4](https://github.com/psi4/psi4).
286
290
  In a conda environment this can be installed with
287
291
  ```bash
288
- conda install psi4 -c psi4
292
+ conda install psi4 -c conda-forge
289
293
  ```
290
294
  Here is a small [tutorial](https://nbviewer.org/github/tequilahub/tequila-tutorials/blob/main/chemistry/ChemistryModule.ipynb) that illustrates the usage.
291
295
 
@@ -399,5 +403,3 @@ Tequila runs on Mac OSX.
399
403
  You might get in trouble with installing qulacs since it currently does not work with Apple's clang compiler.
400
404
  You need to install latest GNU compile (at least gcc-7 and g++7) and set them as default before installing qulacs over pip.
401
405
 
402
- ## Qibo and GPyOpt
403
- Currently you can't use Qibo and GPyOpt within the same environment.
@@ -14,7 +14,7 @@ Tequila can execute the underlying quantum expectation values on state of the ar
14
14
  - [talks and slides](https://kottmanj.github.io/talks_and_material/)
15
15
 
16
16
  # Installation
17
- Recommended Python version is 3.8-3.9.
17
+ Recommended Python version is 3.9 (3.10).
18
18
  Tequila supports linux, osx and windows. However, not all optional dependencies are supported on windows.
19
19
 
20
20
  ## Install from PyPi
@@ -240,14 +240,18 @@ A.G. Cadavid, I. Montalban, A. Dalal, E. Solano, N.N. Hegade
240
240
  Efficient DCQO Algorithm within the Impulse Regime for Portfolio Optimization
241
241
  [arxiv:2308.15475](https://arxiv.org/abs/2308.15475)
242
242
 
243
+ A. Anand, K. Brown
244
+ Hamiltonians, groups, graphs and ansätze
245
+ [arxiv:2312.17146](https://arxiv.org/abs/2312.17146)
246
+
247
+ P.W.K. Jensen, E.R. Kjellgren, P. Reinholdt, K.M. Ziems, S. Coriani, J. Kongsted, S. Sauer
248
+ Quantum Equation of Motion with Orbital Optimization for Computing Molecular Properties in Near-Term Quantum Computing
249
+ [arxiv:2312.12386](https://arxiv.org/abs/2312.12386)
250
+
243
251
  Let us know, if you want your research project and/or tutorial to be included in this list!
244
252
 
245
253
  # Dependencies
246
- Support for additional optimizers or quantum backends can be activated by intalling them in your environment.
247
- Tequila will then detect them automatically.
248
- Currently those are: [Phoenics](https://github.com/aspuru-guzik-group/phoenics)
249
- and [GPyOpt](https://sheffieldml.github.io/GPyOpt/).
250
- Quantum backends are treated in the same way.
254
+ Support for specific backends (quantum simulators, optimizers, quantum chemistry) can be activated by intalling them in your environment.
251
255
 
252
256
  ## Quantum Backends
253
257
  Currently supported
@@ -267,7 +271,7 @@ Currently supported
267
271
  ### [Psi4](https://github.com/psi4/psi4).
268
272
  In a conda environment this can be installed with
269
273
  ```bash
270
- conda install psi4 -c psi4
274
+ conda install psi4 -c conda-forge
271
275
  ```
272
276
  Here is a small [tutorial](https://nbviewer.org/github/tequilahub/tequila-tutorials/blob/main/chemistry/ChemistryModule.ipynb) that illustrates the usage.
273
277
 
@@ -381,5 +385,3 @@ Tequila runs on Mac OSX.
381
385
  You might get in trouble with installing qulacs since it currently does not work with Apple's clang compiler.
382
386
  You need to install latest GNU compile (at least gcc-7 and g++7) and set them as default before installing qulacs over pip.
383
387
 
384
- ## Qibo and GPyOpt
385
- Currently you can't use Qibo and GPyOpt within the same environment.
@@ -940,7 +940,7 @@ def QubitExcitation(angle: typing.Union[numbers.Real, Variable, typing.Hashable]
940
940
  except:
941
941
  raise Exception("QubitExcitation: Needs an even number of targets")
942
942
 
943
- return QCircuit.wrap_gate(QubitExcitationImpl(angle=angle, target=target, assume_real=assume_real, compile_options=compile_options))
943
+ return QCircuit.wrap_gate(QubitExcitationImpl(angle=angle, target=target, assume_real=assume_real, compile_options=compile_options, control=control))
944
944
 
945
945
 
946
946
  """
@@ -313,19 +313,33 @@ def parse_command(command: str, custom_gates_map: Dict[str, QCircuit], qregister
313
313
  return apply_custom_gate(custom_circuit=custom_circuit, qregisters_values=qregisters_values)
314
314
 
315
315
  if name in ("x", "y", "z", "h", "cx", "cy", "cz", "ch"):
316
- return QCircuit.wrap_gate(gates.impl.QGateImpl(name=(name[1] if name[0] == 'c' else name).upper(),
317
- control=get_qregister(args[0], qregisters) if name[0] == 'c' else None,
318
- target=get_qregister(args[1 if name[0] == 'c' else 0], qregisters)))
316
+ target = get_qregister(args[0], qregisters)
317
+ control = None
318
+ if name[0].lower() == 'c':
319
+ control = get_qregister(args[0], qregisters)
320
+ target = get_qregister(args[1], qregisters)
321
+ name = name[1]
322
+ G = getattr(gates, name.upper())
323
+ return G(control=control, target=target)
324
+
319
325
  if name in ("ccx", "ccy", "ccz"):
320
- return QCircuit.wrap_gate(gates.impl.QGateImpl(name=name.upper()[2],
321
- control=[get_qregister(args[0], qregisters), get_qregister(args[1], qregisters)],
322
- target=get_qregister(args[2], qregisters)))
326
+ G = getattr(gates, name[2].upper())
327
+ control = [get_qregister(args[0], qregisters), get_qregister(args[1], qregisters)]
328
+ target = get_qregister(args[2], qregisters)
329
+ return G(control=control, target=target)
330
+
323
331
  if name.startswith("rx(") or name.startswith("ry(") or name.startswith("rz(") or \
324
332
  name.startswith("crx(") or name.startswith("cry(") or name.startswith("crz("):
325
- return QCircuit.wrap_gate(gates.impl.RotationGateImpl(axis=name[2 if name[0] == 'c' else 1],
326
- angle=get_angle(name)[0],
327
- control=get_qregister(args[0], qregisters) if name[0] == 'c' else None,
328
- target=get_qregister(args[1 if name[0] == 'c' else 0], qregisters)))
333
+ angle = get_angle(name)[0]
334
+ i = name.find('(')
335
+ name = name[0:i]
336
+ name = name.upper()
337
+ name = [x for x in name]
338
+ name[-1] = name[-1].lower()
339
+ name = "".join(name)
340
+ G = getattr(gates, name)
341
+ return G(angle=angle,control=get_qregister(args[0], qregisters) if name[0] == 'C' else None,target=get_qregister(args[1 if name[0] == 'C' else 0], qregisters))
342
+
329
343
  if name.startswith("U("):
330
344
  angles = get_angle(name)
331
345
  return gates.U(theta=angles[0], phi=angles[1], lambd=angles[2],
@@ -362,7 +376,7 @@ def parse_command(command: str, custom_gates_map: Dict[str, QCircuit], qregister
362
376
  control=get_qregister(args[0], qregisters),
363
377
  target=get_qregister(args[1], qregisters))
364
378
  if name in ("s", "t", "sdg", "tdg"):
365
- g = gates.Phase(pi / (2 if name.startswith("s") else 4),
379
+ g = gates.Phase(angle=pi / (2 if name.startswith("s") else 4),
366
380
  control=None,
367
381
  target=get_qregister(args[0], qregisters))
368
382
  if name.find("dg") != -1:
@@ -224,7 +224,7 @@ def export_to(circuit,
224
224
  'always_use_generators': True,
225
225
  'group_together': "BARRIER"
226
226
  }
227
- elif not hasattr("style", "items"):
227
+ elif not hasattr(style, "items"):
228
228
  raise Exception(
229
229
  "style needs to be `tequila`, or `standard` or `generators` or a dictionary, you gave: {}".format(
230
230
  str(style)))
@@ -26,7 +26,7 @@ class BinaryHamiltonian:
26
26
  del Hof.terms[()]
27
27
  hamiltonian = QubitHamiltonian.from_openfermion(Hof)
28
28
  if n_qubits is None:
29
- n_qubits = hamiltonian.n_qubits
29
+ n_qubits = max(hamiltonian.qubits)+1
30
30
  binary_terms = [
31
31
  BinaryPauliString(
32
32
  p.binary(n_qubits).binary,
@@ -95,6 +95,8 @@ def Molecule(geometry: str = None,
95
95
  if backend is None:
96
96
  if basis_set is None or basis_set.lower() in ["madness", "mra", "pno"]:
97
97
  backend = "madness"
98
+ basis_set = "mra"
99
+ parameters.basis_set = basis_set
98
100
  if orbital_type is not None and orbital_type.lower() not in ["pno", "mra-pno"]:
99
101
  warnings.warn("only PNOs supported as orbital_type without basis set. Setting to pno - You gave={}".format(orbital_type), TequilaWarning)
100
102
  orbital_type = "pno"
@@ -2,12 +2,12 @@ import os
2
2
  import typing
3
3
  import warnings
4
4
  from dataclasses import dataclass
5
-
5
+ from copy import deepcopy
6
+ from numbers import Real
6
7
  import numpy
7
8
 
8
- from tequila import BitString, QCircuit, TequilaException
9
+ from tequila import BitString, QCircuit, TequilaException,Variable,compile_circuit
9
10
  from tequila.circuit import gates
10
-
11
11
  try:
12
12
  from openfermion.ops.representations import get_active_space_integrals # needs openfermion 1.3
13
13
  except ImportError as E:
@@ -50,16 +50,132 @@ class FermionicGateImpl(gates.QubitExcitationImpl):
50
50
  self._name = "FermionicExcitation"
51
51
  self.transformation = transformation
52
52
  self.indices = indices
53
-
53
+ if not hasattr(indices[0],"__len__"):
54
+ self.indices = [(indices[2 * i], indices[2 * i+1]) for i in range(len(indices) // 2)]
55
+ self.sign = self.format_excitation_variables(self.indices)
56
+ self.indices = self.format_excitation_indices(self.indices)
54
57
  def compile(self, *args, **kwargs):
55
58
  if self.is_convertable_to_qubit_excitation():
56
59
  target = []
57
60
  for x in self.indices:
58
61
  for y in x:
59
62
  target.append(y)
60
- return gates.QubitExcitation(target=target, angle=-self.parameter, control=self.control)
63
+ return gates.QubitExcitation(target=target, angle=self.parameter, control=self.control)
61
64
  else:
62
- return gates.Trotterized(generator=self.generator, control=self.control, angle=self.parameter, steps=1)
65
+ if self.transformation.lower().strip("_") == "jordanwigner":
66
+ return self.fermionic_excitation(angle=self.sign*self.parameter, indices=self.indices, control=self.control,opt=False)
67
+ else:
68
+ return gates.Trotterized(generator=self.generator, control=self.control, angle=self.parameter, steps=1)
69
+ def format_excitation_indices(self, idx):
70
+ """
71
+ Consistent formatting of excitation indices
72
+ idx = [(p0,q0),(p1,q1),...,(pn,qn)]
73
+ sorted as: p0<p1<pn and pi<qi
74
+ :param idx: list of index tuples describing a single(!) fermionic excitation
75
+ :return: list of index tuples
76
+ """
77
+
78
+ idx = [tuple(sorted(x)) for x in idx]
79
+ idx = sorted(idx, key=lambda x: x[0])
80
+ return list(idx)
81
+ def format_excitation_variables(self, idx):
82
+ """
83
+ Consistent formatting of excitation variable
84
+ idx = [(p0,q0),(p1,q1),...,(pn,qn)]
85
+ sorted as: pi<qi and p0 < p1 < p2
86
+ :param idx: list of index tuples describing a single(!) fermionic excitation
87
+ :return: sign of the variable with re-ordered indices
88
+ """
89
+ sig = 1
90
+ for pair in idx:
91
+ if pair[1]>pair[0]:
92
+ sig *= -1
93
+ for pair in range(len(idx)-1):
94
+ if idx[pair+1][0]>idx[pair][0]:
95
+ sig *= -1
96
+ return sig
97
+ def cCRy(self, target: int, dcontrol: typing.Union[list, int], control: typing.Union[list, int],
98
+ angle: typing.Union[Real, Variable, typing.Hashable], case: int = 1) -> QCircuit:
99
+ '''
100
+ Compilation of CRy as on https://doi.org/10.1103/PhysRevA.102.062612
101
+ If not control passed, Ry returned
102
+ Parameters
103
+ ----------
104
+ case: if 1 employs eq. 12 from the paper, if 0 eq. 13
105
+ '''
106
+ if control is not None and not len(control):
107
+ control = None
108
+ if isinstance(dcontrol, int):
109
+ dcontrol = [dcontrol]
110
+ if not len(dcontrol):
111
+ return compile_circuit(gates.Ry(angle=angle, target=target, control=control))
112
+ else:
113
+ if isinstance(angle, str):
114
+ angle = Variable(angle)
115
+ U = QCircuit()
116
+ aux = dcontrol[0]
117
+ ctr = deepcopy(dcontrol)
118
+ ctr.pop(0)
119
+ if case:
120
+ U += self.cCRy(target=target, dcontrol=ctr, angle=angle / 2, case=1, control=control) + gates.H(
121
+ aux) + gates.CNOT(target, aux)
122
+ U += self.cCRy(target=target, dcontrol=ctr, angle=-angle / 2, case=0, control=control) + gates.CNOT(
123
+ target, aux) + gates.H(aux)
124
+ else:
125
+ U += gates.H(aux) + gates.CNOT(target, aux) + self.cCRy(target=target, dcontrol=ctr, angle=-angle / 2,
126
+ case=0, control=control)
127
+ U += gates.CNOT(target, aux) + gates.H(aux) + self.cCRy(target=target, dcontrol=ctr, angle=angle / 2,
128
+ case=1, control=control)
129
+ return U
130
+
131
+ def fermionic_excitation(self, angle: typing.Union[Real, Variable, typing.Hashable], indices: typing.List,
132
+ control: typing.Union[int, typing.List] = None, opt: bool = True) -> QCircuit:
133
+ '''
134
+ Excitation [(i,j),(k,l)],... compiled following https://doi.org/10.1103/PhysRevA.102.062612
135
+ opt: whether to optimized CNOT H CNOT --> Rz Rz CNOT Rz
136
+ '''
137
+ lto = []
138
+ lfrom = []
139
+ if isinstance(indices,tuple) and not hasattr(indices[0],"__len__"):
140
+ indices = [(indices[2 * i], indices[2 * i + 1]) for i in range(len(indices) // 2)]
141
+ for pair in indices:
142
+ lfrom.append(pair[0])
143
+ lto.append(pair[1])
144
+ Upair = QCircuit()
145
+ if isinstance(angle, str) or isinstance(angle, tuple):
146
+ angle = Variable(angle)
147
+ for i in range(len(lfrom) - 1):
148
+ Upair += gates.CNOT(lfrom[i + 1], lfrom[i])
149
+ Upair += gates.CNOT(lto[i + 1], lto[i])
150
+ Upair += gates.X(lto[i]) + gates.X(lfrom[i])
151
+ Upair += gates.CNOT(lto[-1], lfrom[-1])
152
+ crt = lfrom[::-1] + lto
153
+ Uladder = QCircuit()
154
+ pairs = lfrom + lto
155
+ pairs.sort()
156
+ orbs = []
157
+ for o in range(len(pairs) // 2):
158
+ orbs += [*range(pairs[2 * o] + 1, pairs[2 * o + 1])]
159
+ if len(orbs):
160
+ for o in range(len(orbs) - 1):
161
+ Uladder += gates.CNOT(orbs[o], orbs[o + 1])
162
+ Uladder += compile_circuit(gates.CZ(orbs[-1], lto[-1]))
163
+ crt.pop(-1)
164
+ if control is not None and (isinstance(control, int) or len(control) == 1):
165
+ if isinstance(control, int):
166
+ crt.append(control)
167
+ else:
168
+ crt = crt + control
169
+ control = []
170
+ Ur = self.cCRy(target=lto[-1], dcontrol=crt, angle=angle, control=control)
171
+ Upair2 = Upair.dagger()
172
+ if opt:
173
+ Ur.gates.pop(-1)
174
+ Ur.gates.pop(-1)
175
+ Upair2.gates.pop(0)
176
+ Ur += gates.Rz(numpy.pi / 2, target=lto[-1]) + gates.Rz(-numpy.pi / 2, target=lfrom[-1])
177
+ Ur += gates.CNOT(lto[-1], lfrom[-1]) + gates.Rz(numpy.pi / 2, target=lfrom[-1]) + gates.H(lfrom[-1])
178
+ return Upair + Uladder + Ur + Uladder.dagger() + Upair2
63
179
 
64
180
  def __str(self):
65
181
  if self.indices is not None:
@@ -804,20 +920,18 @@ class IntegralManager:
804
920
  _one_body_integrals: numpy.ndarray = None
805
921
  _two_body_integrals: NBodyTensor = None
806
922
  _constant_term: float = None
807
- _basis_type: str = "unknown"
808
923
  _basis_name: str = "unknown"
809
924
  _orbital_type: str = "unknown" # e.g. "HF", "PNO", "native"
810
925
  _orbital_coefficients: numpy.ndarray = None
811
926
  _active_space: ActiveSpaceData = None
812
927
  _orbitals: typing.List[OrbitalData] = None
813
928
 
814
- def __init__(self, one_body_integrals, two_body_integrals, basis_type="custom",
929
+ def __init__(self, one_body_integrals, two_body_integrals,
815
930
  basis_name="unknown", orbital_type="unknown",
816
931
  constant_term=0.0, orbital_coefficients=None, active_space=None, overlap_integrals=None, orbitals=None, *args, **kwargs):
817
932
  self._one_body_integrals = one_body_integrals
818
933
  self._two_body_integrals = two_body_integrals
819
934
  self._constant_term = constant_term
820
- self._basis_type = basis_type
821
935
  self._basis_name = basis_name
822
936
  self._orbital_type = orbital_type
823
937
 
@@ -956,9 +1070,16 @@ class IntegralManager:
956
1070
  """
957
1071
  c = self.get_orthonormalized_orbital_coefficients()
958
1072
  self.orbital_coefficients=c
959
- self._orbital_type="orthonormalized-{}-basis".format(self._orbital_type)
1073
+ self._orbital_type="orthonormalized-{}-basis".format(self._basis_name)
1074
+
1075
+ def is_unitary(self, U):
1076
+ if len(U.shape) != 2: return False
1077
+ if U.shape[0] != U.shape[1]: return False
1078
+ test = (U.conj().T).dot(U) - numpy.eye(U.shape[0])
1079
+ if not numpy.isclose(numpy.linalg.norm(test), 0.0): return False
1080
+ return True
960
1081
 
961
- def transform_orbitals(self, U):
1082
+ def transform_orbitals(self, U, name=None):
962
1083
  """
963
1084
  Transform orbitals
964
1085
  Parameters
@@ -969,10 +1090,12 @@ class IntegralManager:
969
1090
  -------
970
1091
  updates the structure with new orbitals: c = cU
971
1092
  """
972
- c = self.orbital_coefficients
973
- c = numpy.einsum("ix, xj -> ij", c, U, optimize="greedy")
974
- self.orbital_coefficients = c
975
- self._orbital_type += "-transformed"
1093
+ assert self.is_unitary(U)
1094
+ self.orbital_coefficients = numpy.einsum("ix, xj -> ij", self.orbital_coefficients, U, optimize="greedy")
1095
+ if name is None:
1096
+ self._orbital_type += "-transformed"
1097
+ else:
1098
+ self._orbital_type = name
976
1099
 
977
1100
  def get_integrals(self, orbital_coefficients=None, ordering="openfermion", ignore_active_space=False, *args, **kwargs):
978
1101
  """
@@ -1001,7 +1124,9 @@ class IntegralManager:
1001
1124
  active_integrals = get_active_space_integrals(one_body_integrals=h, two_body_integrals=g,
1002
1125
  occupied_indices=self._active_space.frozen_reference_orbitals,
1003
1126
  active_indices=self._active_space.active_orbitals)
1127
+
1004
1128
  c = active_integrals[0] + c
1129
+
1005
1130
  h = active_integrals[1]
1006
1131
  g = NBodyTensor(elems=active_integrals[2], ordering="openfermion")
1007
1132
  g.reorder(to=ordering)
@@ -1069,14 +1194,16 @@ class IntegralManager:
1069
1194
  result += str(x) + "\n"
1070
1195
  return result
1071
1196
 
1072
- def print_basis_info(self, *args, **kwargs) -> None:
1073
- print("{:15} : {}".format("basis_type", self._basis_type), *args, **kwargs)
1197
+ def print_basis_info(self, print_coefficients=True, *args, **kwargs) -> None:
1074
1198
  print("{:15} : {}".format("basis_name", self._basis_name), *args, **kwargs)
1075
1199
  print("{:15} : {}".format("orbital_type", self._orbital_type), *args, **kwargs)
1076
- print("{:15} : {}".format("orthogonal", self.basis_is_orthogonal()), *args, **kwargs)
1077
- print("{:15} : {}".format("functions", self.one_body_integrals.shape[0]), *args, **kwargs)
1200
+ print("{:15} : {}".format("orthogonal basis", self.basis_is_orthogonal()), *args, **kwargs)
1201
+ print("{:15} : {}".format("basis functions", self.one_body_integrals.shape[0]), *args, **kwargs)
1202
+ print("{:15} : {}".format("active orbitals", [o.idx_total for o in self.active_orbitals]), *args, **kwargs)
1078
1203
  print("{:15} : {}".format("reference", [x.idx_total for x in self.reference_orbitals]), *args, **kwargs)
1079
1204
 
1205
+ if not print_coefficients: return
1206
+
1080
1207
  print("Current Orbitals", *args, **kwargs)
1081
1208
  for i,x in enumerate(self.orbitals):
1082
1209
  print(x, *args, **kwargs)