Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tf): pass rcut to PairTab #3794

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deepmd/tf/model/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ def __init__(
self.numb_fparam = self.fitting.get_numb_fparam()
self.numb_aparam = self.fitting.get_numb_aparam()

self.srtab_name = use_srtab
if self.srtab_name is not None:
self.srtab = PairTab(self.srtab_name, rcut=self.get_rcut())
njzjz marked this conversation as resolved.
Show resolved Hide resolved
self.smin_alpha = smin_alpha
self.sw_rmin = sw_rmin
self.sw_rmax = sw_rmax
self.srtab_add_bias = srtab_add_bias
else:
self.srtab = None

def get_rcut(self):
return self.rcut

Expand Down
15 changes: 1 addition & 14 deletions deepmd/tf/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ def __init__(
data_stat_nbatch: int = 10,
data_bias_nsample: int = 10,
data_stat_protect: float = 1e-2,
use_srtab: Optional[str] = None,
smin_alpha: Optional[float] = None,
sw_rmin: Optional[float] = None,
sw_rmax: Optional[float] = None,
srtab_add_bias: bool = True,
spin: Optional[Spin] = None,
compress: Optional[dict] = None,
**kwargs,
Expand All @@ -142,15 +137,6 @@ def __init__(
self.data_stat_nbatch = data_stat_nbatch
self.data_bias_nsample = data_bias_nsample
self.data_stat_protect = data_stat_protect
self.srtab_name = use_srtab
if self.srtab_name is not None:
self.srtab = PairTab(self.srtab_name)
self.smin_alpha = smin_alpha
self.sw_rmin = sw_rmin
self.sw_rmax = sw_rmax
self.srtab_add_bias = srtab_add_bias
else:
self.srtab = None

def get_type_map(self) -> list:
"""Get the type map."""
Expand Down Expand Up @@ -652,6 +638,7 @@ def __init__(
super().__init__(
descriptor=descriptor, fitting=fitting_net, type_map=type_map, **kwargs
)

if isinstance(descriptor, Descriptor):
self.descrpt = descriptor
else:
Expand Down
2 changes: 1 addition & 1 deletion deepmd/tf/model/pairtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
):
super().__init__()
self.tab_file = tab_file
self.tab = PairTab(self.tab_file)
self.tab = PairTab(self.tab_file, rcut=rcut)
self.ntypes = self.tab.ntypes
self.rcut = rcut
if isinstance(sel, int):
Expand Down
4 changes: 4 additions & 0 deletions deepmd/utils/pair_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class PairTab:
The second to the last columes are energies for pairs of certain types.
For example we have two atom types, 0 and 1.
The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.
rcut : float, optional
cutoff raduis for the tabulated potential
"""

def __init__(self, filename: str, rcut: Optional[float] = None) -> None:
Expand All @@ -49,6 +51,8 @@ def reinit(self, filename: str, rcut: Optional[float] = None) -> None:
The second to the last columes are energies for pairs of certain types.
For example we have two atom types, 0 and 1.
The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.
rcut : float, optional
cutoff raduis for the tabulated potential
"""
if filename is None:
self.tab_info, self.tab_data = None, None
Expand Down
Loading