Package: parametrization-clean-cdaksha
ReaxFF Parametrization with Clean ArchitectureContains Python files and Bash scripts as a basis for automated ReaxFF parametrization. Uses the genetic algorithm (GA)
algorithm as well as an artificial neural network (ANN) to optimize a ReaxFF parameter set. Note that this version
is refactored to attempt to comply with Robert Martin's Clean Architecture guidelines. Using the generational genetic
algorithm and neural net (the latter only if enabled), runs one generation, awaiting submission of standalone
ReaxFF optimizations.Getting StartedAs with all work flows,it is a good idea
to work within a Python virtual environmentto create an isolated environment for this Python project.Thissource contains a good tutorial on how to setup a virtual
environment. Another source for help with Python virtual environments ishere.The project files are available as a GitHub repositoryhere.
The project can also be accessed through PyPihere;
the corresponding pip installation command is$pip install parametrization-clean-cdakshaIf you don't have pip and/or Python installed, thenthisguide may prove helpful in performing a basic setup. If, for whatever reason, a distribution manager such as pip or
conda is not available, then the required packages for running the application are shown inrequirements/prod.txt.After installing the package with pip, the current implementation supports a command-line interface with usage$cli --g GENERATION_NUMBER --t TRAINING_PATH --p POPULATION_PATH --c CONFIG_PATHwhereGENERATION_NUMBERis the current generation number in the generational genetic algorithm,TRAINING_PATHis the file path location of the reference ReaxFF training set files,POPULATION_PATHis the location at which
the user wishes the generational genetic algorithm files to be outputted, andCONFIG_PATHis the location at which
a user-defined JSON configuration file can be entered. The last field is not required, as defaults are provided for
each algorithm and genetic algorithm setting. If the last field is specified, a valid user configuration JSON file
is assumed to exist at theCONFIG_PATHlocation.All options used in the default configuration are shown in theexamplefolderhere. The user
can tune one (or many) of these parameters by defining a config.json file at theCONFIG_PATHlocation, such as the
following:{"strategy_settings":{"mutation":"nakata"},"ga_settings":{"population_size":50,"use_neural_network":true}}Note that,at the very least, the user should define thepopulation_sizeparameter. This parameter controls the
number of individuals in the genetic algorithm's population.IfGENERATION_NUMBER= 1, then the first population is initialized, whose ReaxFF optimizations can then be submitted
for evaluation of the parameters. IfGENERATION_NUMBER> 1, the previous generation's data is read fromPOPULATION_PATH, and classic genetic operators are applied to generate the next generation and output to thePOPULATION_PATHonce again, after which the corresponding ReaxFF optimizations may be submitted.To automate the generational genetic algorithm, an example bash script is provided in theexampledirectoryhere. This allows concurrent submission of ReaxFF optimizations and continuation of the
generational genetic algorithm until a threshold, defined by a maximum generation number, is reached. In practice,
this example simply uses this Python application to propagate the genetic algorithm from one generation to the next,
then submits ReaxFF optimizations for those created individuals, monitoring their completion. After the generation
is completed (based on job completion status), the cycle repeats.In practice, this application lends itself to usage with supercomputing. The corresponding supercomputing job for
a SLURM-based environment is also availablehere. This wrapper SLURM script merely calls the bash
script, but makes it so that the user does not need to keep the bash script job running on their own computer; instead,
the bash script will be running on a node in the supercomputer.Again, note that several options are provided for potential mutation, crossover, etc., algorithms that the user may use.
Reasonable defaults based on the literature are provided, but they are easy to override by defining the customconfig.jsonfile and providing the location to the command line interface, as suggested earlier.Thus, the typical setup for usage of this application is as follows:Make sure that the application and requirements are properly installed on the machine, as well as
standalone ReaxFF.Define the user configuration file with any changes to parameters of interest,or at least the population size.Create a wrapper bash script that automates propagation of generations back-to-back based on the example bash
script provided, with proper submission details for the standalone ReaxFF jobs.If using supercomputing resources, create a wrapper job script (SLURM, PBS, etc.) that submits the wrapper bash
script, configured appropriately based on the environment.The workflow for running the optimizations is then as follows:Make sure the user configuration is set as desired and reconfigure beforehand if necessary.Set the reference/training set directory with the required model files:
ffield, geo, params, control, trainset.in, and fort.99.Set the population output directory, where you wish the generational GA files to be outputted.Set the generation number. If this is the very beginning of the run, then the generation number should equal one.
If a previous run is being continued, then this generation number should be the last successfully completed
generation's number incremented by one.Submit the supercomputer job script (SLURM, PBS, etc.).Monitor the total error/objective function as the generations go on, as well as any other statistics of interest.DependenciesThrough PyPI, the installation should already come with NumPy, Pandas, and Click.TensorFlow 2.0 is used for building,
training, and using the feed forward neural network, but is NOT automatically installed.This is because the
application can run without TensorFlow, as long as the option to "use_neural_network" is nottrue, allowing
for compatibility with systems that cannot use TF 2.0. However, those who wish to utilize the neural network can run$pip install -r requirements/prod.txtwhich will check and install all required modules as listed in therequirements/prod.txtfile, including TensorFlow.PrerequisitesProject relies on usage ofpipfor installing required dependencies. Additionally, standalone ReaxFF is required to
run the optimizations for the files that are created. Note that reference ReaxFF training files for the system at hand
are required. At the very least, the training set directory must containtraining_files
|---ffield
|---geo
|---params
|---control
|---trainset.in
|---fort.99Note thatioptfiles are dynamically created with a single line entry,0, to instruct ReaxFF not to use the "manual"
ReaxFF parameter optimization scheme: successful one parameter parabolic extrapolation (SOPPE).Currently,fort.99is required in the training set directory to retrieve DFT energies and weights in the beginning.Note that more information on the ReaxFF files and required setup for optimization can be found in the ReaxFF User
Manual from the lead developer, Dr. Duin. More information about ReaxFF itself can be found by first looking at
Dr. Duin's first paper,ReaxFF: A Reactive Force Field for Hydrocarbons, and going from there.Running the testsThe project can easily be tested by running the test suite through$toxin the project root after installation. Note that TensorFlow is used in building the neural network. If TensorFlow
is unavailable for installation, then the tests corresponding to the neural network will not run. Code coverage can be
checked by running$py.test --cov-report term-missing --cov=parametrization_cleanTo check for conformation to PEP standards, one can useflake8in the project root directory.AuthorsChad Daksha-Initial work-cdakshaLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details