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

Mismatch in the condition of adding properties #53

Closed
ksj20 opened this issue Jan 21, 2025 · 2 comments · Fixed by #55
Closed

Mismatch in the condition of adding properties #53

ksj20 opened this issue Jan 21, 2025 · 2 comments · Fixed by #55

Comments

@ksj20
Copy link

ksj20 commented Jan 21, 2025

Hi,
First of all thank you for the great project.
I have a question regarding the calculator class in forcefield.
In https://github.com/orbital-materials/orb-models/blob/3c79a26ba28ff64a6522b8db30f52e015d0b9064/orb_models/forcefield/calculator.py#L47C1-L51C1, which is

        if model.node_head is not None:
            properties += ["energy", "free_energy"]
        if model.graph_head is not None:
            properties += ["forces"]

Shouldn't energy/free_energy be added to properties when model.graph_head exists, and forces be added when model.node_head exists?
This is contrary to how energy and forces are mapped after prediction in the same python file, which requires graph_pred and node_pred, respectively. This is shown in https://github.com/orbital-materials/orb-models/blob/3c79a26ba28ff64a6522b8db30f52e015d0b9064/orb_models/forcefield/calculator.py#L79C1-L85C1 which is

        if "energy" in self.implemented_properties:
            self.results["energy"] = float(out["graph_pred"].detach().cpu().item())
            self.results["free_energy"] = self.results["energy"]

        if "forces" in self.implemented_properties:
            self.results["forces"] = out["node_pred"].detach().cpu().numpy()

My solution is to correct the if/else conditions to

        if model.graph_head is not None:
            properties += ["energy", "free_energy"]
        if model.node_head is not None:
            properties += ["forces"]

Thank you

@DeNeutoy
Copy link
Contributor

Ah good spot, these are the wrong way around!

        if model.node_head is not None:
            properties += ["energy", "free_energy"]
        if model.graph_head is not None:
            properties += ["forces"]

This is a bug, but doesn't affect any models in practice because all of the models we have released have both an energy and a forces head. If you would like to send a PR for this, please do.

@ksj20
Copy link
Author

ksj20 commented Jan 25, 2025

Sorry I missed it. Thanks for the PR.

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 a pull request may close this issue.

2 participants