Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add espresso recipes and custom calculator #1238

Merged
merged 157 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
7276456
initial
tomdemeyere Nov 20, 2023
e9f760d
pseudos
tomdemeyere Nov 20, 2023
2262cf1
draft PR *not working*
tomdemeyere Nov 22, 2023
c78fbd4
namelist.py deletion
tomdemeyere Nov 22, 2023
560180e
Merge branch 'main' into espresso
Andrew-S-Rosen Nov 22, 2023
acc5a82
neb recipe & calc default to class
tomdemeyere Nov 23, 2023
c27c139
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Nov 23, 2023
ba02f66
first successful run
tomdemeyere Nov 24, 2023
b511c16
custom espresso calc
tomdemeyere Nov 24, 2023
ec67e05
__init__ problem
tomdemeyere Nov 24, 2023
97b72fc
oops
tomdemeyere Nov 24, 2023
4f62e63
first step using ASE calc
tomdemeyere Nov 24, 2023
b636144
ph.x output reader
tomdemeyere Nov 30, 2023
2c548ce
only one mistake? getting better at python
tomdemeyere Nov 30, 2023
288e221
actually using new template
tomdemeyere Nov 30, 2023
7744a7a
pw.x keys
tomdemeyere Nov 30, 2023
59a823a
calc_defaults back in recipes
tomdemeyere Nov 30, 2023
8815fef
changed priority preset/default
tomdemeyere Nov 30, 2023
7ee8f77
organize imports
tomdemeyere Nov 30, 2023
530ea45
ph job does not need atoms
tomdemeyere Nov 30, 2023
a6b9ce2
Atoms does not exist?
tomdemeyere Nov 30, 2023
9280b5f
actually using profiles
tomdemeyere Nov 30, 2023
1fbbb00
oops
tomdemeyere Nov 30, 2023
f45a165
typo input/output name
tomdemeyere Nov 30, 2023
20f2202
add actual writing in write ph...
tomdemeyere Nov 30, 2023
a1139f0
few fixes
tomdemeyere Nov 30, 2023
abed5cb
espresso ph write
tomdemeyere Nov 30, 2023
e58e2ac
cleaning time
tomdemeyere Dec 1, 2023
ada63ab
flake8
tomdemeyere Dec 1, 2023
2ea989f
just a few tests...
tomdemeyere Dec 1, 2023
70f4e11
more tests
tomdemeyere Dec 1, 2023
d11d6d0
__init__.py
tomdemeyere Dec 1, 2023
d7f27b5
__init__.py
tomdemeyere Dec 1, 2023
e1380a3
modern espresso profile
tomdemeyere Dec 1, 2023
8ab04e9
modern espresso profile
tomdemeyere Dec 1, 2023
a6a72d7
modern espresso profile
tomdemeyere Dec 1, 2023
057b72a
Add the missing __init__.py
Andrew-S-Rosen Dec 1, 2023
0bc92d4
Update __init__.py
Andrew-S-Rosen Dec 1, 2023
4011745
Create __init__.py
Andrew-S-Rosen Dec 1, 2023
ddcdbe3
Standardize kwarg naming
Andrew-S-Rosen Dec 1, 2023
83b46ac
Merge branch 'espresso' of github.com:tomdemeyere/quacc into espresso
Andrew-S-Rosen Dec 1, 2023
0398772
Update settings.py to match `main`
Andrew-S-Rosen Dec 2, 2023
635a19c
more tests
tomdemeyere Dec 2, 2023
0e86a82
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 2, 2023
8e1e3d9
modern genericIO needs parallel_info
tomdemeyere Dec 4, 2023
4d61ef7
parallel_info is actually a dict...
tomdemeyere Dec 4, 2023
610c221
no need for pseudo in calc_defaults
tomdemeyere Dec 4, 2023
2496643
big clean up
tomdemeyere Dec 4, 2023
2042b9f
espresso settings as a dict
tomdemeyere Dec 4, 2023
c957b37
`isort`, `black`, and `ruff`
Andrew-S-Rosen Dec 5, 2023
f96485f
Finish unresolved cleanup
Andrew-S-Rosen Dec 5, 2023
20881de
Fix docstring I accidentally deleted
Andrew-S-Rosen Dec 5, 2023
de2bd99
Refactor base function
Andrew-S-Rosen Dec 5, 2023
3a41583
Merge branch 'main' into espresso
Andrew-S-Rosen Dec 5, 2023
513bec2
Ensure espresso presets get shipped
Andrew-S-Rosen Dec 5, 2023
7a54985
Merge branch 'espresso' of github.com:tomdemeyere/quacc into espresso
Andrew-S-Rosen Dec 5, 2023
0591d45
Update core.py
Andrew-S-Rosen Dec 5, 2023
56ab0fd
moving SETTINGS and profile out of recipe
tomdemeyere Dec 5, 2023
746d418
testing on improved copy files
tomdemeyere Dec 5, 2023
9489723
testing on improved copy files
tomdemeyere Dec 5, 2023
c6b58c7
testing on improved copy files
tomdemeyere Dec 5, 2023
797fc98
Mark contributions in about page
Andrew-S-Rosen Dec 5, 2023
49b9404
Add espresso runner
Andrew-S-Rosen Dec 5, 2023
c4cd1ee
(temporary?) trick energy = None
tomdemeyere Dec 5, 2023
58a96cf
modify io to always return dict
tomdemeyere Dec 5, 2023
ec12bdb
no atoms metadata if empty atoms
tomdemeyere Dec 5, 2023
d98a63f
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 5, 2023
0adfd3e
atoms had default Atoms in base_fn
tomdemeyere Dec 5, 2023
fcf1b3a
initial
tomdemeyere Dec 5, 2023
f3d3a9b
type hint
tomdemeyere Dec 5, 2023
86a049b
ase.io.espresso functions clean up utils.py
tomdemeyere Dec 5, 2023
d5a1dd3
tests
tomdemeyere Dec 5, 2023
d3a3b9f
Try two separate functions
Andrew-S-Rosen Dec 6, 2023
bee9dc3
fix
Andrew-S-Rosen Dec 6, 2023
8b89d38
fix
Andrew-S-Rosen Dec 6, 2023
f533b69
fix type hint
Andrew-S-Rosen Dec 6, 2023
fefb8ca
fix comment
Andrew-S-Rosen Dec 6, 2023
a52f087
fix
Andrew-S-Rosen Dec 6, 2023
935c174
fix
Andrew-S-Rosen Dec 6, 2023
4090562
fix
Andrew-S-Rosen Dec 6, 2023
a63fd93
fix
Andrew-S-Rosen Dec 6, 2023
16f4084
fix
Andrew-S-Rosen Dec 6, 2023
817e913
fix
Andrew-S-Rosen Dec 6, 2023
5a51042
fix
Andrew-S-Rosen Dec 6, 2023
e24b9b8
fix
Andrew-S-Rosen Dec 6, 2023
5ad0d51
fix
Andrew-S-Rosen Dec 6, 2023
c99637b
fix
Andrew-S-Rosen Dec 6, 2023
9585f0b
Clean up comment
Andrew-S-Rosen Dec 6, 2023
6b72122
Cleanup
Andrew-S-Rosen Dec 6, 2023
cdc0e78
fix imports
Andrew-S-Rosen Dec 6, 2023
d84eb39
fix
Andrew-S-Rosen Dec 6, 2023
8b58762
Merge remote-tracking branch 'upstream/rosen-copy-files' into espresso
tomdemeyere Dec 6, 2023
0ccddb6
fix load_yaml
tomdemeyere Dec 6, 2023
0e6ceb8
first step towards testing
tomdemeyere Dec 6, 2023
329acbd
oops
tomdemeyere Dec 6, 2023
09145b4
second step to testing
tomdemeyere Dec 6, 2023
4087b46
final steps for tests?
tomdemeyere Dec 6, 2023
63f3583
first step for doc
tomdemeyere Dec 6, 2023
45b987f
deepsource initial
tomdemeyere Dec 6, 2023
118a20f
CWE-73 file security
tomdemeyere Dec 6, 2023
f9dbf2d
fix
tomdemeyere Dec 6, 2023
b62fcda
test good to go
tomdemeyere Dec 6, 2023
a2ff2d0
Clean up docs and apply formatters
Andrew-S-Rosen Dec 7, 2023
d3a958d
Clean up field validation
Andrew-S-Rosen Dec 7, 2023
50bd1f1
Fix broken test suite
Andrew-S-Rosen Dec 7, 2023
8eef5ee
Fix broken test suite
Andrew-S-Rosen Dec 7, 2023
c493e6f
Rerun the test suite for fixed code coverage
Andrew-S-Rosen Dec 7, 2023
b8383b9
final review
tomdemeyere Dec 7, 2023
b9f75db
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 7, 2023
925ad41
docstrings and small changes
tomdemeyere Dec 7, 2023
cc78d90
Update type-hint to prevent future merge conflict
Andrew-S-Rosen Dec 7, 2023
540906f
Merge branch 'main' into espresso
Andrew-S-Rosen Dec 8, 2023
19ac71c
tests tests and tests
tomdemeyere Dec 8, 2023
b0034a0
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 8, 2023
eb67841
tests tests and tests
tomdemeyere Dec 8, 2023
0c8f430
tests tests tests
tomdemeyere Dec 8, 2023
ebe0221
Fix broken test
Andrew-S-Rosen Dec 9, 2023
f2d2d4c
tests and electron-phonon constants in read_ph
tomdemeyere Dec 9, 2023
10cb006
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 9, 2023
49e9bf5
one more test
tomdemeyere Dec 9, 2023
4ee69b4
fix
tomdemeyere Dec 9, 2023
a1b4e1e
fix
tomdemeyere Dec 9, 2023
29d0bbc
oops
tomdemeyere Dec 9, 2023
945e6d8
fix test
tomdemeyere Dec 9, 2023
7cd5377
deepsource and windows fix tests
tomdemeyere Dec 9, 2023
09e27f4
fixing tests
tomdemeyere Dec 9, 2023
037d4c7
wtf?
tomdemeyere Dec 9, 2023
4d24fc8
final commit?
tomdemeyere Dec 9, 2023
7c8fc71
Merge branch 'main' into espresso
Andrew-S-Rosen Dec 10, 2023
2495088
Update tests.yaml
Andrew-S-Rosen Dec 10, 2023
337d127
oops
tomdemeyere Dec 10, 2023
688d730
Merge remote-tracking branch 'origin/espresso' into espresso
tomdemeyere Dec 10, 2023
855a2cc
Add missing type hints to `espresso.py`
Andrew-S-Rosen Dec 10, 2023
24f2736
Add more missing type hints
Andrew-S-Rosen Dec 10, 2023
8ed4918
Fix type hint
Andrew-S-Rosen Dec 10, 2023
a2a0984
Remove `Atoms()`
Andrew-S-Rosen Dec 10, 2023
aeb8ec6
Use absolute `Path.cwd()` for setting default
Andrew-S-Rosen Dec 10, 2023
c49db5f
Use `.resolve()` instead of `.absolute()`
Andrew-S-Rosen Dec 10, 2023
b8c3e09
Additional cleanup
Andrew-S-Rosen Dec 10, 2023
10a737c
Merge branch 'main' into espresso
Andrew-S-Rosen Dec 10, 2023
675fadb
More cleanup
Andrew-S-Rosen Dec 10, 2023
68781e4
Merge branch 'espresso' of github.com:tomdemeyere/quacc into espresso
Andrew-S-Rosen Dec 10, 2023
42ab92b
`sourcery review . --fix`
Andrew-S-Rosen Dec 10, 2023
4a31f4e
Fix Path issue
Andrew-S-Rosen Dec 10, 2023
0284f86
More cleanup
Andrew-S-Rosen Dec 11, 2023
82a55ac
Merge tests
Andrew-S-Rosen Dec 11, 2023
77512ca
Fix test yaml
Andrew-S-Rosen Dec 11, 2023
968058f
Compress test data
Andrew-S-Rosen Dec 11, 2023
0589489
Update documentation for settings
Andrew-S-Rosen Dec 11, 2023
350e783
Merge branch 'main' into espresso
Andrew-S-Rosen Dec 11, 2023
c11a352
Fix pydantic
Andrew-S-Rosen Dec 11, 2023
4766222
Merge branch 'espresso' of github.com:tomdemeyere/quacc into espresso
Andrew-S-Rosen Dec 11, 2023
6a5db4f
Final cleanup?
Andrew-S-Rosen Dec 11, 2023
21711d6
deepsource fix
Andrew-S-Rosen Dec 11, 2023
9caeafc
Use `.expanduser().resolve()`
Andrew-S-Rosen Dec 11, 2023
af5e5fd
Update changelog
Andrew-S-Rosen Dec 11, 2023
0b50043
Add (@tomdemeyere) to CHANGELOG
Andrew-S-Rosen Dec 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/quacc/calculators/espresso/calculators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from quacc import SETTINGS
from quacc.calculators.espresso.core import EspressoCalculator
from quacc.calculators.espresso.keys import (DYNMAT_KEYS, NEB_KEYS, PH_KEYS,
Q2R_KEYS, MATDYN_KEYS)

# Mini classes that might be useful for binaries
# that have very specific requirements

class Ph(EspressoCalculator):
# These are not supposed to change
_BIN = 'ph'
_KEYS = PH_KEYS
_CMD = SETTINGS['ESPRESSO_PH_CMD']

def __init__(self, input_data):
self.input_data = input_data
super().__init__()

class Neb(EspressoCalculator):

_BIN = 'neb'
_KEYS = NEB_KEYS
_CMD = SETTINGS['ESPRESSO_NEB_CMD']

def __init__(self, input_data):
self.input_data = input_data
super().__init__()
self.input_file = 'neb.dat'

class Q2r(EspressoCalculator):
# These are not supposed to change
_BIN = 'q2r'
_KEYS = Q2R_KEYS
_CMD = SETTINGS['ESPRESSO_Q2R_CMD']

def __init__(self, input_data):
self.input_data = input_data
super().__init__()

class Dynmat(EspressoCalculator):
# These are not supposed to change
_BIN = 'dynmat'
_KEYS = DYNMAT_KEYS
_CMD = SETTINGS['ESPRESSO_DYNMAT_CMD']

def __init__(self, input_data):
self.input_data = input_data
super().__init__()

class Matdyn(EspressoCalculator):
# These are not supposed to change
_BIN = 'matdyn'
_KEYS = MATDYN_KEYS
_CMD = SETTINGS['ESPRESSO_MATDYN_CMD']

def __init__(self, input_data):
self.input_data = input_data
super().__init__()
31 changes: 31 additions & 0 deletions src/quacc/calculators/espresso/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from quacc.calculators.espresso.utils import construct_namelist
Andrew-S-Rosen marked this conversation as resolved.
Show resolved Hide resolved
from quacc.calculators.espresso.io import _write, _read

# Very simple class that can run calculations ASE style
# I don't think we even need atoms object here.
Andrew-S-Rosen marked this conversation as resolved.
Show resolved Hide resolved
class EspressoCalculator:
Andrew-S-Rosen marked this conversation as resolved.
Show resolved Hide resolved
tomdemeyere marked this conversation as resolved.
Show resolved Hide resolved
# These are not supposed to change
def __init__(self):
self.input_file = f'{self._BIN}.in'
self.output_file = f'{self._BIN}.out'

def write_input(self, parameters, **kwargs):
_write(self.input_file, parameters, format = self._BIN, **kwargs)

def run(self):
from os import environ
from subprocess import check_call
argv = list(self._CMD) + ['-in', self.input_file]
with open(self.output_file, 'wb') as fd:
check_call(argv, stdout=fd, env=environ)

def execute(self, **kwargs):
parameters = self.to_namelist(self.input_data)
self.write_input(parameters, **kwargs)
self.run()

