-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardcode.py
More file actions
77 lines (61 loc) · 2.1 KB
/
Copy pathhardcode.py
File metadata and controls
77 lines (61 loc) · 2.1 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
''' Write your links and so on here '''
GULP_EXE = '/Users/cmdc2-extra/Work/gulp-4.4/Src/gulp'
PLUMED_EXE = '/Users/cmdc2-extra/Work/Plumed/plumed2-master/src/lib/plumed'
CIF_FILE_DIRECTORY = '/Users/cmdc2-extra/Work/icsdFiles/'
hartrees2eV = 27.211396132
bohr2angstrom = 0.52917724900001
def timeStringToFloat(s):
''' Won't do anything that isn't number + string '''
seconds = {'f': 1.e-15,
'p': 1.e-12,
'n': 1.e-9,
's': 1.,
'm': 60.,
'h': 60.**2.,
'd': 24.* 60.**2.,
'w': 7. * 24. * 60.**2.}
return float(s[:-1]) * seconds[s[-1].lower()]
def dateString():
import time
digits = time.strftime("%x").split('/')
return digits[1] + digits[0] + digits[2]
def groupIntegers(listIn, returnString = True):
''' E.g. if you want to return the numbers of the atoms in some list '''
from itertools import groupby
from operator import itemgetter
for k, g in groupby(enumerate(listIn), lambda (i, x): i-x):
if returnString:
#possibly need to save this as another object if using more than once???
myList = map(itemgetter(1),g)
return ",".join([str(min(myList)) + "-" + str(max(myList))])
else:
return map(itemgetter(1), g)
#### DO THIS ANOTHER TIME IF NEEDED
#def fractionalStoichiometryByWeight(components, returnOrderedDict = True):
# ''' input is dictionary, e.g. {['LiV']: 20., ['BO2']: 80.}
# output is dictionary of each element and also its stoichiometry '''
# for i,j in components.items():
#sum fractions to 1.
# assert(abs(sum([x[1] for x in speciesFraction.items()]) - 1.) < 0.0001)
# if returnOrderedDict:
# from collections import OrderedDict
# return
# else:
# return stoichiometryDict
atomicValenceElectrons = {
'H' : 1,
'Li': 1,
'O' : 6,
'P' : 5,
'Ti': 4
}
# N.B. only use default charges for very quick tests etc- specify for MD and GULP
defaultCharges = {
'Al': 3.,
'B' : 3.,
'O' : -2.,
'Li': 1.,
'Ti': 4.,
'V' : 5.,
'P' : 5.,
}