Skip to content
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

VASP Defect Code #215

Merged
merged 61 commits into from
Mar 6, 2023
Merged

VASP Defect Code #215

merged 61 commits into from
Mar 6, 2023

Conversation

jmmshn
Copy link
Contributor

@jmmshn jmmshn commented Dec 2, 2022

VASP Defect Code

Once the general defect code is merged from #214 we can look at the VASP-specific implementation of the defect workflow will just instantiate the general one with some VASP-specific defaults.

I removed the final aggregation step since I believe that's best done with an additional database for the competing phases.
So the current workflow is only responsible for spawning the defect calculations.

@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Merging #215 (b90d99f) into main (aa0bb07) will increase coverage by 0.10%.
The diff coverage is 82.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   75.46%   75.57%   +0.10%     
==========================================
  Files          55       55              
  Lines        4716     4872     +156     
  Branches      685      701      +16     
==========================================
+ Hits         3559     3682     +123     
- Misses        975     1007      +32     
- Partials      182      183       +1     
Impacted Files Coverage Δ
src/atomate2/vasp/flows/defect.py 83.82% <75.00%> (-11.05%) ⬇️
src/atomate2/common/schemas/defects.py 88.04% <78.26%> (ø)
src/atomate2/common/analysis/defects/jobs.py 89.00% <82.14%> (-8.92%) ⬇️
src/atomate2/common/analysis/defects/flows.py 89.23% <83.33%> (-5.06%) ⬇️
src/atomate2/vasp/sets/defect.py 93.75% <95.83%> (-6.25%) ⬇️
src/atomate2/vasp/jobs/defect.py 100.00% <100.00%> (ø)
src/atomate2/vasp/schemas/calculation.py 89.43% <100.00%> (+1.69%) ⬆️
src/atomate2/common/jobs.py 50.00% <0.00%> (-34.38%) ⬇️
src/atomate2/vasp/sets/base.py 68.57% <0.00%> (+1.03%) ⬆️
... and 1 more

@jmmshn jmmshn marked this pull request as ready for review January 31, 2023 22:05
@@ -672,7 +672,7 @@ def from_vasp_files(

vasprun_kwargs = vasprun_kwargs if vasprun_kwargs else {}
volumetric_files = [] if volumetric_files is None else volumetric_files
vasprun = Vasprun(vasprun_file, **vasprun_kwargs)
vasprun = Vasprun(vasprun_file, parse_potcar_file=True, **vasprun_kwargs)
Copy link
Contributor Author

@jmmshn jmmshn Mar 1, 2023

Choose a reason for hiding this comment

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

So what I said about Structure.charge vs Structure._charge was wrong.
This was the culprit of my HSE caculations running with the wrong charge states.
I think this setting should always be on for vasprun parsing since we are running in a directory that has POTCARs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ This was wrong too it ended up being the CONTCAR copy during the Calculation parsing step.

This is fixed as part of this PR.

# use structure from CONTCAR as it is written to
# greater precision than in the vasprun
# but still need to copy the charge over
structure = contcar.structure
structure._charge = vasprun.final_structure._charge

@jmmshn
Copy link
Contributor Author

jmmshn commented Mar 1, 2023

For Posterity, something like the function below is needed for now to perform the postprocessing without periodic regridding
since it is possible for grid size to change if you relax the bulk structure with ISIF=3. If you run with ISIF=2 only it might get slightly different numbers. vdw group tends to use ISIF=3 so I'm setting that as the default behavior.

def submit_defect(defect, relax_maker, bulk_dir=None, run=False):
    """Submit a defect calculation"""
    ss = MPStaticSet(defect.get_supercell_structure())
    ng, ngf = ss.calculate_ng()
    ng_settings = dict(zip(["NGX", "NGY", "NGZ", "NGXF", "NGYF", "NGZF"], ng + ngf))
    relax_maker = update_user_incar_settings(relax_maker, ng_settings)
    maker = FormationEnergyMaker(
        relax_maker=relax_maker,
    )
    flow = maker.make(defect=defect, bulk_supercell_dir=bulk_dir)
    return flow

Copy link
Member

@utf utf left a comment

Choose a reason for hiding this comment

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

Hi Jimmy, this is looking fantastic. I really like the abstraction support for other DFT codes.

My main comment is the update_bulk_maker stuff. The way other workflows handle different settings for different calculations is just by having a different maker altogether. I think this is conceptually simpler and easier to track down why certain parameters are being set.

I expanded on this more in one of the comments, but can you see a big advantage to using this? If not, can we stick with the default way of handling this (which would also be supported in the code agnostic case) and just have two makers?

I was also thinking we should stick with ISIF=2 for the bulk relaxation for now, as if you want to use ISIF=3, you also need to set the custom grid stuff so it will be difficult for other users until the regridding stuff is implemented. I also talk about this in another comment. I personally think this should be fine (since other research groups do this). But if you have strong feelings I'm happy to discuss.

Anyway, it looks fantastic and I'm excited to use it.

src/atomate2/common/analysis/defects/flows.py Outdated Show resolved Hide resolved
src/atomate2/common/analysis/defects/flows.py Outdated Show resolved Hide resolved


@job(
name="bulk supercell",
Copy link
Member

Choose a reason for hiding this comment

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

can remove trailing ,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

uc_structure: Structure,
relax_maker: RelaxMaker,
sc_mat: NDArray | None = None,
update_bulk_maker: Callable | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

Again, think it is cleaner to remove the update_bulk_maker function since it could be handled more cleanly with just a separate maker to begin with.

src/atomate2/common/analysis/defects/jobs.py Outdated Show resolved Hide resolved
src/atomate2/common/analysis/defects/jobs.py Outdated Show resolved Hide resolved
src/atomate2/common/analysis/defects/jobs.py Outdated Show resolved Hide resolved
src/atomate2/vasp/sets/defect.py Show resolved Hide resolved
src/atomate2/vasp/sets/defect.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@jmmshn jmmshn left a comment

Choose a reason for hiding this comment

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

updated based on comments

@jmmshn jmmshn requested a review from utf March 3, 2023 01:03
Copy link
Member

@utf utf left a comment

Choose a reason for hiding this comment

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

Thanks Jimmy. Just noticed one thing

src/atomate2/common/analysis/defects/jobs.py Outdated Show resolved Hide resolved
}
# TODO: check that the charge state was set correctly

return Response(output=all_chg_outputs, replace=defect_q_jobs)
Copy link
Member

Choose a reason for hiding this comment

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

Same with this here. E.g., see

relax_flow = Flow(relaxations, outputs)
return Response(replace=relax_flow)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right the outputs are all references. It's just that they are all meant to be comsumed by other jobs so this error did not affect anything. I merged your change.

Copy link
Member

@utf utf left a comment

Choose a reason for hiding this comment

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

Sorry, noticed one more thing. And then will merge.

src/atomate2/common/schemas/defects.py Outdated Show resolved Hide resolved
src/atomate2/common/schemas/defects.py Outdated Show resolved Hide resolved
@utf
Copy link
Member

utf commented Mar 6, 2023

Fantastic, thanks Jimmy!

@utf utf merged commit 2f4908e into materialsproject:main Mar 6, 2023
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