コード例 #1
0
ファイル: run_test.py プロジェクト: susilehtola/pyflosic
 def test_flosic_opt(self):
     # FLO-SIC SCF OPT
     vsic_every = 1
     flosic = flosic_optimize('flosic-scf',
                              molecule,
                              0,
                              0,
                              'LDA,PW',
                              get_dfo_basis(sysname),
                              None,
                              opt='FIRE',
                              maxstep=0.1,
                              fmax=0.1,
                              conv_tol=1e-6,
                              grid=7,
                              vsic_every=vsic_every,
                              verbose=4)
     f = open('OPT_FRMORB.log', 'r')
     e_calc = f.readlines()[-1].split()[-2]
     f.close()
     if e_calc.find('*'):
         e_calc = e_calc.split('*')[0]
     e_calc = float(e_calc) / Ha
     e_ref = -40.697563
     self.assertAlmostEqual(e_calc, e_ref, 4)
コード例 #2
0
from ase.io import read
from ase_pyflosic_calculator import PYFLOSIC
from nrlmol_basis import get_dfo_basis
from ase.optimize import LBFGS, FIRE

# Set up a structure.
atoms = read('LiH.xyz')
# We want to use the NRLMOL DFO basis set.
basis = get_dfo_basis('LiH')

# Set up ase calculator.
calc = PYFLOSIC(atoms=atoms,
                charge=0,
                spin=0,
                xc='LDA,PW',
                basis=basis,
                mode='dft')
# Asign the calculator to the ase.atoms object.
atoms.set_calculator(calc)

# Set up ase optimizer.
label = 'OPT_NUCLEI'
maxstep = 0.1
fmax = 0.0001
steps = 1000

# Perform the nuclei optimization.
dyn = FIRE(atoms,
           logfile=label + '.log',
           trajectory=label + '.traj',
           force_consistent=True)
コード例 #3
0
ファイル: run_test.py プロジェクト: susilehtola/pyflosic
from flosic_os import xyz_to_nuclei_fod, ase2pyscf, flosic
from flosic_scf import FLOSIC
from nrlmol_basis import get_dfo_basis
from ase_pyflosic_optimizer import flosic_optimize
from ase.units import Ha

# Geometry
#f_xyz = '../examples/advanced_applications/CH4.xyz'
f_xyz = 'CH4.xyz'
sysname = 'CH4'
molecule = read(f_xyz)
geo, nuclei, fod1, fod2, included = xyz_to_nuclei_fod(molecule)
spin = 0
charge = 0
mol = gto.M(atom=ase2pyscf(nuclei),
            basis=get_dfo_basis(sysname),
            spin=spin,
            charge=charge)


class KnownValues(unittest.TestCase):
    def test_dft(self):
        # DFT
        mf = dft.UKS(mol)
        mf.verbose = 4  # Amount of output. 4: full output.
        mf.max_cycle = 300  # Number of SCF iterations.
        mf.conv_tol = 1e-6  # Accuracy of the SCF cycle.
        mf.grids.level = 7  # Level of the numerical grid. 3 is the standard value.
        mf.xc = 'LDA,PW'  # Exchange-correlation functional in the form: (exchange,correlation)
        e_ref = -40.1187154486949
        self.assertAlmostEqual(mf.kernel(), e_ref, 5)
コード例 #4
0
from ase.io import read
from pyscf import gto,dft
from flosic_os import xyz_to_nuclei_fod,ase2pyscf
from flosic_scf import FLOSIC
from onstuff import ON
from nrlmol_basis import get_dfo_basis

# Loading the structure 
ase_atoms = read('C.xyz')
pyscf_atoms,nuclei,fod1,fod2,included = xyz_to_nuclei_fod(ase_atoms)

# Computational details 
b = get_dfo_basis('C') #'cc-pvqz'
spin = 2
charge = 0

mol = gto.M(atom=ase2pyscf(nuclei),
            basis=b,
            spin=spin,
            charge=charge)

grid_level  = 9
mol.verbose = 4
mol.max_memory = 2000
mol.build()
xc = 'LDA,PW'

# quick dft calculation
mdft = dft.UKS(mol)
mdft.xc = xc
mdft.kernel()