Skip to content

Commit c993d96

Browse files
committed
Remove declarative api from chemistry
1 parent 18e3320 commit c993d96

33 files changed

+156
-908
lines changed

chemistry/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,4 @@ This folder contains some Jupyter Notebook examples showing how to run chemistry
44
Qiskit Chemistry. There are also Python code files too as well as some hdf5 files containing saved
55
molecular data that may be used in experiments.
66

7-
These example programs and notebooks show how to use the dictionary equivalent form of
8-
the [input file](#input-files) that can be used more effectively programmatically when your goal is to
9-
run the content with a range of different values. For example the [energyplot](energyplot.ipynb) notebook
10-
alters the interatomic distance of a molecule, over a range of values, and uses the results to plot graphs.
11-
127
For more detail see the main [index](../index.ipynb#chemistry)
13-
14-
## Input files
15-
16-
The folder [input_files](input_files) contains a number of example input files that can be loaded
17-
and run by the Qiskit Chemistry [GUI](https://github.com/Qiskit/qiskit-chemistry/blob/master/README.md#gui) or by the
18-
[command line](https://github.com/Qiskit/qiskit-chemistry/blob/master/README.md#command-line) tool.

chemistry/beh2_reductions.ipynb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"\n",
1111
"This notebook demonstrates this for Beryllium Dihydride (BeH2) where we show the effect of removing different unoccupied orbitals. We use Qiskit Chemistry to plot graphs of the ground state energy of the Beryllium Dihydride (BeH2) molecule over a range of inter-atomic distances using ExactEigensolver. Freeze core reduction is true and different virtual orbital removals are tried as a comparison.\n",
1212
"\n",
13-
"This notebook populates a dictionary, that is a progammatic representation of an input file, in order to drive the Qiskit Chemistry stack. Such a dictionary can be manipulated programmatically and this is indeed the case here where we alter the molecule supplied to the driver in each loop as well as the orbital reductions.\n",
14-
"\n",
1513
"This notebook has been written to use the PYSCF chemistry driver."
1614
]
1715
},
@@ -102,7 +100,6 @@
102100
" qubit_op, aux_ops = operator.run(qmolecule)\n",
103101
" result = ExactEigensolver(qubit_op).run()\n",
104102
" lines, result = operator.process_algorithm_result(result)\n",
105-
" result['printable'] = lines\n",
106103
" energies[j][i] = result['energy']\n",
107104
" distances[i] = d\n",
108105
"print(' --- complete')\n",
@@ -318,7 +315,6 @@
318315
" qubit_op, aux_ops = operator.run(qmolecule)\n",
319316
" result = ExactEigensolver(qubit_op).run()\n",
320317
" lines, result = operator.process_algorithm_result(result)\n",
321-
" result['printable'] = lines\n",
322318
" e_nofreeze[i] = result['energy']\n",
323319
"\n",
324320
"print(e_nofreeze)"

chemistry/dictinput.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
from qiskit.chemistry.core import Hamiltonian
2121

2222

23-
# An example of using a loop to vary inter-atomic distance. A dictionary is
24-
# created outside the loop, but inside the loop the 'atom' value is updated
23+
# An example of using a loop to vary inter-atomic distance.
24+
# Inside the loop the 'atom' value is updated
2525
# with a new molecular configuration. The molecule is H2 and its inter-atomic distance
2626
# i.e the distance between the two atoms, is altered from 0.5 to 1.0. Each atom is
2727
# specified by x, y, z coords and the atoms are set on the z-axis, equidistant from

chemistry/energyplot.ipynb

Lines changed: 25 additions & 22 deletions
Large diffs are not rendered by default.

chemistry/h2_basis_sets.ipynb

Lines changed: 23 additions & 22 deletions
Large diffs are not rendered by default.

chemistry/h2_excited_states.ipynb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"\n",
1111
"This notebook demonstrates using Qiskit Chemistry to plot graphs of the ground state and excited state energies of the Hydrogen (H2) molecule over a range of inter-atomic distances. This notebook utilizes the fact that when two_qubit_reduction is used with the parity mapping on H2 the resultant hamiltionian solely contains the 4 states we are looking for.\n",
1212
"\n",
13-
"This notebook populates a dictionary, that is a progammatic representation of an input file, in order to drive the Qiskit Chemistry stack. Such a dictionary can be manipulated programmatically and this is indeed the case here where we alter the molecule supplied to the driver in each loop.\n",
14-
"\n",
1513
"This notebook has been written to use the PYSCF chemistry driver."
1614
]
1715
},
@@ -73,8 +71,7 @@
7371
" qubit_op, aux_ops = operator.run(qmolecule)\n",
7472
" result = ExactEigensolver(qubit_op, k=4).run()\n",
7573
" lines, result = operator.process_algorithm_result(result)\n",
76-
" result['printable'] = lines\n",
77-
"\n",
74+
" \n",
7875
" energies[:, i] = result['energies']\n",
7976
" distances[i] = d\n",
8077
"print(' --- complete')\n",

