@@ -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,14 +337,15 @@ 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.
340- laplacian_method: Laplacian calculation method. One of:
341- 'default': take jvp(grad), looping over inputs
342- 'folx': use Microsoft's implementation of forward laplacian
342+ laplacian_method: Laplacian calculation method. One of: 'default': take
343+ jvp(grad), looping over inputs 'folx': use Microsoft's implementation of
344+ forward laplacian
343345 states: Number of excited states to compute. If 0, compute ground state with
344346 default machinery. If 1, compute ground state with excited state machinery
345- state_specific: Only used for excited states (states > 0). If true, then
346- the local energy is computed separately for each output from the network,
347+ state_specific: Only used for excited states (states > 0). If true, then the
348+ local energy is computed separately for each output from the network,
347349 instead of the local energy matrix being computed.
348350 pp_type: type of pseudopotential to use. Only used if ecp_symbols is
349351 provided.
@@ -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,11 @@ 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 )
395+ )
390396 positions = jnp .reshape (data .positions , [states , - 1 ])
391- ae , _ , r_ae , r_ee = vmap_features (positions , data .atoms )
397+ ae , _ , r_ae , r_ee = vmap_features (positions , data .atoms , ndim )
392398
393399 # Compute potential energy
394400 vmap_pot = jax .vmap (potential_energy , (0 , 0 , None , None ))
@@ -442,7 +448,9 @@ def _e_l(
442448 complex_output = complex_output ,
443449 laplacian_method = laplacian_method )
444450 ae , _ , r_ae , r_ee = networks .construct_input_features (
445- data .positions , data .atoms
451+ data .positions ,
452+ data .atoms ,
453+ ndim ,
446454 )
447455 potential = (potential_energy (r_ae , r_ee , data .atoms , effective_charges ) +
448456 pp_local (r_ae ) +
0 commit comments