@@ -321,6 +321,7 @@ def local_energy(
321321 charges : jnp .ndarray ,
322322 nspins : Sequence [int ],
323323 use_scan : bool = False ,
324+ ndim : int = 3 ,
324325 complex_output : bool = False ,
325326 laplacian_method : str = 'default' ,
326327 states : int = 0 ,
@@ -336,6 +337,7 @@ def local_energy(
336337 charges: Shape (natoms). Nuclear charges of the atoms.
337338 nspins: Number of particles of each spin.
338339 use_scan: Whether to use a `lax.scan` for computing the laplacian.
340+ ndim: Number of dimensions.
339341 complex_output: If true, the output of f is complex-valued.
340342 laplacian_method: Laplacian calculation method. One of:
341343 'default': take jvp(grad), looping over inputs
@@ -360,7 +362,7 @@ def local_energy(
360362 if not pp_symbols :
361363 effective_charges = charges
362364 use_pp = False
363- else :
365+ elif ndim == 3 :
364366 effective_charges , pp_local , pp_nonlocal = pp .make_pp_potential (
365367 charges = charges ,
366368 symbols = pp_symbols ,
@@ -369,6 +371,8 @@ def local_energy(
369371 complex_output = complex_output
370372 )
371373 use_pp = not jnp .all (effective_charges == charges )
374+ else :
375+ raise NotImplementedError ("Pseudopotentials only implemented for 3D" )
372376
373377 if not use_pp :
374378 pp_local = lambda * args , ** kwargs : 0.0
@@ -386,9 +390,10 @@ def _e_l(
386390 """
387391 if states :
388392 # Compute features
389- vmap_features = jax .vmap (networks .construct_input_features , (0 , None ))
393+ vmap_features = jax .vmap (
394+ networks .construct_input_features , (0 , None , None ))
390395 positions = jnp .reshape (data .positions , [states , - 1 ])
391- ae , _ , r_ae , r_ee = vmap_features (positions , data .atoms )
396+ ae , _ , r_ae , r_ee = vmap_features (positions , data .atoms , ndim )
392397
393398 # Compute potential energy
394399 vmap_pot = jax .vmap (potential_energy , (0 , 0 , None , None ))
@@ -442,7 +447,7 @@ def _e_l(
442447 complex_output = complex_output ,
443448 laplacian_method = laplacian_method )
444449 ae , _ , r_ae , r_ee = networks .construct_input_features (
445- data .positions , data .atoms
450+ data .positions , data .atoms , ndim ,
446451 )
447452 potential = (potential_energy (r_ae , r_ee , data .atoms , effective_charges ) +
448453 pp_local (r_ae ) +
0 commit comments