diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 52a52954..21606076 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Change Log ========== +v.2.4.1 +---------- +- Speed up eigenvalue parsing by using the faster ``doped`` site-matching functions rather than ``MakeDefectStructureInfo`` from ``pydefect`` +- Minor efficiency & robustness updates. +- Minor docs & tutorials updates +- Minor tests updates + v.2.4.0 ---------- - Electronic structure analysis by @adair-nicolson & @kavanase: diff --git a/docs/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png b/docs/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png index 059f9c04..c4c06fdf 100644 Binary files a/docs/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png and b/docs/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png differ diff --git a/docs/Dev_ToDo.md b/docs/Dev_ToDo.md index ce63cbb6..654c5143 100644 --- a/docs/Dev_ToDo.md +++ b/docs/Dev_ToDo.md @@ -1,6 +1,6 @@ # `doped` Development To-Do List ## Chemical potential -- Check through chemical potential TO-DOs. Need to recheck validity of approximations used for extrinsic competing phases (and code for this). +- Check through chemical potential TO-DOs. Need to recheck validity of approximations used for extrinsic competing phases (and code for this). Proper `vasp_std` setup (with `NKRED` folders like for defect calcs) and `vasp_ncl` generation. - Efficient generation of competing phases for which there are many polymorphs? See SK notes from CdTe competing phases. - Update chemical potential tools to work with new Materials Project API. Currently, supplying an API key for the new Materials Project API returns entries which do not have `e_above_hull` as a property, and so crashes. Ideally would be good to be compatible with both the legacy and new API, which should be fairly straightforward (try importing MPRester from mp_api client except ImportError import from pmg then will need to make a whole separate query/search because `band_gap` and `total_magnetisation` no longer accessible from `get_entries`). See https://docs.materialsproject.org/downloading-data/using-the-api - Publication ready chemical potential diagram plotting tool as in Adam Jackson's `plot-cplap-ternary` (3D) and Sungyhun's `cplapy` (4D) (see `doped_chempot_plotting_example.ipynb`; code there, just needs to be implemented in module functions). `ChemicalPotentialGrid` in `py-sc-fermi` interface could be quite useful for this? (Worth moving that part of code out of `interface` subpackage?) Also can see https://github.com/materialsproject/pymatgen-analysis-defects/blob/main/pymatgen/analysis/defects/plotting/phases.py for 2D chempot plotting. @@ -14,8 +14,7 @@ - Should have `ncols` as an optional parameter for the function, and auto-set this to 2 if the legend height exceeds that of the plot - Don't show transition levels outside of the bandgap (or within a certain range of the band edge, possibly using `pydefect` delocalisation analysis?), as these are shallow and not calculable with the standard supercell approach. - Option for degeneracy-weighted ('reduced') formation energy diagrams, similar to reduced energies in SOD. See Slack discussion and CdTe pyscfermi notebooks. Would be easy to implement if auto degeneracy handling implemented. - - Could also add an optional right-hand-side y-axis for defect concentration (for a chosen anneal temp) to our TLD plotting (e.g. `concentration_T = None`) as done for thesis, noting in docstring that this obvs doesn't account for degeneracy! - - Also carrier concentration vs Fermi level plots as done in the Kumagai PRX paper? With this, should also mention that DOS calcs should be well converged wrt kpoints for accurate Fermi level prediction. + - Could also add an optional right-hand-side y-axis for defect concentration (for a chosen anneal temp) to our TLD plotting (e.g. `concentration_T = None`) as done for thesis, noting in docstring that this obvs doesn't account for degeneracy! - Also see Fig. 6a of the `AiiDA-defects` preprint, want plotting tools like this - Can we add an option to give the `pydefect` defect-structure-info output (shown here https://kumagai-group.github.io/pydefect/tutorial.html#check-defect-structures) – seems quite useful tbf @@ -38,9 +37,8 @@ and/or if it's known from other work for your chosen functional etc.) - Show our workflow for calculating interstitials (see docs Tips page, i.e. `vasp_gam` relaxations first (can point to defects tutorial for this)) -> Need to mention this in the defects tutorial, and point to discussion in Tips docs page. - Add mini-example of calculating the dielectric constant (plus convergence testing with `vaspup2.0`) to docs/examples, and link this when `dielectric` used in parsing examples. Should also note that the dielectric should be in the same xyz Cartesian basis as the supercell calculations (likely but not necessarily the same as the raw output of a VASP dielectric calculation if an oddly-defined primitive cell is used) - - Note about cost of `vasp_ncl` chemical potential calculations for metals, use `ISMEAR = -5`, - possibly `NKRED` etc. (make a function to generate `vasp_ncl` calculation files with `ISMEAR = -5`, with option to set different kpoints) - if `ISMEAR = 0` - converged kpoints still prohibitively large, use vasp_converge_files again to check for quicker convergence with ISMEAR = -5. - - Use `NKRED = 2` for `vasp_ncl` chempot calcs, if even kpoints and over 4. Often can't use `NKRED` with `vasp_std`, because we don't know beforehand the kpts in the IBZ (because symmetry on for `vasp_std` chempot calcs)(same goes for `EVENONLY = True`). + - `vasp_ncl` chemical potential calculations for metals, use `ISMEAR = -5`, possibly `NKRED` etc. (make a function to generate `vasp_ncl` calculation files with `ISMEAR = -5`, with option to set different kpoints) - if `ISMEAR = 0` - converged kpoints still prohibitively large, use vasp_converge_files again to check for quicker convergence with ISMEAR = -5. + - Often can't use `NKRED` with `vasp_std`, because we don't know beforehand the kpts in the IBZ (because symmetry on for `vasp_std` chempot calcs)(same goes for `EVENONLY = True`). - Readily-usable in conjunction with `atomate`, `AiiDA`(-defects), `vise`, `CarrierCapture`, and give some quick examples? Add as optional dependencies. - Workflow diagram with: https://twitter.com/Andrew_S_Rosen/status/1678115044348039168?s=20 @@ -58,7 +56,7 @@ calculations, but only the case when the occupation of the SOC-affected orbitals is constant (typically not the case)) Better to do consistently (link Emily SOC work and/or thesis). - But, can generally use non-SOC energies to reliably determine relative energies of polymorphs of the same composition (oxidation states), to good accuracy. - - Also, can use symmetry with SOC total energy calculations, have tested this. Also `NKRED` possibly useful for expensive (particularly metal) calculations! + - Also, can use symmetry with SOC total energy calculations, have tested this. - Link to Irea review, saying that while spin and configurational degeneracies are accounted for automatically in `doped`, excited-state degeneracy (e.g. with bipolarons/dimers with single and triplet states) are not, so the user should manually account for this if present. Also note that diff --git a/docs/JOSS/doped_JOSS_figure.png b/docs/JOSS/doped_JOSS_figure.png index d677a2e1..dc44b967 100644 Binary files a/docs/JOSS/doped_JOSS_figure.png and b/docs/JOSS/doped_JOSS_figure.png differ diff --git a/docs/JOSS/paper.bib b/docs/JOSS/paper.bib index 56c526b5..3956a28c 100644 --- a/docs/JOSS/paper.bib +++ b/docs/JOSS/paper.bib @@ -1,5 +1,5 @@ @article{cen_cation_2023, - title = {Cation Disorder Dominates the Defect Chemistry of High-Voltage {{LiMn}} 1.5 {{Ni}} 0.5 {{O}} 4 ({{LMNO}}) Spinel Cathodes}, + title = {Cation Disorder Dominates the Defect Chemistry of High-Voltage {{LiMn}}{\textsubscript{1.5}}{{Ni}}{\textsubscript{0.5}}{{O}}{\textsubscript{4}}({{LMNO}}) Spinel Cathodes}, author = {Cen, Jiayi and Zhu, Bonan and R.~Kavanagh, Se{\'a}n and G.~Squires, Alexander and O.~Scanlon, David}, year = {2023}, journal = {Journal of Materials Chemistry A}, @@ -29,12 +29,12 @@ @article{choi_intrinsic_2023 file = {/Users/kavanase/Zotero/storage/DIGWGHAD/Choi et al_2023_Intrinsic Defects and Their Role in the Phase Transition of Na-Ion Anode.pdf} } -@misc{dou_giant_2024, - title = {Giant {{Band Degeneracy}} via {{Orbital Engineering Enhances Thermoelectric Performance}} from {{Sb2Si2Te6}} to {{Sc2Si2Te6}}}, +@article{dou_giant_2024, + title = {Giant {{Band Degeneracy}} via {{Orbital Engineering Enhances Thermoelectric Performance}} from {{Sb{\textsubscript{2}}Si{\textsubscript{2}}Te{\textsubscript{6}}}} to {{Sc{\textsubscript{2}}Si{\textsubscript{2}}Te{\textsubscript{6}}}}}, author = {Dou, Wenzhen and Spooner, Kieran and Kavanagh, Se{\'a}n and Zhou, Miao and Scanlon, David O.}, year = {2024}, month = jan, - publisher = {{ChemRxiv}}, + journal = {{ChemRxiv}}, doi = {10.26434/chemrxiv-2024-hm6vh}, urldate = {2024-01-18}, abstract = {The complex interrelationships among thermoelectric parameters mean that a priori design of high-performing materials is difficult. However, band engineering can allow the power factor to be optimized through enhancement of the Seebeck coefficient. Herein, using layered Sb2Si2Te6 and Sc2Si2Te6 as model systems, we comprehensively investigate and compare their thermoelectric properties by employing density functional theory combined with semiclassical Boltzmann transport theory. Our simulations reveal that Sb2Si2Te6 exhibits superior electrical conductivity compared to Sc2Si2Te6 due to lower scattering rates and more pronounced band dispersion. Remarkably, despite Sb2Si2Te6 exhibiting a lower lattice thermal conductivity, the introduction of Sc-d orbitals dramatically increases conduction band degeneracy in Sc2Si2Te6, yielding a significantly improved Seebeck coefficient relative to Sb2Si2Te6. As a result, Sc2Si2Te6 is predicted to achieve an extraordinary dimensionless figure of merit (ZT) of 3.51 at 1000 K, which significantly surpasses the predicted maximum ZT of 2.76 for Sb2Si2Te6 at 900 K. This work suggests that engineering band degeneracy through compositional variation is an effective strategy for improving the thermoelectric performance of layered materials.}, @@ -82,7 +82,7 @@ @article{hyde_lithium_2023 } @article{kavanagh_frenkel_2022, - title = {Frenkel {{Excitons}} in {{Vacancy-Ordered Titanium Halide Perovskites}} ({{Cs2TiX6}})}, + title = {Frenkel {{Excitons}} in {{Vacancy-Ordered Titanium Halide Perovskites}} ({{Cs{\textsubscript{2}}TiX{\textsubscript{6}}}})}, author = {Kavanagh, Se{\'a}n R. and Savory, Christopher N. and Liga, Shanti M. and Konstantatos, Gerasimos and Walsh, Aron and Scanlon, David O.}, year = {2022}, month = dec, @@ -151,7 +151,7 @@ @article{kim_carriercapturejl_2020 } @article{krajewska_enhanced_2021, - title = {Enhanced Visible Light Absorption in Layered {{Cs}}{\textsubscript{3}}{{Bi}}{\textsubscript{2}}{{Br}}{\textsubscript{9}} through Mixed-Valence {{Sn}}({\textsc{Ii}})/{{Sn}}({\textsc{Iv}}) Doping}, + title = {Enhanced Visible Light Absorption in Layered {{Cs}}{\textsubscript{3}}{{Bi}}{\textsubscript{2}}{{Br}}{\textsubscript{9}} through Mixed-Valence {{Sn}}({\textsc{II}})/{{Sn}}({\textsc{IV}}) Doping}, shorttitle = {Enhanced Visible Light Absorption in Layered {{Cs}} {\textsubscript{3}} {{Bi}} {\textsubscript{2}} {{Br}} {\textsubscript{9}} through Mixed-Valence {{Sn}}(}, author = {Krajewska, Chantalle J. and Kavanagh, Se{\'a}n R. and Zhang, Lina and Kubicki, Dominik J. and Dey, Krishanu and Ga{\l}kowski, Krzysztof and Grey, Clare P. and Stranks, Samuel D. and Walsh, Aron and Scanlon, David O. and Palgrave, Robert G.}, year = {2021}, @@ -204,22 +204,25 @@ @article{larsen_atomic_2017 } @article{li_computational_2024, - title = {Computational {{Prediction}} of an {{Antimony-Based}} n-{{Type Transparent Conducting Oxide}}: {{F-Doped Sb2O5}}}, + title = {Computational {{Prediction}} of an {{Antimony-Based}} n-{{Type Transparent Conducting Oxide}}: {{F-Doped Sb{\textsubscript{2}}O{\textsubscript{5}}}}}, shorttitle = {Computational {{Prediction}} of an {{Antimony-Based}} n-{{Type Transparent Conducting Oxide}}}, author = {Li, Ke and Willis, Joe and Kavanagh, Se{\'a}n R. and Scanlon, David O.}, year = {2024}, month = mar, journal = {Chemistry of Materials}, + volume = {36}, + number = {6}, + pages = {2907--2916}, publisher = {American Chemical Society}, issn = {0897-4756}, doi = {10.1021/acs.chemmater.3c03257}, - urldate = {2024-03-25}, + urldate = {2024-04-10}, abstract = {Transparent conducting oxides (TCOs) possess a unique combination of optical transparency and electrical conductivity, making them indispensable in optoelectronic applications. However, their heavy dependence on a small number of established materials limits the range of devices that they can support. The discovery and development of additional wide bandgap oxides that can be doped to exhibit metallic-like conductivity are therefore necessary. In this work, we use hybrid density functional theory to identify a binary Sb(V) system, Sb2O5, as a promising TCO with high conductivity and transparency when doped with fluorine. We conducted a full point defect analysis, finding F-doped Sb2O5 to exhibit degenerate n-type transparent conducting behavior. The inherently large electron affinity found in antimony oxides also widens their application in organic solar cells. Following our previous work on zinc antimonate, this work provides additional support for designing Sb(V)-based oxides as cost-effective TCOs for a broader range of applications.}, - file = {/Users/kavanase/Zotero/storage/75HBJQ28/Li et al_2024_Computational Prediction of an Antimony-Based n-Type Transparent Conducting.pdf} + file = {/Users/kavanase/Zotero/storage/9Q32H4UP/Li et al_2024_Computational Prediction of an Antimony-Based n-Type Transparent Conducting.pdf} } @article{liga_mixed-cation_2023, - title = {Mixed-{{Cation Vacancy-Ordered Perovskites}} ({{Cs2Ti1}}{\textendash}{{xSnxX6}}; {{X}} = {{I}} or {{Br}}): {{Low-Temperature Miscibility}}, {{Additivity}}, and {{Tunable Stability}}}, + title = {Mixed-{{Cation Vacancy-Ordered Perovskites}} ({{Cs{\textsubscript{2}}Ti{\textsubscript{1-x}}Sn{\textsubscript{x}}X{\textsubscript{6}}}}; {{X}} = {{I}} or {{Br}}): {{Low-Temperature Miscibility}}, {{Additivity}}, and {{Tunable Stability}}}, shorttitle = {Mixed-{{Cation Vacancy-Ordered Perovskites}} ({{Cs2Ti1}}{\textendash}{{xSnxX6}}; {{X}} = {{I}} or {{Br}})}, author = {Liga, Shanti M. and Kavanagh, Se{\'a}n R. and Walsh, Aron and Scanlon, David O. and Konstantatos, Gerasimos}, year = {2023}, @@ -275,7 +278,7 @@ @article{mosquera-lois_imperfections_2023 file = {/Users/kavanase/Zotero/storage/HXUPFXNP/Mosquera-Lois et al_2023_Imperfections are not 0 K.pdf} } -@misc{mosquera-lois_machine-learning_2024, +@article{mosquera-lois_machine-learning_2024, title = {Machine-Learning Structural Reconstructions for Accelerated Point Defect Calculations}, author = {{Mosquera-Lois}, Irea and Kavanagh, Se{\'a}n R. and Ganose, Alex M. and Walsh, Aron}, year = {2024}, @@ -283,12 +286,13 @@ @misc{mosquera-lois_machine-learning_2024 number = {arXiv:2401.12127}, eprint = {2401.12127}, primaryclass = {cond-mat, physics:physics}, - publisher = {{arXiv}}, + journal = {{arXiv}}, urldate = {2024-01-23}, abstract = {Defects dictate the properties of many functional materials. To understand the behaviour of defects and their impact on physical properties, it is necessary to identify the most stable defect geometries. However, global structure searching is computationally challenging for high-throughput defect studies or materials with complex defect landscapes, like alloys or disordered solids. Here, we tackle this limitation by harnessing a machine-learning surrogate model to qualitatively explore the defect structural landscape. By learning defect motifs in a family of related metal chalcogenide and mixed anion crystals, the model successfully predicts favourable reconstructions for unseen defects in unseen compositions for 90\% of cases, thereby reducing the number of first-principles calculations by 73\%. Using CdSe\$\_x\$Te\$\_\{1-x\}\$ alloys as an exemplar, we train a model on the end member compositions and apply it to find the stable geometries of all inequivalent vacancies for a range of mixing concentrations, thus enabling more accurate and faster defect studies for configurational complex systems.}, archiveprefix = {arxiv}, keywords = {Condensed Matter - Materials Science,Physics - Chemical Physics}, - file = {/Users/kavanase/Zotero/storage/EBQE6RWG/Mosquera-Lois et al_2024_Machine-learning structural reconstructions for accelerated point defect.pdf;/Users/kavanase/Zotero/storage/QXBJ2AI6/2401.html} + file = {/Users/kavanase/Zotero/storage/EBQE6RWG/Mosquera-Lois et al_2024_Machine-learning structural reconstructions for accelerated point defect.pdf;/Users/kavanase/Zotero/storage/QXBJ2AI6/2401.html}, + doi = {10.48550/arXiv.2401.12127}, } @article{mosquera-lois_search_2021, @@ -380,7 +384,7 @@ @article{neilson_defap_2022 } @article{nicolson_cu2sise3_2023, - title = {{{Cu2SiSe3}} as a Promising Solar Absorber: Harnessing Cation Dissimilarity to Avoid Killer Antisites}, + title = {{{Cu{\textsubscript{2}}SiSe{\textsubscript{3}}}} as a Promising Solar Absorber: Harnessing Cation Dissimilarity to Avoid Killer Antisites}, shorttitle = {{{Cu2SiSe3}} as a Promising Solar Absorber}, author = {Nicolson, Adair and Kavanagh, Se{\'a}n R. and Savory, Christopher N. and Watson, Graeme W. and Scanlon, David O.}, year = {2023}, @@ -434,8 +438,8 @@ @article{squires_py-sc-fermi_2023 file = {/Users/kavanase/Zotero/storage/E2EBAUM5/Squires et al. - 2023 - py-sc-fermi self-consistent Fermi energies and de.pdf} } -@misc{togo_textttspglib_2018, - title = {\${\textbackslash}texttt\{\vphantom\}{{Spglib}}\vphantom\{\}\$: A Software Library for Crystal Symmetry Search}, +@article{togo_textttspglib_2018, + title = {{\texttt{spglib}}: A Software Library for Crystal Symmetry Search}, shorttitle = {\${\textbackslash}texttt\{\vphantom\}{{Spglib}}\vphantom\{\}\$}, author = {Togo, Atsushi and Tanaka, Isao}, year = {2018}, @@ -443,7 +447,7 @@ @misc{togo_textttspglib_2018 number = {arXiv:1808.01590}, eprint = {1808.01590}, primaryclass = {cond-mat}, - publisher = {{arXiv}}, + journal = {{arXiv}}, doi = {10.48550/arXiv.1808.01590}, urldate = {2023-09-27}, abstract = {A computer algorithm to search crystal symmetries of crystal structures has been implemented in software \${\textbackslash}texttt\{spglib\}\$. An iterative algorithm is employed to find a set of space group operations that belongs to any one of space group types by accepting certain amount of distortion for input unit cell structures. The source code is distributed under the BSD 3-Clause License that is a permissive free software licence. Although \${\textbackslash}texttt\{spglib\}\$ is a small code, the iteration loops made the source code complicated. The aim of this text is to provide the algorithm details to those people who are interested in inside-\${\textbackslash}texttt\{spglib\}\$. This text is written for \${\textbackslash}texttt\{spglib\}\$ v1.10.4.}, @@ -471,7 +475,7 @@ @article{turiansky_nonrad_2021 } @article{wang_four-electron_2023-1, - title = {Four-Electron Negative-\${{U}}\$ Vacancy Defects in Antimony Selenide}, + title = {Four-Electron Negative-{\textit{U}} Vacancy Defects in Antimony Selenide}, author = {Wang, Xinwei and Kavanagh, Se{\'a}n R. and Scanlon, David O. and Walsh, Aron}, year = {2023}, month = oct, @@ -490,14 +494,17 @@ @article{willis_limits_2023 title = {Limits to {{Hole Mobility}} and {{Doping}} in {{Copper Iodide}}}, author = {Willis, Joe and Claes, Romain and Zhou, Qi and Giantomassi, Matteo and Rignanese, Gian-Marco and Hautier, Geoffroy and Scanlon, David O.}, year = {2023}, - month = oct, + month = nov, journal = {Chemistry of Materials}, - publisher = {{American Chemical Society}}, + volume = {35}, + number = {21}, + pages = {8995--9006}, + publisher = {American Chemical Society}, issn = {0897-4756}, doi = {10.1021/acs.chemmater.3c01628}, - urldate = {2023-10-25}, - abstract = {Over one hundred years have passed since the discovery of the p-type transparent conducting material copper iodide, predating the concept of the ``electron{\textendash}hole'' itself. Supercentenarian status notwithstanding, little is understood about the charge transport mechanisms in CuI. Herein, a variety of modeling techniques are used to investigate the charge transport properties of CuI, and limitations to the hole mobility over experimentally achievable carrier concentrations are discussed. Poor dielectric response is responsible for extensive scattering from ionized impurities at degenerately doped carrier concentrations, while phonon scattering is found to dominate at lower carrier concentrations. A phonon-limited hole mobility of 162 cm2 V{\textendash}1 s{\textendash}1 is predicted at room temperature. The simulated charge transport properties for CuI are compared to existing experimental data, and the implications for future device performance are discussed. In addition to charge transport calculations, the defect chemistry of CuI is investigated with hybrid functionals, revealing that reasonably localized holes from the copper vacancy are the predominant source of charge carriers. The chalcogens S and Se are investigated as extrinsic dopants, where it is found that despite relatively low defect formation energies, they are unlikely to act as efficient electron acceptors due to the strong localization of holes and subsequent deep transition levels.}, - file = {/Users/kavanase/Zotero/storage/Y9EHVRSY/acs.chemmater.html} + urldate = {2024-04-10}, + abstract = {Over one hundred years have passed since the discovery of the p-type transparent conducting material copper iodide, predating the concept of the ``electron--hole'' itself. Supercentenarian status notwithstanding, little is understood about the charge transport mechanisms in CuI. Herein, a variety of modeling techniques are used to investigate the charge transport properties of CuI, and limitations to the hole mobility over experimentally achievable carrier concentrations are discussed. Poor dielectric response is responsible for extensive scattering from ionized impurities at degenerately doped carrier concentrations, while phonon scattering is found to dominate at lower carrier concentrations. A phonon-limited hole mobility of 162 cm2 V--1 s--1 is predicted at room temperature. The simulated charge transport properties for CuI are compared to existing experimental data, and the implications for future device performance are discussed. In addition to charge transport calculations, the defect chemistry of CuI is investigated with hybrid functionals, revealing that reasonably localized holes from the copper vacancy are the predominant source of charge carriers. The chalcogens S and Se are investigated as extrinsic dopants, where it is found that despite relatively low defect formation energies, they are unlikely to act as efficient electron acceptors due to the strong localization of holes and subsequent deep transition levels.}, + file = {/Users/kavanase/Zotero/storage/IXIEWT7W/Willis et al_2023_Limits to Hole Mobility and Doping in Copper Iodide.pdf} } @article{willis_possibility_2023, @@ -808,15 +815,15 @@ @article{cp2k URL = {https://doi.org/10.1063/5.0007045}, eprint = {https://doi.org/10.1063/5.0007045} } -@misc{wang_upper_2024, - title = {Upper Efficiency Limit of {{Sb2Se3}} Solar Cells}, +@article{wang_upper_2024, + title = {Upper Efficiency Limit of {{Sb{\textsubscript{2}}Se{\textsubscript{3}}}} Solar Cells}, author = {Wang, Xinwei and Kavanagh, Se{\'a}n R. and Scanlon, David O. and Walsh, Aron}, year = {2024}, month = feb, number = {arXiv:2402.04434}, eprint = {2402.04434}, primaryclass = {cond-mat}, - publisher = {{arXiv}}, + journal = {{arXiv}}, doi = {10.48550/arXiv.2402.04434}, urldate = {2024-02-22}, abstract = {Antimony selenide (Sb2Se3) is at the forefront of an emerging class of sustainable photovoltaic materials. Despite notable developments over the past decade, the light-to-electricity conversion efficiency of Sb2Se3 has reached a plateau of {\textasciitilde}10\%. Is this an intrinsic limitation of the material or is there scope to rival the success of metal halide perovskite solar cells? Here we assess the trap-limited conversion efficiency of Sb2Se3. First-principles defect analysis of the hole and electron capture rates for point defects demonstrates the critical role of vacancies as active recombination centres. We predict an upper limit of 25\% efficiency in Sb2Se3 grown under optimal equilibrium conditions where the concentrations of charged vacancies are minimised. We further reveal how the detrimental effect of Se vacancies can be reduced by extrinsic oxygen passivation, highlighting a pathway to achieve high-performance metal selenide solar cells close to the thermodynamic limit.}, @@ -826,7 +833,7 @@ @misc{wang_upper_2024 } @article{yuan_discovery_2024, - title = {Discovery of the {{Zintl-phosphide BaCd2P2}} as a Long Carrier Lifetime and Stable Solar Absorber}, + title = {Discovery of the {{Zintl-phosphide BaCd{\textsubscript{2}}P{\textsubscript{2}}}} as a Long Carrier Lifetime and Stable Solar Absorber}, author = {Yuan, Zhenkun and Dahliah, Diana and Hasan, Muhammad Rubaiat and Kassa, Gideon and Pike, Andrew and Quadir, Shaham and Claes, Romain and Chandler, Cierra and Xiong, Yihuang and Kyveryga, Victoria and Yox, Philip and Rignanese, Gian-Marco and Dabo, Ismaila and Zakutayev, Andriy and Fenning, David P. and Reid, Obadiah G. and Bauers, Sage and Liu, Jifeng and Kovnir, Kirill and Hautier, Geoffroy}, year = {2024}, month = mar, @@ -839,7 +846,7 @@ @article{yuan_discovery_2024 } @article{broberg_high-throughput_2023, - title = {High-Throughput Calculations of Charged Point Defect Properties with Semi-Local Density Functional Theory---Performance Benchmarks for Materials Screening Applications}, + title = {High-Throughput Calculations of Charged Point Defect Properties with Semi-Local Density Functional Theory – Performance Benchmarks for Materials Screening Applications}, author = {Broberg, Danny and Bystrom, Kyle and Srivastava, Shivani and Dahliah, Diana and Williamson, Benjamin A. D. and Weston, Leigh and Scanlon, David O. and Rignanese, Gian-Marco and Dwaraknath, Shyam and Varley, Joel and Persson, Kristin A. and Asta, Mark and Hautier, Geoffroy}, year = {2023}, month = may, diff --git a/docs/JOSS/paper.md b/docs/JOSS/paper.md index ccd22259..69debd25 100644 --- a/docs/JOSS/paper.md +++ b/docs/JOSS/paper.md @@ -62,8 +62,8 @@ bibliography: paper.bib Defects are a universal feature of crystalline solids, dictating the key properties and performance of many functional materials. Given their crucial importance yet inherent difficulty in measuring experimentally, computational methods (such as DFT and ML/classical force-fields) are widely used to predict defect behaviour at the atomic level and the resultant impact on macroscopic properties. -Here we report ``doped``, a Python package for the generation, pre-/post-processing and analysis of defect supercell calculations. -``doped`` has been built to implement the defect simulation workflow in an efficient, user-friendly yet powerful and fully-flexible manner, with the goal of providing a robust general-purpose platform for conducting reproducible calculations of solid-state defect properties. +Here we report ``doped``, a Python package for the generation, pre-/post-processing, and analysis of defect supercell calculations. +``doped`` has been built to implement the defect simulation workflow in an efficient and user-friendly – yet powerful and fully-flexible – manner, with the goal of providing a robust general-purpose platform for conducting reproducible calculations of solid-state defect properties. [//]: # (such as conductivity, carrier recombination, catalytic activity etc) [//]: # (The typically dilute concentration of defects, despite their major impact on macroscopic properties, renders their experimental characterisation extremely challenging however. ) @@ -77,12 +77,12 @@ Here we report ``doped``, a Python package for the generation, pre-/post-process The materials science sub-field of computational defect modelling has seen considerable growth in recent years, driven by the crucial importance of these species in functional materials and the major advances in computational methodologies and resources facilitating their accurate simulation. Software which enables researchers to efficiently and accurately perform these calculations, while allowing for in-depth target analyses of the resultant data, is thus of significant value to the community. Indeed there are many critical stages in the computational workflow for defects, which when performed manually not only consume significant researcher time and effort but also leave room for human error – particularly for newcomers to the field. -Moreover, there are growing efforts to perform high-throughput investigations of defects in solids [@xiong_high-throughput_2023,@yuan_discovery_2024,@broberg_high-throughput_2023], necessitating robust, user-friendly and efficient software implementing this calculation workflow. +Moreover, there are growing efforts to perform high-throughput investigations of defects in solids [@xiong_high-throughput_2023; @yuan_discovery_2024; @broberg_high-throughput_2023], necessitating robust, user-friendly, and efficient software implementing this calculation workflow. [//]: # (By expediting the defect simulation workflow and providing efficient analysis tools, ``doped`` aims to... facilitate the investigation of defects in solids, and to enable the efficient and reproducible calculation of solid-state defect properties.) Given this importance of defect simulations and the complexity of the workflow, a number of software packages have been developed with the goal of managing pre- and post-processing of defect calculations, including work on the `HADES`/`METADISE` codes from the 1970s [@parker_hades_2004], to more recent work from @Kumagai2021, @Broberg2018, @Shen2024, @neilson_defap_2022, @Arrigoni2021, @Goyal2017, @Huang2022, @pean_presentation_2017 and @naik_coffee_2018.[^1] -While each of these codes have their strengths, they do not include the full suite of functionality provided by `doped` – some of which is discussed below – nor adopt the same focus on user-friendliness (along with sanity-checking warnings & error catching) and efficiency with full flexibility and wide-ranging functionality, targeting expert-level users and newcomers to the field alike. +While each of these codes have their strengths, they do not include the full suite of functionality provided by `doped` – some of which is discussed below – nor adopt the same focus on user-friendliness (along with sanity-checking warnings and error catching) and efficiency with full flexibility and wide-ranging functionality, targeting expert-level users and newcomers to the field alike. [^1]: Some of these packages are no longer maintained, not compatible with high-throughput architectures, and/or are closed-source/commercial packages. @@ -96,11 +96,11 @@ While each of these codes have their strengths, they do not include the full sui # doped -`doped` is a Python software for the generation, pre-/post-processing and analysis of defect supercell calculations, as depicted in \autoref{fig_workflow}. -The design philosophy of `doped` has been to implement the defect simulation workflow in an efficient, reproducible, user-friendly yet powerful and fully-customisable manner, combining reasonable defaults with full user control for each parameter in the workflow. -As depicted in \autoref{fig_workflow}, the core functionality of `doped` is the generation of defect supercells and competing phases, writing calculation input files, parsing calculation outputs and analysing/plotting defect-related properties. This functionality and recommended usage of `doped` is demonstrated in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html) on the [documentation website](https://doped.readthedocs.io/en/latest/). +`doped` is a Python package for the generation, pre-/post-processing, and analysis of defect supercell calculations, as depicted in \autoref{fig_workflow}. +The design philosophy of `doped` has been to implement the defect simulation workflow in an efficient, reproducible, and user-friendly – yet powerful and fully-customisable – manner, combining reasonable defaults with full user control for each parameter in the workflow. +As depicted in \autoref{fig_workflow}, the core functionality of `doped` is the generation of defect supercells and competing phases, writing calculation input files, parsing calculation outputs, and analysing/plotting defect-related properties. This functionality and recommended usage of `doped` is demonstrated in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html) on the [documentation website](https://doped.readthedocs.io/en/latest/). -![**a.** Average minimum periodic image distance, normalised by the ideal image distance at that volume (i.e. for a perfect close-packed face-centred cubic (FCC) cell), versus the number of primitive unit cells, for the supercell generation algorithms of `doped`, `ASE` and `pymatgen`. "SC" = simple cubic and "HCP" = hexagonal close-packed. **b.** Average performance of various charge state estimation routines, in terms of false positives/negatives. "ICSD probabilities" refers to a model based on the probabilities of oxidation states, as given by their occurrence in the ICSD database. Asterisk indicates that `pyCDT` "false _negatives_" are underestimated as the majority of this test set used the estimated charge state ranges from `pyCDT`. "Ox. state" = oxidation state. Example **(c)** Kumagai-Oba (extended Freysoldt-Neugebauer-Van-de-Walle; "eFNV") finite-size correction plot, **(d)** defect formation energy diagram, **(e)** chemical potential / stability region, **(f)** Fermi level vs. annealing temperature, **(g)** defect/carrier concentrations vs. annealing temperature and **(h)** Fermi level / carrier concentration heatmap plots from `doped`. Automated plots of single-particle eigenvalues from DFT supercell calculations for **(i)** $V_{Cu}^{0}$ in $Cu_2SiSe_3$ and **(j)** $V_{Cd}^{-1}$ in CdTe. **(k)** Automated site displacement analysis, plotting atomic displacements with respect to the defect site against distance to the defect site, for $V_{Cd}^{-1}$ in CdTe. Data and code to reproduce these plots is provided in the [`docs/JOSS`](https://github.com/SMTG-Bham/doped/blob/main/docs/JOSS) subfolder of the `doped` GitHub repository. \label{fig1}](doped_JOSS_figure.png) +![Performance and example outputs from `doped`. **(a)** Average minimum periodic image distance, normalised by the ideal image distance (i.e. for a close-packed face-centred cubic (FCC) cell), vs. number of unit cells for supercell generation algorithms in `doped`, `ASE`, and `pymatgen`. "SC" = simple cubic and "HCP" = hexagonal close-packed. **(b)** Average performance of various charge state estimation routines. "ICSD probabilities" refers to a model based oxidation state probabilities, as given by their occurrence in the ICSD database. Asterisk indicates that `pyCDT` "false _negatives_" are underestimated as the majority of this test set used the `pyCDT` charge state ranges. "Ox. state" = oxidation state. Example **(c)** Kumagai-Oba (eFNV) finite-size correction plot, **(d)** defect formation energy diagram, **(e)** chemical potential / stability region, **(f)** Fermi level vs. annealing temperature, **(g)** defect/carrier concentrations vs. annealing temperature and **(h)** Fermi level / carrier concentration heatmap plots from `doped`. Automated plots of single-particle eigenvalues from DFT supercell calculations for **(i)** $V_{Cu}^{0}$ in Cu$_2$SiSe$_3$ and **(j)** $V_{Cd}^{-1}$ in CdTe. **(k)** Automated site displacement analysis, plotting atomic displacements with respect to the defect site against distance to the defect site, for $V_{Cd}^{-1}$ in CdTe. Data and code to reproduce these plots is provided in the [`docs/JOSS`](https://github.com/SMTG-Bham/doped/blob/main/docs/JOSS) folder of the `doped` GitHub repository. \label{fig1}](doped_JOSS_figure.png) Some key advances of `doped` include: @@ -108,7 +108,8 @@ Some key advances of `doped` include: - Over a test set of simple cubic, trigonal, orthorhombic, monoclinic and face-centred cubic unit cells, the `doped` algorithm is found to give mean improvements of 35.2%, 9.1% and 6.7% in the minimum image distance for a given (maximum) number of unit cells as compared to the `pymatgen` cubic supercell algorithm, the `ASE` optimal cell shape algorithm with simple-cubic target shape, and `ASE` with FCC target shape respectively – in the range of 2-20 unit cells. For 2-50 unit cells (for which the mean values across this test set are plotted in \autoref{fig1}a), this becomes 36.0%, 9.3% and 5.6% respectively. Given the approximately cubic scaling of DFT computational cost with the number of atoms, these correspond to significant reductions in cost (~20-150%). - As always, the user has full control over supercell generation in `doped`, with the ability to specify/adjust constraints on the minimum image distance, number of atoms or transformation matrix, or to simply provide a pre-generated supercell if desired. - **Charge-state Estimation:** Defects in solids can adopt various electronic charge states. However, the set of stable charge states for a given defect is typically not known _a priori_, so one must choose a set of _possible_ defect charge states to calculate – usually relying on some form of chemical intuition. In this regard, extremal defect charge states that are calculated but do not end up being stable can be considered 'false positives' or 'wasted' calculations,[^2] while charge states which are stable but were not calculated can be considered 'false negatives' or 'missed' calculations. `doped` builds on other routines which use known elemental oxidation states to additionally account for oxidation state _probabilities_, the electronic state of the host crystal and charge state magnitudes. Implementing these features in a simple cost function, we find a significant improvement in terms of both efficiency (reduced false positives) and completeness (reduced false negatives) for this charge state estimation, as shown in \autoref{fig1}b.[^3] - - Again, this step is fully-customisable. The user can tune the probability threshold at which to include charge states or manually specify defect charge states. All probability factors computed are available to the user and saved to the defect `JSON` files for full reproducibility. + + Again, this step is fully-customisable. The user can tune the probability threshold at which to include charge states or manually specify defect charge states. All probability factors computed are available to the user and saved to the defect `JSON` files for full reproducibility. [^2]: Note that _unstable_ defect charge states which are intermediate between _stable_ charge states (e.g. $X^0$ for a defect $X$ with a (+1/-1) negative-U level) should still be calculated and are _not_ considered false positives. @@ -127,15 +128,15 @@ Some key advances of `doped` include: N_D = gN_s \exp(-E_f/k_BT) \end{equation} - where $g$ is the product of all degeneracy factors, $N_s$ is the concentration of lattice sites for that defect, $E_f$ is the defect formation energy and $N_D$ is the defect concentration. $g$ can affect predicted defect/carrier concentrations by up to 2/3 orders of magnitude [@mosquera-lois_imperfections_2023; @kavanagh_impact_2022], and is often overlooked in defect calculations, partly due to the (previous) requirement of significant manual effort and knowledge of group theory. + where $g$ is the product of all degeneracy factors, $N_s$ is the concentration of lattice sites for that defect, $E_f$ is the defect formation energy and $N_D$ is the defect concentration. $g$ can affect predicted defect/carrier concentrations by up to two or three orders of magnitude [@mosquera-lois_imperfections_2023; @kavanagh_impact_2022], and is often overlooked in defect calculations, partly due to the (previous) requirement of significant manual effort and knowledge of group theory. - **Automated Compatibility Checking:** When parsing defect calculations, `doped` automatically checks that calculation parameters which could affect the defect formation energy (e.g. _k_-point grid, energy cutoff, pseudopotential choice, exchange fraction, Hubbard U etc.) are consistent between the defect and reference calculations. This is a common source of accidental error in defect calculations, and `doped` provides informative warnings if any inconsistencies are detected. -- **Thermodynamic Analysis:** `doped` provides a suite of flexible tools for the analysis of defect thermodynamics, including formation energy diagrams (\autoref{fig1}d), equilibrium & non-equilibrium Fermi level solving (\autoref{fig1}f), doping analysis (\autoref{fig1}g,h), Brouwer-type diagrams etc. These include physically-motivated (but tunable) grouping of defect sites, full inclusion of metastable states, support for complex system constraints, optimisation over high-dimensional chemical & temperature space and highly-customisable plotting. In-depth examples are provided in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html). +- **Thermodynamic Analysis:** `doped` provides a suite of flexible tools for the analysis of defect thermodynamics, including formation energy diagrams (\autoref{fig1}d), equilibrium & non-equilibrium Fermi level solving (\autoref{fig1}f), doping analysis (\autoref{fig1}g,h), Brouwer-type diagrams etc. These include physically-motivated (but tunable) grouping of defect sites, full inclusion of metastable states, support for complex system constraints, optimisation over high-dimensional chemical & temperature space and highly customisable plotting. In-depth examples are provided in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html). -- **Finite-Size Corrections:** Both the isotropic Freysoldt (FNV) [@Freysoldt2009] and anisotropic Kumagai (eFNV) [@kumagai_electrostatics-based_2014] image charge corrections are implemented automatically in `doped`, with tunable sampling radii / sites (which may be desirable for e.g. layered materials), automated correction plotting (to visualise/analyse convergence; \autoref{fig1}c) and automatic sampling error estimation. +- **Finite-Size Corrections:** Both the isotropic Freysoldt (FNV) [@Freysoldt2009] and anisotropic Kumagai (eFNV) [@kumagai_electrostatics-based_2014] image charge corrections are implemented automatically in `doped`, with tunable sampling radii / sites (which may be desirable for e.g. layered materials), automated correction plotting (to visualise/analyse convergence; \autoref{fig1}c), and automatic sampling error estimation. -- **Reproducibility & Tabulation:** `doped` has been built to support and encourage reproducibility, with all input parameters and calculation results saved to lightweight `JSON` files. This allows for easy sharing of calculation inputs/outputs and reproducible analysis. Several tabulation functions are also provided to facilitate the quick summarising of key quantities as exemplified in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html) (including defect formation energy contributions, charge transition levels (with/without metastable states), symmetry, degeneracy and multiplicity factors, defect/carrier concentrations, chemical potential limits, dopability limits, doping windows...) to aid transparency, reproducibility, comparisons with other works and general analysis. The use of these tabulated outputs in supporting information of publications is encouraged. +- **Reproducibility & Tabulation:** `doped` has been built to support and encourage reproducibility, with all input parameters and calculation results saved to lightweight `JSON` files. This allows for easy sharing of calculation inputs/outputs and reproducible analysis. Several tabulation functions are also provided to facilitate the quick summarising of key quantities as exemplified in the [tutorials](https://doped.readthedocs.io/en/latest/Tutorials.html) (including defect formation energy contributions, charge transition levels (with/without metastable states), symmetry, degeneracy and multiplicity factors, defect/carrier concentrations, chemical potential limits, dopability limits, doping windows...) to aid transparency, reproducibility, comparisons with other works, and general analysis. The use of these tabulated outputs in supporting information of publications is encouraged. - **High-Throughput Compatibility:** `doped` is built to be compatible with high-throughput architectures such as [atomate(2)](https://github.com/materialsproject/atomate2) [@atomate] or [AiiDA](https://aiida.net) [@AiiDA], aided by its object-oriented Python framework, JSON-serializable classes and sub-classed `pymatgen` objects. Examples are provided on the [documentation website](https://doped.readthedocs.io/en/latest/). diff --git a/docs/conf.py b/docs/conf.py index 64700bee..8f7a8278 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ author = 'Seán R. Kavanagh' # The full version, including alpha/beta/rc tags -release = '2.4.0' +release = '2.4.1' # -- General configuration --------------------------------------------------- diff --git a/doped/analysis.py b/doped/analysis.py index aab66429..057d1daf 100644 --- a/doped/analysis.py +++ b/doped/analysis.py @@ -589,6 +589,27 @@ def __init__( and dir not in (self.bulk_path.split("/") if self.bulk_path else []) ] + if not possible_defect_folders: # user may have specified the defect folder directly, so check + # if we can dynamically determine the defect folder: + possible_defect_folders = [ + dir + for dir in os.listdir(os.path.join(self.output_path, os.pardir)) + if any( + "vasprun" in file and ".xml" in file + for file_list in [ + tup[2] for tup in os.walk(os.path.join(self.output_path, os.pardir, dir)) + ] + for file in file_list + ) + and ( + os.path.basename(self.output_path) in dir # only that defect directory + or "bulk" in str(dir).lower() # or a bulk directory, for later + ) + and dir not in (self.bulk_path.split("/") if self.bulk_path else []) + ] + if possible_defect_folders: # update output path (otherwise will crash with informative error) + self.output_path = os.path.join(self.output_path, os.pardir) + if self.subfolder is None: # determine subfolder to use vasp_subfolders = [ subdir diff --git a/doped/utils/plotting.py b/doped/utils/plotting.py index f531d8d5..697dafe4 100644 --- a/doped/utils/plotting.py +++ b/doped/utils/plotting.py @@ -627,7 +627,7 @@ def _get_legends_txt(for_legend, all_entries=False): while defect_name in legends_txt: i += 1 - defect_name = f"{defect_name}$_{{-{chr(96 + i)}}}$" # d, e, f etc + defect_name = f"{defect_name.rsplit('$_', 1)[0]}$_{{-{chr(96 + i)}}}$" # d, e, f etc legends_txt.append(defect_name) @@ -663,7 +663,7 @@ def _rename_key_and_dicts( while key in output_dict: i += 1 - key = f"{key}_{chr(96 + i)}" # d, e, f etc + key = f"{key.rsplit('_', 1)[0]}_{chr(96 + i)}" # d, e, f etc return key, output_dicts diff --git a/examples/chemical_potentials_tutorial.ipynb b/examples/chemical_potentials_tutorial.ipynb index fd66b1a2..db913a90 100644 --- a/examples/chemical_potentials_tutorial.ipynb +++ b/examples/chemical_potentials_tutorial.ipynb @@ -386,6 +386,16 @@ }, "id": "1f5f72e255e8bca6" }, + { + "metadata": {}, + "cell_type": "markdown", + "source": [ + "```{tip}\n", + "_Usually_ we expect mostly equivalent energy convergence with respect to _k_-points / basis set for semi-local (GGA) and hybrid DFT. _**However,**_ this may not be the case when there is a major qualitative change in behaviour between semi-local/hybrid DFT, such as going from metallic at the GGA level to semiconducting with hybrid DFT – which can occur for relatively low band gap systems. In these cases, it can be worth performing the convergence tests with hybrid DFT to see if convergence is reached at lower _k_-point densities / basis set sizes.\n", + "```" + ], + "id": "d7c6d3cbe30fd891" + }, { "cell_type": "code", "execution_count": 11, @@ -543,6 +553,18 @@ }, "id": "621f6eb8e7815ba5" }, + { + "metadata": {}, + "cell_type": "markdown", + "source": [ + "```{tip}\n", + "For hybrid DFT competing phase relaxations, it is often a good idea to use the [`NKRED(X,Y,Z)`](https://www.vasp.at/wiki/index.php/NKRED) `INCAR` tag(s), which reduce the _k_-point grid used in the Fock exchange potential by the factor specified, to speed up the calculations while retaining good accuracy. Note that `NKRED(X,Y,Z)` needs to divide into the number of _k_-points in the corresponding direction. Typically `NKRED(X,Y,Z)` has a greater effect on energy rather than force accuracy, and so it is often useful to use `NKRED(X,Y,Z)` values of `2` – or possibly `3` for high _k_-point densities – to pre-converge the structure relaxation, before then continuing the calculations without `NKRED(X,Y,Z)` for the final energy; which often then only requires one or two ionic steps. \n", + "\n", + "`NKRED(X,Y,Z)` is particularly useful for metals, where overall dense _k_-point grids are required, but the Fock exchange contribution typically converges at much lower _k_-point densities. In such cases, `NKRED(X,Y,Z)` can be used to greatly reduce the computational cost with minimal loss of accuracy. A further relaxation/energy calculation without `NKRED(X,Y,Z)` may not be required in these cases, but it is good practice to check the accuracy by comparing the energies of the same structure with and without `NKRED(X,Y,Z)`.\n", + "```" + ], + "id": "47203ec1c58e5147" + }, { "cell_type": "markdown", "id": "7e57cb66", diff --git a/pyproject.toml b/pyproject.toml index 0334a0cf..2e991e5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "doped" -version = "2.4.0" +version = "2.4.1" description = "Python package to setup, process and analyse solid-state defect calculations with VASP" authors = [{name = "Seán Kavanagh", email = "skavanagh@seas.harvard.edu"}] readme = "README.md" diff --git a/tests/data/remote_baseline_plots/CdTe_v_cd_m2_eigenvalue_plot.png b/tests/data/remote_baseline_plots/CdTe_v_cd_m2_eigenvalue_plot.png index 51c248d3..1b428e6e 100644 Binary files a/tests/data/remote_baseline_plots/CdTe_v_cd_m2_eigenvalue_plot.png and b/tests/data/remote_baseline_plots/CdTe_v_cd_m2_eigenvalue_plot.png differ diff --git a/tests/data/remote_baseline_plots/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png b/tests/data/remote_baseline_plots/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png index 059f9c04..c4c06fdf 100644 Binary files a/tests/data/remote_baseline_plots/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png and b/tests/data/remote_baseline_plots/Cu2SiSe3_v_Cu_0_eigenvalue_plot.png differ diff --git a/tests/dope_potcar_tests.ipynb b/tests/dope_potcar_tests.ipynb index f4495e05..6d3c6e72 100644 --- a/tests/dope_potcar_tests.ipynb +++ b/tests/dope_potcar_tests.ipynb @@ -13,13 +13,26 @@ }, { "cell_type": "code", - "execution_count": 1, + "source": [ + "from pymatgen.core.structure import Structure\n", + "from doped.generation import DefectsGenerator\n", + "\n", + "relaxed_primitive_CdTe = Structure.from_file(\"../examples/CdTe/relaxed_primitive_POSCAR\")\n", + "defect_gen = DefectsGenerator(relaxed_primitive_CdTe)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-04-10T20:34:05.619409Z", + "start_time": "2024-04-10T20:33:41.367733Z" + } + }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Generating DefectEntry objects: 100.0%|██████████| [00:01, 70.27it/s]" + "Generating DefectEntry objects: 100.0%|██████████| [00:11, 8.67it/s] " ] }, { @@ -27,23 +40,23 @@ "output_type": "stream", "text": [ "Vacancies Guessed Charges Conv. Cell Coords Wyckoff\n", - "----------- --------------- ------------------- ---------\n", - "v_Cd [-2,-1,0,+1] [0.000,0.000,0.000] 4a\n", - "v_Te [-1,0,+1,+2] [0.250,0.250,0.250] 4c\n", + "----------- ----------------- ------------------- ---------\n", + "v_Cd [+1,0,-1,-2] [0.000,0.000,0.000] 4a\n", + "v_Te [+2,+1,0,-1] [0.250,0.250,0.250] 4c\n", "\n", - "Substitutions Guessed Charges Conv. Cell Coords Wyckoff\n", + "Substitutions Guessed Charges Conv. Cell Coords Wyckoff\n", "--------------- --------------------- ------------------- ---------\n", - "Cd_Te [0,+1,+2,+3,+4] [0.250,0.250,0.250] 4c\n", - "Te_Cd [-4,-3,-2,-1,0,+1,+2] [0.000,0.000,0.000] 4a\n", + "Cd_Te [+4,+3,+2,+1,0] [0.250,0.250,0.250] 4c\n", + "Te_Cd [+2,+1,0,-1,-2,-3,-4] [0.000,0.000,0.000] 4a\n", "\n", - "Interstitials Guessed Charges Conv. Cell Coords Wyckoff\n", + "Interstitials Guessed Charges Conv. Cell Coords Wyckoff\n", "--------------- --------------------- ------------------- ---------\n", - "Cd_i_C3v [0,+1,+2] [0.625,0.625,0.625] 16e\n", - "Cd_i_Td_Cd2.83 [0,+1,+2] [0.750,0.750,0.750] 4d\n", - "Cd_i_Td_Te2.83 [0,+1,+2] [0.500,0.500,0.500] 4b\n", - "Te_i_C3v [-2,-1,0,+1,+2,+3,+4] [0.625,0.625,0.625] 16e\n", - "Te_i_Td_Cd2.83 [-2,-1,0,+1,+2,+3,+4] [0.750,0.750,0.750] 4d\n", - "Te_i_Td_Te2.83 [-2,-1,0,+1,+2,+3,+4] [0.500,0.500,0.500] 4b\n", + "Cd_i_C3v [+2,+1,0] [0.625,0.625,0.625] 16e\n", + "Cd_i_Td_Cd2.83 [+2,+1,0] [0.750,0.750,0.750] 4d\n", + "Cd_i_Td_Te2.83 [+2,+1,0] [0.500,0.500,0.500] 4b\n", + "Te_i_C3v [+4,+3,+2,+1,0,-1,-2] [0.625,0.625,0.625] 16e\n", + "Te_i_Td_Cd2.83 [+4,+3,+2,+1,0,-1,-2] [0.750,0.750,0.750] 4d\n", + "Te_i_Td_Te2.83 [+4,+3,+2,+1,0,-1,-2] [0.500,0.500,0.500] 4b\n", "\n", "The number in the Wyckoff label is the site multiplicity/degeneracy of that defect in the conventional ('conv.') unit cell, which comprises 4 formula unit(s) of CdTe.\n", "Note that Wyckoff letters can depend on the ordering of elements in the conventional standard structure, for which doped uses the spglib convention.\n" @@ -57,43 +70,52 @@ ] } ], - "source": [ - "from pymatgen.core.structure import Structure\n", - "from doped.generation import DefectsGenerator\n", - "\n", - "relaxed_primitive_CdTe = Structure.from_file(\"../examples/CdTe/relaxed_primitive_POSCAR\")\n", - "defect_gen = DefectsGenerator(relaxed_primitive_CdTe)" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2023-09-07T09:26:09.819686Z", - "start_time": "2023-09-07T09:26:04.393988Z" - } - } + "execution_count": 1 }, { "cell_type": "code", - "execution_count": 2, "metadata": { "pycharm": { "name": "#%%\n" }, "ExecuteTime": { - "end_time": "2023-09-07T09:26:09.885533Z", - "start_time": "2023-09-07T09:26:09.820782Z" + "end_time": "2024-04-10T20:34:05.767167Z", + "start_time": "2024-04-10T20:34:05.621443Z" } }, - "outputs": [], "source": [ "from doped.vasp import DefectsSet\n", "ds = DefectsSet(defect_gen, user_incar_settings={\"Whoops\": \"lol\"})\n", "# doped should warn me if I put in a whack INCAR tag (or misspell)" - ] + ], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n", + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n", + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n", + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n", + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n", + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n" + ] + } + ], + "execution_count": 2 }, { "cell_type": "code", - "execution_count": 3, + "source": [ + "ds.defect_sets[\"v_Cd_-2\"].vasp_std" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-04-10T20:34:05.792944Z", + "start_time": "2024-04-10T20:34:05.767970Z" + } + }, "outputs": [ { "name": "stderr", @@ -104,51 +126,63 @@ }, { "data": { - "text/plain": "DefectDictSet" + "text/plain": [ + "doped DefectDictSet with supercell composition Cd26 Te27. Available attributes:\n", + "{'charge_state', 'auto_ismear', 'international_monoclinic', 'prev_vasprun', 'nelect', 'user_potcar_functional', 'potcar_symbols', 'incar', 'constrain_total_magmom', 'user_potcar_settings', 'sort_structure', 'user_kpoints_settings', 'sym_prec', 'config_dict', 'inherit_incar', 'incar_updates', 'potcar', 'poscar_comment', 'vdw', 'prev_incar', 'standardize', 'potcar_functional', 'validate_magmom', 'user_incar_settings', 'bandgap_tol', 'files_to_transfer', 'prev_outcar', 'poscar', 'force_gamma', 'bandgap', 'auto_kpar', 'kpoints', 'structure', 'use_structure_charge', 'reduce_structure', 'kpoints_updates', 'prev_kpoints'}\n", + "\n", + "Available methods:\n", + "{'get_input_set', 'validate_monty_v2', 'calculate_ng', 'override_from_prev_calc', 'validate_monty_v1', 'from_dict', 'unsafe_hash', 'write_input', 'estimate_nbands', 'get_vasp_input', 'as_dict', 'from_prev_calc', 'to_json'}" + ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "ds.defect_sets[\"v_Cd_-2\"].vasp_std" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2023-09-07T09:26:09.891001Z", - "start_time": "2023-09-07T09:26:09.885731Z" - } - } + "execution_count": 3 }, { "cell_type": "code", - "execution_count": 4, - "outputs": [], "source": [ "ds.defect_sets[\"v_Cd_-2\"].write_gam()" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:26:10.244340Z", - "start_time": "2023-09-07T09:26:09.890477Z" + "end_time": "2024-04-10T20:34:05.905512Z", + "start_time": "2024-04-10T20:34:05.793997Z" } - } + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Cannot find Whoops from your user_incar_settings in the list of INCAR flags\n" + ] + } + ], + "execution_count": 4 }, { "cell_type": "code", - "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" }, "ExecuteTime": { - "end_time": "2023-09-07T09:26:10.967828Z", - "start_time": "2023-09-07T09:26:10.247355Z" + "end_time": "2024-04-10T20:34:06.629257Z", + "start_time": "2024-04-10T20:34:05.908187Z" } }, + "source": [ + "!grep PAW_PBE v_Cd_-2/vasp_gam/POTCAR\n", + "!grep ZVAL v_Cd_-2/vasp_gam/POTCAR\n", + "print(f\"NELECT should be: {31*12 + 32*6 + 2}\")\n", + "!grep NELECT v_Cd_-2/vasp_gam/INCAR\n", + "!grep NUP v_Cd_-2/vasp_gam/INCAR\n", + "!grep EDIFF v_Cd_-2/vasp_gam/INCAR" + ], "outputs": [ { "name": "stdout", @@ -161,180 +195,190 @@ " POMASS = 112.411; ZVAL = 12.000 mass and valenz\r\n", " POMASS = 127.600; ZVAL = 6.000 mass and valenz\r\n", "NELECT should be: 566\n", - "NELECT = 566.0\r\n", - "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN = Typical variable parameters\r\n", + "NELECT = 476.0\r\n", + "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN, MAGMOM = Typical variable parameters\r\n", "NUPDOWN = 0\r\n", "EDIFF = 1e-05\r\n", "EDIFFG = -0.01\r\n" ] } ], - "source": [ - "!grep PAW_PBE v_Cd_-2/vasp_gam/POTCAR\n", - "!grep ZVAL v_Cd_-2/vasp_gam/POTCAR\n", - "print(f\"NELECT should be: {31*12 + 32*6 + 2}\")\n", - "!grep NELECT v_Cd_-2/vasp_gam/INCAR\n", - "!grep NUP v_Cd_-2/vasp_gam/INCAR\n", - "!grep EDIFF v_Cd_-2/vasp_gam/INCAR" - ] + "execution_count": 5 }, { "cell_type": "code", - "execution_count": 15, - "outputs": [], "source": [ "ds = DefectsSet(defect_gen, user_potcar_settings={\"POTCAR\":{\"Cd\": \"Cd_sv_GW\"}})" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:26:38.112748Z", - "start_time": "2023-09-07T09:26:38.109647Z" + "end_time": "2024-04-10T20:34:55.318684Z", + "start_time": "2024-04-10T20:34:55.171175Z" } - } + }, + "outputs": [], + "execution_count": 6 }, { "cell_type": "code", - "execution_count": 16, - "outputs": [], "source": [ "ds.defect_sets[\"v_Cd_-2\"].write_gam()" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:26:38.675503Z", - "start_time": "2023-09-07T09:26:38.248394Z" + "end_time": "2024-04-10T20:34:56.021623Z", + "start_time": "2024-04-10T20:34:55.971166Z" } - } + }, + "outputs": [], + "execution_count": 7 }, { "cell_type": "code", - "execution_count": 17, + "source": [ + "!grep PAW_PBE v_Cd_-2/vasp_gam/POTCAR\n", + "!grep ZVAL v_Cd_-2/vasp_gam/POTCAR\n", + "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", + "!grep NELECT v_Cd_-2/vasp_gam/INCAR\n", + "!grep NUP v_Cd_-2/vasp_gam/INCAR\n", + "!grep EDIFF v_Cd_-2/vasp_gam/INCAR" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-04-10T20:34:57.184342Z", + "start_time": "2024-04-10T20:34:56.453901Z" + } + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + " PAW_PBE Cd_sv_GW 16Apr2014 \r\n", + " TITEL = PAW_PBE Cd_sv_GW 16Apr2014\r\n", " PAW_PBE Te 08Apr2002 \r\n", " TITEL = PAW_PBE Te 08Apr2002\r\n", " POMASS = 112.411; ZVAL = 20.000 mass and valenz\r\n", " POMASS = 127.600; ZVAL = 6.000 mass and valenz\r\n", "NELECT should be: 814\n", - "NELECT = 814.0\r\n", - "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN = Typical variable parameters\r\n", + "NELECT = 684.0\r\n", + "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN, MAGMOM = Typical variable parameters\r\n", "NUPDOWN = 0\r\n", "EDIFF = 1e-05\r\n", "EDIFFG = -0.01\r\n" ] } ], + "execution_count": 8 + }, + { + "cell_type": "code", "source": [ - "!grep PAW_PBE v_Cd_-2/vasp_gam/POTCAR\n", - "!grep ZVAL v_Cd_-2/vasp_gam/POTCAR\n", - "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", - "!grep NELECT v_Cd_-2/vasp_gam/INCAR\n", - "!grep NUP v_Cd_-2/vasp_gam/INCAR\n", - "!grep EDIFF v_Cd_-2/vasp_gam/INCAR" + "ds.defect_sets[\"v_Cd_-2\"].write_nkred_std()" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:26:39.825864Z", - "start_time": "2023-09-07T09:26:39.169833Z" + "end_time": "2024-04-10T20:34:58.657044Z", + "start_time": "2024-04-10T20:34:58.621384Z" } - } + }, + "outputs": [], + "execution_count": 9 }, { "cell_type": "code", - "execution_count": 18, - "outputs": [], "source": [ - "ds.defect_sets[\"v_Cd_-2\"].write_nkred_std()" + "!grep PAW_PBE v_Cd_-2/vasp_nkred_std/POTCAR\n", + "!grep ZVAL v_Cd_-2/vasp_nkred_std/POTCAR\n", + "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", + "!grep NELECT v_Cd_-2/vasp_nkred_std/INCAR\n", + "!grep NUP v_Cd_-2/vasp_nkred_std/INCAR\n", + "!grep EDIFF v_Cd_-2/vasp_nkred_std/INCAR\n", + "!grep NKRED v_Cd_-2/vasp_nkred_std/INCAR\n", + "!grep KPAR v_Cd_-2/vasp_nkred_std/INCAR" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:27:01.046362Z", - "start_time": "2023-09-07T09:27:00.774243Z" + "end_time": "2024-04-10T20:34:59.749020Z", + "start_time": "2024-04-10T20:34:58.825714Z" } - } - }, - { - "cell_type": "code", - "execution_count": 20, + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + " PAW_PBE Cd_sv_GW 16Apr2014 \r\n", + " TITEL = PAW_PBE Cd_sv_GW 16Apr2014\r\n", " PAW_PBE Te 08Apr2002 \r\n", " TITEL = PAW_PBE Te 08Apr2002\r\n", " POMASS = 112.411; ZVAL = 20.000 mass and valenz\r\n", " POMASS = 127.600; ZVAL = 6.000 mass and valenz\r\n", "NELECT should be: 814\n", - "NELECT = 814.0\r\n", - "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN = Typical variable parameters\r\n", + "NELECT = 684.0\r\n", + "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN, MAGMOM = Typical variable parameters\r\n", "NUPDOWN = 0\r\n", "EDIFF = 1e-05\r\n", "EDIFFG = -0.01\r\n", "NKRED = 2\r\n", - "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN = Typical variable parameters\r\n", - "KPAR = 2\r\n" + "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN, MAGMOM = Typical variable parameters\r\n", + "KPAR = 4 # 2 or >=4 k-points in at least two directions\r\n" ] } ], + "execution_count": 10 + }, + { + "cell_type": "code", "source": [ - "!grep PAW_PBE v_Cd_-2/vasp_nkred_std/POTCAR\n", - "!grep ZVAL v_Cd_-2/vasp_nkred_std/POTCAR\n", - "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", - "!grep NELECT v_Cd_-2/vasp_nkred_std/INCAR\n", - "!grep NUP v_Cd_-2/vasp_nkred_std/INCAR\n", - "!grep EDIFF v_Cd_-2/vasp_nkred_std/INCAR\n", - "!grep NKRED v_Cd_-2/vasp_nkred_std/INCAR\n", - "!grep KPAR v_Cd_-2/vasp_nkred_std/INCAR" + "ds = DefectsSet(defect_gen, user_kpoints_settings={\"reciprocal_density\": 1000})" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:27:33.403880Z", - "start_time": "2023-09-07T09:27:32.489830Z" + "end_time": "2024-04-10T20:35:00.480618Z", + "start_time": "2024-04-10T20:35:00.449080Z" } - } + }, + "outputs": [], + "execution_count": 11 }, { "cell_type": "code", - "execution_count": 23, - "outputs": [], "source": [ - "ds = DefectsSet(defect_gen, user_kpoints_settings={\"reciprocal_density\": 1000})" + "ds.defect_sets[\"v_Cd_-2\"].write_ncl()" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:29:07.643677Z", - "start_time": "2023-09-07T09:29:07.638480Z" + "end_time": "2024-04-10T20:35:00.631771Z", + "start_time": "2024-04-10T20:35:00.604420Z" } - } + }, + "outputs": [], + "execution_count": 12 }, { "cell_type": "code", - "execution_count": 24, - "outputs": [], "source": [ - "ds.defect_sets[\"v_Cd_-2\"].write_ncl()" + "!grep PAW_PBE v_Cd_-2/vasp_ncl/POTCAR\n", + "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", + "!grep NELECT v_Cd_-2/vasp_ncl/INCAR\n", + "!grep NUP v_Cd_-2/vasp_ncl/INCAR\n", + "!cat v_Cd_-2/vasp_ncl/KPOINTS" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-07T09:29:08.423270Z", - "start_time": "2023-09-07T09:29:08.135259Z" + "end_time": "2024-04-10T20:35:01.702925Z", + "start_time": "2024-04-10T20:35:01.116045Z" } - } - }, - { - "cell_type": "code", - "execution_count": 25, + }, "outputs": [ { "name": "stdout", @@ -345,30 +389,17 @@ " PAW_PBE Te 08Apr2002 \r\n", " TITEL = PAW_PBE Te 08Apr2002\r\n", "NELECT should be: 814\n", - "NELECT = 566.0\r\n", - "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN = Typical variable parameters\r\n", + "NELECT = 476.0\r\n", + "# May want to change NCORE, KPAR, AEXX, ENCUT, IBRION, LREAL, NUPDOWN, ISPIN, MAGMOM = Typical variable parameters\r\n", "NUPDOWN = 0\r\n", "KPOINTS from doped, with reciprocal_density = 1000/Å⁻³\r\n", "0\r\n", "Gamma\r\n", - "4 4 4\r\n" + "5 5 5\r\n" ] } ], - "source": [ - "!grep PAW_PBE v_Cd_-2/vasp_ncl/POTCAR\n", - "print(f\"NELECT should be: {31*20 + 32*6 + 2}\")\n", - "!grep NELECT v_Cd_-2/vasp_ncl/INCAR\n", - "!grep NUP v_Cd_-2/vasp_ncl/INCAR\n", - "!cat v_Cd_-2/vasp_ncl/KPOINTS" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2023-09-07T09:30:05.088638Z", - "start_time": "2023-09-07T09:30:04.583849Z" - } - } + "execution_count": 13 }, { "cell_type": "code", @@ -392,16 +423,19 @@ }, { "cell_type": "code", - "execution_count": 27, "metadata": { "pycharm": { "name": "#%%\n" }, "ExecuteTime": { - "end_time": "2023-09-07T09:33:23.990277Z", - "start_time": "2023-09-07T09:33:23.924556Z" + "end_time": "2024-04-10T20:35:04.621195Z", + "start_time": "2024-04-10T20:35:04.571784Z" } }, + "source": [ + "from shakenbreak.input import Distortions\n", + "Dist = Distortions(defect_gen)" + ], "outputs": [ { "name": "stdout", @@ -411,14 +445,20 @@ ] } ], - "source": [ - "from shakenbreak.input import Distortions\n", - "Dist = Distortions(defect_gen)" - ] + "execution_count": 14 }, { "cell_type": "code", - "execution_count": 28, + "source": [ + "defects_dict, distortion_metadata = Dist.write_vasp_files()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-04-10T20:35:26.152399Z", + "start_time": "2024-04-10T20:35:08.086314Z" + } + }, "outputs": [ { "name": "stdout", @@ -430,152 +470,136 @@ "Defect: v_Cd\u001B[0m\n", "\u001B[1mNumber of missing electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect v_Cd in charge state: -2. Number of distorted neighbours: 0\n", - "\n", - "Defect v_Cd in charge state: -1. Number of distorted neighbours: 1\n", + "Defect v_Cd in charge state: +1. Number of distorted neighbours: 3\n", "\n", "Defect v_Cd in charge state: 0. Number of distorted neighbours: 2\n", "\n", - "Defect v_Cd in charge state: +1. Number of distorted neighbours: 3\n", + "Defect v_Cd in charge state: -1. Number of distorted neighbours: 1\n", + "\n", + "Defect v_Cd in charge state: -2. Number of distorted neighbours: 0\n", "\u001B[1m\n", "Defect: v_Te\u001B[0m\n", "\u001B[1mNumber of extra electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect v_Te in charge state: -1. Number of distorted neighbours: 3\n", - "\n", - "Defect v_Te in charge state: 0. Number of distorted neighbours: 2\n", + "Defect v_Te in charge state: +2. Number of distorted neighbours: 0\n", "\n", "Defect v_Te in charge state: +1. Number of distorted neighbours: 1\n", "\n", - "Defect v_Te in charge state: +2. Number of distorted neighbours: 0\n", + "Defect v_Te in charge state: 0. Number of distorted neighbours: 2\n", + "\n", + "Defect v_Te in charge state: -1. Number of distorted neighbours: 3\n", "\u001B[1m\n", "Defect: Cd_Te\u001B[0m\n", "\u001B[1mNumber of extra electrons in neutral state: 4\u001B[0m\n", "\n", - "Defect Cd_Te in charge state: 0. Number of distorted neighbours: 4\n", + "Defect Cd_Te in charge state: +4. Number of distorted neighbours: 0\n", "\n", - "Defect Cd_Te in charge state: +1. Number of distorted neighbours: 3\n", + "Defect Cd_Te in charge state: +3. Number of distorted neighbours: 1\n", "\n", "Defect Cd_Te in charge state: +2. Number of distorted neighbours: 2\n", "\n", - "Defect Cd_Te in charge state: +3. Number of distorted neighbours: 1\n", + "Defect Cd_Te in charge state: +1. Number of distorted neighbours: 3\n", "\n", - "Defect Cd_Te in charge state: +4. Number of distorted neighbours: 0\n", + "Defect Cd_Te in charge state: 0. Number of distorted neighbours: 4\n", "\u001B[1m\n", "Defect: Te_Cd\u001B[0m\n", "\u001B[1mNumber of missing electrons in neutral state: 4\u001B[0m\n", "\n", - "Defect Te_Cd in charge state: -4. Number of distorted neighbours: 0\n", + "Defect Te_Cd in charge state: +2. Number of distorted neighbours: 2\n", "\n", - "Defect Te_Cd in charge state: -3. Number of distorted neighbours: 1\n", + "Defect Te_Cd in charge state: +1. Number of distorted neighbours: 3\n", "\n", - "Defect Te_Cd in charge state: -2. Number of distorted neighbours: 2\n", + "Defect Te_Cd in charge state: 0. Number of distorted neighbours: 4\n", "\n", "Defect Te_Cd in charge state: -1. Number of distorted neighbours: 3\n", "\n", - "Defect Te_Cd in charge state: 0. Number of distorted neighbours: 4\n", + "Defect Te_Cd in charge state: -2. Number of distorted neighbours: 2\n", "\n", - "Defect Te_Cd in charge state: +1. Number of distorted neighbours: 3\n", + "Defect Te_Cd in charge state: -3. Number of distorted neighbours: 1\n", "\n", - "Defect Te_Cd in charge state: +2. Number of distorted neighbours: 2\n", + "Defect Te_Cd in charge state: -4. Number of distorted neighbours: 0\n", "\u001B[1m\n", "Defect: Cd_i_C3v\u001B[0m\n", "\u001B[1mNumber of extra electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Cd_i_C3v in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Cd_i_C3v in charge state: +2. Number of distorted neighbours: 0\n", "\n", "Defect Cd_i_C3v in charge state: +1. Number of distorted neighbours: 1\n", "\n", - "Defect Cd_i_C3v in charge state: +2. Number of distorted neighbours: 0\n", + "Defect Cd_i_C3v in charge state: 0. Number of distorted neighbours: 2\n", "\u001B[1m\n", "Defect: Cd_i_Td_Cd2.83\u001B[0m\n", "\u001B[1mNumber of extra electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Cd_i_Td_Cd2.83 in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Cd_i_Td_Cd2.83 in charge state: +2. Number of distorted neighbours: 0\n", "\n", "Defect Cd_i_Td_Cd2.83 in charge state: +1. Number of distorted neighbours: 1\n", "\n", - "Defect Cd_i_Td_Cd2.83 in charge state: +2. Number of distorted neighbours: 0\n", + "Defect Cd_i_Td_Cd2.83 in charge state: 0. Number of distorted neighbours: 2\n", "\u001B[1m\n", "Defect: Cd_i_Td_Te2.83\u001B[0m\n", "\u001B[1mNumber of extra electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Cd_i_Td_Te2.83 in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Cd_i_Td_Te2.83 in charge state: +2. Number of distorted neighbours: 0\n", "\n", "Defect Cd_i_Td_Te2.83 in charge state: +1. Number of distorted neighbours: 1\n", "\n", - "Defect Cd_i_Td_Te2.83 in charge state: +2. Number of distorted neighbours: 0\n", + "Defect Cd_i_Td_Te2.83 in charge state: 0. Number of distorted neighbours: 2\n", "\u001B[1m\n", "Defect: Te_i_C3v\u001B[0m\n", "\u001B[1mNumber of missing electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Te_i_C3v in charge state: -2. Number of distorted neighbours: 0\n", + "Defect Te_i_C3v in charge state: +4. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_C3v in charge state: -1. Number of distorted neighbours: 1\n", + "Defect Te_i_C3v in charge state: +3. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_C3v in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Te_i_C3v in charge state: +2. Number of distorted neighbours: 4\n", "\n", "Defect Te_i_C3v in charge state: +1. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_C3v in charge state: +2. Number of distorted neighbours: 4\n", + "Defect Te_i_C3v in charge state: 0. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_C3v in charge state: +3. Number of distorted neighbours: 3\n", + "Defect Te_i_C3v in charge state: -1. Number of distorted neighbours: 1\n", "\n", - "Defect Te_i_C3v in charge state: +4. Number of distorted neighbours: 2\n", + "Defect Te_i_C3v in charge state: -2. Number of distorted neighbours: 0\n", "\u001B[1m\n", "Defect: Te_i_Td_Cd2.83\u001B[0m\n", "\u001B[1mNumber of missing electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: -2. Number of distorted neighbours: 0\n", + "Defect Te_i_Td_Cd2.83 in charge state: +4. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: -1. Number of distorted neighbours: 1\n", + "Defect Te_i_Td_Cd2.83 in charge state: +3. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Te_i_Td_Cd2.83 in charge state: +2. Number of distorted neighbours: 4\n", "\n", "Defect Te_i_Td_Cd2.83 in charge state: +1. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: +2. Number of distorted neighbours: 4\n", + "Defect Te_i_Td_Cd2.83 in charge state: 0. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: +3. Number of distorted neighbours: 3\n", + "Defect Te_i_Td_Cd2.83 in charge state: -1. Number of distorted neighbours: 1\n", "\n", - "Defect Te_i_Td_Cd2.83 in charge state: +4. Number of distorted neighbours: 2\n", + "Defect Te_i_Td_Cd2.83 in charge state: -2. Number of distorted neighbours: 0\n", "\u001B[1m\n", "Defect: Te_i_Td_Te2.83\u001B[0m\n", "\u001B[1mNumber of missing electrons in neutral state: 2\u001B[0m\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: -2. Number of distorted neighbours: 0\n", + "Defect Te_i_Td_Te2.83 in charge state: +4. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: -1. Number of distorted neighbours: 1\n", + "Defect Te_i_Td_Te2.83 in charge state: +3. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: 0. Number of distorted neighbours: 2\n", + "Defect Te_i_Td_Te2.83 in charge state: +2. Number of distorted neighbours: 4\n", "\n", "Defect Te_i_Td_Te2.83 in charge state: +1. Number of distorted neighbours: 3\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: +2. Number of distorted neighbours: 4\n", + "Defect Te_i_Td_Te2.83 in charge state: 0. Number of distorted neighbours: 2\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: +3. Number of distorted neighbours: 3\n", + "Defect Te_i_Td_Te2.83 in charge state: -1. Number of distorted neighbours: 1\n", "\n", - "Defect Te_i_Td_Te2.83 in charge state: +4. Number of distorted neighbours: 2\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "input.py:306: UserWarning: A previously-generated defect folder v_Cd_-2 exists in tests, and the Unperturbed defect structure could not be matched to the current defect species: v_Cd_-2. These are assumed to be inequivalent defects, so the previous v_Cd_-2 will be renamed to v_Cda_-2 and ShakeNBreak files for the current defect will be saved to v_Cdb_-2, to prevent overwriting.\n" + "Defect Te_i_Td_Te2.83 in charge state: -2. Number of distorted neighbours: 0\n" ] } ], - "source": [ - "defects_dict, distortion_metadata = Dist.write_vasp_files()" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2023-09-07T09:37:17.796027Z", - "start_time": "2023-09-07T09:33:42.000335Z" - } - } + "execution_count": 15 }, { "cell_type": "code", diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 73807f73..98aefa41 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -771,8 +771,27 @@ def test_extrinsic_Sb2Se3(self): for warn in w ) + # spot check: + assert np.isclose(Sb2Se3_O_thermo.get_formation_energy("O_Se_Cs_Sb2.02_-2"), -1.84684, atol=1e-3) + return Sb2Se3_O_thermo.plot(chempots={"O": -8.9052, "Se": -5}) # example chempots + def test_extrinsic_Sb2Se3_parsing_with_single_defect_dir(self): + with warnings.catch_warnings(record=True) as w: # no warning about negative corrections with + # strong anisotropic dielectric: + Sb2Se3_O_dp = DefectsParser( + output_path=f"{self.Sb2Se3_DATA_DIR}/defect/O_-2", + bulk_path=f"{self.Sb2Se3_DATA_DIR}/bulk", + dielectric=self.Sb2Se3_dielectric, + ) + print([warn.message for warn in w]) # for debugging + assert not w # no warnings + self._check_DefectsParser(Sb2Se3_O_dp) + Sb2Se3_O_thermo = Sb2Se3_O_dp.get_defect_thermodynamics() + assert np.isclose(Sb2Se3_O_thermo.get_formation_energy("O_Se_Cs_Sb2.02_-2"), -1.84684, atol=1e-3) + + assert len(Sb2Se3_O_thermo.defect_entries) == 1 # only the one specified defect parsed + @custom_mpl_image_compare(filename="Sb2Si2Te6_v_Sb_-3_eFNV_plot_no_intralayer.png") def test_sb2si2te6_eFNV(self): with warnings.catch_warnings(record=True) as w: @@ -2008,8 +2027,8 @@ def test_extrinsic_substitution_parsing_and_freysoldt_and_kumagai(self): print([str(warn.message) for warn in w]) assert any( f"Estimated error in the Freysoldt (FNV) charge correction for defect {F_O_1_ent.name} is " - f"0.000 eV (i.e. which is greater than the `error_tolerance`: 0.000 eV). You may want to " - f"check the accuracy of the correction by plotting the site potential differences (using " + f"3.54e-04 eV (i.e. which is greater than the `error_tolerance`: 1.00e-05 eV). You may want " + f"to check the accuracy of the correction by plotting the site potential differences (using " f"`defect_entry.get_freysoldt_correction()` with `plot=True`). Large errors are often due " f"to unstable or shallow defect charge states (which can't be accurately modelled with " f"the supercell approach; see " diff --git a/tests/test_chemical_potentials.py b/tests/test_chemical_potentials.py index d04ec80e..3042a4a1 100644 --- a/tests/test_chemical_potentials.py +++ b/tests/test_chemical_potentials.py @@ -329,7 +329,10 @@ def test_to_csv(self): reloaded_cpa = chemical_potentials.CompetingPhasesAnalyzer(self.stable_system) reloaded_cpa.from_csv("competing_phases.csv") reloaded_cpa_data = reloaded_cpa._get_and_sort_formation_energy_data() - assert pd.DataFrame(stable_cpa_data).equals(pd.DataFrame(reloaded_cpa_data)) + print( + pd.DataFrame(stable_cpa_data).to_dict(), pd.DataFrame(reloaded_cpa_data).to_dict() + ) # for debugging + assert pd.DataFrame(stable_cpa_data).round(4).equals(pd.DataFrame(reloaded_cpa_data).round(4)) # check chem limits the same: _compare_chempot_dicts(stable_cpa.chempots, reloaded_cpa.chempots) @@ -345,7 +348,9 @@ def test_to_csv(self): reloaded_ext_cpa.from_csv("competing_phases.csv") reloaded_ext_cpa._get_and_sort_formation_energy_data() - assert reloaded_ext_cpa.formation_energy_df.equals(self.ext_cpa.formation_energy_df) + assert reloaded_ext_cpa.formation_energy_df.round(4).equals( + self.ext_cpa.formation_energy_df.round(4) + ) # test pruning: self.ext_cpa.to_csv("competing_phases.csv", prune_polymorphs=True) @@ -403,8 +408,8 @@ def test_from_csv_minimal(self): reloaded_cpa = chemical_potentials.CompetingPhasesAnalyzer(self.stable_system) reloaded_cpa.from_csv("competing_phases.csv") - assert not cpa.formation_energy_df.equals( - reloaded_cpa.formation_energy_df + assert not cpa.formation_energy_df.round(4).equals( + reloaded_cpa.formation_energy_df.round(4) ) # no kpoints or raw energy, but should have formula, energy_per_fu, energy_per_atom, # elemental amounts (i.e. Zr and O here) and formation_energy: minimal_columns = [ @@ -425,7 +430,7 @@ def test_from_csv_minimal(self): reloaded_cpa.formation_energy_df = reloaded_cpa.formation_energy_df.round(5) print(trimmed_df, reloaded_cpa.formation_energy_df) print(trimmed_df.columns, reloaded_cpa.formation_energy_df.columns) - assert trimmed_df.equals(reloaded_cpa.formation_energy_df) + assert trimmed_df.round(4).equals(reloaded_cpa.formation_energy_df.round(4)) # check chem limits the same: _compare_chempot_dicts(cpa.chempots, reloaded_cpa.chempots)