chemistry/h2_mappings.ipynb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"\n",
1111
"This notebook demonstrates using Qiskit Chemistry to plot graphs of the ground state energy of the Hydrogen (H2) molecule over a range of inter-atomic distances with different fermionic mappings to quantum qubits.\n",
1212
"\n",
13-
"This notebook populates a dictionary, that is a progammatic representation of an input file, in order to drive the Qiskit Chemistry stack. Such a dictionary can be manipulated programmatically and this is indeed the case here where we alter the molecule supplied to the driver in each loop.\n",
14-
"\n",
1513
"This notebook has been written to use the PYSCF chemistry driver."
1614
]
1715
},
@@ -79,14 +77,6 @@
7977
"from qiskit.chemistry.drivers import PySCFDriver\n",
8078
"from qiskit.chemistry.core import Hamiltonian, QubitMappingType\n",
8179
"\n",
82-
"# Input dictionary to configure Qiskit Chemistry for the chemistry problem.\n",
83-
"qiskit_chemistry_dict = {\n",
84-
" 'problem': {'random_seed': 50},\n",
85-
" 'driver': {'name': 'PYSCF'},\n",
86-
" 'PYSCF': {'atom': '', 'basis': 'sto3g'},\n",
87-
" 'operator': {'name': 'hamiltonian', 'qubit_mapping': '', 'two_qubit_reduction': False},\n",
88-
" 'algorithm': {'name': ''}\n",
89-
"}\n",
9080
"molecule = 'H .0 .0 -{0}; H .0 .0 {0}'\n",
9181
"\n",
9282
"algorithms = ['VQE', 'ExactEigensolver']\n",
@@ -107,15 +97,6 @@
10797
" print('\\b\\b{:2d}'.format(i), end='', flush=True)\n",
10898
" d = start + i*by/steps \n",
10999
" for j in range(len(algorithms)):\n",
110-
" if algorithms[j] == 'ExactEigensolver':\n",
111-
" if 'optimizer' in qiskit_chemistry_dict:\n",
112-
" del qiskit_chemistry_dict['optimizer']\n",
113-
" if 'variational_form' in qiskit_chemistry_dict:\n",
114-
" del qiskit_chemistry_dict['variational_form']\n",
115-
" else:\n",
116-
" qiskit_chemistry_dict['optimizer'] = {'name': 'L_BFGS_B', 'maxfun': 2500}\n",
117-
" qiskit_chemistry_dict['variational_form'] = {'name': 'RYRZ', 'depth': 5}\n",
118-
" \n",
119100
" for k in range(len(mappings)): \n",
120101
" driver = PySCFDriver(molecule.format(d/2), basis='sto3g')\n",
121102
" qmolecule = driver.run()\n",
@@ -132,7 +113,6 @@
132113
" seed_transpiler=aqua_globals.random_seed))\n",
133114
"\n",
134115
" lines, result = operator.process_algorithm_result(result)\n",
135-
" result['printable'] = lines\n",
136116
" energies[k][j][i] = result['energy']\n",
137117
" hf_energies[i] = result['hf_energy'] # Independent of algorithm & mapping\n",
138118
" distances[i] = d\n",

chemistry/h2_particle_hole.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
" seed_transpiler=aqua_globals.random_seed))\n",
119119
" \n",
120120
" lines, result = operator.process_algorithm_result(result)\n",
121-
" result['printable'] = lines\n",
122121
" energies[k][j][i] = result['energy']\n",
123122
" hf_energies[i] = result['hf_energy']\n",
124123
" if algorithms[j] == 'VQE':\n",

chemistry/h2_swaprz.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
" seed_transpiler=aqua_globals.random_seed))\n",
9797
" \n",
9898
" lines, result = operator.process_algorithm_result(result)\n",
99-
" result['printable'] = lines\n",
10099
" energies[j][i] = result['energy']\n",
101100
" hf_energies[i] = result['hf_energy']\n",
102101
" if algorithms[j] == 'VQE':\n",

chemistry/h2_uccsd.ipynb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"\n",
99
"This notebook demonstrates using Qiskit Chemistry to plot graphs of the ground state energy of the Hydrogen (H2) molecule over a range of inter-atomic distances using VQE and UCCSD. It is compared to the same energies as computed by the ExactEigensolver. `UCCSD` should be used together with `HartreeFock` initial state.\n",
1010
"\n",
11-
"This notebook populates a dictionary, that is a progammatic representation of an input file, in order to drive the Qiskit Chemistry stack. Such a dictionary can be manipulated programmatically and this is indeed the case here where we alter the molecule supplied to the driver in each loop.\n",
12-
"\n",
1311
"This notebook has been written to use the PYQUANTE chemistry driver. See the PYQUANTE chemistry driver readme if you need to install the external PyQuante2 library that this driver requires."
1412
]
1513
},
@@ -100,7 +98,6 @@
10098
" result = algo.run(QuantumInstance(BasicAer.get_backend('statevector_simulator')))\n",
10199
" \n",
102100
" lines, result = operator.process_algorithm_result(result)\n",
103-
" result['printable'] = lines\n",
104101
" energies[j][i] = result['energy']\n",
105102
" hf_energies[i] = result['hf_energy']\n",
106103
" if algorithms[j] == 'VQE':\n",

0 commit comments

Comments
 (0)