Skip to content

Commit

Permalink
Update generateDFTD3.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Oct 23, 2023
1 parent d732b8e commit c64eaf4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ repos:
- id: black
args: [--line-length, '180']
language_version: python3
# - repo: https://github.com/PyCQA/flake8
# rev: 6.0.0
# hooks:
# - id: flake8
# args: [--count, --show-source, --statistics]
# additional_dependencies:
# - flake8-bugbear
# - flake8-builtins
# - flake8-comprehensions
# - flake8-debugger
# - flake8-logging-format
# - pep8-naming
# - pyflakes
# - tryceratops
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-debugger
- flake8-logging-format
- pep8-naming
- pyflakes
- tryceratops
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
hooks:
Expand Down
58 changes: 32 additions & 26 deletions ppafm/cli/generateDFTD3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,57 @@

import sys

import numpy as np

import ppafm as PPU
import ppafm.fieldFFT as fFFT
import ppafm.HighLevel as PPH
from ppafm import elements
from ppafm.defaults import d3

from .. import common
from ..HighLevel import computeDFTD3

def main():

parser = PPU.CLIParser(
description='Generate Grimme DFT-D3 vdW force field using the Becke-Johnson damping function. '
'The generated force field is saved to FFvdW_{x,y,z}.[ext].'
def main():
parser = common.CLIParser(
description="Generate Grimme DFT-D3 vdW force field using the Becke-Johnson damping function. " "The generated force field is saved to FFvdW_{x,y,z}.[ext]."
)

parser.add_arguments(['input', 'input_format', 'output_format', 'noPBC', 'energy'])
parser.add_argument('--df_name', action='store', default='PBE',
help='Which density functional-specific scaling parameters (s6, s8, a1, a2) to use. Give the name of the functional. '
'The following functionals are available: PBE, B1B95, B2GPPLYP, B3PW91, BHLYP, BMK, BOP, BPBE, CAMB3LYP, LCwPBE, '
'MPW1B95, MPWB1K, mPWLYP, OLYP, OPBE, oTPSS, PBE38, PBEsol, PTPSS, PWB6K, revSSB, SSB, TPSSh, HCTH120, B2PLYP, '
'B3LYP, B97D, BLYP, BP86, DSDBLYP, PBE0, PBE, PW6B95, PWPB95, revPBE0, revPBE38, revPBE, rPW86PBE, TPSS0, TPSS.')
parser.add_argument('--df_params', action='store', default=None, nargs=4, type=float, metavar=('s6', 's8', 'a1', 'a2'),
help='Manually specify scaling parameters s6, s8, a1, a2. Overwrites --df_name.')
parser.add_arguments(["input", "input_format", "output_format", "noPBC", "energy"])
parser.add_argument(
"--df_name",
action="store",
default="PBE",
help="Which density functional-specific scaling parameters (s6, s8, a1, a2) to use. Give the name of the functional. "
"The following functionals are available: PBE, B1B95, B2GPPLYP, B3PW91, BHLYP, BMK, BOP, BPBE, CAMB3LYP, LCwPBE, "
"MPW1B95, MPWB1K, mPWLYP, OLYP, OPBE, oTPSS, PBE38, PBEsol, PTPSS, PWB6K, revSSB, SSB, TPSSh, HCTH120, B2PLYP, "
"B3LYP, B97D, BLYP, BP86, DSDBLYP, PBE0, PBE, PW6B95, PWPB95, revPBE0, revPBE38, revPBE, rPW86PBE, TPSS0, TPSS.",
)
parser.add_argument(
"--df_params",
action="store",
default=None,
nargs=4,
type=float,
metavar=("s6", "s8", "a1", "a2"),
help="Manually specify scaling parameters s6, s8, a1, a2. Overwrites --df_name.",
)
args = parser.parse_args()

try:
# Try overwriting global parameters with params.ini file
PPU.loadParams('params.ini')
except:
# Try overwriting global parameters with params.ini file.
common.loadParams("params.ini")
except Exception:
print("No params.ini provided => using default parameters.")

# Overwrite global parameters with command line arguments
PPU.apply_options(vars(args))
# Overwrite global parameters with command line arguments.
common.apply_options(vars(args))

if args.df_params is not None:
p = args.df_params
df_params = {'s6': p[0], 's8': p[1], 'a1': p[2], 'a2': p[3]}
df_params = {"s6": p[0], "s8": p[1], "a1": p[2], "a2": p[3]}
else:
if args.df_name not in d3.DF_DEFAULT_PARAMS:
print(f'Unknown functional name `{args.df_name}`!')
print(f"Unknown functional name `{args.df_name}`!")
sys.exit(1)
df_params = args.df_name

PPH.computeDFTD3(args.input, df_params=df_params, geometry_format=args.input_format, save_format=args.output_format, compute_energy=args.energy)
computeDFTD3(args.input, df_params=df_params, geometry_format=args.input_format, save_format=args.output_format, compute_energy=args.energy)


if __name__ == "__main__":
Expand Down

0 comments on commit c64eaf4

Please sign in to comment.