-
Notifications
You must be signed in to change notification settings - Fork 874
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
Standardise and update VASP input sets #3484
Conversation
Thanks, this is great stuff (as usual)!🥇
Do you think this needs better test coverage? In general, just having looked at the whole code and knowing |
Just wanted to say thank you for this! Both from pymatgen and atomate2 perspective! |
Just to note that the remaining failing tests are also failing on the master branch currently, and not to do with this PR (seems like it is missing PBE64 potcars). |
Thank you for this! |
That is a good question. It is almost impossible to catch all edge cases. That said, we could probably develop a quick testing suite that generates input files using the old input sets for a range of structures and options and then compares them to the new input sets. I would very much appreciate help with this if possible. |
Just pushed a fix (816cd3a) for the failing test on
Is this otherwise ready to go from your side? I.e. is now the time to add tests? |
Yes, from my point of view this should be ready for more testing. I just added some commits that aim to minimise the diff. |
Hello everyone, Thanks for this @utf, I think it's very good work and a very good way forward to merge the two input sets implementations lying respectively in pymatgen and atomate2 and I definitely agree with the need to not have two different implementations of the input generators/sets. I have a couple of questions and/or comments though, no idea if any of this can be addressed in any way.
I understand there has already been many discussions on this topic but maybe some of these questions could be addressed somehow ? (VaspInput becoming a subclass of InputSet and VaspInputSet having "VaspInputGenerator" alias ? other ideas ?) |
I always assumed the I'm open to adding an alias |
Thanks for your thoughts @davidwaroquiers.
That is the goal. If there are some very specialised input sets needed for an atomate2 workflow then potentially they don't have to go in pymatgen. But by and large, the input sets will live in pymatgen and the workflow code will live in atomate2.
I'm in favour of this, since we have the abstract interface defined and there are a growing number of codes that support it. The downsides to doing this are small as far as I can see and won't require breaking any existing pymatgen code.
I understand the logic here but I'm personally against renaming VaspInputSet. I think this will add additional confusion to existing pymatgen users. If necessary we could rename any remaining input sets in atomate2 to match the pymatgen naming, and also optionlly update the
On the point of pymatgen/pymatgen/io/vasp/sets.py Line 98 in a48d541
My suggestion would be:
I think this leaves the overall picture cleaner since now there is no confusion between On a separate note, I've found the |
Go right ahead with the file split! I've been considering merging DictSet and VispInputSet as well so no convincing needed here but was planning to deprecate DictSet. Why keep that? |
My thought process is that most (if not all) people who have made a custom input set will have subclassed
I'll just note that the features in this PR will not break these other implementations! |
I think this is a really important point! |
We can have a long deprecation period or even keep |
Thanks for the feedback @utf and indeed I agree with trying to be backward compatible with existing code using pymatgen. I understand the push towards keeping VaspInputSet (or DictSet for the matter). Still, it confuses me: the VaspInputSet (or the DictSet, if VIS properties and methods are merged into it) has a get_input_set method, which should return a (subclass of) InputSet (i.e. the VaspInput object, currently not a subclass of InputSet). If a change from VaspInputSet (DictSet) to VaspInputGenerator (?) is not on the table, I think it could even be considered to change the pymatgen/io/core interface: e.g. InputSet becoming an object called e.g. "Input", and InputGenerator becoming an InputSet. That way the InputSet is a "factory"/"generator" object that returns an Input object. This means modifying all atomate2 generators and sets but I think it decreases confusion (my preference still being on generators being VaspInputGenerators and InputSets being InputSets, although again, I acknowledge the problems for existing users/codes of pymatgen). On a general level, while I agree that backward incompatible changes should be avoided as much as possible, in some cases, it can be beneficial (either from a developer or from a user's perspective). In this case, I would think that having a long deprecation period for VaspInputSet to change it to VaspInputGenerator would have been ok and would be beneficial for both the user (a vasp input generator generates a set of inputs, i.e. a vasp input set/ or just vasp input) and the developer (clear api defined in pymatgen/io/core). In any case, I will of course adhere to the decisions made. |
Hi @davidwaroquiers, agreed that the naming is confusing. I'll defer to others as to the exact direction taken if deprecations/renaming is to happen. |
My decision is that I have no problems with having an alias called VaspInputGenerator. But VASPInputSet will not be deprecated. Let's be pragmatic - there are many things we probably want to rename. But deprecation of classes/methods creates headaches and unless there is an actual practical benefit, i.e., a large change in functionality or the API, these should not be done. |
We discussed at the atomate2 meeting, I think the plan is for @Zhuoying to add more tests and then propose merging this |
3c23114
to
36e289c
Compare
@Zhuoying When are the tests going to be done? Surely it does not take several months to write a few tests? |
In the interest of getting this unstuck I suggest we merge this PR as is (thanks again @utf!) and add tests later if we discover any problems. |
I - cautious by nature - would like to point out that this is a core functionality of pymatgen. Thus, in my opinion, we should merge it only if we are sure that such bugs are very unlikely. (Decision is up to you all as maintainers, of course!) |
Existing tests are passing which is meaningful since test coverage on VASP IO is decent. IMO we shouldn't hold this PR to higher standards than PMG in general and frankly, bugs are not that unlikely in PMG. |
(Thanks. I know that there are bugs in pymatgen and that they are not unlikely. Also in my code. 😉 I don't see why this is supporting fewer tests though 😅) As I said, maintainers have to decide. And I even gave a 👍 for the point that existing tests are passing. |
more test coverage is always good but it seems like no one has time to actually write the tests right now |
I can support the effort of writing more tests - where do we feel like current test coverage is lacking? Also, does this PR cover the recent atomate2 PR that corrected how dict-like |
@esoteric-ephemera yes it does! |
@utf Thanks for the nice PR and @janosh @shyuep Thanks for approving and merging it. @esoteric-ephemera Thanks for offering the efforts. Any tests on Magmomldau are welcome (currently coverage not very high). Also we are roaming between atomate2 and pymatgen to accommodate the recent changes. |
@esoteric-ephemera @Zhuoying have a look at the output of pip install pytest pytest-coverage
# cd into pmg repo
pytest tests/io/vasp --cov pymatgen/io/vasp for where new tests are most needed:
use |
Summary
This PR refactors the VASP input sets to make them compatible with atomate2 and fixes some of the issues that have been raised previously.
This PR does not introduce any breaking changes. The API for the input sets has not changed and pymatgen users can continue to use their existing code.
The input sets are compatible with pymatgen, atomate1, and atomate2. The most drastic change is that now all input sets are dataclasses. This made addressing the following issues easier and also should make it easier to create new input sets in the future. Note, I did not copy the atomate2 input sets to pymatgen, instead I refactored the pymatgen input sets specifically to avoid any breaking changes.
Issues addressed
Closes #3492.
In addition to updating the
get_vasp_input
function to allow starting from a previous directory, this PR addresses the following points:__init__
,.incar
,override_from_prev_calc
functions. Some input sets inherited fromDictSet
, some fromMPRelaxSet
, some fromMPStaticSet
. This made it difficult to pin down why a particular setting was getting set. Now, all logic specific to an input set is provided in theincar_updates
andkpoints_updates
property functions that define any changes to the base input set config. This function is also used when starting from a previous calculation, so all the logic is in one place.user_incar_settings
was left down to specific input set implementations and there were a number of examples where this was not respected (e.g., see EDIFF setting inMPStaticSet
orMPNonSCFSet
where it is not possible to specify MAGMOM through user_incar_settings). Now,user_incar_settings
is always applied in a standard way and will always take precedence.MPNonSCFSet
andMPHSEBSSet
did not have feature parity. E.g.,MPNonSCFSet
had optics modes which also make sense forMPHSEBSSet
. I tried to add feature parity between similar input sets where possible.override_from_prev
andfrom_prev_calc
were defined repeatedly in most input sets. I therefore moved these functions to the baseDictSet
. I also added an optioninherit_incar
to dict set which can beTrue
,False
, or a list of keys to inherit (as copied fromMatPESSet
). If a class hasinherit_incar
enabled and but uses thefrom_prev
function to initialise their input set, the only thing that will get used is theStructure
from the previous directory and the bandgap information.