From 2174abd8cd8b918d7ffb84b63a3d2cde03e62162 Mon Sep 17 00:00:00 2001 From: Yangxing Wang Date: Sat, 8 Aug 2026 02:24:07 +0800 Subject: [PATCH] Add keyword for user defined polarization groups --- .gitignore | 1 + PoltypeModules/multipole.py | 9 ++++++++- PoltypeModules/poltype.py | 3 +++ README/README_HELP.MD | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7a75863a..cdd07fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ __init__.py +.vscode/ \ No newline at end of file diff --git a/PoltypeModules/multipole.py b/PoltypeModules/multipole.py index 12a38609..b80b6cb2 100644 --- a/PoltypeModules/multipole.py +++ b/PoltypeModules/multipole.py @@ -611,7 +611,14 @@ def gen_peditinfile(poltype,mol): f.write("\n") f.flush() os.fsync(f.fileno()) - f.write("2\n") + if poltype.polgrpcutbnds: + f.write("3\n") + for b in poltype.polgrpcutbnds.strip(" ,'\"").split(","): + a1, a2 = b.split("/") + f.write(f"{a1} {a2}\n") + f.write("\n") + else: + f.write("2\n") f.write("N\n") f.write("Y\n") diff --git a/PoltypeModules/poltype.py b/PoltypeModules/poltype.py index b219e71a..5a484edb 100644 --- a/PoltypeModules/poltype.py +++ b/PoltypeModules/poltype.py @@ -127,6 +127,7 @@ class PolarizableTyper(): fragmenterdebugmode:bool=False jobsatsametime:int=0 usepoleditframes:bool=True + polgrpcutbnds:str="" databasematchonly:bool=False setupfragjobsonly:bool=False allowradicals:bool=False @@ -465,6 +466,8 @@ def __post_init__(self): elif "usepoleditframes" in newline: self.usepoleditframes=self.SetDefaultBool(line,a,True) + elif "polgrpcutbnds" in newline: + self.polgrpcutbnds=a elif "generateextendedconf" in newline: self.generateextendedconf=self.SetDefaultBool(line,a,True) elif "userconformation" in newline: diff --git a/README/README_HELP.MD b/README/README_HELP.MD index 32ee0cff..7996dffe 100644 --- a/README/README_HELP.MD +++ b/README/README_HELP.MD @@ -113,6 +113,7 @@ ``usepoleditframes`` specifies to use POLEDIT frames rather than poltype frame detection. Default is True. +``polgrpcutbnds`` defines a custom list of bonds to cut for polarization group separation. The format is a comma-separated list of atom index pairs (e.g., "1/2,3/4,5/6"). The default is "", which means to put all atoms in one group. ``dmamethod`` specifies which quantum method to use for distributed multipole analysis (DMA). Default is MP2.