forked from chunfuchen/aqua-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdictinput.py
40 lines (37 loc) · 1.75 KB
/
dictinput.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
# Copyright 2018 IBM.
#
# 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 qiskit_acqua_chemistry
# An example of using a loop to vary inter-atomic distance. A dictionary is
# created outside the loop, but inside the loop the 'atom' value is updated
# with a new molecular configuration. The molecule is H2 and its inter-atomic distance
# i.e the distance between the two atoms, is altered from 0.5 to 1.0. Each atom is
# specified by x, y, z coords and the atoms are set on the z-axis, equidistant from
# the origin, and updated by d inside the loop where the molecule string has this value
# substituted by format(). Note the negative sign preceding the first format
# substitution point i.e. the {} brackets
#
input_dict = {
'driver': {'name': 'PYSCF'},
'PYSCF': {'atom': None, 'unit': 'Angstrom', 'charge': 0, 'spin': 0, 'basis': 'sto3g'},
'algorithm': {'name': 'ExactEigensolver'},
}
molecule = 'H .0 .0 -{0}; H .0 .0 {0}'
for i in range(21):
d = (0.5 + i*0.5/20)/2
input_dict['PYSCF']['atom'] = molecule.format(d)
solver = qiskit_acqua_chemistry.ACQUAChemistry()
result = solver.run(input_dict)
print('{:.4f} : {}'.format(d*2, result['energy']))