From dfeb6bdcc904bf6fee4eb094158ba517ba9b3fad Mon Sep 17 00:00:00 2001 From: kumaranu Date: Thu, 16 May 2024 18:36:22 -0700 Subject: [PATCH] Auto stash before merge of "main" and "origin/main" Did a lot of restructuring. --- src/__init__.py | 0 src/calc_properties.py | 37 ------------- src/calcs.py | 11 ---- src/calcs1.py | 43 --------------- src/check_graph_iso.py | 2 +- src/check_neb_results.py | 3 +- src/initialize_path.py | 1 - src/mep_tests/tools/__init__.py | 0 src/{ => mep_tests/tools}/analyze_all_data.py | 0 .../tools/check_neb_convergence.py} | 2 +- .../tools/download_data_neb.py} | 0 src/{ => mep_tests/tools}/plot.py | 0 src/{ => mep_tests/tools}/plot1.py | 0 src/{ => mep_tests/tools}/plot2.py | 51 ++++++++++-------- src/setup_images.py | 2 - src/test1.py | 4 +- {src => tests}/MACE_model.model | Bin {src => tests}/MACE_model_cpu.model | Bin 18 files changed, 34 insertions(+), 122 deletions(-) create mode 100644 src/__init__.py delete mode 100644 src/calc_properties.py delete mode 100644 src/calcs1.py create mode 100644 src/mep_tests/tools/__init__.py rename src/{ => mep_tests/tools}/analyze_all_data.py (100%) rename src/{check.py => mep_tests/tools/check_neb_convergence.py} (94%) rename src/{bb.py => mep_tests/tools/download_data_neb.py} (100%) rename src/{ => mep_tests/tools}/plot.py (100%) rename src/{ => mep_tests/tools}/plot1.py (100%) rename src/{ => mep_tests/tools}/plot2.py (73%) rename {src => tests}/MACE_model.model (100%) rename {src => tests}/MACE_model_cpu.model (100%) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/calc_properties.py b/src/calc_properties.py deleted file mode 100644 index 109909b..0000000 --- a/src/calc_properties.py +++ /dev/null @@ -1,37 +0,0 @@ -from ase.io import read, write -from calcs import calc - -# Read molecular configurations from XYZ file -atoms_list = read('/global/scratch/users/kumaranu/saved_files/neb_nn_inputs/263/output.xyz', index=':') - -# Create a calculator instance (e.g., EMT) -mlcalculator = calc() - -# Iterate over each molecular configuration -for atoms in atoms_list: - mlcalculator.calculate(atoms) - - # Calculate energies and forces - energy = mlcalculator.results['energy'] - forces = mlcalculator.results['forces'] - - # Store energies and forces in the atoms object - atoms.info['energy'] = energy - atoms.arrays['forces'] = forces - -# Write the updated atoms object with energies and forces to a new XYZ file -write('/global/scratch/users/kumaranu/saved_files/neb_nn_inputs/263/output1.xyz', atoms_list) - - -''' -h2 = Atoms(numbers=[1, 1], positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) -mlcalculator.calculate(h2) - -print(mlcalculator.results['energy']) # mean of calculated molecular energies, shape (1,) -print(mlcalculator.results['forces']) # mean of calculated atomic forces, shape (n_atom, 3) -print(mlcalculator.results['hessian']) # mean of calculated atomic Hessian, shape (n_atom, 3, n_atom, 3) -print(mlcalculator.results['energy_disagreement']) # disagreement among calculated molecular -''' - - - diff --git a/src/calcs.py b/src/calcs.py index 86fd58b..b367cff 100644 --- a/src/calcs.py +++ b/src/calcs.py @@ -45,14 +45,3 @@ def calc(): device=device ) return mlcalculator - -''' -h2 = Atoms(numbers=[1, 1], positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) -mlcalculator.calculate(h2) - -print(mlcalculator.results['energy']) # mean of calculated molecular energies, shape (1,) -print(mlcalculator.results['forces']) # mean of calculated atomic forces, shape (n_atom, 3) -print(mlcalculator.results['hessian']) # mean of calculated atomic Hessian, shape (n_atom, 3, n_atom, 3) -print(mlcalculator.results['energy_disagreement']) # disagreement among calculated molecular -''' - diff --git a/src/calcs1.py b/src/calcs1.py deleted file mode 100644 index 03518b0..0000000 --- a/src/calcs1.py +++ /dev/null @@ -1,43 +0,0 @@ -from mace.calculators import MACECalculator -from newtonnet.utils.ase_interface import MLAseCalculator -from ase import Atoms - - -def calc_mace(): - - mlcalculator = MACECalculator( - model_paths='/global/home/users/kumaranu/Documents/gpu_jobs/MACE_model.model', - #model_paths='/global/home/users/kumaranu/Documents/mep_tests/src/MACE_model_cpu.model', - device='cuda', - #device='cpu', - default_dtype="float64", - ) - return mlcalculator - - -def calc(): - mlcalculator = MLAseCalculator( - model_path=[ - '/global/home/users/kumaranu/Documents/NewtonNet/example/predict/training_52/models/best_model_state.tar', - ], # path to model file, str or list of str - settings_path=[ - '/global/home/users/kumaranu/Documents/NewtonNet/example/predict/training_52/run_scripts/config0.yml', - ], # path to configuration file, str or list of str - hess_method=None, # method to calculate hessians. 'autograd', 'fwd_diff', 'cnt_diff', or None (default: 'autograd') - # hess_precision=1e-5, # hessian gradient calculation precision for 'fwd_diff' and 'cnt_diff', ignored otherwise (default: None) - disagreement='std', # method to calculate disagreement among models. 'std', 'std_outlierremoval', 'range':, 'values', or None (default: 'std') - #device='cuda' # 'cpu' or list of cuda - device='cpu' # 'cpu' or list of cuda - ) - return mlcalculator - -''' -h2 = Atoms(numbers=[1, 1], positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) -mlcalculator.calculate(h2) - -print(mlcalculator.results['energy']) # mean of calculated molecular energies, shape (1,) -print(mlcalculator.results['forces']) # mean of calculated atomic forces, shape (n_atom, 3) -print(mlcalculator.results['hessian']) # mean of calculated atomic Hessian, shape (n_atom, 3, n_atom, 3) -print(mlcalculator.results['energy_disagreement']) # disagreement among calculated molecular -''' - diff --git a/src/check_graph_iso.py b/src/check_graph_iso.py index c82d44d..a3dbc97 100644 --- a/src/check_graph_iso.py +++ b/src/check_graph_iso.py @@ -5,7 +5,7 @@ from pymatgen.analysis.graphs import MoleculeGraph from pymatgen.analysis.local_env import OpenBabelNN from networkx.algorithms.graph_hashing import weisfeiler_lehman_graph_hash -from plot2 import gen_energy_profile +from src.mep_tests.tools.plot2 import gen_energy_profile def add_specie_suffix(graph): diff --git a/src/check_neb_results.py b/src/check_neb_results.py index b741b98..1300e71 100644 --- a/src/check_neb_results.py +++ b/src/check_neb_results.py @@ -1,6 +1,6 @@ import glob, os, sys from ase.io import read -from calcs1 import calc +from calcs import calc import numpy as np from ase import Atoms from multiprocessing import Pool @@ -79,4 +79,3 @@ def process_file(i): for result in results: if result is not None: print(result) - diff --git a/src/initialize_path.py b/src/initialize_path.py index 4926215..0706f22 100644 --- a/src/initialize_path.py +++ b/src/initialize_path.py @@ -126,4 +126,3 @@ def setup_analysis( print(f'Forward_barrier: {ts_e - r_e}') print(f'Reverse_barrier: {ts_e - p_e}') - diff --git a/src/mep_tests/tools/__init__.py b/src/mep_tests/tools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/analyze_all_data.py b/src/mep_tests/tools/analyze_all_data.py similarity index 100% rename from src/analyze_all_data.py rename to src/mep_tests/tools/analyze_all_data.py diff --git a/src/check.py b/src/mep_tests/tools/check_neb_convergence.py similarity index 94% rename from src/check.py rename to src/mep_tests/tools/check_neb_convergence.py index d08b0c0..3ef518c 100644 --- a/src/check.py +++ b/src/mep_tests/tools/check_neb_convergence.py @@ -12,7 +12,7 @@ print(f'{i:03}: {INF[-1].split()[1]}') else: print(f'{i:03}: No NEB file.') - os.chdir('../') + os.chdir('../../../') else: print(f'{i:03} does not exist.') diff --git a/src/bb.py b/src/mep_tests/tools/download_data_neb.py similarity index 100% rename from src/bb.py rename to src/mep_tests/tools/download_data_neb.py diff --git a/src/plot.py b/src/mep_tests/tools/plot.py similarity index 100% rename from src/plot.py rename to src/mep_tests/tools/plot.py diff --git a/src/plot1.py b/src/mep_tests/tools/plot1.py similarity index 100% rename from src/plot1.py rename to src/mep_tests/tools/plot1.py diff --git a/src/plot2.py b/src/mep_tests/tools/plot2.py similarity index 73% rename from src/plot2.py rename to src/mep_tests/tools/plot2.py index 6fe4e79..bcf8541 100644 --- a/src/plot2.py +++ b/src/mep_tests/tools/plot2.py @@ -80,26 +80,33 @@ def gen_energy_profile( # if len(sys.argv) != 3: # print("Usage: python script.py ") # sys.exit(1) - ref_dir = '/home/kumaranu/Downloads/neb_nn_inputs' - index = '001' - geodesic_xyz = os.path.join( - ref_dir, - index, - 'geodesic_path.xyz', - ) - neb_path_xyz = os.path.join( - ref_dir, - index, - 'optimized_path_aseneb_NEBOptimizer_None.xyz' - ) - ts_xyz = os.path.join( - ref_dir, - index, - 'TS.xyz', - ) + #ref_dir = '/home/kumaranu/Downloads/neb_nn_inputs' + #index = '001' + ref_dir = '/home/kumaranu/Downloads/neb_rgd1_inputs' + for i in range(999): + index = f'{i:03}' + # index = '679' + try: + geodesic_xyz = os.path.join( + ref_dir, + index, + 'geodesic_path.xyz', + ) + neb_path_xyz = os.path.join( + ref_dir, + index, + 'optimized_path_aseneb_NEBOptimizer_None.xyz' + ) + ts_xyz = os.path.join( + ref_dir, + index, + 'TS.xyz', + ) - barrier_err = gen_energy_profile( - geodesic_xyz, - neb_path_xyz, - ts_xyz, - ) + barrier_err = gen_energy_profile( + geodesic_xyz, + neb_path_xyz, + ts_xyz, + ) + except: + continue diff --git a/src/setup_images.py b/src/setup_images.py index 58b97ed..64a5cd9 100644 --- a/src/setup_images.py +++ b/src/setup_images.py @@ -1,5 +1,4 @@ import os -import copy from calcs import calc from ase.io import read, write from typing import Any, Dict, Iterator, List, Sequence, Tuple, TypeVar, Union @@ -40,4 +39,3 @@ def setup_images( write('geodesic_path.xyz', images) return images - diff --git a/src/test1.py b/src/test1.py index f5a1f5b..076a724 100644 --- a/src/test1.py +++ b/src/test1.py @@ -24,12 +24,12 @@ def main(config_file: str) -> None: run_neb_method( method=input_set['method'], optimizer=ase_optimizer, + opt_method=None, precon=None, - optmethod=None, logdir=inputs['input_paths']['logdir'], xyz_r_p=inputs['input_paths']['xyz_r_p'], xyz_ts=inputs['input_paths']['xyz_ts'], - N_intermediate=inputs['geodesic_inputs']['N_intermediate'], + n_intermediate=inputs['geodesic_inputs']['N_intermediate'], ) diff --git a/src/MACE_model.model b/tests/MACE_model.model similarity index 100% rename from src/MACE_model.model rename to tests/MACE_model.model diff --git a/src/MACE_model_cpu.model b/tests/MACE_model_cpu.model similarity index 100% rename from src/MACE_model_cpu.model rename to tests/MACE_model_cpu.model