-
Notifications
You must be signed in to change notification settings - Fork 18
added Input.format_before_coords() and Input.format_after_coords() #155
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,6 +167,120 @@ def moinp(self, value: Path | str | os.PathLike[str] | None) -> None: | |
| # > METHODS | ||
| # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
|
||
| def format_before_coords(self, working_directory: Path) -> str: | ||
| """ | ||
| Function to format input data that appears before the coordinate block in the ORCA .inp file. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| working_directory: Path | ||
| working directory of the ORCA calculation. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| If the working directory is empty | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comment to the line where the Exception might be raised. |
||
|
|
||
| Returns | ||
| ------- | ||
| str | ||
| Formatted string of input data | ||
| """ | ||
| input_before_coords = "" | ||
| try: | ||
| simple_keywords = self.simple_keywords | ||
| blocks = self.blocks.values() if self.blocks else () | ||
| arbitrary_strings = self.arbitrary_strings | ||
|
|
||
| # --------------------------------- | ||
| # > Arbitrary Strings: top | ||
| # --------------------------------- | ||
| if arbitrary_strings: | ||
| for item in arbitrary_strings: | ||
| if item.pos is ArbitraryStringPos.TOP: | ||
| input_before_coords += f"{item.format_orca()}\n" | ||
|
|
||
| # --------------------------------- | ||
| # > Simple Keywords | ||
| # --------------------------------- | ||
| if simple_keywords: | ||
| for keyword in simple_keywords: | ||
| if isinstance(keyword, str): | ||
| input_before_coords += f"!{keyword}\n" | ||
| else: | ||
| input_before_coords += f"!{keyword.format_orca()}\n" | ||
|
|
||
| # --------------------------------- | ||
| # > Special Strings | ||
| # --------------------------------- | ||
| if (memory := self.memory) is not None: | ||
| input_before_coords += f"%maxcore {memory:d}\n" | ||
| if (ncores := self.ncores) is not None: | ||
| input_before_coords += f"%pal\n nprocs {ncores:d}\nend\n" | ||
| if (moinp := self.moinp) is not None: | ||
| input_before_coords += f'%moinp "{moinp.relative_to(working_directory)}"\n' | ||
|
|
||
| # --------------------------------- | ||
| # > Block Options: Before coords | ||
| # --------------------------------- | ||
| if blocks: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add more details. When is this raised?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify this point a bit more?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. |
||
| for block in blocks: | ||
| if not block.aftercoord: | ||
| input_before_coords += f"\n{block.format_orca()}\n" | ||
|
|
||
| # --------------------------------- | ||
| # > Arbitrary Strings: Before Coords | ||
| # --------------------------------- | ||
| if arbitrary_strings: | ||
| for item in arbitrary_strings: | ||
| if item.pos is ArbitraryStringPos.BEFORE_COORDS: | ||
| input_before_coords += f"\n{item}\n" | ||
|
|
||
| return input_before_coords | ||
|
|
||
| except ValueError as err: | ||
| raise ValueError(f"Error formatting Input: {err}") from err | ||
|
|
||
| def format_after_coords(self) -> str: | ||
| """ | ||
| Function to format input data that appears after the coordinate block in the ORCA .inp file. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add more details. When is this raised? |
||
|
|
||
|
|
||
| Returns | ||
| ------- | ||
| str | ||
| Formatted string of input data | ||
|
|
||
| """ | ||
| input_after_coords = "" | ||
| try: | ||
| blocks = self.blocks.values() if self.blocks else () | ||
| arbitrary_strings = self.arbitrary_strings | ||
| # --------------------------------- | ||
| # > Block options: After coords | ||
| # --------------------------------- | ||
| if blocks: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| for block in blocks: | ||
| if block.aftercoord: | ||
| input_after_coords += f"\n{block.format_orca()}\n" | ||
|
|
||
| # --------------------------------- | ||
| # > Arbitrary Strings: Bottom | ||
| # --------------------------------- | ||
| if arbitrary_strings: | ||
| for item in arbitrary_strings: | ||
| if item.pos is ArbitraryStringPos.BOTTOM: | ||
| input_after_coords += f"\n{item}\n" | ||
|
|
||
| return input_after_coords | ||
|
|
||
| except ValueError as err: | ||
| raise ValueError(f"Error formatting Input: {err}") from err | ||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # > SIMPLE KEYWORDS | ||
| # ---------------------------------------------------------------------- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.