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

Pyberny addition #3

wants to merge 50 commits into from

Conversation

jlheflin
Copy link

Is this pull request associated with an issue(s)?
No.

Description
Adds a beginning branch for adding PyBerny as an option for optimizing a chemical system geometry.

TODOs
Implement ModuleManager so that modules can be loaded

@CLAassistant
Copy link

CLAassistant commented Jun 14, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@ryanmrichard ryanmrichard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried building this? Based on what's here, I suspect the build will fail.

Take a look at https://github.com/NWChemEx/FriendZone. In particular, try to mirror its file structure (notably the C++/Python split).

You also need a test for your function see here for an example of how to add one to the build system.

src/structurefinder/PyBernyOpt.py Outdated Show resolved Hide resolved
src/structurefinder/PyBernyOpt.py Outdated Show resolved Hide resolved
jlheflin and others added 6 commits June 18, 2024 09:24
make lowercase to avoid problems on case-insensitive filesystems.
I'd add your toolchain to the .gitignore. We've talked about at some point having a repo with some starter toolchains, but for now we're not checking them in to any repos.
Copy link
Member

@jwaldrop107 jwaldrop107 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments regarding documentation and workflows.

.github/workflows/pull_request.yaml Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
.github/workflows/merge.yaml Show resolved Hide resolved
Copy link
Member

@ryanmrichard ryanmrichard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you haven't figured this out yet, the EnergyNuclearGradientStdVectorD property type actually returns both the energy and the gradient. Also the module needs not only the chemical system, but the point at which to take the derivative.

src/python/structurefinder/pyberny/__init__.py Outdated Show resolved Hide resolved
src/python/structurefinder/pyberny/__init__.py Outdated Show resolved Hide resolved

energy = submods["Energy"].run_as(TotalEnergy(), geom)
gradients = submods["Gradient"].run_as(
EnergyNuclearGradientStdVectorD(), geom, pointset1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EnergyNuclearGradientStdVectorD(), geom, pointset1)
EnergyNuclearGradientStdVectorD(), geom, geom.molecule.nuclei)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried this, unfortunately it does not work. Here is the resulting output:

ValueError: Input value: "Pybind11 Object" has failed bounds checks: Type == chemist::PointSet<double>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That error is because Nuclei does not derive from PointSet<double> like I originally thought. It's the point charges in Nuclei that that derive from PointSet<double>, i.e. you actually need geom.molecule.nuclei.charges. See if that fixes the error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get back an error that states geom.molecule.nuclei has no attribute charges.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NWChemEx/Chemist#417 should fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aforementioned PR has been merged, try again.

@ryanmrichard
Copy link
Member

@jlheflin your current error is because you're depending on friendzone for your module. Modules shouldn't directly depend on other modules/functionality found in other plugins. Instead they should depend on property types. For now, what I would do is write a function which loops over the XYZ you get back from PyBerny and directly fill that in to a ChemicalSystem object.

@ryanmrichard
Copy link
Member

@jwaldrop107 and I discussed some options for making a more reusable solution, but let's tackle that later.

CMakeLists.txt Outdated
Comment on lines 67 to 71
nwx_pybind11_tests(
py_${PROJECT_NAME}
"${${PROJECT_NAME}_PYTHON_TEST_DIR}/unit_tests/test_${PROJECT_NAME}.py"
SUBMODULES simde chemist pluginplay parallelzone
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nwx_pybind11_tests(
py_${PROJECT_NAME}
"${${PROJECT_NAME}_PYTHON_TEST_DIR}/unit_tests/test_${PROJECT_NAME}.py"
SUBMODULES simde chemist pluginplay parallelzone
)
cmaize_find_or_build_dependency(
nwchemex
URL github.com/NWChemEx/NWChemEx
BUILD_TARGET nwchemex
FIND_TARGET nwx::nwchemex
CMAKE_ARGS BUILD_TESTING=OFF
)
nwx_pybind11_tests(
py_${PROJECT_NAME}
"${${PROJECT_NAME}_PYTHON_TEST_DIR}/unit_tests/test_${PROJECT_NAME}.py"
DEPENDS nwchemex
SUBMODULES simde chemist pluginplay parallelzone friendzone chemcache nwchemex
)

Try this for your CI error. Your unit test depends on NWChemEx (which also means it's technically an integration test) so you need to install NWChemEx and link to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants