Skip to content

Commit

Permalink
add reverse swap
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Sep 6, 2024
1 parent 2c0638a commit 6c5d68f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions calphy/alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,20 @@ def run_integration(self, iteration=1):

#add swaps if n_swap is > 0
if self.calc.monte_carlo.n_swaps > 0:
self.logger.info(f'{self.calc.monte_carlo.n_swaps} swap moves are performed between 2 and 1 every {self.calc.monte_carlo.n_steps}')
lmp.command("fix swap all atom/swap %d %d %d %f ke no types 2 1"%(self.calc.monte_carlo.n_steps,
self.calc.monte_carlo.n_swaps,
np.random.randint(1, 10000),
self.calc._temperature))
if self.calc.monte_carlo.reverse_swap:
self.logger.info(f'{self.calc.monte_carlo.n_swaps} swap moves are performed between 2 and 1 every {self.calc.monte_carlo.n_steps}')
lmp.command("fix swap all atom/swap %d %d %d %f ke no types 2 1"%(self.calc.monte_carlo.n_steps,
self.calc.monte_carlo.n_swaps,
np.random.randint(1, 10000),
self.calc._temperature))
else:
self.logger.info(f'{self.calc.monte_carlo.n_swaps} swap moves are performed between 1 and 2 every {self.calc.monte_carlo.n_steps}')
self.logger.info('note that swaps are not reversed')
lmp.command("fix swap all atom/swap %d %d %d %f ke no types 1 2"%(self.calc.monte_carlo.n_steps,
self.calc.monte_carlo.n_swaps,
np.random.randint(1, 10000),
self.calc._temperature))

lmp.command("variable a equal f_swap[1]")
lmp.command("variable b equal f_swap[2]")
lmp.command("fix swap2 all print 1 \"${a} ${b} ${blambda}\" screen no file swap.backward_%d.dat"%iteration)
Expand Down
1 change: 1 addition & 0 deletions calphy/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _to_float(val):
class MonteCarlo(BaseModel, title='Options for Monte Carlo moves during particle swap moves'):
n_steps: Annotated[int, Field(default=1, gt=0, description='perform swap moves every n_step')]
n_swaps: Annotated[int, Field(default=0, gt=0, description='number of swap moves to perform')]
reverse_swap: Annotated[ bool, Field(default=True)]

class CompositionScaling(BaseModel, title='Composition scaling input options'):
_input_chemical_composition: PrivateAttr(default=None)
Expand Down

0 comments on commit 6c5d68f

Please sign in to comment.