Skip to content

A new "ndirect" mode for preprocessing#4

Open
Cloudac7 wants to merge 5 commits into
txie-93:masterfrom
Cloudac7:master
Open

A new "ndirect" mode for preprocessing#4
Cloudac7 wants to merge 5 commits into
txie-93:masterfrom
Cloudac7:master

Conversation

@Cloudac7

Copy link
Copy Markdown

For some large, non-orthogonal box, it could be rather slow using direct mode to preprocess. So in this pr, a new mode ndirect, using numpy ndarray to produce neighbor list, is developed and has been tested to give the same result as the original direct mode.

@txie-93 txie-93 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! The code looks great. I have several very minor issues, mainly about formatting. The code should be ready to merge once you fix those. In addition, did you test if the new algorithm gives the exact same results as the existing two for the given trajectories?

Comment thread README.md
```

Note that the graph construction is slow especially for large MD trajectories. There two different graph construction algorithms implemented. The default `--backend kdtree` has a linear scaling but only works for orthogonal simulation box. For non-orthogonal simulation, use flag `--backend direct` which has a quadratic scaling. You can also take advantage of the multiprocessing with flag `--n-workers`. For other flags, checkout the help information with `python preprocess.py -h`.
Note that the graph construction is slow especially for large MD trajectories. There two different graph construction algorithms implemented. The default `--backend kdtree` has a linear scaling but only works for orthogonal simulation box. For non-orthogonal simulation, use flag `--backend direct` or `--backend ndirect` which has a quadratic scaling (for the two choices, the latter is specially efficient for large cells, while the former could be quick for small ones). You can also take advantage of the multiprocessing with flag `--n-workers`. For other flags, checkout the help information with `python preprocess.py -h`.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typos:
Two different graph convolution algorithm -> three

Comment thread gdynet/parsers.py
'lattices but has quadratic scaling. '
'lattices but has quadratic scaling. "ndirect" is '
'an enhanced method for "direct" which could '
'accelarate the process ofdealing with large lattices.'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ofdealing -> of dealing

Comment thread gdynet/parsers.py
prep_parser.add_argument('--backend', choices=['kdtree', 'direct'],
default='kdtree', help='either "kdtree" or "direct", '
prep_parser.add_argument('--backend', choices=['kdtree', 'direct', 'ndirect'],
default='kdtree', help='"kdtree", "direct" or "ndirect" available, '

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove “available” after “ndirect”

Comment thread gdynet/preprocess.py
'nbr_lists': nbr_lists,
'nbr_dists': nbr_dists}
elif self.backend == 'ndirect':
stcs = [Structure(lattice=lattices[i],

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t use such complex list comprehensions. Use a for loop for code readability.

Comment thread gdynet/preprocess.py
a, b, c = [np.ceil(2*self.radius/d).astype('int')
for d in stcs[0].lattice.abc]
if [a, b, c] != [1, 1, 1]:
_ = [stc.make_supercell(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a for loop here. As well as several places below.

Comment thread gdynet/preprocess.py
:, 1:1+self.n_nbrs] for stc in tqdm(
stcs, desc='Generating neighbor index...', disable=not self.verbose)], dtype='int32')
nbr_dists = np.array([np.sort(stc.distance_matrix)[
:, 1:1+self.n_nbrs] for stc in tqdm(

@txie-93 txie-93 Oct 17, 2019

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reformat your code according to PEP8? There should be whitespaces between 1+ for example. You can do it with automated tools.

@Cloudac7

Copy link
Copy Markdown
Author

Thank you for your contribution! The code looks great. I have several very minor issues, mainly about formatting. The code should be ready to merge once you fix those. In addition, did you test if the new algorithm gives the exact same results as the existing two for the given trajectories?

Thanks a lot for pointing out and I will fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants