-
Notifications
You must be signed in to change notification settings - Fork 0
Fcuantico patch 1 #7
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
Draft
fcuantico
wants to merge
27
commits into
master
Choose a base branch
from
fcuantico-patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
dfc9647
FIRE and NSTOVSUT optimization methods added
fcuantico 50a4e1a
FIRE optimizers added
fcuantico b09befa
First changes to be2_FIRE.py
fcuantico 26d9a5d
First changes to be2_FIRE.py
fcuantico 5a24d17
getting coordinates of molecule line 37
fcuantico 125c87f
adding fire folder and testing backward_euler.py
fcuantico 46c5e06
last changes not final June 1st
fcuantico f66687e
gitignore and change to backward_euler.py
fcuantico c949302
updates to backward_euler.py and test_backward_eluer.py
fcuantico b63221c
update of backward_euler.py
fcuantico 7d590c4
getting ready for master merge
fcuantico 82565f1
made changes to make sure that pyberny setup works now
jlheflin ca17edc
ignored editor files
jlheflin c444367
removed editor files
jlheflin 20719c0
remove Testing folder and cleaned pyberny test file
fcuantico ae22916
changed pyberny test
fcuantico 374fc9a
Committing clang-format changes
github-actions[bot] 78ca585
Track VSCode settings to prevent automatic rebuilds
fcuantico 8ced491
backward euler and fire completed
fcuantico c0a830c
Merge branch 'fcuantico-patch-1' of github.com:NWChemEx/StructureFind…
fcuantico bba231d
Committing clang-format changes
github-actions[bot] 6479618
Committing clang-format changes
github-actions[bot] 83304ff
SAVED BY JACOB backward_euler.py
fcuantico dd43daf
Committing clang-format changes
github-actions[bot] 8ea88dc
prints tst.xyz
fcuantico 9ebefd0
clean gitignore
fcuantico b7805c8
file removal
fcuantico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,5 +14,9 @@ | |
|
|
||
| __pycache__/ | ||
| build/ | ||
| venv/ | ||
| .venv/ | ||
| install/ | ||
| toolchain.cmake | ||
| .vscode/ | ||
| StructureFinder.code-workspace | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2025 NWChemEx Community | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
89 changes: 89 additions & 0 deletions
89
src/python/structurefinder/fire/backward_euler/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Copyright 2023 NWChemEx-Project | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import pluginplay as pp | ||
| from simde import EnergyNuclearGradientStdVectorD, TotalEnergy, MoleculeFromString | ||
| from berny import Berny, geomlib | ||
| import chemist | ||
| import numpy as np | ||
| import tensorwrapper as tw | ||
|
|
||
|
|
||
| class GeomoptViaPyberny(pp.ModuleBase): | ||
|
|
||
| def __init__(self): | ||
| pp.ModuleBase.__init__(self) | ||
| self.satisfies_property_type(TotalEnergy()) | ||
| self.description("Performs PyBerny optimization") | ||
| self.add_submodule(TotalEnergy(), "Energy") | ||
| self.add_submodule(EnergyNuclearGradientStdVectorD(), "Gradient") | ||
| self.add_submodule(MoleculeFromString(), "StringConv") | ||
|
|
||
| def run_(self, inputs, submods): | ||
| pt = TotalEnergy() | ||
| mol, = pt.unwrap_inputs(inputs) | ||
| molecule = mol.molecule | ||
|
|
||
| # Convert Chemist Chemical System to XYZ | ||
| xyz = "" | ||
| xyz += (str(molecule.size()) + "\n\n") | ||
| for i in range(molecule.size()): | ||
| xyz += (molecule.at(i).name + " " + str(molecule.at(i).x) + " " + | ||
| str(molecule.at(i).y) + " " + str(molecule.at(i).z) + "\n") | ||
|
|
||
| # Loads the geometry string into the Berny optimizer | ||
| # object. | ||
| optimizer = Berny(geomlib.loads(xyz, fmt='xyz')) | ||
|
|
||
| for geom in optimizer: | ||
|
|
||
| # Converts the "Berny" geometry object to Chemical System | ||
| geom2xyz = geom.dumps('xyz') | ||
| print('Berny Geom to XYZ value: \n' + geom2xyz + '\n') | ||
| lines = geom2xyz.split('\n') | ||
| print('Lines of geom2xyz: \n' + str(lines) + '\n') | ||
| mol_string = '\n'.join(lines[2:]) | ||
| print('Lines to string: \n' + mol_string + '\n') | ||
| xyz2chem_mol = submods["StringConv"].run_as( | ||
| MoleculeFromString(), mol_string) | ||
| print('String conversion from xyz to chem sys: \n' + | ||
| str(xyz2chem_mol.nuclei) + '\n') | ||
| geom = chemist.ChemicalSystem(xyz2chem_mol) | ||
| print('Chemical system of xyz2chem_mol: \n' + | ||
| str(geom.molecule.nuclei) + '\n') | ||
| geom_nuclei = geom.molecule.nuclei.as_nuclei() | ||
| geom_points = geom_nuclei.charges.point_set | ||
|
|
||
| # Main optimizer operation | ||
| energy = submods["Energy"].run_as(TotalEnergy(), geom) | ||
| print('Interim energy: \n' + str(energy) + '\n') | ||
| gradients = submods["Gradient"].run_as( | ||
| EnergyNuclearGradientStdVectorD(), geom, | ||
| geom_points.as_point_set()) | ||
| print('Interim gradient: \n' + str(gradients) + '\n') | ||
| optimizer.send((energy, gradients)) | ||
|
|
||
| opt_geom = geom.molecule.nuclei | ||
| print( | ||
| 'Resulting relaxed geometry (assigned to variable opt_geom): \n' + | ||
| str(opt_geom)) | ||
| # Optimized energy is of type "float" | ||
| e = tw.Tensor(energy) | ||
| print(e) | ||
| rv = self.results() | ||
| return pt.wrap_results(rv, e) | ||
|
|
||
|
|
||
| def load_pyberny_modules(mm): | ||
| mm.add_module("PyBerny", GeomoptViaPyberny()) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents in this file are just copy/paste from elsewhere. Everything but the license header can be deleted.