From 94ee6c1a83e05335e0466a6d121dc5f3c75ed7a8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 23 Oct 2023 22:00:20 +0200 Subject: [PATCH] Update generateLJFF.py --- ppafm/cli/generateLJFF.py | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/ppafm/cli/generateLJFF.py b/ppafm/cli/generateLJFF.py index e14e8c65..19861404 100755 --- a/ppafm/cli/generateLJFF.py +++ b/ppafm/cli/generateLJFF.py @@ -1,35 +1,26 @@ #!/usr/bin/python -import os +from pathlib import Path -import numpy as np - -import ppafm as PPU -import ppafm.fieldFFT as fFFT -import ppafm.HighLevel as PPH -from ppafm import elements +from .. import common +from ..HighLevel import computeLJ def main(): + parser = common.CLIParser(description="Generate a Lennard-Jones, Morse, or vdW force field. The generated force field is saved to FFLJ_{x,y,z}.[ext].") - parser = PPU.CLIParser( - description='Generate a Lennard-Jones, Morse, or vdW force field. ' - 'The generated force field is saved to FFLJ_{x,y,z}.[ext].' - ) - - parser.add_arguments(['input', 'input_format', 'output_format', 'ffModel', 'energy', 'noPBC']) + parser.add_arguments(["input", "input_format", "output_format", "ffModel", "energy", "noPBC"]) args = parser.parse_args() try: - PPU.loadParams( 'params.ini' ) - except ValueError as e: - print(e) - print("no params.ini provided => using default params ") + common.loadParams("params.ini") + except Exception: + print("No params.ini provided => using default parameters.") - PPU.apply_options(vars(args)) + common.apply_options(vars(args)) - speciesFile = 'atomtypes.ini' if os.path.isfile('atomtypes.ini') else None + species_file = "atomtypes.ini" if Path("atomtypes.ini").is_file() else None - PPH.computeLJ( args.input, geometry_format=args.input_format, speciesFile=speciesFile, save_format=args.output_format, computeVpot=args.energy, ffModel=args.ffModel ) + computeLJ(args.input, geometry_format=args.input_format, speciesFile=species_file, save_format=args.output_format, computeVpot=args.energy, ffModel=args.ffModel) if __name__ == "__main__":