-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExVol.py
51 lines (31 loc) · 1.57 KB
/
ExVol.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
41
42
43
44
45
46
47
48
49
50
51
import click
from exvol.input import InputData, read_structure_filename
from exvol.ex_vol import ensure_tracer_is_one_pbc_replica, estimate_excluded_volume
from exvol.messaging import copyright_notice, timestamp
import multiprocessing
from multiprocessing import Pool
from functools import partial
import numpy as np
#-------------------------------------------------------------------------------
@click.command()
@click.argument('input_filename',
type = click.Path( exists = True ))
def main(input_filename):
timestamp( 'Reading input from {} file', input_filename )
i = InputData(input_filename)
timestamp( 'Input data:\n{}', i )
print('You have {0:1d} CPUs'.format(i.input_data["omp_cores"]))
tracer = read_structure_filename(i.input_data["tracer_filename"])
ensure_tracer_is_one_pbc_replica(tracer, i.input_data["box_size"])
crowders = read_structure_filename(i.input_data["crowders_filename"])
pool = Pool(processes=i.input_data["omp_cores"])
estimate_excluded_volume_partial = partial( estimate_excluded_volume, tracer = tracer, crowders = crowders, number_of_trials = i.input_data["number_of_trials"], box_size = i.input_data["box_size"], disable_progress_bar = i.input_data["disable_progress_bar"] )
excluded_volume = pool.map( estimate_excluded_volume_partial, i.input_data["seed"] )
print(excluded_volume)
exvol = np.mean(excluded_volume)
dexvol = np.std(excluded_volume)
print('fex = {} +/- {}'.format(exvol, dexvol))
#-------------------------------------------------------------------------------
if __name__ == '__main__':
copyright_notice()
main()