valyte 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ include README.md
2
+ include valyte/Logo.png
valyte-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.2
2
+ Name: valyte
3
+ Version: 0.1.0
4
+ Summary: A CLI tool for VASP post-processing (DOS plotting)
5
+ Home-page: https://github.com/nikyadav002/Valyte-Project
6
+ Author: Nikhil
7
+ Author-email: nikhil@example.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: numpy
14
+ Requires-Dist: matplotlib
15
+ Requires-Dist: pymatgen
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ <p align="center">
27
+ <img src="valyte/Logo.png" alt="Valyte Logo" width="100%"/>
28
+ </p>
29
+
30
+ # Valyte
31
+
32
+ **Valyte** is a comprehensive CLI tool for VASP workflows, providing both pre-processing and post-processing capabilities with a focus on clean, publication-quality outputs and modern aesthetics.
33
+
34
+ ## Features
35
+
36
+ ### Pre-processing
37
+ - **Supercell Creation**: Generate supercells from POSCAR files.
38
+ - **Interactive K-Point Generation**: Create KPOINTS files with automatic grid calculation based on K-spacing.
39
+ - **Band KPOINTS Generation**: Automatic high-symmetry path detection for band structure calculations.
40
+
41
+ ### Post-processing
42
+ - **DOS Plotting**:
43
+ - Smart Plotting: Automatically handles total DOS and Projected DOS (PDOS).
44
+ - Orbital-Resolved: Plots individual orbitals (s, p, d, f) by default.
45
+ - Adaptive Legend: Intelligently hides the legend if PDOS contributions are low.
46
+ - Gradient Fill: Aesthetically pleasing gradient fills for DOS peaks.
47
+ - **Band Structure Plotting**:
48
+ - VBM alignment to 0 eV.
49
+ - Color-coded bands (Purple for VB, Teal for CB).
50
+ - High-symmetry path labels from KPOINTS.
51
+ - **Publication Quality**: Clean aesthetics, custom fonts (Arial, Helvetica, Times New Roman), high DPI output.
52
+
53
+ ## Installation
54
+
55
+ Clone the repository and install in editable mode:
56
+
57
+ ```bash
58
+ git clone https://github.com/nikyadav002/Valyte-Project
59
+ cd Valyte-Project
60
+ pip install -e .
61
+ ```
62
+
63
+ ## Examples
64
+
65
+ <p align="center">
66
+ <img src="valyte/valyte_dos.png" alt="DOS Plot Example" width="47%"/>
67
+ <img src="valyte/valyte_band.png" alt="Band Structure Example" width="38%"/>
68
+ </p>
69
+
70
+ ## Updating Valyte
71
+
72
+ To update to the latest version:
73
+
74
+ ```bash
75
+ cd Valyte-Project
76
+ git pull
77
+ pip install -e .
78
+ ```
79
+
80
+ ## Usage
81
+
82
+ The main command is `valyte`.
83
+
84
+ <details>
85
+ <summary><strong>Click to view detailed usage instructions</strong></summary>
86
+
87
+ <br>
88
+
89
+ ### 🧊 Create Supercell
90
+
91
+ Generate a supercell from a POSCAR file:
92
+
93
+ ```bash
94
+ valyte supercell nx ny nz [options]
95
+ ```
96
+
97
+ **Example:**
98
+ ```bash
99
+ # Create a 2×2×2 supercell
100
+ valyte supercell 2 2 2
101
+
102
+ # Specify input and output files
103
+ valyte supercell 3 3 1 -i POSCAR_primitive -o POSCAR_3x3x1
104
+ ```
105
+
106
+ **Options:**
107
+ - `-i`, `--input`: Input POSCAR file (default: `POSCAR`).
108
+ - `-o`, `--output`: Output filename (default: `POSCAR_supercell`).
109
+
110
+ ---
111
+
112
+ ### 📉 Band Structure
113
+
114
+ #### 1. Generate KPOINTS
115
+
116
+ Automatically generate a KPOINTS file with high-symmetry paths for band structure calculations.
117
+
118
+ ```bash
119
+ valyte band kpt-gen [options]
120
+ ```
121
+
122
+ **Options:**
123
+ - `-i`, `--input`: Input POSCAR file (default: `POSCAR`).
124
+ - `-n`, `--npoints`: Points per segment (default: `40`).
125
+ - `-o`, `--output`: Output filename (default: `KPOINTS`).
126
+
127
+ **Example:**
128
+ ```bash
129
+ valyte band kpt-gen -n 60 -i POSCAR_relaxed -o KPOINTS_band
130
+ ```
131
+
132
+ ### 🕸️ Generate K-Points (Interactive)
133
+
134
+ Generate a `KPOINTS` file for SCF calculations interactively.
135
+
136
+ ```bash
137
+ valyte kpt
138
+ ```
139
+
140
+ This command will prompt you for:
141
+ 1. **K-Mesh Scheme**: Monkhorst-Pack or Gamma.
142
+ 2. **K-Spacing**: Value in $2\pi/\AA$ (e.g., 0.04).
143
+
144
+ It automatically calculates the optimal grid based on your `POSCAR` structure.
145
+
146
+ #### 2. Plot Band Structure
147
+
148
+ Plot the electronic band structure from `vasprun.xml`.
149
+
150
+ ```bash
151
+ valyte band [options]
152
+ ```
153
+
154
+ **Options:**
155
+ - `--vasprun`: Path to `vasprun.xml` (default: current directory).
156
+ - `--kpoints`: Path to `KPOINTS` file for path labels (default: looks for `KPOINTS` in same dir).
157
+ - `--ylim`: Energy range, e.g., `--ylim -4 4`.
158
+ - `-o, --output`: Output filename (default: `valyte_band.png`).
159
+
160
+ **Example:**
161
+ ```bash
162
+ valyte band --ylim -3 3 -o my_bands.png
163
+ ```
164
+
165
+ ---
166
+
167
+ ### 📊 Plot DOS
168
+
169
+ ```bash
170
+ valyte dos [path/to/vasprun.xml] [options]
171
+ ```
172
+
173
+ You can provide the path as a positional argument, use the `--vasprun` flag, or omit it to use the current directory.
174
+
175
+ **Examples:**
176
+ ```bash
177
+ # Plot all orbitals for all elements (Default)
178
+ valyte dos
179
+
180
+ # Plot specific elements (Total PDOS)
181
+ valyte dos -e Fe O
182
+
183
+ # Plot specific orbitals
184
+ valyte dos -e "Fe(d)" "O(p)"
185
+
186
+ # Plot mixed (Fe Total and Fe d-orbital)
187
+ valyte dos -e Fe "Fe(d)"
188
+ ```
189
+
190
+ **Options:**
191
+ - `-e`, `--elements`: Specific elements or orbitals to plot.
192
+ - Example: `-e Fe O` (Plots Total PDOS for Fe and O).
193
+ - Example: `-e Fe(d) O(p)` (Plots Fe d-orbital and O p-orbital).
194
+ - Example: `-e Fe Fe(d)` (Plots Fe Total and Fe d-orbital).
195
+ - `--xlim`: Energy range (default: `-6 6`).
196
+ - `--ylim`: DOS range (e.g., `--ylim 0 10`).
197
+ - `--scale`: Scaling factor for Y-axis (e.g., `--scale 3` divides DOS by 3).
198
+ - `--fermi`: Draw a dashed line at the Fermi level (E=0). Default is OFF.
199
+ - `--pdos`: Plot only Projected DOS (hide Total DOS).
200
+ - `--legend-cutoff`: Threshold for legend visibility (default: `0.10` = 10%).
201
+ - `-o`, `--output`: Output filename (default: `valyte_dos.png`).
202
+ - `--font`: Font family (default: `Arial`).
203
+
204
+ **Example:**
205
+
206
+ ```bash
207
+ valyte dos ./vasp_data --xlim -5 5 -o my_dos.png
208
+ ```
209
+
210
+ </details>
valyte-0.1.0/README.md ADDED
@@ -0,0 +1,185 @@
1
+ <p align="center">
2
+ <img src="valyte/Logo.png" alt="Valyte Logo" width="100%"/>
3
+ </p>
4
+
5
+ # Valyte
6
+
7
+ **Valyte** is a comprehensive CLI tool for VASP workflows, providing both pre-processing and post-processing capabilities with a focus on clean, publication-quality outputs and modern aesthetics.
8
+
9
+ ## Features
10
+
11
+ ### Pre-processing
12
+ - **Supercell Creation**: Generate supercells from POSCAR files.
13
+ - **Interactive K-Point Generation**: Create KPOINTS files with automatic grid calculation based on K-spacing.
14
+ - **Band KPOINTS Generation**: Automatic high-symmetry path detection for band structure calculations.
15
+
16
+ ### Post-processing
17
+ - **DOS Plotting**:
18
+ - Smart Plotting: Automatically handles total DOS and Projected DOS (PDOS).
19
+ - Orbital-Resolved: Plots individual orbitals (s, p, d, f) by default.
20
+ - Adaptive Legend: Intelligently hides the legend if PDOS contributions are low.
21
+ - Gradient Fill: Aesthetically pleasing gradient fills for DOS peaks.
22
+ - **Band Structure Plotting**:
23
+ - VBM alignment to 0 eV.
24
+ - Color-coded bands (Purple for VB, Teal for CB).
25
+ - High-symmetry path labels from KPOINTS.
26
+ - **Publication Quality**: Clean aesthetics, custom fonts (Arial, Helvetica, Times New Roman), high DPI output.
27
+
28
+ ## Installation
29
+
30
+ Clone the repository and install in editable mode:
31
+
32
+ ```bash
33
+ git clone https://github.com/nikyadav002/Valyte-Project
34
+ cd Valyte-Project
35
+ pip install -e .
36
+ ```
37
+
38
+ ## Examples
39
+
40
+ <p align="center">
41
+ <img src="valyte/valyte_dos.png" alt="DOS Plot Example" width="47%"/>
42
+ <img src="valyte/valyte_band.png" alt="Band Structure Example" width="38%"/>
43
+ </p>
44
+
45
+ ## Updating Valyte
46
+
47
+ To update to the latest version:
48
+
49
+ ```bash
50
+ cd Valyte-Project
51
+ git pull
52
+ pip install -e .
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ The main command is `valyte`.
58
+
59
+ <details>
60
+ <summary><strong>Click to view detailed usage instructions</strong></summary>
61
+
62
+ <br>
63
+
64
+ ### 🧊 Create Supercell
65
+
66
+ Generate a supercell from a POSCAR file:
67
+
68
+ ```bash
69
+ valyte supercell nx ny nz [options]
70
+ ```
71
+
72
+ **Example:**
73
+ ```bash
74
+ # Create a 2×2×2 supercell
75
+ valyte supercell 2 2 2
76
+
77
+ # Specify input and output files
78
+ valyte supercell 3 3 1 -i POSCAR_primitive -o POSCAR_3x3x1
79
+ ```
80
+
81
+ **Options:**
82
+ - `-i`, `--input`: Input POSCAR file (default: `POSCAR`).
83
+ - `-o`, `--output`: Output filename (default: `POSCAR_supercell`).
84
+
85
+ ---
86
+
87
+ ### 📉 Band Structure
88
+
89
+ #### 1. Generate KPOINTS
90
+
91
+ Automatically generate a KPOINTS file with high-symmetry paths for band structure calculations.
92
+
93
+ ```bash
94
+ valyte band kpt-gen [options]
95
+ ```
96
+
97
+ **Options:**
98
+ - `-i`, `--input`: Input POSCAR file (default: `POSCAR`).
99
+ - `-n`, `--npoints`: Points per segment (default: `40`).
100
+ - `-o`, `--output`: Output filename (default: `KPOINTS`).
101
+
102
+ **Example:**
103
+ ```bash
104
+ valyte band kpt-gen -n 60 -i POSCAR_relaxed -o KPOINTS_band
105
+ ```
106
+
107
+ ### 🕸️ Generate K-Points (Interactive)
108
+
109
+ Generate a `KPOINTS` file for SCF calculations interactively.
110
+
111
+ ```bash
112
+ valyte kpt
113
+ ```
114
+
115
+ This command will prompt you for:
116
+ 1. **K-Mesh Scheme**: Monkhorst-Pack or Gamma.
117
+ 2. **K-Spacing**: Value in $2\pi/\AA$ (e.g., 0.04).
118
+
119
+ It automatically calculates the optimal grid based on your `POSCAR` structure.
120
+
121
+ #### 2. Plot Band Structure
122
+
123
+ Plot the electronic band structure from `vasprun.xml`.
124
+
125
+ ```bash
126
+ valyte band [options]
127
+ ```
128
+
129
+ **Options:**
130
+ - `--vasprun`: Path to `vasprun.xml` (default: current directory).
131
+ - `--kpoints`: Path to `KPOINTS` file for path labels (default: looks for `KPOINTS` in same dir).
132
+ - `--ylim`: Energy range, e.g., `--ylim -4 4`.
133
+ - `-o, --output`: Output filename (default: `valyte_band.png`).
134
+
135
+ **Example:**
136
+ ```bash
137
+ valyte band --ylim -3 3 -o my_bands.png
138
+ ```
139
+
140
+ ---
141
+
142
+ ### 📊 Plot DOS
143
+
144
+ ```bash
145
+ valyte dos [path/to/vasprun.xml] [options]
146
+ ```
147
+
148
+ You can provide the path as a positional argument, use the `--vasprun` flag, or omit it to use the current directory.
149
+
150
+ **Examples:**
151
+ ```bash
152
+ # Plot all orbitals for all elements (Default)
153
+ valyte dos
154
+
155
+ # Plot specific elements (Total PDOS)
156
+ valyte dos -e Fe O
157
+
158
+ # Plot specific orbitals
159
+ valyte dos -e "Fe(d)" "O(p)"
160
+
161
+ # Plot mixed (Fe Total and Fe d-orbital)
162
+ valyte dos -e Fe "Fe(d)"
163
+ ```
164
+
165
+ **Options:**
166
+ - `-e`, `--elements`: Specific elements or orbitals to plot.
167
+ - Example: `-e Fe O` (Plots Total PDOS for Fe and O).
168
+ - Example: `-e Fe(d) O(p)` (Plots Fe d-orbital and O p-orbital).
169
+ - Example: `-e Fe Fe(d)` (Plots Fe Total and Fe d-orbital).
170
+ - `--xlim`: Energy range (default: `-6 6`).
171
+ - `--ylim`: DOS range (e.g., `--ylim 0 10`).
172
+ - `--scale`: Scaling factor for Y-axis (e.g., `--scale 3` divides DOS by 3).
173
+ - `--fermi`: Draw a dashed line at the Fermi level (E=0). Default is OFF.
174
+ - `--pdos`: Plot only Projected DOS (hide Total DOS).
175
+ - `--legend-cutoff`: Threshold for legend visibility (default: `0.10` = 10%).
176
+ - `-o`, `--output`: Output filename (default: `valyte_dos.png`).
177
+ - `--font`: Font family (default: `Arial`).
178
+
179
+ **Example:**
180
+
181
+ ```bash
182
+ valyte dos ./vasp_data --xlim -5 5 -o my_dos.png
183
+ ```
184
+
185
+ </details>
valyte-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
valyte-0.1.0/setup.py ADDED
@@ -0,0 +1,33 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="valyte",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "numpy",
9
+ "matplotlib",
10
+ "pymatgen",
11
+ ],
12
+ include_package_data=True,
13
+ package_data={
14
+ "valyte": ["*.png"],
15
+ },
16
+ entry_points={
17
+ "console_scripts": [
18
+ "valyte=valyte.cli:main",
19
+ ],
20
+ },
21
+ author="Nikhil",
22
+ author_email="nikhil@example.com",
23
+ description="A CLI tool for VASP post-processing (DOS plotting)",
24
+ long_description=open("README.md").read(),
25
+ long_description_content_type="text/markdown",
26
+ url="https://github.com/nikyadav002/Valyte-Project",
27
+ classifiers=[
28
+ "Programming Language :: Python :: 3",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Operating System :: OS Independent",
31
+ ],
32
+ python_requires=">=3.6",
33
+ )
Binary file
File without changes
@@ -0,0 +1,56 @@
1
+ """
2
+ Band structure KPOINTS generation module for Valyte.
3
+ """
4
+
5
+ import os
6
+ from pymatgen.core import Structure
7
+ from pymatgen.symmetry.bandstructure import HighSymmKpath
8
+
9
+
10
+ def generate_band_kpoints(poscar_path="POSCAR", npoints=40, output="KPOINTS"):
11
+ """
12
+ Generates KPOINTS file in line-mode for band structure calculations.
13
+ Uses SeeK-path method for high-symmetry path determination.
14
+
15
+ Args:
16
+ poscar_path (str): Path to input POSCAR file.
17
+ npoints (int): Number of points per segment (default: 40).
18
+ output (str): Output filename for KPOINTS.
19
+ """
20
+
21
+ if not os.path.exists(poscar_path):
22
+ raise FileNotFoundError(f"{poscar_path} not found")
23
+
24
+ # Read structure
25
+ structure = Structure.from_file(poscar_path)
26
+
27
+ # Get high-symmetry path using SeeK-path method
28
+ kpath = HighSymmKpath(structure, path_type="setyawan_curtarolo")
29
+
30
+ # Get the path
31
+ path = kpath.kpath["path"]
32
+ kpoints = kpath.kpath["kpoints"]
33
+
34
+ # Write KPOINTS file
35
+ with open(output, 'w') as f:
36
+ f.write("k-points for band structure\n")
37
+ f.write(f"{npoints}\n")
38
+ f.write("Line-mode\n")
39
+ f.write("Reciprocal\n")
40
+
41
+ # Write each segment
42
+ for segment in path:
43
+ for i in range(len(segment) - 1):
44
+ start = segment[i]
45
+ end = segment[i + 1]
46
+
47
+ start_coords = kpoints[start]
48
+ end_coords = kpoints[end]
49
+
50
+ f.write(f" {start_coords[0]:.6f} {start_coords[1]:.6f} {start_coords[2]:.6f} ! {start}\n")
51
+ f.write(f" {end_coords[0]:.6f} {end_coords[1]:.6f} {end_coords[2]:.6f} ! {end}\n")
52
+ f.write("\n")
53
+
54
+ # Print success message
55
+ path_str = ' → '.join([' - '.join(seg) for seg in path])
56
+ print(f"✅ KPOINTS generated: {output} ({path_str}, {npoints} pts/seg)")
@@ -0,0 +1,127 @@
1
+ import os
2
+ import numpy as np
3
+ import matplotlib as mpl
4
+ mpl.use("agg")
5
+ mpl.rcParams["axes.unicode_minus"] = False
6
+ import matplotlib.pyplot as plt
7
+ from pymatgen.io.vasp import Vasprun, BSVasprun
8
+ from pymatgen.electronic_structure.plotter import BSPlotter
9
+
10
+ def plot_band_structure(vasprun_path, kpoints_path=None, output="valyte_band.png",
11
+ ylim=None, figsize=(4, 4), dpi=400, font="Arial"):
12
+ """
13
+ Plots the electronic band structure from vasprun.xml.
14
+
15
+ Args:
16
+ vasprun_path (str): Path to vasprun.xml file.
17
+ kpoints_path (str, optional): Path to KPOINTS file (for labels).
18
+ output (str): Output filename.
19
+ ylim (tuple, optional): Energy range (min, max).
20
+ figsize (tuple): Figure size in inches.
21
+ dpi (int): Resolution of the output image.
22
+ font (str): Font family.
23
+ """
24
+
25
+ # --- Font configuration ---
26
+ font_map = {
27
+ "arial": "Arial",
28
+ "helvetica": "Helvetica",
29
+ "times": "Times New Roman",
30
+ "times new roman": "Times New Roman",
31
+ }
32
+ font = font_map.get(font.lower(), "Arial")
33
+ mpl.rcParams["font.family"] = font
34
+ mpl.rcParams["axes.linewidth"] = 1.4
35
+ mpl.rcParams["font.weight"] = "bold"
36
+ mpl.rcParams["font.size"] = 14
37
+ mpl.rcParams["xtick.major.width"] = 1.2
38
+ mpl.rcParams["ytick.major.width"] = 1.2
39
+
40
+ # print(f"🔍 Reading {vasprun_path} ...") # Silent mode
41
+
42
+ try:
43
+ # Load VASP output
44
+ # BSVasprun is optimized for band structures
45
+ vr = BSVasprun(vasprun_path, parse_projected_eigen=False)
46
+ bs = vr.get_band_structure(kpoints_filename=kpoints_path, line_mode=True)
47
+ except Exception as e:
48
+ raise ValueError(f"Failed to load band structure: {e}")
49
+
50
+ # Use BSPlotter to get the data in a plot-friendly format
51
+ bs_plotter = BSPlotter(bs)
52
+ data = bs_plotter.bs_plot_data(zero_to_efermi=True)
53
+
54
+ # Extract data
55
+ distances = data['distances'] # List of lists (one per segment)
56
+ energies = data['energy'] # Can be list of dicts OR dict of lists depending on pymatgen version/structure
57
+ ticks = data['ticks'] # Dict with 'distance' and 'label'
58
+
59
+ # Setup plot
60
+ fig, ax = plt.subplots(figsize=figsize)
61
+
62
+ # Colors
63
+ color_vb = "#8e44ad" # Purple
64
+ color_cb = "#2a9d8f" # Teal
65
+
66
+ # Plot bands
67
+ # Iterate over segments
68
+ for i in range(len(distances)):
69
+ d = distances[i]
70
+
71
+ # Handle different energy data structures
72
+ if isinstance(energies, dict):
73
+ # Structure: {'1': [seg1, seg2, ...], '-1': ...}
74
+ # Iterate over spins
75
+ for spin in energies:
76
+ # energies[spin] is a list of segments
77
+ # energies[spin][i] is the list of bands for segment i
78
+ for band in energies[spin][i]:
79
+ # Determine color based on energy relative to VBM (0 eV)
80
+ if np.mean(band) <= 0:
81
+ c = color_vb
82
+ else:
83
+ c = color_cb
84
+ ax.plot(d, band, color=c, lw=1.5, alpha=1.0)
85
+ else:
86
+ # Structure: [{'1': bands, ...}, {'1': bands, ...}] (List of dicts)
87
+ # Iterate over spin channels in this segment
88
+ for spin in energies[i]:
89
+ # energies[i][spin] is a list of arrays (one per band)
90
+ for band in energies[i][spin]:
91
+ if np.mean(band) <= 0:
92
+ c = color_vb
93
+ else:
94
+ c = color_cb
95
+ ax.plot(d, band, color=c, lw=1.5, alpha=1.0)
96
+
97
+ # Setup X-axis (K-path)
98
+ ax.set_xticks(ticks['distance'])
99
+ # Clean up labels (remove formatting like $ if needed, but pymatgen usually does a good job)
100
+ clean_labels = [l.replace("$\\mid$", "|") for l in ticks['label']]
101
+ ax.set_xticklabels(clean_labels, fontsize=14, fontweight="bold")
102
+
103
+ # Draw vertical lines at high-symmetry points
104
+ for d in ticks['distance']:
105
+ ax.axvline(d, color="k", lw=0.8, ls="-", alpha=0.3)
106
+
107
+ # Draw VBM line (E=0)
108
+ ax.axhline(0, color="k", lw=0.8, ls="--", alpha=0.5)
109
+
110
+ # Setup Y-axis
111
+ ax.set_ylabel("Energy (eV)", fontsize=16, fontweight="bold", labelpad=8)
112
+ if ylim:
113
+ ax.set_ylim(ylim)
114
+ # Set y-ticks with 1 eV spacing
115
+ yticks = np.arange(np.ceil(ylim[0]), np.floor(ylim[1]) + 1, 1)
116
+ ax.set_yticks(yticks)
117
+ else:
118
+ # Default zoom around gap
119
+ ax.set_ylim(-4, 4)
120
+ ax.set_yticks(np.arange(-4, 5, 1))
121
+
122
+ ax.set_xlim(distances[0][0], distances[-1][-1])
123
+
124
+ plt.tight_layout()
125
+ plt.savefig(output, dpi=dpi)
126
+ plt.close(fig)
127
+ # print(f"✅ Band structure saved to {output}") # Silent mode