Comments (5)
@naik-aakash This time, the code and the result are as follows:
from pymatgen.io.vasp.inputs import Kpoints
from pymatgen.core import Structure
import numpy as np
# Read the structure file (e.g., POSCAR file)
structure = Structure.from_file("POSCAR")
# Define the factor (commonly 50)
factor = 50
# Calculate the magnitudes of the reciprocal lattice vectors
reciprocal_lattice = structure.lattice.reciprocal_lattice_crystallographic
reciprocal_lengths = [np.linalg.norm(vector) for vector in reciprocal_lattice.matrix]
# Calculate the k-point grid density
kpoint_density = [int(round(factor * length)) for length in reciprocal_lengths]
# Create Kpoints object
kpoints = Kpoints(comment="Automatic mesh",
num_kpts=0,
style=Kpoints.supported_modes.Gamma,
kpts=[kpoint_density],
kpts_shift=[0, 0, 0])
# Write to KPOINTS file
kpoints.write_file("KPOINTS")
print(f"KPOINTS file generated with grid density: {kpoint_density}")
# Check it as follows:
In [1]: from pymatgen.io.vasp.inputs import Kpoints
...: from pymatgen.core import Structure
...: import numpy as np
...:
...: # Read the structure file (e.g., POSCAR file)
...: structure = Structure.from_file("POSCAR")
...:
...: # Define the factor (commonly 50)
...: factor = 50
...:
...: # Calculate the magnitudes of the reciprocal lattice vectors
...: reciprocal_lattice = structure.lattice.reciprocal_lattice_crystallographic
...: reciprocal_lengths = [np.linalg.norm(vector) for vector in reciprocal_lattice.matrix]
...:
...: # Calculate the k-point grid density
...: kpoint_density = [int(round(factor * length)) for length in reciprocal_lengths]
...:
...: # Create Kpoints object
...: kpoints = Kpoints(comment="Automatic mesh",
...: num_kpts=0,
...: style=Kpoints.supported_modes.Gamma,
...: kpts=[kpoint_density],
...: kpts_shift=[0, 0, 0])
...:
...: # Write to KPOINTS file
...: kpoints.write_file("KPOINTS")
...:
...: print(f"KPOINTS file generated with grid density: {kpoint_density}")
KPOINTS file generated with grid density: [16, 16, 16]
The generated KPOINTS
file:
$ cat KPOINTS
Automatic mesh
0
Gamma
16 16 16
from lobsterpy.
Hi there,
In the example here, I noticed the following Warning:
The ‘KPOINTS’ file is not adapted; the user must select the appropriate grid density before starting VASP computations.
Usually, a factor of 50 x reciprocal lattice vectors is sufficient for reliable bonding analysis results.So, I regenerated the ‘KPOINTS’ file as follows using the corresponding 'POSCAR' file:
In [23]: from pymatgen.io.vasp.inputs import Kpoints ...: from pymatgen.core import Structure ...: import numpy as np ...: ...: # Read the structure file (e.g., POSCAR file) ...: structure = Structure.from_file("POSCAR") ...: ...: # Define the factor (commonly 50) ...: factor = 50 ...: ...: # Calculate the magnitudes of the reciprocal lattice vectors ...: reciprocal_lattice = structure.lattice.reciprocal_lattice ...: reciprocal_lengths = [np.linalg.norm(vector) for vector in reciprocal_lattice.matrix] ...: ...: # Calculate the k-point grid density ...: kpoint_density = [int(round(factor * length)) for length in reciprocal_lengths] ...: ...: # Create Kpoints object ...: kpoints = Kpoints(comment="Automatic mesh", ...: num_kpts=0, ...: style=Kpoints.supported_modes.Gamma, ...: kpts=[kpoint_density], ...: kpts_shift=[0, 0, 0]) ...: ...: # Write to KPOINTS file ...: kpoints.write_file("KPOINTS") ...: ...: print(f"KPOINTS file generated with grid density: {kpoint_density}") KPOINTS file generated with grid density: [99, 99, 99]The generated
KPOINTS
file is shown below:$ cat KPOINTS Automatic mesh 0 Gamma 99 99 99
As you can see, this will result in a very dense k-point grid, which will require very intensive computational resources. So, I want to know do we really need a very large k-point grid density to do the VASP computation in order to do the further LOBSTER computation?
Regards, Zhao
Thank you for raising the issue.
Surely, this is not what we referring to. It's not possible to use this many kpoints in VASP.
@naik-aakash could you add a few more details. Confusing might come from 2pi added or not to the definition.
from lobsterpy.
Hi @hongyi-zhao, thanks for reaching out to us.
We refer to structure.lattice.reciprocal_lattice_crystallographic
lattice vectors (which do not have an additional 2pi factor, as @JaGeo mentioned). Then, you should be able to get the required k-point grid density for reliable LOBSTER computations.
Below is the slightly tweaked code snippet, which should get the desired results
reciprocal_lattice = structure.lattice.reciprocal_lattice_crystallographic
factor = 50
reciprocal_lengths = [np.linalg.norm(vector) for vector in
reciprocal_lattice.matrix]
kpoint_density = [int(round(factor * length)) for length in
reciprocal_lengths]
kpoints = Kpoints(comment="Automatic mesh",
num_kpts=0,
style=Kpoints.supported_modes.Gamma,
kpts=[kpoint_density],
kpts_shift=[0, 0, 0])
See here for the pymatgen definition.
We will update the documentation to make this clearer in the next release 😄
from lobsterpy.
@hongyi-zhao , Yes, this should be enough 😃
from lobsterpy.
See materialsproject/pymatgen#3709 for the related discussion.
from lobsterpy.
Related Issues (20)
- `lobsterpy plot-automatic-ia -orbplot` does not work HOT 6
- Lobsterpy does not work if only POSCAR.lobster exists
- Automatic anlysis does not work in cli for spin polarized computations HOT 1
- Orbital contributions should be summed by orbital type HOT 2
- Fatband plots
- Large number of environments break the automatic plot HOT 1
- Plot does not save png correctly
- Code of conduct HOT 2
- Speed up installation
- Tests for multi-center bonding plotting features
- Edge features from LobsterNeighbors
- Fix warnings for flake8 pre-commit CI
- import of `typing` causing issues for down stream installs HOT 12
- Developers installation out of date HOT 7
- [CI] `test_cli` failed on MacOS due to different `matplotlib` rounding precision HOT 4
- [Bug] NumPy 2.x breaks CI tests HOT 5
- My confusion on different basis sets involved in one lobster computation. HOT 12
- Some quesitons on the lobster_basis used by this package. HOT 16
- Fractional occupancies. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lobsterpy.