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

Autograd w.r.t. nuclei positions #22

Open
Binbose opened this issue Oct 26, 2024 · 1 comment
Open

Autograd w.r.t. nuclei positions #22

Binbose opened this issue Oct 26, 2024 · 1 comment

Comments

@Binbose
Copy link

Binbose commented Oct 26, 2024

Hey, I was wondering if mess is able to calculate forces on atoms with jax's autodiff? I tried it like this:

def struc_to_energy(r):
    mol = Structure(
            atomic_number=jnp.array([8, 1, 1]),
            position=to_bohr(r),
        )
    basis = basisset(mol, "6-31g")
    H = Hamiltonian(basis, xc_method="pbe")
    E, C, sol = minimise(H)
    return E
    

struc_to_energy_grad = jax.grad(struc_to_energy)
r = jnp.array([
                    [0.0000, 0.0000, 0.1165],
                    [0.0000, 0.7694, -0.4661],
                    [0.0000, -0.7694, -0.4661],
                ])

but I am getting errors from np.array being called on 'r' in the Structure construction and I dont see a good way to get around this.

@hatemhelal
Copy link
Member

hatemhelal commented Oct 29, 2024

We'd like to support this more generally but a few more pieces need to be implemented to make your example work:

Both of these are feasible but for the moment this is a work in progress. I suggest leaving this issue open as a reminder to check this works as the different pieces come together.

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

No branches or pull requests

2 participants