Skip to content

more energy_grid_options#31

Open
Lonya0 wants to merge 7 commits into
deepmodeling:mainfrom
Lonya0:cmp
Open

more energy_grid_options#31
Lonya0 wants to merge 7 commits into
deepmodeling:mainfrom
Lonya0:cmp

Conversation

@Lonya0

@Lonya0 Lonya0 commented Jun 27, 2026

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_options to the argument schema and implement flexible energy-grid generation in NEGF (explicit energies, steps, and forcing rules).
  • Add support for override_overlap and 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.

Comment thread dpnegf/runner/NEGF.py
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 thread dpnegf/runner/NEGF.py
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 thread dpnegf/runner/NEGF.py
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 thread dpnegf/runner/NEGF.py
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants