Exemplo n.º 1
0
    # Create SHCI molecule for just variational opt.
    # Active spaces chosen to reflect valence active space.
    mch = shci.SHCISCF(mf, norb, nelec)
    mch.fcisolver.nPTiter = 0  # Turn off perturbative calc.
    mch.fcisolver.outputFile = 'no_PT.dat'
    mch.fcisolver.sweep_iter = [0, 3]
    mch.fcisolver.DoRDM = True
    # Setting large epsilon1 thresholds highlights improvement from perturbation.
    mch.fcisolver.sweep_epsilon = [1e-2, 1e-2]
    e_noPT = mch.mc1step()[0]

    # Run a single SHCI iteration with perturbative correction.
    mch.fcisolver.stochastic = False  # Turns on deterministic PT calc.
    mch.fcisolver.outputFile = 'PT.dat'  # Save output under different name.
    shci.writeSHCIConfFile(mch.fcisolver, [nelec / 2, nelec / 2], True)
    shci.executeSHCI(mch.fcisolver)

    # Open and get the energy from the binary energy file hci.e.
    # Open and get the energy from the
    with open(mch.fcisolver.outputFile, 'r') as f:
        lines = f.readlines()

    e_PT = float(lines[len(lines) - 1].split()[2])

    # e_PT = shci.readEnergy( mch.fcisolver )

    # Comparison Calculations
    del_PT = e_PT - e_noPT
    del_shci = e_CASSCF - e_PT

    print('\n\nEnergies for %s2 give in E_h.' % dimer_atom)
Exemplo n.º 2
0
# Create SHCI molecule for just variational opt.
# Active spaces chosen to reflect valence active space.
mc = shci.SHCISCF(mf, ncas, nelecas)
mc.fcisolver.mpiprefix = 'mpirun -np 2'
mc.fcisolver.stochastic = True
mc.fcisolver.nPTiter = 0  # Turn off perturbative calc.
mc.fcisolver.sweep_iter = [0]
# Setting large epsilon1 thresholds highlights improvement from perturbation.
mc.fcisolver.sweep_epsilon = [5e-3]
e_noPT = mc.mc1step()[0]

# Run a single SHCI iteration with perturbative correction.
mc.fcisolver.stochastic = False  # Turns on deterministic PT calc.
mc.fcisolver.epsilon2 = 1e-8
shci.writeSHCIConfFile(mc.fcisolver, [nelecas / 2, nelecas / 2], False)
shci.executeSHCI(mc.fcisolver)
e_PT = shci.readEnergy(mc.fcisolver)  #struct.unpack(format, file1.read())

# Comparison Calculations
del_PT = e_PT - e_noPT
del_shci = e_CASSCF - e_PT

print('\n\nEnergies for %s2 give in E_h.' % dimer_atom)
print('=====================================')
print('SHCI Variational: %6.12f' % e_noPT)
# Prints the total energy including the perturbative component.
print('SHCI Perturbative: %6.12f' % e_PT)
print('Perturbative Change: %6.12f' % del_PT)
print('CASSCF Total Energy: %6.12f' % e_CASSCF)
print('E(CASSCF) - E(SHCI): %6.12f' % del_shci)
print("Total Time:    ", time.time() - t0)