more energy_grid_options#31
Open
Lonya0 wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands NEGF configuration flexibility by introducing richer energy-grid configuration (energy_grid_options) and supporting an external overlap override, while also tuning self-energy parallel execution behavior.
Changes:
- Add
energy_grid_optionsto the argument schema and implement flexible energy-grid generation inNEGF(explicit energies, steps, and forcing rules). - Add support for
override_overlapand propagate it into electronic-structure calculations. - Adjust self-energy parallel execution to allocate BLAS threads per task and refine saved self-energy detection / paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| dpnegf/utils/elec_struc_cal.py | Adds override_overlap plumbing and fallback behavior for overlap loading. |
| dpnegf/utils/argcheck.py | Extends config schema with energy_grid_options and override_overlap. |
| dpnegf/runner/NEGF.py | Implements new energy-grid behavior, passes overlap override, and normalizes self-energy save path. |
| dpnegf/negf/lead_property.py | Tunes joblib/BLAS threading behavior and updates saved self-energy detection logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.eta_lead = eta_lead; self.eta_device = eta_device | ||
| self.emin = emin; self.emax = emax; self.espacing = espacing | ||
|
|
||
| assert energy_grid_options or (espacing and emin and emax), "target energy grid not defined" |
Comment on lines
+424
to
+429
| zero_index = int(np.clip(round((0.0 - emin) / (emax - emin) * (energy_steps - 1)), 0, energy_steps - 1)) | ||
| left_spacing = abs(float(self.emin)) / zero_index if zero_index > 0 else 0.0 | ||
| right_spacing = abs(float(self.emax)) / (energy_steps - 1 - zero_index) if zero_index < energy_steps - 1 else 0.0 | ||
| espacing = max(left_spacing, right_spacing, espacing if left_spacing == 0.0 and right_spacing == 0.0 else 0.0) | ||
| emin = -zero_index * espacing | ||
| emax = (energy_steps - 1 - zero_index) * espacing |
Comment on lines
383
to
+387
| if self.out_dos or self.out_tc or self.out_current_nscf or self.out_ldos: | ||
| # Energy gird is set relative to Fermi level | ||
| self.uni_grid = torch.linspace(start=self.emin, end=self.emax, steps=int((self.emax-self.emin)/self.espacing)) | ||
| if self.energies is not None: | ||
| self.uni_grid = torch.as_tensor(self.energies, dtype=torch.get_default_dtype()) | ||
| else: | ||
| emin = float(self.emin) |
| else: | ||
| raise ValueError('data should be either a string, ase.Atoms, or AtomicData') | ||
|
|
||
| override_overlap = None if override_overlap == False else override_overlap if override_overlap else self.override_overlap |
Comment on lines
151
to
153
| if isinstance(override_overlap, str): | ||
| assert os.path.exists(override_overlap), "Overlap file not found." | ||
| overlap_blocks = h5py.File(override_overlap, "r") |
| ''' | ||
|
|
||
|
|
||
| override_overlap = None if override_overlap == False else override_overlap if override_overlap else self.override_overlap |
Comment on lines
+148
to
+153
| if 'override_overlap' in kwargs: | ||
| assert isinstance(kwargs['override_overlap'], str) | ||
| self.override_overlap = kwargs['override_overlap'] | ||
| log.info(msg="Using external calculated overlap overriding!") | ||
| else: | ||
| self.override_overlap = None |
| thread_per_task_from_jobs = int(n_cpus / safe_n_jobs) | ||
| if thread_per_task_from_jobs > 1: | ||
| log.info(f"n_cpus:{n_cpus} is twice more than safe_n_jobs:{safe_n_jobs},") | ||
| thread_per_task = max(thread_per_task_from_jobs, thread_per_task_from_tasks) |
Comment on lines
+1016
to
+1018
| name = file.name.lower() | ||
| if "self_energy" in name or "se" in name: | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.