Unverified Commit 4cec6442 authored by Gao, Xiang's avatar Gao, Xiang Committed by GitHub
Browse files

Fix order of wrapping and strain (#221)

parent 14d2ef70
...@@ -77,6 +77,12 @@ class Calculator(ase.calculators.calculator.Calculator): ...@@ -77,6 +77,12 @@ class Calculator(ase.calculators.calculator.Calculator):
coordinates = torch.tensor(self.atoms.get_positions()) coordinates = torch.tensor(self.atoms.get_positions())
coordinates = coordinates.unsqueeze(0).to(self.device).to(self.dtype) \ coordinates = coordinates.unsqueeze(0).to(self.device).to(self.dtype) \
.requires_grad_('forces' in properties) .requires_grad_('forces' in properties)
if pbc_enabled:
coordinates = utils.map2central(cell, coordinates, pbc)
if self.overwrite and atoms is not None:
atoms.set_positions(coordinates.detach().cpu().reshape(-1, 3).numpy())
if 'stress' in properties: if 'stress' in properties:
displacements = torch.zeros(3, 3, requires_grad=True, displacements = torch.zeros(3, 3, requires_grad=True,
dtype=self.dtype, device=self.device) dtype=self.dtype, device=self.device)
...@@ -87,9 +93,6 @@ class Calculator(ase.calculators.calculator.Calculator): ...@@ -87,9 +93,6 @@ class Calculator(ase.calculators.calculator.Calculator):
coordinates = coordinates + strain_x + strain_y + strain_z coordinates = coordinates + strain_x + strain_y + strain_z
if pbc_enabled: if pbc_enabled:
coordinates = utils.map2central(cell, coordinates, pbc)
if self.overwrite and atoms is not None:
atoms.set_positions(coordinates.detach().cpu().reshape(-1, 3).numpy())
if 'stress' in properties: if 'stress' in properties:
strain_x = self.strain(cell, displacement_x, 0) strain_x = self.strain(cell, displacement_x, 0)
strain_y = self.strain(cell, displacement_y, 1) strain_y = self.strain(cell, displacement_y, 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment