forked from qcware/platform_client_library_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphysics.py
More file actions
51 lines (43 loc) · 1.54 KB
/
physics.py
File metadata and controls
51 lines (43 loc) · 1.54 KB
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
41
42
43
44
45
46
47
48
49
50
51
from . import request
def mat_to_dict(mat):
the_dict = {}
for i in range(mat.shape[0]):
for j in range(mat.shape[1]):
the_dict[(i, j)] = mat[i, j]
Q_new = {}
for it in the_dict.keys():
val_loop = the_dict[it]
if (it[1], it[0]) in the_dict.keys() and it[1] != it[0] and it[1] > it[0]:
val_loop += the_dict[(it[1], it[0])]
Q_new[it] = val_loop
elif it[1] == it[0]:
Q_new[it] = the_dict[it]
return Q_new
# VQE call
def find_ground_state_energy(key,
molecule,
basis='sto-3g',
solver='projectq',
multiplicity=1,
charge=0,
sampling=False,
sampling_trials=1000,
guess_amplitudes=None,
initial_state='UCCSD',
minimizer='swarm',
host="https://platform.qcware.com",
):
params = {
"key": key,
"molecule": molecule,
"basis": basis,
"solver": solver,
"multiplicity": multiplicity,
"charge": charge,
"sampling": sampling,
"sampling_trials": sampling_trials,
'guess_amplitudes': guess_amplitudes,
'initial_state': initial_state,
'minimizer': minimizer
}
return request.post(host + "/api/v2/find_ground_state_energy", params, 'VQE')