Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit 93d5d2a

Browse files
committed
Fix 2 bugs, rename tilde.sh to tilde, refactor
1 parent ea0d978 commit 93d5d2a

File tree

7 files changed

+56
-31
lines changed

7 files changed

+56
-31
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ Run ```pip install -r requirements.txt``` to install Python dependencies.
2525
Finally, ensure if the framework is ready:
2626

2727
```shell
28-
./utils/tilde.sh -x
28+
./utils/tilde -x
2929
```
3030

3131
Additionally, installation is covered in [this blog post](https://blog.tilde.pro/simple-ab-initio-materials-data-mining-tutorial-6127c777dabc).
3232

3333
## Usage
3434

3535
```shell
36-
./utils/tilde.sh --help
36+
./utils/tilde --help
3737
```
3838

3939
For example, to scan folder(s) recursively (**-r**), with terse print (**-t**), showing information on calculation metadata (**-i**) and convergence (**-v**) and adding results to a database (**-a**):
4040

4141
```shell
42-
./utils/tilde.sh /home/user/work1 /home/work2 -r -t -v -a -i
42+
./utils/tilde /home/user/work1 /home/work2 -r -t -v -a -i
4343
```
4444

4545
Other example: for the perovskite structures (shipped with Tilde), extract the distortion of the MO6-octahedra wrt cubic phase (in Euler angles). Here the **-m** switch invokes **perovskite_tilting** module (see **apps** folder):
4646

4747
```shell
48-
./utils/tilde.sh tilde/tests/apps/perovskite_tilting/outputs -m perovskite_tilting
48+
./utils/tilde tilde/tests/apps/perovskite_tilting/outputs -m perovskite_tilting
4949
```
5050

5151
## GUI

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@
6666
'futures',
6767
'httplib2',
6868
'quantum_esperanto',
69-
'pycrystal'
69+
'pycrystal >= 1.0.2'
7070
]
7171

7272
setup(
7373
name='tilde',
74-
version='0.9.2',
74+
version='0.9.3',
7575
description='Materials informatics framework for ab initio data repositories',
7676
long_description=long_description,
7777
url='https://github.com/tilde-lab/tilde',
@@ -87,10 +87,10 @@
8787
'Programming Language :: Python :: 2',
8888
'Programming Language :: Python :: 2.7',
8989
'Programming Language :: Python :: 3',
90-
'Programming Language :: Python :: 3.4',
9190
'Programming Language :: Python :: 3.5',
9291
'Programming Language :: Python :: 3.6',
93-
'Programming Language :: Python :: 3.7'
92+
'Programming Language :: Python :: 3.7',
93+
'Programming Language :: Python :: 3.8'
9494
],
9595
keywords='CRYSTAL Quantum-ESPRESSO VASP ab-initio materials informatics first-principles',
9696
packages=packages,
@@ -99,7 +99,8 @@
9999
tests_require= ['nose',],
100100
test_suite='nose.collector',
101101
scripts=[
102-
"utils/tilde.sh",
103-
"utils/entry.py"
102+
"utils/tilde",
103+
"utils/entry.py",
104+
"utils/gui_server.py"
104105
]
105106
)

tilde/core/common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def cmp_e_conv(vals):
117117

118118
def generate_cif(structure, comment=None, symops=['+x,+y,+z']):
119119
parameters = cell_to_cellpar(structure.cell)
120+
120121
cif_data = "# " + comment + "\n\n" if comment else ''
121122
cif_data += 'data_tilde_project\n'
122123
cif_data += '_cell_length_a ' + "%2.6f" % parameters[0] + "\n"
@@ -125,19 +126,21 @@ def generate_cif(structure, comment=None, symops=['+x,+y,+z']):
125126
cif_data += '_cell_angle_alpha ' + "%2.6f" % parameters[3] + "\n"
126127
cif_data += '_cell_angle_beta ' + "%2.6f" % parameters[4] + "\n"
127128
cif_data += '_cell_angle_gamma ' + "%2.6f" % parameters[5] + "\n"
128-
cif_data += "_symmetry_space_group_name_H-M 'P1'" + "\n"
129+
cif_data += "_symmetry_space_group_name_H-M 'P1'" + "\n\n"
129130
cif_data += 'loop_' + "\n"
130131
cif_data += '_symmetry_equiv_pos_as_xyz' + "\n"
131132
for i in symops:
132133
cif_data += i + "\n"
133-
cif_data += 'loop_' + "\n"
134+
135+
cif_data += '\nloop_' + "\n"
136+
cif_data += '_atom_site_label' + "\n"
134137
cif_data += '_atom_site_type_symbol' + "\n"
135138
cif_data += '_atom_site_fract_x' + "\n"
136139
cif_data += '_atom_site_fract_y' + "\n"
137140
cif_data += '_atom_site_fract_z' + "\n"
138141
pos = structure.get_scaled_positions()
139142
for n, i in enumerate(structure):
140-
cif_data += "%s % 1.8f % 1.8f % 1.8f\n" % (i.symbol, pos[n][0], pos[n][1], pos[n][2])
143+
cif_data += "%s %s % 1.8f % 1.8f % 1.8f\n" % (i.symbol, i.symbol, pos[n][0], pos[n][1], pos[n][2])
141144
return cif_data
142145

143146
def generate_xyz(atoms):

tilde/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def connect_database(settings, named=None, no_pooling=False, default_actions=Tru
101101
sys.exit(INIT_DATA + ' not found!')
102102

103103
f = open(INIT_DATA)
104-
statements = filter(None, f.read().splitlines())
104+
statements = list(filter(None, f.read().splitlines()))
105105
f.close()
106106

107107
nlines = 0

tilde/parsers/CRYSTAL/CRYSTAL.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def __init__(self, filename):
4141
elif filename.endswith('.out'):
4242
check_files = [filename.replace('.out', '') + '.d12', filename.replace('.out', '') + '.gui']
4343
for check in check_files:
44-
if os.path.exists(os.path.join(cur_folder, check)): self.related_files.append(os.path.join(cur_folder, check))
44+
if os.path.exists(os.path.join(cur_folder, check)):
45+
self.related_files.append(os.path.join(cur_folder, check))
4546

4647
@staticmethod
4748
def fingerprints(test_string):

utils/entry.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@
7171
if args.path or args.targetlist:
7272
finalized = 'YES' if settings['skip_unfinished'] else 'NO'
7373
notests = 'YES' if settings['skip_notenergy'] else 'NO'
74-
print("Only finalized: %s; only with total energy: %s; skip paths if they start/end with any of: %s" % (finalized, notests, settings['skip_if_path']))
74+
print("Only finalized: %s; only with total energy: %s; skip paths if they start/end with any of: %s" %
75+
(finalized, notests, settings['skip_if_path'])
76+
)
7577

7678
if args.path and args.targetlist:
7779
args.targetlist = None
7880
if args.path:
7981
target_source = args.path
8082
if args.targetlist:
81-
if not os.path.exists(args.targetlist): sys.exit("Incorrect file: %s" % args.targetlist)
83+
if not os.path.exists(args.targetlist):
84+
sys.exit("Incorrect file: %s" % args.targetlist)
8285
target_source = (ln.strip() for ln in open(args.targetlist))
8386

8487
# -x option
@@ -100,7 +103,8 @@
100103
output_lines, add_msg = '', ''
101104

102105
if error:
103-
if args.terse and 'was read' in error: continue
106+
if args.terse and 'was read' in error:
107+
continue
104108
print(task, error)
105109
logging.info("%s %s" % (task, error))
106110
continue
@@ -119,16 +123,23 @@
119123
found_topics = []
120124
skip_topics = ['location', 'elements', 'nelem', 'natom', 'spg']
121125
for n, entity in enumerate(work.hierarchy):
122-
if entity['cid'] > 1999 or entity['source'] in skip_topics: continue # apps hierarchy
126+
if entity['cid'] > 1999 or entity['source'] in skip_topics:
127+
continue # apps hierarchy
123128

124129
if entity['multiple']:
125-
try: found_topics.append(
126-
[entity['category']] + [num2name(x, entity, work.hierarchy_values) for x in calc.info[ entity['source'] ]]
127-
)
128-
except KeyError: pass
130+
try:
131+
found_topics.append(
132+
[entity['category']] + [num2name(x, entity, work.hierarchy_values) for x in calc.info[ entity['source'] ]]
133+
)
134+
except KeyError:
135+
pass
129136
else:
130-
try: found_topics.append( [entity['category'], num2name(calc.info.get(entity['source']), entity, work.hierarchy_values)] )
131-
except KeyError: pass
137+
try:
138+
found_topics.append(
139+
[entity['category'], num2name(calc.info.get(entity['source']), entity, work.hierarchy_values)]
140+
)
141+
except KeyError:
142+
pass
132143

133144
j, out = 0, ''
134145
for t in found_topics:
@@ -143,9 +154,16 @@
143154
output_lines += str(calc.convergence) + "\n"
144155
if calc.tresholds:
145156
for i in range(len(calc.tresholds)):
146-
try: ncycles = calc.ncycles[i]
147-
except IndexError: ncycles = ""
148-
output_lines += "%1.2e" % calc.tresholds[i][0] + " "*2 + "%1.5f" % calc.tresholds[i][1] + " "*2 + "%1.4f" % calc.tresholds[i][2] + " "*2 + "%1.4f" % calc.tresholds[i][3] + " "*2 + "E=" + "%1.4f" % calc.tresholds[i][4] + " eV" + " "*2 + "(%s)" % ncycles + "\n"
157+
try:
158+
ncycles = calc.ncycles[i]
159+
except IndexError:
160+
ncycles = "^"
161+
output_lines += "%1.2e" % calc.tresholds[i][0] + " " * 2 + \
162+
"%1.5f" % calc.tresholds[i][1] + " " * 2 + \
163+
"%1.4f" % calc.tresholds[i][2] + " " * 2 + \
164+
"%1.4f" % calc.tresholds[i][3] + " " * 2 + \
165+
"E=" + ("%1.4f" % calc.tresholds[i][4] if calc.tresholds[i][4] else "^") + " eV" + " " * 2 + \
166+
"(%s)" % ncycles + "\n"
149167

150168
# -s option
151169
if args.structures:
@@ -160,8 +178,10 @@
160178

161179
# -c option
162180
if args.cif:
163-
try: calc.structures[ args.cif ]
164-
except IndexError: output_lines += "Warning! Structure "+args.cif+" not found!" + "\n"
181+
try:
182+
calc.structures[args.cif]
183+
except IndexError:
184+
output_lines += "Warning! Structure " + args.cif + " not found!" + "\n"
165185
else:
166186
N = args.cif if args.cif > 0 else len(calc.structures) + 1 + args.cif
167187
comment = calc.info['formula'] + " extracted from " + task + " (structure N " + str(N) + ")"
@@ -173,7 +193,7 @@
173193

174194
# -m option
175195
if args.module:
176-
if args.module == True:
196+
if args.module is True:
177197
calc = work.postprocess(calc, dry_run=True)
178198
output_lines += "Modules to be invoked: " + str([i for i in calc.apps]) + "\n"
179199
else:
File renamed without changes.

0 commit comments

Comments
 (0)