def calculator(): # Obviously this calculator should be adapted return SJM( poissonsolver={'dipolelayer': 'xy'}, gpts=(48, 32, 168), kpts=(4, 6, 1), xc='PBE', spinpol=False, potential=potential, occupations=FermiDirac(0.1), maxiter=400, cavity=EffectivePotentialCavity( effective_potential=SJMPower12Potential(atomic_radii, u0, H2O_layer=True), temperature=T, surface_calculator=GradientSurface()), dielectric=LinearDielectric(epsinf=epsinf), interactions=[SurfaceInteraction(surface_tension=gamma)], )
calc.set(xc=beef) solvent.calc = calc E_sv = solvent.get_potential_energy() #BEEF best fit energy ense = BEEFEnsemble(calc) dE_sv = ense.get_ensemble_energies( ) #N=2000 non-self-consist calculation to generate uncertainty spread #Perform solvent-only (solvated phase) calculation scalc = SolvationGPAW(xc=xc, gpts=h2gpts(h, solvent.get_cell(), idiv=16), cavity=EffectivePotentialCavity( effective_potential=Power12Potential( atomic_radii, u0), temperature=T, surface_calculator=GradientSurface()), dielectric=LinearDielectric(epsinf=epsinf), interactions=[SurfaceInteraction(surface_tension=gamma)]) solvent.calc = scalc solvent.get_potential_energy() scalc.set(xc=beef) solvent.calc = scalc E_sv_sol = solvent.get_potential_energy() ense = BEEFEnsemble(scalc) dE_sv_sol = ense.get_ensemble_energies() ''' #Perform single-ion (gas phase) calculation ion = Atoms(sym) calc.set(xc=xc,charge = charge) ion.calc = calc ion.set_cell(cell)
if not SKIP_REF_CALC: atoms.calc = GPAW(xc='LDA', h=h, convergence=convergence) Eref = atoms.get_potential_energy() print(Eref) Fref = atoms.get_forces() print(Fref) else: # setups: 0.9.11271, same settings as above Eref = -11.9879852185 Fref = np.array( [[1.77087917e-12, -2.38046360e-12, -6.05015925e+00], [7.91317656e-14, 1.61479184e+00, 6.87595580e-02], [2.62581472e-13, -1.61479184e+00, 6.87595580e-02]]) atoms.calc = SolvationGPAW( xc='LDA', h=h, convergence=convergence, cavity=EffectivePotentialCavity( effective_potential=Power12Potential(atomic_radii=atomic_radii, u0=u0), temperature=T ), dielectric=LinearDielectric(epsinf=1.0), ) Etest = atoms.get_potential_energy() Eeltest = atoms.calc.get_electrostatic_energy() Ftest = atoms.get_forces() equal(Etest, Eref, energy_eps * atoms.calc.get_number_of_electrons()) equal(Ftest, Fref, forces_eps) equal(Eeltest, Etest)