Skip to content

Commit

Permalink
Tweaks to allow for 1D and 2D MT corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
elinscott committed Nov 6, 2023
1 parent bbefdfc commit 371b931
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/koopmans/utils/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def construct_cell_parameters_block(atoms: Atoms) -> Dict[str, Any]:
params = dict(**cell_to_parameters(atoms.cell))
else:
params = {'vectors': [list(row) for row in atoms.cell[:]], 'units': 'angstrom'}
params['periodic'] = all(atoms.pbc)
params['periodic'] = atoms.pbc
return params


Expand Down
5 changes: 0 additions & 5 deletions src/koopmans/workflows/_koopmans_dscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,11 +1034,6 @@ def new_kcp_calculator(self, calc_presets: str = 'dft_init',
if 'print' in calc.prefix:
calc.parameters.print_wfc_anion = True

if self.parameters.mt_correction:
calc.parameters.which_compensation = 'tcc'
else:
calc.parameters.which_compensation = 'none'

# If we are using frozen orbitals, we override the above logic and freeze the variational orbitals
# post-initialization
if self.parameters.frozen_orbitals and 'init' not in calc.prefix and not any([s == calc.prefix for s in
Expand Down
14 changes: 14 additions & 0 deletions src/koopmans/workflows/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,20 @@ def new_calculator(self,
# Create the calculator
calc = calc_class(atoms=copy.deepcopy(self.atoms), **all_kwargs)

# Add Martyna-Tuckerman settings for kcp calculators
if calc.parameters.is_valid('which_compensation'):
if self.parameters.mt_correction:
if all(self.atoms.pbc):
calc.parameters.which_compensation = 'tcc'
elif self.atoms.pbc == [False, False, True]:
calc.parameters.which_compensation = 'tcc1d'
elif self.atoms.pbc == [True, True, False]:
calc.parameters.which_compensation = 'tcc2d'
else:
raise ValueError('Martyna-Tuckerman correction not implemented for this geometry; for 1D and 2D systems please use z as the unique axis')
else:
calc.parameters.which_compensation = 'none'

# Add the directory if provided
if directory is not None:
calc.directory = directory
Expand Down

0 comments on commit 371b931

Please sign in to comment.