def read_results(self, **kwargs):
return _read(self.output_file, format = self._BIN, **kwargs)

def to_namelist(self):
return construct_namelist(self.input_data, keys=self._KEYS)
43 changes: 43 additions & 0 deletions src/quacc/calculators/espresso/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""I/O utilities for the espresso calculator."""

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pathlib import Path
from typing import Any


# Three ways to call a function based on a string:

# 1. use the globals() dictionary
# 2. use sys.modules[__name__] and getattr
# 3. keep track of all functions in a dictionary

def _write(filename, parameters, *, format, **kwargs):
lines = write_namelist(filename, parameters)

with open(filename, 'w') as fd:
fd.write(''.join(lines))

def write_namelist(filename: str | Path, parameters: dict):
# This function aim to write basic input keywords to a file
# For additional cards (binary specifics) this is down in the child class
# Stolen from ase.io.espresso, maybe this could be made to a function "write_namelist"
# and imported here? See with the ASE gods.
pwi = []
for section in parameters:
pwi.append('&{0}\n'.format(section.upper()))
for key, value in parameters[section].items():
if value is True:
pwi.append(' {0:16} = .true.\n'.format(key))
elif value is False:
pwi.append(' {0:16} = .false.\n'.format(key))
else:
# repr format to get quotes around strings
pwi.append(' {0:16} = {1!r:}\n'.format(key, value))
pwi.append('/\n') # terminate section
pwi.append('\n')
return pwi

def write_ph_specifics():
pass
168 changes: 168 additions & 0 deletions src/quacc/calculators/espresso/keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# We work ase.io.espresso style, but we need to add the namelist keys for each binary.
# !!! For now this is GPT3.5 generated, must be checked !!!
Andrew-S-Rosen marked this conversation as resolved.
Show resolved Hide resolved

from ase.io.espresso import Namelist

PH_KEYS = Namelist([
Andrew-S-Rosen marked this conversation as resolved.
Show resolved Hide resolved
('input_ph', [
'amass',
'outdir',
'prefix',
'niter_ph',
'tr2_ph',
'alpha_mix',
'nmix_ph',
'verbosity',
'reduce_io',
'max_seconds',
'dftd3_hess',
'fildyn',
'fildrho',
'fildvscf',
'epsil',
'lrpa',
'lnoloc',
'trans',
'lraman',
'eth_rps',
'eth_ns',
'dek',
'recover',
'low_directory_check',
'only_init',
'qplot',
'q2d',
'q_in_band_form',
'electron_phonon',
'el_ph_nsigma',
'el_ph_sigma',
'ahc_dir',
'ahc_nbnd',
'ahc_nbndskip',
'skip_upperfan',
'lshift_q',
'zeu',
'zue',
'elop',
'fpol',
'ldisp',
'nogg',
'asr',
'ldiag',
'lqdir',
'search_sym',
'nq1',
'nq2',
'nq3',
'nk1',
'nk2',
'nk3',
'k1',
'k2',
'k3',
'diagonalization',
'read_dns_bare',
'ldvscf_interpolate',
'wpot_dir',
'do_long_range',
'do_charge_neutral',
'start_irr',
'last_irr',
'nat_todo',
'modenum',
'start_q',
'last_q',
'dvscf_star',
'drho_star',]
)])

NEB_KEYS = Namelist([
('path', [
'string_method',
'restart_mode',
'nstep_path',
'num_of_images',
'opt_scheme',
'CI_scheme',
'first_last_opt',
'minimum_image',
'temp_req',
'ds',
'k_max',
'k_min',
'path_thr',
'uses_masses',
'use_freezing',
'lfcp',
'fcp_mu',
'fcp_thr',
'fcp_scheme']
)])

Q2R_KEYS = Namelist([('input', [
'fildyn',
'flfrc',
'zasr',
'loto_2d',
'write_lr']
)])

MATDYN_KEYS = Namelist([
('&input', [
'flfrc',
'asr',
'huang',
'dos',
'nk1',
'nk2',
'nk3',
'deltaE',
'ndos',
'degauss',
'fldos',
'flfrq',
'flvec',
'fleig',
'fldyn',
'at',
'l1',
'l2',
'l3',
'ntyp',
'amass',
'readtau',
'fltau',
'la2F',
'q_in_band_form',
'q_in_cryst_coord',
'eigen_similarity',
'fd',
'na_ifc',
'nosym',
'loto_2d',
'loto_disable',
'read_lr',
'write_frc']
)])

DYNMAT_KEYS = Namelist([
('&input', [
'fildyn',
'q',
'amass',
'asr',
'remove_interaction_blocks',
'axis',
'lperm',
'lplasma',
'filout',
'fileig',
'filmol',
'filxsf',
'loto_2d',
'el_ph_nsig',
'el_ph_sigma']
)])

# Is this cleaner to import?
ALL_KEYS = {'ph': PH_KEYS, 'neb': NEB_KEYS, 'q2r': Q2R_KEYS, 'dynmat': DYNMAT_KEYS}
Loading
Loading