-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packmol: overhaul and add tests #17
Conversation
I guess the tests will not work in the CI environment because |
@htz1992213 after thinking more about this, I think there are 2 possible ways we can proceed. Either way, I'd like to develop a separate packmol IO class as part of my htmd branch in pymatgen. There's no reason this Given that, we can either:
Please let me know which way you'd like to go. Thanks! |
@rkingsbury Thanks! I will work on the PR and get back to you! |
FYI @htz1992213 I have now implemented a full I/O class for packmol in pymatgen. See this file It's not merged yet so still somewhat subject to change. A lot of the contents are taken from my work here, with some slight modifications like not using the mdgo method of volume estimation, for example. |
@rkingsbury Thanks for the overhaul, the changes look great! One minor thing is about the tests. I added a packmol executable so that the CI can run the tests. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkingsbury I have suggested changes to the test that use alternative checks. Could you please take a look? Thanks!
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Thanks for the good suggestions @htz1992213 ; I've adopted all of them. In addition, per discussion over in rkingsbury/pymatgen#3, I removed the
Which version of packmol are you using in the CI? I set up a clean conda environment and installed the conda version of packmol, which is v20.010. All tests passed. Support for paths with spaces was added in v20.3.0. So based on my limited testing, it seems like having the I'm happy to hear opinions one way or another on whether we should leave the |
Just wanted to chime in. I've now had issues with the quotation marks in both |
Hey @orioncohen , I think Tingzheng and I figured it out. Here are the highlights as best I've been able to figure out:
That's the logic that's implemented in Tingzheng's recent fix, which allowed all tests to pass here. Is this consistent with your testing? I'm going to add the fixes to my pymatgen version as well. |
Made a note about the version number issue here m3g/packmol#6 |
See HouGroup/mdgo#17. Thanks @htz1992213 and @orioncohen for bug reporting and fixes.
…tion into atomate2 (#2692) * LAMMPS: add sets.py * LAMMPS: linting with black * LAMMPS: basic InputSet class * Example generator docstring * example * linting * revert alchemy change related to VaspInput * fixed an issue where quotation marks inside strings were causing packmol to not recognize file names * rm spurious quotation marks. See rkingsbury#3 * fixed bug where working directory was changed and never restored * two bug fixes * Packmol: better handling of " in filepaths See HouGroup/mdgo#17. Thanks @htz1992213 and @orioncohen for bug reporting and fixes. * Packmol: add test for chdir behavior * added myself to author list * LAMMPS: add sets.py * LAMMPS: linting with black * LAMMPS: basic InputSet class * Example generator docstring * example * linting * revert alchemy change related to VaspInput * LammpsInputConstructor initiation * LammpsInputConstructor initiation * Revert "LammpsInputConstructor initiation" This reverts commit 62dd52e. * helper methods for stages * method to initiate new stage * method to add single LAMMPS command * method to add comment * method to LAMMPS command as string * method to add stage commands * method to add commands using dict * method to generate LAMMPS input * comment fix * method to generate LammpsInputFile * method for str representation of LammpsInputFile * method for reading LammpsInputFile str * docstring format change * from_file method * Minor fix and __str__ method * merge methods for add commands * Merge LammpsInputConstructor and LammpsInputFile * Remove LammpsInputConstructor * Update LammpsInputFile Docstring * formatting and minor fixes * Update vasp outputs in case of serial compilation * Linting * Linting, pre-commit,... * Simplified interface for LammpsInputFile * Updated documentation * Added unit tests * Added parse rule about & symbol for the input file * Tentative concrete implementation of Lammps sets for minimization * Moved structure to get_input_set * Adding a BaseLammpsGenerator object for cleaner further implementation * pre-commit changes * Typos, updated maintainers and contributors * Modified the input_settings from dict of dicts to list of tuples. Easier handling of non-default cases. * Added options to ignore comments when reading/writing inputs, and ignore stages when reading/writing inputs * Added documentation. * Remove tuples. Add functionalities to lammps inputs. Add/update tests. * Made LammpsMinimization MSONable. These sets still require some refactorization to make them more sustainable (in the same fashion as vasp and lammps). * Data -> structure bug in lammps sets * Removed sets.py from pymatgen. This is workflow-related stuff and will now live in https://github.com/Matgenix/atomate2-lammps * Added type hinting * Upgraded documentation. Added basic sets.py back after discussion. * Followed unittest2pytest * Added functionalities to LammpsInputFile * Added keep_stages option to LammpsInputSet and Generator. * Removed changes in outputs, should not be part of this PR (and should in any case be updated). * Included Matthew's suggesions. * Including suggestions from @rkingsbury * Updated tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Adding coul (short for coulomb in lammps io) to list of words to ignore by codespell. * Reverted changes in vasp outputs, made a separate PR. * Same as previous commit * Attribute .list_of_commands is not .stages, and its structure is a list of dicts. * Refactoring of some methods and parts. Added the possibility to add a whole stage, including checks needed on the given stage. * Small refactoring, added a method to rename stages. * make PackmolSet.from_directory @abc.abstractmethod * ruff --fix $(gh pr view 2692 --json files --jq '.files.[].path' | grep '.py') --------- Co-authored-by: Ryan Kingsbury <RKingsbury@lbl.gov> Co-authored-by: orioncohen <orion@lbl.gov> Co-authored-by: Ryan Kingsbury <rkingsbury@users.noreply.github.com> Co-authored-by: mholekev <mholekev@ucsd.edu> Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Summary
This PR overhauls
PackmolWrapper
and adds a set of thorough unit tests. These changes were motivated by my recent experience using the pymatgenPackmolRunner
class (which has many deficiencies) and this one to try to build structures. With this PR, I have brought themdgo
version up to feature parity with the pymatgen one and made it more robust to cases where packmol times out or fails to satisfy all packing constraints.Major changes include:
structures
nowmolecules
) also contains the numbers of each molecule. Previously the numbers were passed as a separate list. To me, if we are already providing a[dict]
that specifies the names and structures of every molecule, we might as well include the numbers there too to minimize chances of a mistake.PackmolRunner
had but this class did not. Namely, support forMolecule
objects, ability to customize control parameters, and ability to automatically determine box sizerun_packmol()
commandPath
in addition tostr
Additional dependencies introduced (if any)
TODO - thinking longer term
I believe this PR is good to go, pending review.
However, longer term I also feel that it would make sense to move this functionality back into pymatgen and create a proper
InputSet
class for packmol that follows the forthcoming abstract IO interface I've been developing. For example, instead ofmake_packmol_input
we would usewrite_input
to be consistent with that interface.It doesn't really make sense to adopt that new interface within
mdgo
until it's merged into pymatgen. So one approach would be to merge this PR for use inmdgo
now, with the understanding that it may quickly be superceded by a parallel implementation inpymatgen
that has a slightly different interface. When that happens, I will deprecate the pymatgenPackmolRunner
and we could also add a deprecation warning here. It's a little messy, but since not many people usemdgo
yet I think it's OK.An alternate approach would be to go ahead and change the interface here so that it looks and acts just like what will eventually be in
pymatgen
, without actually inheriting any of those base classes yet. That way people can start getting used to the new interface and not have to change their code when we update it to use the abcs in pymatgen later.Happy to discuss in more detail @htz1992213 .
Before a pull request can be merged, the following items must be checked:
is to run the following in the correct sequence on your local machine. Start with running
black on your new code. This will automatically reformat
your code to PEP8 conventions and removes most issues. Then run
pycodestyle, followed by
flake8.
Run pydocstyle on your code.