firecode 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- firecode/TEST_NOTEBOOK.ipynb +3940 -0
- firecode/__init__.py +0 -0
- firecode/__main__.py +118 -0
- firecode/_gaussian.py +97 -0
- firecode/algebra.py +405 -0
- firecode/ase_manipulations.py +879 -0
- firecode/atropisomer_module.py +516 -0
- firecode/automep.py +130 -0
- firecode/calculators/__init__.py +29 -0
- firecode/calculators/_gaussian.py +98 -0
- firecode/calculators/_mopac.py +242 -0
- firecode/calculators/_openbabel.py +154 -0
- firecode/calculators/_orca.py +129 -0
- firecode/calculators/_xtb.py +786 -0
- firecode/concurrent_test.py +119 -0
- firecode/embedder.py +2590 -0
- firecode/embedder_options.py +577 -0
- firecode/embeds.py +881 -0
- firecode/errors.py +65 -0
- firecode/graph_manipulations.py +333 -0
- firecode/hypermolecule_class.py +364 -0
- firecode/mep_relaxer.py +199 -0
- firecode/modify_settings.py +186 -0
- firecode/mprof.py +65 -0
- firecode/multiembed.py +148 -0
- firecode/nci.py +186 -0
- firecode/numba_functions.py +260 -0
- firecode/operators.py +776 -0
- firecode/optimization_methods.py +609 -0
- firecode/parameters.py +84 -0
- firecode/pka.py +275 -0
- firecode/profiler.py +17 -0
- firecode/pruning.py +421 -0
- firecode/pt.py +32 -0
- firecode/quotes.json +6651 -0
- firecode/quotes.py +9 -0
- firecode/reactive_atoms_classes.py +666 -0
- firecode/references.py +11 -0
- firecode/rmsd.py +74 -0
- firecode/settings.py +75 -0
- firecode/solvents.py +126 -0
- firecode/tests/C2F2H4.xyz +10 -0
- firecode/tests/C2H4.xyz +8 -0
- firecode/tests/CH3Cl.xyz +7 -0
- firecode/tests/HCOOH.xyz +7 -0
- firecode/tests/HCOOOH.xyz +8 -0
- firecode/tests/chelotropic.txt +3 -0
- firecode/tests/cyclical.txt +3 -0
- firecode/tests/dihedral.txt +2 -0
- firecode/tests/string.txt +3 -0
- firecode/tests/trimolecular.txt +9 -0
- firecode/tests.py +151 -0
- firecode/torsion_module.py +1035 -0
- firecode/utils.py +541 -0
- firecode-1.0.0.dist-info/LICENSE +165 -0
- firecode-1.0.0.dist-info/METADATA +321 -0
- firecode-1.0.0.dist-info/RECORD +59 -0
- firecode-1.0.0.dist-info/WHEEL +5 -0
- firecode-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
3
|
+
from time import perf_counter
|
|
4
|
+
|
|
5
|
+
import plotext as plt
|
|
6
|
+
|
|
7
|
+
from firecode.calculators._xtb import xtb_opt
|
|
8
|
+
from firecode.utils import read_xyz, time_to_string, timing_wrapper
|
|
9
|
+
|
|
10
|
+
procs_set = {
|
|
11
|
+
'GFN-FF' : (1, 2, 4, 8),
|
|
12
|
+
'GFN2-XTB' : (4, 8, 12, 16, 32, 48),
|
|
13
|
+
# 'AIMNET2' : (1, 2, 4, 8, 12),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# from aimnet2_firecode.interface import aimnet2_worker
|
|
17
|
+
# import torch
|
|
18
|
+
|
|
19
|
+
threads_set = {1, 2,
|
|
20
|
+
4, 6, 8,
|
|
21
|
+
12, 16, 32, 48,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def run_concurrent_test(filename):
|
|
25
|
+
'''
|
|
26
|
+
Run geometry opitmizations on filename with various
|
|
27
|
+
processors and threads settings to determine the best
|
|
28
|
+
configuration to use in productive runs.
|
|
29
|
+
|
|
30
|
+
'''
|
|
31
|
+
|
|
32
|
+
data = read_xyz(filename)
|
|
33
|
+
|
|
34
|
+
cpus = len(os.sched_getaffinity(0))
|
|
35
|
+
# device = 'gpu' if torch.cuda.is_available() else 'cpu'
|
|
36
|
+
|
|
37
|
+
# In case there are more than 48 CPUs
|
|
38
|
+
threads_set.add(cpus)
|
|
39
|
+
|
|
40
|
+
print(f'--> Detected {cpus} CPUs (considering hyperthreading)')
|
|
41
|
+
|
|
42
|
+
for method in procs_set.keys():
|
|
43
|
+
print(f'\nStarting {method} test...')
|
|
44
|
+
|
|
45
|
+
timings = {p:[] for p in procs_set[method]}
|
|
46
|
+
thread_info = {p:[] for p in procs_set[method]}
|
|
47
|
+
best_avg_time = 1E8
|
|
48
|
+
best_settings = None
|
|
49
|
+
|
|
50
|
+
for procs in reversed(procs_set[method]):
|
|
51
|
+
for threads in threads_set:
|
|
52
|
+
|
|
53
|
+
# only run test if we are using between 50% and 100% of cpu resources
|
|
54
|
+
if cpus/2 <= procs * threads <= cpus:
|
|
55
|
+
|
|
56
|
+
processes = []
|
|
57
|
+
cum_exec_time = 0
|
|
58
|
+
# gpu_rank = i % threads if device == 'gpu' else None
|
|
59
|
+
|
|
60
|
+
with ProcessPoolExecutor(max_workers=threads) as executor:
|
|
61
|
+
|
|
62
|
+
t_start_batch = perf_counter()
|
|
63
|
+
|
|
64
|
+
for i in range(threads):
|
|
65
|
+
|
|
66
|
+
p = executor.submit(
|
|
67
|
+
timing_wrapper,
|
|
68
|
+
xtb_opt,
|
|
69
|
+
# aimnet2_worker,
|
|
70
|
+
data.atomcoords[0],
|
|
71
|
+
data.atomnos,
|
|
72
|
+
method=method,
|
|
73
|
+
solvent='THF',
|
|
74
|
+
procs=procs,
|
|
75
|
+
# maxiter=1000,
|
|
76
|
+
conv_thr="tight",
|
|
77
|
+
title=f'Candidate_{i}',
|
|
78
|
+
# cuda=(device=='gpu'),
|
|
79
|
+
# gpu_rank=gpu_rank,
|
|
80
|
+
)
|
|
81
|
+
processes.append(p)
|
|
82
|
+
|
|
83
|
+
for i, process in enumerate(as_completed(processes)):
|
|
84
|
+
_, elapsed = process.result()
|
|
85
|
+
cum_exec_time += elapsed
|
|
86
|
+
|
|
87
|
+
t_end_batch = perf_counter()
|
|
88
|
+
elapsed = t_end_batch-t_start_batch
|
|
89
|
+
avg = elapsed/threads
|
|
90
|
+
timings[procs].append(avg)
|
|
91
|
+
thread_info[procs].append(threads)
|
|
92
|
+
|
|
93
|
+
speedup = cum_exec_time/elapsed
|
|
94
|
+
if avg < best_avg_time:
|
|
95
|
+
best_avg_time = avg
|
|
96
|
+
best_settings = (procs, threads)
|
|
97
|
+
|
|
98
|
+
print(f'{method} --> {procs:2} cores/process, {threads:2} threads ({round(speedup, 2):6}x speedup) : {time_to_string(elapsed/threads, digits=3):10} per structure')
|
|
99
|
+
|
|
100
|
+
plt.theme("pro")
|
|
101
|
+
plt.title(method)
|
|
102
|
+
# plt.plotsize(75,15)
|
|
103
|
+
x, y =[], []
|
|
104
|
+
for procs in procs_set[method]:
|
|
105
|
+
times = timings.get(procs, None)
|
|
106
|
+
if times is not None:
|
|
107
|
+
for thread, time in zip(thread_info[procs], times):
|
|
108
|
+
x.append(f'{procs:2}c/{thread}t') # for procs, thread in zip(procs, thread_info[procs])],
|
|
109
|
+
y.append(round(time, 3))
|
|
110
|
+
|
|
111
|
+
plt.simple_bar(x, y, width=90, color='red', title=f'{filename}/{method}')
|
|
112
|
+
|
|
113
|
+
# plt.xticks(ticks=set(flatten(thread_info.values(), typefunc=int)))
|
|
114
|
+
plt.xlabel("# Threads")
|
|
115
|
+
plt.ylabel("Time per structure (s)")
|
|
116
|
+
plt.show()
|
|
117
|
+
plt.cld()
|
|
118
|
+
|
|
119
|
+
print(f'\n--> Suggested settings for {method}: {best_settings[0]} cores, {best_settings[1]} threads')
|