Skip to content

Commit

Permalink
rm expcell batch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbluque committed Aug 7, 2024
1 parent 3578ceb commit 63408a3
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions src/fairchem/core/common/relaxation/optimizers/optimizable.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,76 +556,3 @@ def get_forces(

def __len__(self):
return len(self.batch.pos) + 3 * len(self.batch)


class OptimizableExpCellBatch(OptimizableBatch):
"""Modify the supercell and the atom positions in relaxations.
Based on ase FrechetCellFilter to work on data batches and that in JuLIP.jl:
https://github.com/JuliaMolSim/JuLIP.jl/blob/master/src/expcell.jl
"""

def __init__(
self,
batch: Batch,
trainer: BaseTrainer,
transform: torch.nn.Module | None = None,
numpy: bool = False,
mask_converged: bool = True,
cumulative_mask: bool = True,
mask: Sequence[bool] | None = None,
cell_factor: float | None = None,
hydrostatic_strain: bool = False,
constant_volume: bool = False,
scalar_pressure: float = 0.0,
):
"""Create a filter that returns the forces and unit cell stresses together, for simultaneous optimization.
For full details see:
E. B. Tadmor, G. S. Smith, N. Bernstein, and E. Kaxiras,
Phys. Rev. B 59, 235 (1999)
Args:
batch: A batch of atoms graph data
model: An instance of a BaseTrainer derived class
transform: graph transform
numpy: whether to cast results to numpy arrays
mask_converged: if true will mask systems in batch that are already converged
cumulative_mask: if true, once system is masked then it remains masked even if new predictions give forces
above threshold, ie. once masked always masked. Note if this is used make sure to check convergence with
the same fmax always
mask: a boolean mask specifying which strain components are allowed to relax
cell_factor:
Factor by which deformation gradient is multiplied to put
it on the same scale as the positions when assembling
the combined position/cell vector. The stress contribution to
the forces is scaled down by the same factor. This can be thought
of as a very simple preconditioners. Default is number of atoms
which gives approximately the correct scaling.
hydrostatic_strain:
Constrain the cell by only allowing hydrostatic deformation.
The virial tensor is replaced by np.diag([np.trace(virial)]*3).
constant_volume:
Project out the diagonal elements of the virial tensor to allow
relaxations at constant volume, e.g. for mapping out an
energy-volume curve. Note: this only approximately conserves
the volume and breaks energy/force consistency so can only be
used with optimizers that do require a line minimisation
(e.g. FIRE).
scalar_pressure:
Applied pressure to use for enthalpy pV term. As above, this
breaks energy/force consistency.
"""
super().__init__(
batch=batch,
trainer=trainer,
transform=transform,
numpy=numpy,
mask_converged=mask_converged,
cumulative_mask=cumulative_mask,
mask=mask,
cell_factor=cell_factor,
hydrostatic_strain=hydrostatic_strain,
constant_volume=constant_volume,
scalar_pressure=scalar_pressure,
)

0 comments on commit 63408a3

Please sign in to comment.