Skip to content

Commit

Permalink
add new pair style options
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Nov 13, 2023
1 parent c251bb8 commit 4e5efd5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 41 deletions.
28 changes: 14 additions & 14 deletions calphy/alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ def run_integration(self, iteration=1):
if self.calc.pair_style[0] == self.calc.pair_style[1]:
pc = self.calc.pair_coeff[0]
pcraw = pc.split()
pc1 = " ".join([*pcraw[:2], *[self.calc.pair_style[0],], "1", *pcraw[2:]])
pc1 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[0],], "1", *pcraw[2:]])
pc = self.calc.pair_coeff[1]
pcraw = pc.split()
pc2 = " ".join([*pcraw[:2], *[self.calc.pair_style[1],], "2", *pcraw[2:]])
pc2 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[1],], "2", *pcraw[2:]])
else:
pc = self.calc.pair_coeff[0]
pcraw = pc.split()
pc1 = " ".join([*pcraw[:2], *[self.calc.pair_style[0],], *pcraw[2:]])
pc1 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[0],], *pcraw[2:]])
pc = self.calc.pair_coeff[1]
pcraw = pc.split()
pc2 = " ".join([*pcraw[:2], *[self.calc.pair_style[1],], *pcraw[2:]])
pc2 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[1],], *pcraw[2:]])


lmp.command("pair_style hybrid/scaled v_flambda %s v_blambda %s"%(
Expand All @@ -208,12 +208,12 @@ def run_integration(self, iteration=1):


#apply pair force commands
if self.calc.pair_style[0] == self.calc.pair_style[1]:
lmp.command("compute c1 all pair %s 1"%self.calc.pair_style[0])
lmp.command("compute c2 all pair %s 2"%self.calc.pair_style[1])
if self.calc._pair_style_names[0] == self.calc._pair_style_names[1]:
lmp.command("compute c1 all pair %s 1"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair %s 2"%self.calc._pair_style_names[1])
else:
lmp.command("compute c1 all pair %s"%self.calc.pair_style[0])
lmp.command("compute c2 all pair %s"%self.calc.pair_style[1])
lmp.command("compute c1 all pair %s"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair %s"%self.calc._pair_style_names[1])


# Output variables.
Expand Down Expand Up @@ -260,12 +260,12 @@ def run_integration(self, iteration=1):


#apply pair force commands
if self.calc.pair_style[0] == self.calc.pair_style[1]:
lmp.command("compute c1 all pair %s 1"%self.calc.pair_style[0])
lmp.command("compute c2 all pair %s 2"%self.calc.pair_style[1])
if self.calc._pair_style_names[0] == self.calc._pair_style_names[1]:
lmp.command("compute c1 all pair %s 1"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair %s 2"%self.calc._pair_style_names[1])
else:
lmp.command("compute c1 all pair %s"%self.calc.pair_style[0])
lmp.command("compute c2 all pair %s"%self.calc.pair_style[1])
lmp.command("compute c1 all pair %s"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair %s"%self.calc._pair_style_names[1])


# Output variables.
Expand Down
10 changes: 5 additions & 5 deletions calphy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def set_hybrid_potential(lmp, options, eps, ghost_elements=0):
[
*pcraw[:2],
*[
options._pair_style_with_options[0],
options._pair_style_names[0],
],
*pcraw[2:],
]
Expand Down Expand Up @@ -239,7 +239,7 @@ def set_double_hybrid_potential(lmp, options, ghost_elements=0):
[
*pcraw1[:2],
*[
options.pair_style[0],
options._pair_style_names[0],
],
"1",
*pcraw1[2:],
Expand All @@ -249,7 +249,7 @@ def set_double_hybrid_potential(lmp, options, ghost_elements=0):
[
*pcraw2[:2],
*[
options.pair_style[1],
options._pair_style_names[1],
],
"2",
*pcraw2[2:],
Expand All @@ -260,7 +260,7 @@ def set_double_hybrid_potential(lmp, options, ghost_elements=0):
[
*pcraw1[:2],
*[
options.pair_style[0],
options._pair_style_names[0],
],
*pcraw1[2:],
]
Expand All @@ -269,7 +269,7 @@ def set_double_hybrid_potential(lmp, options, ghost_elements=0):
[
*pcraw2[:2],
*[
options.pair_style[1],
options._pair_style_names[1],
],
*pcraw2[2:],
]
Expand Down
29 changes: 12 additions & 17 deletions calphy/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,28 +252,23 @@ def _validate_all(self) -> 'Input':
else:
self._temperature_high = self.temperature_high

ps_lst = []
ps_options_lst = []
for ps in self.pair_style:
ps_split = ps.split()
ps_lst.append(ps_split[0])
if len(ps) > 1:
ps_options_lst.append(" ".join(ps_split[1:]))
else:
ps_options_lst.append("")

if len(self.pair_style) != len(ps_options_lst):
ps_options_lst = [ps_options_lst[0] for x in range(len(self.pair_style))]
#fix pair styles
#two main lists
# _pair_style_with_options, read in as it is from file
# _pair_style_names, just the names of the pair styles

_pair_style_names = []

ps_options_lst = [" ".join([self.pair_style[i], ps_options_lst[i]]) for i in range(len(self.pair_style))]
for ps in self.pair_style:
ps_split = ps.split()
_pair_style_names.append(ps_split[0])

#val = self.fix_paths(val)
self.pair_style = ps_lst

#only set if its None
if self._pair_style_with_options is None:
self._pair_style_with_options = ps_options_lst

self._pair_style_with_options = self.pair_style
self._pair_style_names = _pair_style_names
#now fix pair coeffs with path
if self.fix_potential_path:
self.pair_coeff = self.fix_paths(self.pair_coeff)
Expand Down
6 changes: 3 additions & 3 deletions calphy/liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ def run_integration(self, iteration=1):

pc = self.calc.pair_coeff[0]
pcraw = pc.split()
pcnew = " ".join([*pcraw[:2], *[self.calc.pair_style[0],], *pcraw[2:]])
pcnew = " ".join([*pcraw[:2], *[self.calc._pair_style_names[0],], *pcraw[2:]])

lmp.command("pair_coeff %s"%pcnew)
lmp.command("pair_coeff * * ufm %f 1.5"%self.eps)

lmp.command("compute c1 all pair %s"%self.calc.pair_style[0])
lmp.command("compute c1 all pair %s"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair ufm")

lmp.command("variable step equal step")
Expand Down Expand Up @@ -274,7 +274,7 @@ def run_integration(self, iteration=1):
lmp.command("pair_coeff %s"%pcnew)
lmp.command("pair_coeff * * ufm %f 1.5"%self.eps)

lmp.command("compute c1 all pair %s"%self.calc.pair_style[0])
lmp.command("compute c1 all pair %s"%self.calc._pair_style_names[0])
lmp.command("compute c2 all pair ufm")

lmp.command("variable step equal step")
Expand Down
4 changes: 2 additions & 2 deletions calphy/phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ def reversible_scaling(self, iteration=1):
#set up potential
pc = self.calc.pair_coeff[0]
pcraw = pc.split()
pcnew1 = " ".join([*pcraw[:2], *[self.calc.pair_style[0],], "1", *pcraw[2:]])
pcnew2 = " ".join([*pcraw[:2], *[self.calc.pair_style[0],], "2", *pcraw[2:]])
pcnew1 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[0],], "1", *pcraw[2:]])
pcnew2 = " ".join([*pcraw[:2], *[self.calc._pair_style_names[0],], "2", *pcraw[2:]])

lmp.command("pair_style hybrid/scaled v_one %s v_fscale %s"%(self.calc._pair_style_with_options[0], self.calc._pair_style_with_options[0]))
lmp.command("pair_coeff %s"%pcnew1)
Expand Down

0 comments on commit 4e5efd5

Please sign in to comment.