-
Notifications
You must be signed in to change notification settings - Fork 24
Added UMA infrastructure #895
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
alongd
wants to merge
3
commits into
main
Choose a base branch
from
uma
base: main
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.
+611
−15
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -92,7 +92,18 @@ def get_calculator(calc_config: dict, charge: int = 0, multiplicity: int = 1): | |
| if multiplicity > 1: | ||
| raise ValueError("ARC's integration with MOPAC vua the ASE calculator does not support multiplicity > 1.") | ||
| return MOPAC(**kwargs) | ||
|
|
||
|
|
||
| elif name in ('uma', 'fairchem'): | ||
|
Collaborator
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. Does fairchem has a model that is not uma? Do we want to leave the option to call |
||
| # UMA (Meta FAIR fairchem-core). Total charge and spin (= multiplicity) are conditioned on | ||
| # the ase.Atoms via atoms.info in main(); they are not calculator kwargs. | ||
| from fairchem.core import FAIRChemCalculator, pretrained_mlip | ||
| model = calc_config.get('model', 'uma-s-1p1') | ||
| device = calc_config.get('device', 'cpu') | ||
| task = calc_config.get('task', 'omol') | ||
| predictor = pretrained_mlip.get_predict_unit(model, device=device) | ||
| return FAIRChemCalculator(predictor, task_name=task) | ||
|
|
||
|
|
||
| from ase.calculators.calculator import get_calculator_class | ||
| try: | ||
| calc_class = get_calculator_class(name) | ||
|
|
@@ -313,8 +324,10 @@ def main(): | |
| settings = input_dict.get('settings', {}) | ||
| charge = input_dict.get('charge', 0) | ||
| multiplicity = input_dict.get('multiplicity', 1) | ||
|
|
||
| is_ts = input_dict.get('is_ts', False) | ||
|
|
||
| atoms = Atoms(symbols=xyz['symbols'], positions=xyz['coords']) | ||
| atoms.info.update({'charge': charge, 'spin': multiplicity}) # UMA (omol) conditions on these | ||
| calc = get_calculator(settings, charge, multiplicity) | ||
|
Comment on lines
329
to
331
|
||
| atoms.calc = calc | ||
|
|
||
|
|
@@ -342,13 +355,16 @@ def save_current_geometry(out_dict, atoms_obj, input_xyz): | |
| 'scipyfminbfgs': SciPyFminBFGS, 'scipyfmincg': SciPyFminCG, | ||
| 'sella': None, | ||
| } | ||
| if engine_name == 'sella': | ||
| logfile = os.path.join(os.path.dirname(input_path), 'opt.log') | ||
| if is_ts or engine_name == 'sella': | ||
| # A TS search needs a saddle-point optimizer; UMA ships none, so use Sella. | ||
| from sella import Sella | ||
| opt_class = Sella | ||
| opt = opt_class(atoms, order=1 if is_ts else 0, logfile=logfile) | ||
| else: | ||
| opt_class = engine_dict.get(engine_name, BFGS) | ||
| opt = opt_class(atoms, logfile=os.path.join(os.path.dirname(input_path), 'opt.log')) | ||
| opt = opt_class(atoms, logfile=logfile) | ||
|
|
||
| try: | ||
| opt.run(fmax=fmax, steps=steps) | ||
| save_current_geometry(output, atoms, xyz) | ||
|
|
@@ -360,6 +376,26 @@ def save_current_geometry(out_dict, atoms_obj, input_xyz): | |
| # For non-optimization jobs, still save the geometry | ||
| save_current_geometry(output, atoms, xyz) | ||
|
|
||
| if job_type == 'irc': | ||
| from sella import IRC | ||
| from ase.io import read | ||
| fmax = float(settings.get('fmax', 0.001)) | ||
| steps = int(settings.get('steps', 1000)) | ||
| direction = input_dict.get('irc_direction', 'forward') | ||
| traj_path = os.path.join(os.path.dirname(input_path), 'irc.traj') | ||
| try: | ||
| irc = IRC(atoms, logfile=os.path.join(os.path.dirname(input_path), 'irc.log'), | ||
| trajectory=traj_path) | ||
| irc.run(fmax=fmax, steps=steps, direction=direction) | ||
| images = read(traj_path, index=':') | ||
| output['irc_traj'] = [ | ||
| {'coords': tuple(map(tuple, image.get_positions().tolist())), | ||
| 'symbols': xyz['symbols'], | ||
| 'isotopes': xyz.get('isotopes') or tuple([None] * len(xyz['symbols']))} | ||
| for image in images] | ||
| except Exception as exc: | ||
| output['error'] = f"IRC failed: {exc}" | ||
|
|
||
| if job_type in ['freq', 'optfreq']: | ||
| try: | ||
| freq_results = run_vibrational_analysis(atoms, settings) | ||
|
|
||
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.
Can you add a source for that please? Is that like a known issue?