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

[Version 2.0] Add pip install functionality and optimize code #19

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
dev/*
dev/*
__pycache__/
3 changes: 3 additions & 0 deletions atst_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from atst_tools.abacus_autoneb import AbacusAutoNEB
from atst_tools.abacus_neb import AbacusNEB
from atst_tools.abacus_dimer import AbacusDimer
2 changes: 1 addition & 1 deletion source/abacus_autoneb.py → atst_tools/abacus_autoneb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ase.io import read, write
from ase.calculators.abacus import Abacus, AbacusProfile
#from ase.mep.autoneb import AutoNEB # official
from my_autoneb import AutoNEB
from atst_tools.my_autoneb import AutoNEB
from ase.parallel import world, parprint, paropen
from ase.optimize import FIRE, BFGS
from ase.constraints import FixAtoms
Expand Down
6 changes: 4 additions & 2 deletions source/abacus_dimer.py → atst_tools/abacus_dimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
# Dimer calculation workflow by using ABACUS calculator
# part of ATST-Tools scripts

import os
import sys

import numpy as np
from ase.io import Trajectory, read, write
from ase.mep import DimerControl, MinModeAtoms, MinModeTranslate
#from my_dimer import DimerControl, MinModeAtoms, MinModeTranslate
from ase.calculators.abacus import Abacus, AbacusProfile
import os, sys
import numpy as np

class AbacusDimer:
"""Customize Dimer calculation workflow by using ABACUS"""
Expand Down
8 changes: 6 additions & 2 deletions source/abacus_neb.py → atst_tools/abacus_neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# NEB calculation workflow by ASE-ABACUS
# part of ATST-Tools scripts

from typing import Optional
import os
from ase.calculators.abacus import Abacus, AbacusProfile
from ase.optimize import FIRE, BFGS
Expand Down Expand Up @@ -114,7 +115,7 @@ def set_neb_chain(self, climb=True, fmax=0.05):
return neb


def run(self, optimizer=FIRE, fmax=0.05, climb=True, outfile="neb.traj", properties=["energy", "forces", "stress"]):
def run(self, optimizer=FIRE, fmax=0.05, climb=True, outfile="neb.traj", properties=["energy", "forces", "stress"], max_steps: Optional[int] = None):
"""Run Abacus NEB

optimizer (Optimizer object): defaults to FIRE. BFGS, LBFGS, GPMin, MDMin and QuasiNewton are supported, recommend FIRE method
Expand All @@ -126,5 +127,8 @@ def run(self, optimizer=FIRE, fmax=0.05, climb=True, outfile="neb.traj", propert
# traj = Trajectory(outfile, 'w', neb, properties=properties) # cannot run for now
traj = Trajectory(outfile, 'w', neb)
opt = optimizer(neb, trajectory=traj)
opt.run(fmax)
if max_steps is not None and max_steps > 0:
opt.run(fmax=fmax, steps=max_steps)
else:
opt.run(fmax)
print("----- NEB calculation finished -----")
7 changes: 4 additions & 3 deletions source/my_autoneb.py → atst_tools/my_autoneb.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Refined AutoNEB workflow by QuantumMisaka in 20231128
# Parts of ATST-Tools

import numpy as np

import shutil
import os
import types
from math import log
from math import exp
from math import log, exp
from contextlib import ExitStack
from pathlib import Path
from warnings import warn

import numpy as np

from ase.io import Trajectory
from ase.io import read
from ase.mep import NEB
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/my_neb.py → atst_tools/my_neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def plot_bands(self, constant_x=False, constant_y=False,
with PdfPages(label + '.pdf') as pdf:
for index in range(nebsteps):
sys.stdout.write('\rProcessing band {:10d} / {:10d}'
.format(index, nebsteps))
.format(index + 1, nebsteps))
sys.stdout.flush()
fig, ax = pyplot.subplots()
images = self.images[index * nimages:(index + 1) * nimages]
Expand Down
4 changes: 3 additions & 1 deletion source/neb2vib.py → atst_tools/neb2vib.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# using neb chain to get the main vibrate atoms
# JamesMisaka in 2024-02-11

import sys

from ase.io import read
from ase.mep.neb import NEBTools
import numpy as np
import sys


norm = np.linalg.norm

Expand Down
4 changes: 2 additions & 2 deletions neb/neb_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def get_TS_stru(self, name="TS_get"):
"""Get TS structure from NEB chain"""
raw_barrier = NEBTools(self.neb_chain).get_barrier(fit=False, raw=True)
for atoms in self.neb_chain:
if atoms.get_potential_energy() == raw_barrier:
if atoms.get_potential_energy() == raw_barrier[0]:
write(f"{name}.cif", atoms, format="cif")
write(f"{name}.stru", atoms, format="stru")
write(f"{name}.stru", atoms, format="abacus")
print(f"TS structure is saved as {name}.cif and {name}.stru")
return

Expand Down
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from setuptools import setup, find_packages

setup(
name="atst-tools",
version="0.1",
packages=find_packages(),
install_requires=[],
python_requires=">=3.9",
)