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

Pyberny addition #3

Draft
wants to merge 50 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c6af382
Initial commit using cookiecutter to generate plugin template.
jlheflin Jun 13, 2024
313f15d
Added PyBernyOpt.py and __init__.py
jlheflin Jun 14, 2024
4146ec8
Removed scripting text at top of PyBernyOpt
jlheflin Jun 14, 2024
68d7614
Removed structurefinder_mm.cpp and added structurefinder_mm.py for Mo…
jlheflin Jun 14, 2024
6e0b3dd
Removed structurefinder_mm.py and moved python module structurefinder…
jlheflin Jun 18, 2024
fca3d17
Mirrored file structure of FriendZone
jlheflin Jun 20, 2024
e9d44ee
PyBernyOpt.py now returns the energy as well as the xyz string of the…
jlheflin Jun 20, 2024
c6a3b71
Changed wording on self.input in __init__.py to reflect the correct i…
jlheflin Jun 20, 2024
b3374d8
Rename PyBernyOpt.py to pybernyopt.py
ryanmrichard Jun 20, 2024
5d0f334
Delete default_toolchain.cmake
ryanmrichard Jun 20, 2024
46e5ace
Made it so that the xyz string that is made is generated by a loop ov…
jlheflin Jun 20, 2024
423ec3d
more aligned with nwx
ryanmrichard Jun 24, 2024
853fc8c
Merge pull request #4 from NWChemEx/refactor
jlheflin Jun 24, 2024
907b88a
Committing clang-format changes
github-actions[bot] Jun 24, 2024
4ba4214
Restructured to nwx style, added __init__.py files for structurefinde…
jlheflin Jun 24, 2024
1fcb570
Fixed typo
jlheflin Jun 24, 2024
5488415
Committing clang-format changes
github-actions[bot] Jun 24, 2024
8377697
Adjusted __init__.py files to reflect that of FriendZone
jlheflin Jun 25, 2024
80542aa
Fixed indentation issue
jlheflin Jun 25, 2024
0e4b3ca
address jwaldrop's comments
ryanmrichard Jun 25, 2024
1978f02
Delete src/python/structurefinder/pybernyopt.py
ryanmrichard Jun 25, 2024
e1e0524
add exception
ryanmrichard Jun 25, 2024
4a86be4
Merge branch 'pyberny_addition' of https://github.com/nwchemex/struct…
ryanmrichard Jun 25, 2024
54ba7c9
Committing clang-format changes
github-actions[bot] Jun 25, 2024
2b63ee8
Made suggested changes to test_pybernyop.py and the pyberny __init__.…
jlheflin Jun 25, 2024
2c73442
Adjusted __init__.py in pybery to make it work
jlheflin Jun 27, 2024
a20f551
Committing clang-format changes
github-actions[bot] Jun 27, 2024
4613bc4
Adjusted __init__.py to include the correct submodule 'Energy and Gra…
jlheflin Jun 27, 2024
40c921b
Resolve conflict
jlheflin Jun 27, 2024
df33484
Committing clang-format changes
github-actions[bot] Jun 27, 2024
6f68017
Change property type from TotalEnergy to EnergyNuclearGradientStdVectorD
jlheflin Jun 27, 2024
96a6432
Resolve conflict
jlheflin Jun 27, 2024
69ec4bc
Committing clang-format changes
github-actions[bot] Jun 27, 2024
49c9c72
Fix missing modules in pyberny __init__.py
jlheflin Jun 27, 2024
71e2f35
Committing clang-format changes
github-actions[bot] Jun 27, 2024
6a1c6dd
This does not fix anything, but if 'pointset1' is replaced by 'chemis…
jlheflin Jun 27, 2024
6761af5
Committing clang-format changes
github-actions[bot] Jun 27, 2024
81fcb06
Reverted changes
jlheflin Jun 27, 2024
276a0bd
Committing clang-format changes
github-actions[bot] Jun 27, 2024
bb561b6
Fixed missing TotalEnergy import
jlheflin Jun 28, 2024
9800bc3
Made suggested change from 'pointset1' to geom.molecule.nuclei
jlheflin Jun 28, 2024
d1206c1
Made suggested changes regarding removal of incorrectly specified cod…
jlheflin Jun 28, 2024
69d06f6
Added PointSetD() to gradient calculation and fixed string output
jlheflin Jun 28, 2024
ad568ea
Committing clang-format changes
github-actions[bot] Jun 28, 2024
477e58f
Added diagnostic printing and removed dependency of FriendZone
jlheflin Jul 8, 2024
591ba2d
Fixed merge conflicts
jlheflin Jul 8, 2024
8f420ab
Added parameters to allow tests to be passed for PyBerny optimization.
jlheflin Jul 8, 2024
1746d1b
Committing clang-format changes
github-actions[bot] Jul 8, 2024
fceb006
Adjusted test files
jlheflin Jul 8, 2024
84d379d
Added NWChemEx as a dependency for integration test
jlheflin Jul 9, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.14)

## Set Project and Version
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" VERSION)
project(structurefinder VERSION "${VERSION}" LANGUAGES CXX)

## Get CMaize
include(cmake/get_cmaize.cmake)

## Paths ##
set(${PROJECT_NAME}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(${PROJECT_NAME}_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(${PROJECT_NAME}_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")

ryanmrichard marked this conversation as resolved.
Show resolved Hide resolved
## Options ##
cmaize_option_list(
BUILD_TESTING OFF "Should the tests be built?"
)

## Find or build dependencies ##
cmaize_find_or_build_dependency(
simde
URL github.com/NWChemEx/SimDE
VERSION master
BUILD_TARGET simde
FIND_TARGET nwx::simde
CMAKE_ARGS BUILD_TESTING=OFF
)

## Add libraries ##
cmaize_add_library(
${PROJECT_NAME}
SOURCE_DIR "${${PROJECT_NAME}_SOURCE_DIR}/${PROJECT_NAME}"
INCLUDE_DIRS "${${PROJECT_NAME}_INCLUDE_DIR}/${PROJECT_NAME}"
DEPENDS simde
)

## Build tests ##
if("${BUILD_TESTING}")
## Find or build dependencies for tests
cmaize_find_or_build_dependency(
Catch2
URL github.com/catchorg/Catch2
BUILD_TARGET Catch2
FIND_TARGET Catch2::Catch2
VERSION v2.x
)

## Add Tests ##
cmaize_add_tests(
test_${PROJECT_NAME}
SOURCE_DIR "${${PROJECT_NAME}_TESTS_DIR}/unit_tests"
INCLUDE_DIRS "${${PROJECT_NAME}_INCLUDE_DIR}/${PROJECT_NAME}"
DEPENDS Catch2 ${PROJECT_NAME}
)

endif()

## Add package ##
cmaize_add_package(
${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}::
)
35 changes: 35 additions & 0 deletions cmake/get_cmaize.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function(get_cmaize)

if("${CMAIZE_VERSION}" STREQUAL "")
set(CMAIZE_VERSION v1.1.0 )
endif()

# Store whether we are building tests or not, then turn off the tests
if(BUILD_TESTING)
set(build_testing_old "${BUILD_TESTING}")
endif()
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)

# Download CMakePP and bring it into scope
include(FetchContent)
FetchContent_Declare(
cmaize
GIT_REPOSITORY https://github.com/CMakePP/CMaize
GIT_TAG ${CMAIZE_VERSION}
)
FetchContent_MakeAvailable(cmaize)

# Restore the previous value, if set
# Unset otherwise
if(build_testing_old)
set(BUILD_TESTING "${build_testing_old}" CACHE BOOL "" FORCE)
else()
unset(BUILD_TESTING CACHE)
endif()
endfunction()

# Call the function we just wrote to get CMaize
get_cmaize()

# Include CMaize
include(cmaize/cmaize)
8 changes: 8 additions & 0 deletions src/python/structurefinder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pluginplay as pp
from simde import TotalEnergy

def __init__(self):
pp.ModuleBase.__init__(self)
self.description("Geometry Optimizer Plugin")
self.satisfies_property_type(TotalEnergy())
self.add_input('molecule')
36 changes: 36 additions & 0 deletions src/python/structurefinder/pybernyopt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from nwchemex import chemist
from berny import Berny, geomlib, optimize
from berny.solvers import MopacSolver

# Molecule for testing
#h2 = chemist.Molecule()
#a1 = chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 0.0)
#a2 = chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 1.0)
#h2.push_back(a1)
#h2.push_back(a2)

def optimize_pyberny(molecule):
"""
This function takes a chemical system and uses PyBerny
to optimize the provided geometry (molecule) and
returns the energy of the optimized system.
"""
# Convert a Chemical System to an XYZ coordinate string
xyz = str(molecule.size()) + "\n\n" + str(molecule.nuclei)
ryanmrichard marked this conversation as resolved.
Show resolved Hide resolved

# Loads the geometry string into the Berny optimizer
# object.
optimizer = Berny(geomlib.loads(xyz, fmt='xyz'))

# Uses MOPAC/OpenMOPAC to perform geometry optimization.
# The program "mopac" must be in system PATH
solver = MopacSolver()
next(solver)
for geom in optimizer:
energy, gradients = solver.send((list(geom), geom.lattice))
optimizer.send((energy, gradients))

relaxed = geom
xyz_opt = relaxed.dumps(fmt='xyz')
# Optimized energy is of type "float"
return energy, xyz_opt
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0