-
Notifications
You must be signed in to change notification settings - Fork 32
SimpleTask feature #218
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
Open
nakul680
wants to merge
52
commits into
faccts:feature/simple-tasks
Choose a base branch
from
nakul680:simple_keyword_lookup
base: feature/simple-tasks
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.
Open
SimpleTask feature #218
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
125f439
add from_string method for simple keywords
nakul680 665e5d3
registry
nakul680 aa9d68f
task params class, simple keyword lookup
nakul680 1796784
minimal implementation of Simple Tasks
nakul680 9fa47b5
flesh out structure of base Task classes
nakul680 dac75a2
added field validator for assignment and overloaded getters and sette…
nakul680 038e98c
added restart function, optimized duplicate code
nakul680 e1cb6ab
added docstrings , renamed TaskParams to Settings, added TaskSettings…
nakul680 0adf343
changes from todays meeting
nakul680 c009bfc
flesh out the different tasks
nakul680 5a8a881
example for simple task
nakul680 525af5f
api changes
nakul680 ebf38ea
fixed nox errors
nakul680 196c3c1
correct run() method for OptTask
nakul680 569b2b6
alternate API for initializing method settings
nakul680 6a4cbd5
added possibility to switch methods between families, dicct now allow…
nakul680 022dac6
add goat task, flesh out sqmsettings and add dlpnoccsettings
nakul680 8887d46
added documentation
nakul680 5cb47e1
add unit tests
nakul680 d741c80
added examples for simple tasks
nakul680 6e75dac
add from_string() method
nakul680 812d290
add unit tests for SimpleTask.from_string()
nakul680 eabdb09
fix:allow users to freely edit SimpleTask.input_object
nakul680 810ff7c
fix: add final_energy property to case TaskResults class
nakul680 234e99b
fix: renamed simple tasks folder
nakul680 6852399
fix: reorder simple tasks examples on complexity
nakul680 858d094
fix: separate tasks into their own folders
nakul680 fb9f758
fix: edit __init__ file of simple tasks subfolders to allow for easy …
nakul680 87b40aa
docs: add documentation to SimpleKeyword
nakul680 a40f634
fix: fix code formatting and extra imports
nakul680 e8c2c1f
fix: move all implemented simple tasks to task folder
nakul680 f0c1d7f
fix:changed __add__() to __or__() for merging of Block objects.
nakul680 ef37088
fix: remove registries from SimpleKeywordBox classes.
nakul680 d0d96d9
fix: remove dead attribute `name` from `SimpleKeyword` and store alia…
nakul680 4971a00
docs: add documentation for get_subclass_by_name() in `Block`
nakul680 3abe614
fix:add example for user modification of input_object in SimpleTask o…
nakul680 63a8ab7
fix:add input_object init to SimpleTask init
nakul680 7723a91
fix: give preference to user input settings over data that exists in …
nakul680 c21e797
fix:refactor variables in `Block.get_subclasses_by_name()`
nakul680 66cf5af
fix: refactor variables and correct docstrings in `SimpleKeywordBox` …
nakul680 1b84e1d
fix: add documentation to improve code clarity
nakul680 1736aa7
fix: change type annotation in DlpnoCcSettings
nakul680 b833ff0
fix: edit examples to take into account new examples
nakul680 abac0c2
fix: add __init__() of OptTask that was mistakenly removed
nakul680 fe4d015
fix:add input_object init to SimpleTask init
nakul680 71ce3d4
fix:remove overridden constructors in SimpleTasks and allow init of S…
nakul680 92a1c81
fix: remove unused imports
nakul680 6bbbca1
fix: change leftoover cached properties into properties and update co…
nakul680 c66d29c
fix: add documentation to functions in `SimpleTask` class
nakul680 8e568b9
fix: add documentation for task settings type getter
nakul680 fc201cb
fix: rename `input_object` to `input` and `calc_object` to `calculator`
nakul680 a8a52fe
fix: change working_dir type annotations to include strings
nakul680 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
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,5 @@ | ||
| 3 | ||
|
|
||
| O -3.56626 1.77639 0.00000 | ||
| H -2.59626 1.77639 0.00000 | ||
| H -3.88959 1.36040 -0.81444 |
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,43 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from opi.input.simple_keywords import AtomicCharge | ||
| from opi.input.structures import Structure | ||
| from opi.simple_tasks import SinglePointResults, SinglePointTask | ||
|
|
||
|
|
||
| def run_exmp057( | ||
| structure: Structure | None = None, working_dir: Path = Path("RUN") | ||
| ) -> SinglePointResults: | ||
| # > if no structure is given read structure from inp.xyz | ||
| if structure is None: | ||
| structure = Structure.from_xyz("inp.xyz") | ||
|
|
||
| # > set up the task | ||
| simple_task = SinglePointTask( | ||
| method="b3lyp", basis_set="def2-svp", solvation_model="cpcm", solvent="water" | ||
| ) | ||
| # > there are task and method-specific settings, these can be set through kwargs | ||
|
|
||
| # > It is possible to modify the input object associated with the task object for more specific settings | ||
| simple_task.input.add_simple_keywords(AtomicCharge.HIRSHFELD) | ||
|
|
||
| # > run the calculation with given data | ||
| singlepoint_result = simple_task.run("job", structure, working_dir=working_dir) | ||
|
|
||
| # > check if the ORCA calculation terminated normally | ||
| if not singlepoint_result.status: | ||
| print("SinglePoint task failed") | ||
| sys.exit(1) | ||
|
|
||
| # > extract primary property from the `TaskResults` object. For a single point calculation, it is the final energy. | ||
| final_energy = singlepoint_result.final_energy | ||
|
|
||
| print(f"Final single point energy: {final_energy: 10f} Eh") | ||
|
|
||
| return singlepoint_result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_exmp057() | ||
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,5 @@ | ||
| 3 | ||
|
|
||
| O -3.56626 1.77639 0.00000 | ||
| H -2.59626 1.77639 0.00000 | ||
| H -3.88959 1.36040 -0.81444 |
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,32 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from opi.input.structures import Structure | ||
| from opi.simple_tasks import EngradResults, EngradTask | ||
|
|
||
|
|
||
| def run_exmp058( | ||
| structure: Structure | None = None, working_dir: Path = Path("RUN") | ||
| ) -> EngradResults: | ||
| # > if no structure is given read structure from inp.xyz | ||
| if structure is None: | ||
| structure = Structure.from_xyz("inp.xyz") | ||
|
|
||
| engrad_task = EngradTask(method="r2scan-3c") | ||
| engrad_result = engrad_task.run("job", structure, working_dir=working_dir) | ||
|
|
||
| if not engrad_result.status: | ||
| print(f"Engrad task failed, see output file: {engrad_result.output.get_outfile()}") | ||
| sys.exit(1) | ||
|
|
||
| print("FINAL SINGLE POINT ENERGY") | ||
| print(engrad_result.final_energy) | ||
| print("SCF ENERGY") | ||
| print(engrad_result.output.get_energies()["SCF"]) | ||
|
|
||
| return engrad_result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_exmp058() |
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,10 @@ | ||
| 8 | ||
| Coordinates from ORCA-job job E -79.174339553991 | ||
| C -0.07696488620844 0.00264225043565 0.01503449747601 | ||
| C 1.42297403167085 0.00026730705255 0.00170779972564 | ||
| H -0.52956432516482 0.16759451146808 0.99517342002418 | ||
| H -0.47206799721260 0.78060586812661 -0.64348212080303 | ||
| H -0.47202276565405 -0.94827280862626 -0.35199393102178 | ||
| H 1.83370076026311 0.95190889480824 0.34680814012902 | ||
| H 1.83362978930886 -0.78232192510389 0.64382744884855 | ||
| H 1.80356539299709 -0.17242409816099 -1.00707525437860 |
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,44 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from opi.input.structures import Structure | ||
| from opi.simple_tasks import OptResults, OptSettings, OptTask | ||
| from opi.simple_tasks.method_settings import DftSettings | ||
|
|
||
|
|
||
| def run_exmp059(structure: Structure | None = None, working_dir: Path = Path("RUN")) -> OptResults: | ||
| # > if no structure is given read structure from inp.xyz | ||
| if structure is None: | ||
| structure = Structure.from_xyz("../exmp057_singlepoint_simpletask/inp.xyz") | ||
|
|
||
| # > set up the task | ||
| simple_task = OptTask( | ||
|
haneug marked this conversation as resolved.
|
||
| method="b3lyp", | ||
| basis_set="def2-svp", | ||
| solvation_model="cpcm", | ||
| solvent="water", | ||
| method_settings=DftSettings(scf_maxiter=150), | ||
| task_settings=OptSettings(opt_threshold="tight"), | ||
| ) | ||
| # > there are task and method-specific settings, these can be set through kwargs | ||
|
|
||
| # > run the calculation with given data | ||
| opt_result = simple_task.run("job", structure, working_dir=working_dir) | ||
|
|
||
| # > check if the ORCA calculation terminated normally | ||
| if not opt_result.status: | ||
| print("Opt task failed") | ||
| sys.exit(1) | ||
|
|
||
| # > extract optimized structure from the `OptResults` object | ||
| structure = opt_result.structure | ||
|
|
||
| print("Optimized Structure:") | ||
| print(structure.format_orca()) | ||
|
|
||
| return opt_result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_exmp059() | ||
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,5 @@ | ||
| 3 | ||
|
|
||
| O -3.56626 1.77639 0.00000 | ||
| H -2.59626 1.77639 0.00000 | ||
| H -3.88959 1.36040 -0.81444 |
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,51 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from opi.input.structures import Structure | ||
| from opi.output.ir_mode import IrMode | ||
| from opi.simple_tasks import FreqResults, FreqTask | ||
|
|
||
|
|
||
| def run_exmp060(structure: Structure | None = None, working_dir: Path = Path("RUN")) -> FreqResults: | ||
| # > if no structure is given read structure from inp.xyz | ||
| if structure is None: | ||
| structure = Structure.from_xyz("inp.xyz") | ||
|
|
||
| freq_task = FreqTask(method="tpss", basis_set="def2-svp") | ||
| freq_result = freq_task.run("job", structure, working_dir=working_dir) | ||
|
|
||
| if not freq_result.status: | ||
| print(f"Freq task failed, see output file: {freq_result.output.get_outfile()}") | ||
| sys.exit(1) | ||
|
|
||
| output = freq_result.output | ||
|
|
||
| ir_dict = output.get_ir() | ||
| print(IrMode.header()) | ||
| for ir_mode in ir_dict.values(): | ||
| print(ir_mode) | ||
|
|
||
| ngeoms = len(output.results_properties.geometries) | ||
| print("N GEOMETRIES") | ||
| print(ngeoms) | ||
| print("FINAL SINGLE POINT ENERGY") | ||
| print(output.get_final_energy()) | ||
| print("Temperature [K]") | ||
| print(output.results_properties.geometries[0].thermochemistry_energies[0].temperature) | ||
| print("Final Gibbs free energy") | ||
| print(output.get_free_energy()) | ||
| print("Zero-point energy") | ||
| print(output.get_zpe()) | ||
| print("Final enthalpy H") | ||
| print(output.get_enthalpy()) | ||
| print("Final entropy S") | ||
| print(output.get_entropy()) | ||
| print("G-E(el)") | ||
| print(freq_result.free_energy_delta) | ||
|
|
||
| return freq_result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_exmp060() |
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,10 @@ | ||
| 8 | ||
| Coordinates from ORCA-job job E -79.174339553991 | ||
| C -0.07696488620844 0.00264225043565 0.01503449747601 | ||
| C 1.42297403167085 0.00026730705255 0.00170779972564 | ||
| H -0.52956432516482 0.16759451146808 0.99517342002418 | ||
| H -0.47206799721260 0.78060586812661 -0.64348212080303 | ||
| H -0.47202276565405 -0.94827280862626 -0.35199393102178 | ||
| H 1.83370076026311 0.95190889480824 0.34680814012902 | ||
| H 1.83362978930886 -0.78232192510389 0.64382744884855 | ||
| H 1.80356539299709 -0.17242409816099 -1.00707525437860 |
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,39 @@ | ||
| #!/usr/bin/env python3 | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from opi.input.structures import Properties, Structure | ||
| from opi.simple_tasks import GoatSettings, GoatTask | ||
|
|
||
|
|
||
| def run_exmp061( | ||
| structure: Structure | None = None, working_dir: Path = Path("RUN") | ||
| ) -> tuple[list[Structure], list[Properties]]: | ||
|
|
||
| # > if no structure is given read structure from inp.xyz | ||
| if structure is None: | ||
| structure = Structure.from_xyz("inp.xyz") | ||
|
|
||
| goat_settings = GoatSettings(goat_maxiter=128, goat_explore=True) | ||
| goat_task = GoatTask("gfn2-xtb", task_settings=goat_settings) | ||
|
|
||
| goat_result = goat_task.run("job", structure, working_dir=working_dir, ncores=4) | ||
|
|
||
| # > check if the ORCA calculation terminated normally | ||
| if not goat_result.status: | ||
| print("GOAT task failed") | ||
| sys.exit(1) | ||
|
|
||
| structures, properties_list = goat_result.primary_property | ||
|
|
||
| # > Print structures that were read | ||
| for structure, properties in zip(structures, properties_list): | ||
| print(f"FINAL ENERGY: {properties.energy_total}") | ||
| print(structure.to_xyz_block()) | ||
|
|
||
| return structures, properties_list | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_exmp061() |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.