def test_benzene_gradients_plain(): coords, species, vol_ratios = benzene_dimer[0] ene, gradients = MBDGeom(coords).mbd_energy_species( species, vol_ratios, 0.83, variant='plain', force=True ) with MBDGeom(coords) as geom: num_gradients = numerical_gradients( geom, 'mbd_energy_species', species, vol_ratios, 0.83, variant='plain' ) for i in range(len(coords)): assert gradients[i] == approx(num_gradients[i], rel=1e-10, abs=1e-10)
def test_argon_crystal_gradients(): coords, lattice, k_grid, species, vol_ratios = argon_crystal ene, gradients, latt_gradients = MBDGeom( coords, lattice, k_grid ).mbd_energy_species(species, vol_ratios, 0.83, force=True) with MBDGeom(coords, lattice, k_grid) as geom: num_gradients = numerical_gradients( geom, 'mbd_energy_species', species, vol_ratios, 0.83 ) for i in range(len(coords)): assert gradients[i] == approx(num_gradients[i], rel=1e-10, abs=1e-10) with MBDGeom(coords, lattice, k_grid) as geom: num_latt_gradients = numerical_latt_gradients( geom, 'mbd_energy_species', species, vol_ratios, 0.83 ) for i in range(3): assert latt_gradients[i] == approx(num_latt_gradients[i], rel=1e-10, abs=1e-10)