Exemplo n.º 1
0
def vmc_pbyp_input_from_p2q(p2q, system, suffix='-p2q'):
    from nexus import vmc

    # determine ID and path from p2q simulation
    myid = p2q.identifier.replace(suffix, '-vmc')
    p2q_dir = os.path.basename(p2q.path)
    mypath = p2q.path.replace(p2q_dir, 'vmc')

    # write default inputs
    vmc_block = obj(move='pbyp',
                    warmupsteps=16,
                    blocks=64,
                    steps=4,
                    substeps=4,
                    timestep=0.4,
                    walkers=16,
                    checkpoint=0)
    calcs = [vmc(**vmc_block)]
    vmc_inputs = obj(identifier=myid,
                     path=mypath,
                     system=system,
                     input_type='basic',
                     bconds='ppp',
                     calculations=calcs,
                     dependencies=[(p2q, 'orbitals')])
    return vmc_inputs
Exemplo n.º 2
0
 def check_empty_settings():
     settings(command_line=False, )
     settings.command_line = True
     nexus_core.command_line = True
     check_settings_core_noncore()
     # nexus core sets basic run stages and Pseudopotentials object
     assert (nexus_core.stages_set == set(
         nexus_core_defaults.primary_modes))
     assert (isinstance(nexus_core.pseudopotentials, Pseudopotentials))
     assert (len(nexus_core.pseudopotentials) == 0)
     nexus_core.stages_set = set()
     nexus_core.stages = []
     nexus_core.pseudopotentials = None
     assert (object_eq(nexus_core, nexus_core_defaults))
     # nexus noncore sets Pseudopotentials and BasisSets objects
     assert (isinstance(nexus_noncore.pseudopotentials, Pseudopotentials))
     assert (len(nexus_noncore.pseudopotentials) == 0)
     assert (isinstance(nexus_noncore.basissets, BasisSets))
     assert (len(nexus_noncore.basissets) == 0)
     nnc_defaults = obj(nexus_noncore_defaults, nexus_core_noncore_defaults)
     nexus_noncore.pseudopotentials = None
     nexus_noncore.basissets = None
     assert (object_eq(nexus_noncore, nnc_defaults))
     # other settings objects should be at default also
     aux_defaults()
Exemplo n.º 3
0
def dmc_wbyw_input_from_p2q(p2q,
                            system,
                            nwalker=512,
                            tss=[0.006, 0.002],
                            corr=0.4,
                            suffix='-p2q'):
    from nexus import dmc

    # get a quick start from VMC defaults
    dmc_inputs = vmc_wbyw_input_from_p2q(p2q, system)

    # change ID and path
    myid = p2q.identifier.replace(suffix, '-dmc')
    p2q_dir = os.path.basename(p2q.path)
    mypath = p2q.path.replace(p2q_dir, 'dmc')
    dmc_inputs.identifier = myid
    dmc_inputs.path = mypath

    # ask VMC for samples
    calcs = dmc_inputs.calculations
    assert len(calcs) == 1  # expect 1 VMC calculation
    vcalc = calcs[0]
    vcalc['samples'] = nwalker

    # add DMC calculations
    for ts in tss:
        steps = int(round(corr / ts))
        dmc_block = obj(move='not_pbyp_or_whatever',
                        blocks=64,
                        steps=steps,
                        timestep=ts,
                        targetwalkers=nwalker)
        calcs += [dmc(**dmc_block)]
    # end for ts
    return dmc_inputs
Exemplo n.º 4
0
def vmc_wbyw_input_from_p2q(p2q, system, suffix='-p2q'):
    """ construct vmc (walker-by-walker) inputs as nexus.obj
   assume orbitals come from a mean-field calculation "p2q"

   The returned nexus.obj can be edited at will even after return
    thus, the "system" input is not actually mandatory. I put it 
    there simply as a reminder.

   The "job" attribute still needs to be filled in after return.
   "job" is not assigned in this function to improve tranferability 
   among machines.
  Args:
   p2q (nexus.Pw2qmcpack): may also be any other Simulation object 
    having 'orbitals' in 'application_results'.
   system (nexus.PhysicalSystem): system to simulate.
   suffix (str,optional): suffix to the p2q simulation identifier and path.
  """
    from nexus import vmc

    # determine ID and path from p2q simulation
    myid = p2q.identifier.replace(suffix, '-vmc')
    p2q_dir = os.path.basename(p2q.path)
    mypath = p2q.path.replace(p2q_dir, 'vmc')

    # write default inputs
    vmc_block = obj(
        warmuptimestep=0.01,
        move='not_pbyp_or_whatever',
        warmupsteps=128,
        blocks=64,
        steps=4,
        substeps=4,
        timestep=0.03,
        walkers=16,
    )
    calcs = [vmc(**vmc_block)]
    vmc_inputs = obj(identifier=myid,
                     path=mypath,
                     system=system,
                     input_type='basic',
                     bconds='ppp',
                     calculations=calcs,
                     dependencies=[(p2q, 'orbitals')])
    return vmc_inputs
Exemplo n.º 5
0
def gamma_opt_input(p2q, system, init_jas=None):
    from nexus import loop, linear

    myid = p2q.identifier.replace('-p2q', '-opt')
    nscf_dir = os.path.basename(p2q.path)
    mypath = p2q.path.replace(nscf_dir, 'opt')

    linopt = obj(
        minmethod='OneShiftOnly',
        energy=0.95,
        reweightedvariance=0.05,
        unreweightedvariance=0.0,
        warmupsteps=40,
        blocks=128,
        substeps=3,
        timestep=0.8,
        samples=8192,
    )
    calcs = [loop(max=5, qmc=linear(**linopt))]

    myjas = init_jas
    if init_jas is None:
        myjas = [('J1', 'size', 8, 'cusp', 1), ('J2', 'size', 8)]
    # end if

    opt_inputs = obj(
        identifier=myid,
        path=mypath,
        input_type='basic',
        system=system,
        bconds='ppp',  # periodic in xyz directions
        calculations=calcs,
        twistnum=0,
        estimators=[],
        jastrows=myjas,
        pseudos=[],
        dependencies=[(p2q, 'orbitals')])
    return opt_inputs
Exemplo n.º 6
0
def p2q_input_from_nscf(nscf, suffix='-nscf', cusp_corr=False):
    """ take an nscf simulation object and create a p2q run to generate wavefunction.
  Args: 
    nscf (nexus.Pwscf): nscf simulation object. An scf simulation object can also be used here.
    suffix (str,optional): suffix in the identifier and path of the nscf simulation. Default is '-nscf'.
    cusp_corr (bool,optional): apply cusp correction, namely divide DFT orbitals by RPA Jastrows. This option requires a custom version of quantum espresso. Default=False.
  Returns:
    nexus.obj: inputs necessary for the p2q run.
  """
    p2q_input = obj(identifier=nscf.identifier.replace(suffix, '-p2q'),
                    path=nscf.path,
                    outdir=nscf.input.control.outdir,
                    write_psir=False,
                    dependencies=(nscf, 'orbitals'))
    if cusp_corr:
        p2q_input['cusp_corr'] = True

    return p2q_input
vo2 = generate_physical_system(
    structure=s,
    V1=13,
    V2=13,
    O=6,
)

# generate pwscf input
pw = generate_pwscf_input(
    selector='generic',
    calculation='scf',
    disk_io='low',
    verbosity='high',
    wf_collect=True,
    input_dft='lda',
    hubbard_u=obj(V1=3.5, V2=3.5),
    ecutwfc=350,
    bandfac=1.3,
    nosym=True,
    occupations='smearing',
    smearing='fermi-dirac',
    degauss=0.0001,
    nspin=2,
    start_mag=obj(V1=1.0, V2=-1.0),
    diagonalization='david',
    conv_thr=1e-8,
    mixing_beta=0.2,
    electron_maxstep=1000,
    system=vo2,
    pseudos=['V.opt.upf', 'O.opt.upf'],
    kgrid=(6, 6, 6),
Exemplo n.º 8
0
# vasp inputs used by all runs
shared_inputs = obj(
    encut=550,
    ediff=1e-8,
    algo='Normal',
    nelm=400,
    nwrite=2,
    prec='Accurate',
    ismear=-5,
    lwave=False,
    lcharg=False,
    lreal='.FALSE.',
    nbands=200,
    ispin=2,
    magmom=24 * [0] + [-6, 6, 6, -6, 6, -6, -6, 6] + 8 * [0],
    ldau=True,
    ldautype=2,
    ldaul=[-1, 2, -1],
    ldauu=[0, 2, 0],
    ldauj=[0, 0, 0],
    lmaxmix=4,
    lorbit=11,
    kpar=8,
    ncore=4,
    pseudos=[
        'Bi.d.lda.POTCAR',  # TITEL= PAW Bi_d 09Feb1998
        'Fe.pv.lda.POTCAR',  # TITEL= PAW Fe_pv 03Mar1998
        'O.lda.POTCAR'
    ]  # TITEL= PAW O 31May2000
)
Exemplo n.º 9
0
               C  0.8925  0.8925  0.8925
               ''',
    kgrid    = (1,1,1),
    kshift   = (0,0,0),
    C        = 4,
    )

scf = generate_pyscf(
    identifier = 'scf',                      # log output goes to scf.out
    path       = 'diamond_pp_dft_gamma',     # directory to run in
    job        = job(serial=True,threads=16),# pyscf must run w/o mpi
    template   = './dft_template.py',        # pyscf template file
    system     = system,
    cell       = obj(                        # used to make Cell() inputs
        basis         = 'bfd-vdz',
        ecp           = 'bfd',
        drop_exponent = 0.1,
        verbose       = 5,
        ),
    save_qmc   = True,                # save wfn data for qmcpack
    )

c4q = generate_convert4qmc(
    identifier   = 'c4q',
    path         = 'diamond_pp_dft_gamma',
    job          = job(cores=1),
    no_jastrow   = True,
    dependencies = (scf,'orbitals'),
    )

qmc = generate_qmcpack(
    identifier   = 'vmc',
Exemplo n.º 10
0
    results='',
    sleep=3,
    machine='ws16',
)

system = generate_physical_system(structure='H2O.xyz', )

scf = generate_pyscf(
    identifier='scf',  # log output goes to scf.out
    path='h2o_ae_hf',  # directory to run in
    job=job(serial=True),  # pyscf must run serially         
    template='./scf_template.py',  # pyscf template file
    system=system,
    mole=obj(  # used to make Mole() inputs
        verbose=5,
        basis='ccpvtz',
        symmetry=True,
    ),
    save_qmc=True,  # save wfn data for qmcpack
)

c4q = generate_convert4qmc(
    identifier='c4q',
    path='h2o_ae_hf',
    job=job(cores=1),
    no_jastrow=True,
    dependencies=(scf, 'orbitals'),
)

qmc = generate_qmcpack(
    identifier='vmc',
Exemplo n.º 11
0
def apply_machine_settings(machine, run_dir, account='', nk=1, **kwargs):
    """ apply default machines settings for hydrogen simulations
   return a dictionary of jobs for ['dft','p2q','opt','dmc'] 
  Args:
    machine (str): one of ['golub','titan','ws4','ws8',...]. 'ws' stands for workstation.
    run_dir (str): directory to run the jobs in.
    account (str,optional): default is to depend on the machine's default in nexus.
    nk (int,optional): the npool option in pw.x, default is 1 because it always runs. For large number of kpoints, set nk to be as large as possible for speed.
    kwargs (dict): extra keyword arguments to be passed to nexus.settings.
  Returns:
    dict: jobs, a dictionary of nexus.obj objects for ['dft','p2q','opt','dmc'], each can be passed to create nexus.Job objects using Job(**jobs['dft']), for example.
    """
    if (machine not in ['golub', 'titan', 'eos', 'bluewaters_xe'
                        ]) and (not machine.startswith('ws')):
        raise NotImplementedError('cannot handle machine=%s yet' % machine)
    # end if

    from nexus import settings, obj
    if machine == 'titan':
        account = 'mat158'
        pseudo_dir = '/ccs/home/yyang173/scratch/hsolid/pseudo'
        vdw_table = '/ccs/home/yyang173/scratch/hsolid/vdw/vdW_kernel_table'
        qedir = '~/soft/espresso-5.3.0/bin'
        ccdir = '~/soft/qmcpack-espresso-5.3.0/bin'
        qmcdir = '~/soft/kylin_qmcpack'
    elif machine == 'eos':
        account = 'mat158'
        pseudo_dir = '/ccs/home/yyang173/scratch/hsolid/pseudo'
        vdw_table = '/ccs/home/yyang173/scratch/hsolid/vdw/vdW_kernel_table'
        qedir = '~/soft/espresso-5.3.0/bin'
        ccdir = '~/soft/qmcpack-espresso-5.3.0/bin'
        qmcdir = '~/soft/intel_kylin_qmcpack'
    elif machine == 'bluewaters_xe':
        pseudo_dir = '/u/sciteam/yang5/scratch/hsolid/pseudo'
        vdw_table = '/u/sciteam/yang5/scratch/hsolid/vdw/vdW_kernel_table'
        qedir = '~/soft/espresso-5.3.0/bin'
        ccdir = '~/soft/qmcpack-espresso-5.3.0/bin'
        qmcdir = '~/soft/kylin_qmcpack'
    elif machine == 'golub':
        pseudo_dir = '/home/yyang173/scratch/hsolid/pseudo'
        vdw_table = '/home/yyang173/scratch/hsolid/vdw/vdW_kernel_table'
        qedir = '/projects/physics/yyang/soft/espresso-5.3.0/bin'
        ccdir = '/projects/physics/yyang/soft/qmcpack-espresso-5.3.0/bin'
        qmcdir = '~/soft/kylin_qmcpack'
    else:  # workstation, defaults should do
        pseudo_dir = '/home/yyang173/Desktop/hsolid/pseudo'
        vdw_table = '/home/yyang173/Desktop/hsolid/vdw/vdW_kernel_table'
        qedir = '~/soft/espresso-5.3.0/bin'
        ccdir = '~/soft/qmcpack-espresso-5.3.0/bin'
        qmcdir = '~/soft/kylin_qmcpack'
    # end if
    settings(runs=run_dir,
             machine=machine,
             account=account,
             pseudo_dir=pseudo_dir,
             vdw_table=vdw_table,
             **kwargs)

    pw_bin = os.path.join(qedir, 'pw.x')
    cc_bin = os.path.join(ccdir, 'pw2qmcpack.x')
    qmc_bin = os.path.join(qmcdir, "qmcpack_cpu_real")
    tabc_bin = os.path.join(qmcdir, "qmcpack_cpu_comp")

    # assign jobs
    if machine == 'titan':
        dft_job = obj(nodes=1,
                      minutes=10,
                      app_options="-nk %d" % nk,
                      app=pw_bin)
        p2q_job = obj(nodes=1, serial=True, minutes=30, app=cc_bin)
        opt_job = obj(nodes=4, threads=8, hours=2, app=qmc_bin)
        dmc_job = obj(nodes=8, threads=8, hours=2, app=qmc_bin)
    elif machine == 'eos':
        dft_job = obj(nodes=1,
                      minutes=10,
                      app_options="-nk %d" % nk,
                      app=pw_bin)
        p2q_job = obj(nodes=1, serial=True, minutes=30, app=cc_bin)
        opt_job = obj(nodes=4, threads=8, hours=2, app=qmc_bin)
        dmc_job = obj(nodes=8, threads=8, hours=2, app=qmc_bin)
    elif machine == 'bluewaters_xe':
        dft_job = obj(nodes=1,
                      minutes=10,
                      app_options="-nk %d" % nk,
                      app=pw_bin)
        p2q_job = obj(nodes=1, serial=True, minutes=30, app=cc_bin)
        opt_job = obj(nodes=4, threads=8, hours=2, app=qmc_bin)
        dmc_job = obj(nodes=8, threads=8, hours=2, app=qmc_bin)
        for job in [dft_job, p2q_job, opt_job, dmc_job]:
            job['user_env'] = False  # the -V option is deprecated
        # end for
    elif machine == 'golub':
        dft_job = obj(nodes=1, hours=4, app=pw_bin, app_options='-nk %d' % nk)
        p2q_job = obj(nodes=1, serial=True, minutes=30, app=cc_bin)
        opt_job = obj(nodes=1, threads=8, hours=4, app=qmc_bin)
        dmc_job = obj(nodes=1, threads=8, hours=4, app=qmc_bin)
    else:
        dft_job = obj(app_options='-nk %d' % nk, app=pw_bin)
        p2q_job = obj(serial=True, app=cc_bin)
        opt_job = obj(app=qmc_bin, threads=8)
        dmc_job = obj(app=qmc_bin, threads=8)
    # end if
    tabc_job = dmc_job.copy()
    tabc_job.app = tabc_bin
    jobs = {
        'dft': dft_job,
        'p2q': p2q_job,
        'opt': opt_job,
        'dmc': dmc_job,
        'tabc': tabc_job
    }

    return jobs
Exemplo n.º 12
0
params_defaults = obj(
    electron_maxstep=200,
    system=None,
    j=11,
    dft_pps=None,
    qmc_pps=None,
    dft_grid=(6, 6, 6),
    tilings=[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]],
    qmc_grids=[(3, 3, 3)],
    uatoms=None,
    ulist=None,
    charge=0,
    tot_mag=None,
    machine='titan',
    j3=True,
    j2=False,
    code='cpu',
    qp=False,
    big=False,
    density=None,
    nopre=False,
    tmoves=False,
    meshfactor=1.0,
    hybrid_rcut=None,
    hybrid_lmax=None,
    rcut=None,
    two_u=False,
    natoms=None,
    vmc=False,
    vmc_opt=True,
    twistnum=1,
    excitation=None,
    bundle=False,
    qmc_skip_submit=False,
    timesteps=None,
    qmc=True,
    seed=None,
    kshift=(0, 0, 0),
    print_ke_corr=False,
    relax=False,
    relax_functional='PBESOL',
    relax_u=4,
    relax_pps=None,
    relax_pp_dir=None,
    nscf_only=False,
    nscf_skip=False,
)
Exemplo n.º 13
0
    hubbard_u={1: 3.1},
    starting_magnetization={1: 0.9},
    starting_ns_eigenvalue={
        (1, 2, 1): 0.0,
        (2, 2, 1): 0.0476060,
        (3, 2, 1): 0.0476060,
        (4, 2, 1): 0.9654373,
        (5, 2, 1): 0.9954307
    },
    # electrons inputs
    conv_thr=1.0e-9,
    mixing_beta=0.7,
    diagonalization='david',
    mixing_fixed_ns=500,
    # atomic_species inputs
    mass=obj(Fe=58.69000),
    pseudos=['Fe.pbe-nd-rrkjus.UPF'],
    # atomic_positions inputs
    elem=['Fe', 'Fe'],
    pos=[[2.070000000, 0.000000000, 0.000000000],
         [0.000000000, 0.000000000, 0.000000000]],
    pos_specifier='angstrom',
    # k_points inputs
    kgrid=(1, 1, 1),
    kshift=(1, 1, 1),
)

# manipulate and write
for ecut in [100, 120, 140, 160]:
    pw.system.ecutwfc = ecut
    pw.write('scf_05_ecut_{0}.in'.format(ecut))
Exemplo n.º 14
0
#! /usr/bin/env python

import numpy as np
# ======= setup machine and jobs =======
from nexus import settings, Job, obj
machine_settings = obj(
    runs='grid',  # default to 'runs'
    generate_only=0,
    status_only=0,
    sleep=1,
    machine='ws1',
    ericfmt='/opt/intel14/gamess-2014R1/auxdata/ericfmt.dat')
settings(**machine_settings)
gms_job = Job(serial=True, app="rungms", cores=1)

# ======= structure =======
from nexus import generate_physical_system, Structure
from nexus import generate_gamess

CH = 1.0655  # ang
CN = 1.1538  # ang
basis = 'ccd'

# ======= simulations =======
'''
MODERN BASIS SET FAMILIES (CCN, PCN, MCP_NZP, IMCP) ARE INTENDED
 FOR USE ONLY AS SPHERICAL HARMONIC BASIS SETS. PLEASE SET ISPHER=1
  IN THE $CONTRL GROUP IN ORDER TO USE GBASIS=ACCT
'''

rhf_runs = []
Exemplo n.º 15
0
#! /usr/bin/env python

import numpy as np
# ======= setup machine and jobs =======
from nexus import settings,Job,obj
machine_settings = obj(
    runs          = 'grid', # default to 'runs'
    generate_only = 0,
    status_only   = 0,
    sleep         = 1,
    machine       = 'ws1',
    ericfmt       = '/opt/intel14/gamess-2014R1/auxdata/ericfmt.dat'
)
settings(**machine_settings)
gms_job = Job(serial=True,app="rungms",cores=1)

# ======= structure =======
from nexus import generate_physical_system, Structure
from nexus import generate_gamess

CH = 1.0655 # ang
CN = 1.1538 # ang
basis = 'ccd'

# ======= simulations =======
'''
MODERN BASIS SET FAMILIES (CCN, PCN, MCP_NZP, IMCP) ARE INTENDED
 FOR USE ONLY AS SPHERICAL HARMONIC BASIS SETS. PLEASE SET ISPHER=1
  IN THE $CONTRL GROUP IN ORDER TO USE GBASIS=ACCT
'''
Exemplo n.º 16
0
shared_inputs = obj(
    # nexus inputs
    identifier='scf',
    job=job(cores=8, app='rmg-cpu'),
    pseudos=['C.BFD.xml'],
    input_type='generic',
    # control options
    calculation_mode='Quench Electrons',
    compressed_infile=False,
    compressed_outfile=False,
    description='diamond',
    energy_convergence_criterion=1.0e-09,
    max_scf_steps=100,
    #start_mode             = 'Restart From File',
    write_data_period=10,
    # cell parameter options
    atomic_coordinate_type='Cell Relative',
    kpoint_is_shift=(0, 0, 0),
    kpoint_mesh=(4, 4, 4),
    potential_grid_refinement=2,
    # pseudopotential related options
    localize_localpp=False,
    localize_projectors=False,
    # kohn sham solver options
    kohn_sham_mucycles=3,
    kohn_sham_solver='davidson',
    # orbital occupation options
    occupations_type='Fixed',
    # charge density mixing options
    charge_density_mixing=0.5,
    charge_mixing_type='Broyden',
    potential_acceleration_constant_step=1.0,
    # diagonalization options
    subdiag_driver='lapack',
    ## testing options
    #test_energy            = -11.39547539 # reference energy for validation
    # miscellaneous options
    kpoint_distribution=8,
)
Exemplo n.º 17
0
                              net_spin=1)
mag = [0.7]
tot_mag = 1

#######################################################################
########################## Change here only ##########################

shared_scf = obj(
    input_type='generic',
    occupations='smearing',
    smearing='gaussian',
    degauss=0.005,
    tot_magnetization=tot_mag,
    ####################
    #plus-u is here
    input_DFT='PBE',
    lda_plus_u=True,
    ####################
    ecutwfc=320,
    start_mag=obj(Ni=mag[0]),
    conv_thr=1.0e-7,
    mixing_beta=0.2,
    # no_sym is deleted! jtk added
    use_folded=True,
)
params = obj(electron_maxstep=100,
             system=ph,
             j=11,
             dft_pps=['Li.BFD.upf', 'Ni.opt.upf', 'O.opt.upf'],
             qmc_pps=['Li.BFD.xml', 'Ni.opt.xml', 'O.opt.xml'],
             dft_grid=(5, 5, 5),
             tilings=[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]],
Exemplo n.º 18
0
    H          = 1,
    net_spin   = 0,   # 2S
    net_charge = 0,
    )

sims = []
# perform Hartree-Fock
scf = generate_pyscf(
    identifier = 'scf',               # log output goes to scf.out
    path       = 'scf',            # directory to run in
    job          = job(serial=True, nodes=4, queue='debug', hours=0.5, constraint='knl', presub=scf_presub),
    #job        = job(serial=True, nodes=1, threads=4, presub=scf_presub),
    template   = 'scf_guess/scf_template.py', # pyscf template file
    system     = system,
    mole       = obj(                 # used to make Mole() inputs
        verbose  = 4,
        #symmetry = 'D2h',
        ),
    save_qmc   = True,                # save wfn data for qmcpack
    )
sims.append(scf)

#### convert orbitals to QMCPACK format
c4q = generate_convert4qmc(
    identifier   = 'c4q',
    path         = 'scf',
    job          = job(nodes=4, queue='debug', hours=0.50, constraint='knl', presub=scf_presub),
    #job        = job(serial=True, nodes=1, threads=4),
    no_jastrow   = True,
    hdf5         = True,              # use hdf5 format
    dependencies = (scf,'orbitals'),
    )
Exemplo n.º 19
0
def mworkflow(shared_qe, params, sims):

    for i in params_defaults.keys():
        if i not in params:
            setattr(params, i, params_defaults[i])
        #end if
    #end if
    if params.j3:
        if params.code == 'gpu':
            print "GPU code and j3 not possible yet"
            exit()
        #end if
    #end if
    if params.excitation is not None:
        params.twistnum = 0
    ########################
    #DMC and VMC parameters#
    ########################
    samples = 25600  #25600
    vmcblocks = 100
    dmcblocks = 300
    dmceqblocks = 200
    dmcwalkers = 1024  # For cades it is multiplied by 2
    vmcdt = 0.3
    if params.vmc:
        vmcblocks = 9000
        vmcdt = 0.3
        dmcblocks = 1
        dmceqblocks = 1
    #end if
    #############################
    # Machine specific variables#
    #############################
    if params.machine == 'cades':
        minnodes = 1
        scf_nodes = 2
        scf_hours = 48
        p2q_nodes = scf_nodes
        p2q_hours = 1

        qeapp = 'pw.x -npool 4 '
        if params.dft_grid == (1, 1, 1):
            scf_nodes = 1
            qeapp = 'pw.x'
        #end if
        qe_presub = 'module purge; module load PE-intel/3.0; module load hdf5_parallel/1.10.3'

        opt_nodes = 4
        opt_hours = 12
        dmcnodespertwist = 0.5
        dmc_hours = 24
        qmc_threads = 18
        walkers = qmc_threads
        blocks = samples / (walkers * opt_nodes)
        params.code = 'cpu'
        qmcapp = ' qmcpack_cades_cpu_comp_SoA'
        qmc_presub = 'module purge; module load PE-intel'

        opt_job = Job(nodes=opt_nodes,
                      hours=opt_hours,
                      threads=qmc_threads,
                      app=qmcapp,
                      presub=qmc_presub)

    elif params.machine == 'titan' or params.machine == 'eos':
        minnodes = 1
        dmcwalkers *= 2
        scf_nodes = 8
        scf_hours = 2
        p2q_nodes = scf_nodes
        p2q_hours = 1

        qeapp = 'pw.x -npool 4 '
        qe_presub = ''

        if params.machine == 'eos':
            opt_nodes = 16
            opt_hours = 2
            qmc_threads = 16
            walkers = qmc_threads
            blocks = samples / (walkers * opt_nodes)

            params.code = 'cpu'
            qmcapp = '/ccs/home/kayahan/SOFTWARE/qmcpack/eos/qmcpack/qmcpack_eos_cpu_comp_SoA'
            qmc_presub = ''

            params.rundmc = False
        elif params.machine == 'titan':
            if params.code == 'cpu':
                dmcwalkers *= 2
                vmcblocks = 50
                opt_nodes = 16
                opt_hours = 2
                dmcnodespertwist = 32
                dmc_hours = 6
                qmc_threads = 16
                walkers = qmc_threads
                blocks = samples / (walkers * opt_nodes)

                qmcapp = '/ccs/home/kayahan/SOFTWARE/qmcpack/titan/qmcpack/qmcpack_titan_cpu_comp_SoA'
                qmc_presub = ''

                params.rundmc = True
            elif params.code == 'gpu':
                dmcwalkers *= 8
                opt_nodes = 4
                opt_hours = 4
                dmcnodespertwist = 8
                dmc_hours = 1.5
                qmc_threads = 16
                walkers = qmc_threads
                blocks = samples / (walkers * opt_nodes)
                qmcapp = '/ccs/home/kayahan/SOFTWARE/qmcpack/titan/qmcpack/qmcpack_titan_gpu_comp_SoA'
                qmc_presub = 'module load cudatoolkit'
            #end if
        #end if

        opt_job = Job(nodes=opt_nodes,
                      hours=opt_hours,
                      threads=qmc_threads,
                      app=qmcapp,
                      presub=qmc_presub)

    elif params.machine == 'cetus' or params.machine == 'mira':
        if params.machine == 'cetus':
            minnodes = 128
            opt_hours = 1
            dmc_hours = 1
        elif params.machine == 'mira':
            minnodes = 128
            dmc_hours = 1
            dmc_hours = 1
        #end if

        scf_nodes = 128
        scf_hours = 1
        p2q_nodes = 128
        p2q_hours = 1

        qeapp = 'pw.x'
        qe_presub = ''

        opt_nodes = 128.0
        opt_nodes = np.round(opt_nodes / minnodes) * minnodes
        dmcnodespertwist = 18
        qmc_threads = 16
        walkers = qmc_threads
        qmc_processes_per_node = 16
        blocks = samples / (walkers * opt_nodes)
        params.code = 'cpu'
        qmcapp = 'qmcpack'
        qmc_presub = ''
        opt_job = Job(nodes=opt_nodes,
                      hours=opt_hours,
                      threads=qmc_threads,
                      processes_per_node=qmc_processes_per_node,
                      app=qmcapp,
                      presub=qmc_presub)
    elif params.machine == 'summit':
        dmcwalkers *= 8
        minnodes = 1
        scf_nodes = 2
        scf_hours = 24
        p2q_nodes = 2
        p2q_hours = 1

        qeapp = 'pw.x -npool 4 '
        if params.dft_grid == (1, 1, 1):
            scf_nodes = 1
            qeapp = 'pw.x'
    #end if
        qe_presub = 'module purge; module load PE-intel/3.0'
        opt_nodes = 4
        opt_hours = 4
        dmcnodespertwist = 8
        dmc_hours = 6
        qmc_threads = 42
        walkers = qmc_threads
        blocks = samples / (walkers * opt_nodes)
        qmcapp = '/ccs/home/kayahan/SOFTWARE/qmcpack/summit/qmcpack/build_summit_comp/bin/qmcpack'
    else:
        print "Machine is not defined!"
        exit()
    #end if

    scf_job = Job(nodes=scf_nodes,
                  hours=scf_hours,
                  app=qeapp,
                  presub=qe_presub)
    p2q_job = Job(nodes=p2q_nodes,
                  hours=p2q_hours,
                  app='pw2qmcpack.x -npool 4 ',
                  presub=qe_presub)

    if params.big or params.qp:
        dmcblocks *= 4
        dmcnodespertwist *= 1
        dmc_hours *= 2
        dmcwalkers *= 2
    #end if
    shared_qe.wf_collect = False
    shared_qe.nosym = True
    shared_qe.job = scf_job
    shared_qe.pseudos = params.dft_pps
    if params.tot_mag is not None:
        shared_qe.tot_magnetization = params.tot_mag
    #end if
    if params.two_u:
        ulist = [params.ulist[0]]
    else:
        ulist = params.ulist
    #end if
    shared_relax = shared_qe.copy()

    # qmcs list to possibly bundle all DMC calculations
    qmcs = []
    scf_ks_energy = 0
    for u in ulist:
        if u != 0.:
            shared_qe.hubbard_u = obj()
            shared_relax.hubbard_u = obj()
            for inum, i in enumerate(params.uatoms):
                if params.two_u:
                    setattr(shared_qe.hubbard_u, i, params.ulist[inum])
                else:
                    setattr(shared_qe.hubbard_u, i, u)
                    setattr(shared_relax.hubbard_u, i, params.relax_u)
                    #end if
            #end for
        #end if
        scf_inf = None
        scf_path = './scf-u-' + str(u) + '-inf'
        if params.relax:
            shared_relax = shared_qe.copy()
            shared_relax['ion_dynamics'] = 'bfgs'
            shared_relax['cell_dynamics'] = 'bfgs'
            shared_relax['calculation'] = 'vc-relax'
            shared_relax['conv_thr'] = 10e-6
            shared_relax['forc_conv_thr'] = 0.001
            shared_relax['input_DFT'] = params.relax_functional
            shared_relax.nosym = True
            coarse_relax = generate_pwscf(
                identifier='scf',
                path='./coarse_relax-u-' + str(params.relax_u) + '-inf',
                electron_maxstep=params.electron_maxstep,
                nogamma=True,
                system=params.system,
                kgrid=params.dft_grid,
                **shared_relax)
            sims.append(coarse_relax)

            shared_relax['conv_thr'] = 10e-8
            shared_relax['forc_conv_thr'] = 0.001
            fine_relax = generate_pwscf(
                identifier='scf',
                path='./fine_relax-u-' + str(params.relax_u) + '-inf',
                electron_maxstep=params.electron_maxstep,
                nogamma=True,
                system=params.system,
                kgrid=params.dft_grid,
                dependencies=(coarse_relax, 'structure'),
                **shared_relax)
            sims.append(fine_relax)

            scf_inf = generate_pwscf(
                identifier='scf',
                path=scf_path,
                electron_maxstep=params.electron_maxstep,
                nogamma=True,
                system=params.system,
                #nosym = True,
                kgrid=params.dft_grid,
                calculation='scf',
                dependencies=(fine_relax, 'structure'),
                **shared_qe)
            #pdb.set_trace()

        else:
            scf_inf = generate_pwscf(
                identifier='scf',
                path=scf_path,
                electron_maxstep=params.electron_maxstep,
                nogamma=True,
                system=params.system,
                #nosym = True,
                kgrid=params.dft_grid,
                calculation='scf',
                **shared_qe)

        sims.append(scf_inf)

        if params.nscf_only is True:
            params.tilings = []
            params.vmc_opt = False
            params.qmc = False

        if params.print_ke_corr:
            scf_dir = scf_inf.remdir
            pwscf_output = scf_inf.input.control.outdir
            datafile_xml = scf_dir + '/' + pwscf_output + '/pwscf.save/data-file-schema.xml'
            if os.path.isfile(datafile_xml):
                xmltree = minidom.parse(datafile_xml)
                ks_energies = xmltree.getElementsByTagName("ks_energies")
                eig_tot = 0
                for kpt in ks_energies:
                    w = float(
                        kpt.getElementsByTagName('k_point')[0].getAttribute(
                            'weight'))
                    eigs = np.array(kpt.getElementsByTagName('eigenvalues')
                                    [0].firstChild.nodeValue.split(' '),
                                    dtype='f')
                    occs = np.array(
                        kpt.getElementsByTagName(
                            'occupations')[0].firstChild.nodeValue.split(' '),
                        dtype='f')  #Non-integer occupations from DFT
                    eig_tot += w * sum(
                        eigs * occs) / 2  #Divide by two for both spins
                #end for
                print scf_dir, "e_tot eigenvalues in Ha ", eig_tot / 2
                if scf_ks_energy == 0:
                    scf_ks_energy = eig_tot / 2
            #end if
        #end if
        for tl_num, tl in enumerate(params.tilings):
            for k in params.qmc_grids:
                knum = k[1] * k[2] * k[0]
                if params.relax:
                    relax = fine_relax  #prim = scf_inf.load_analyzer_image().input_structure.copy()
                    print 'Make sure the previous run is loaded to results!'
                    #scf_inf.system.structure
                else:
                    relax = scf_inf
                    prim = params.system.structure.copy()
                    #system = params.system
                prim.clear_kpoints()
                super = prim.tile(tl)

                tl_np = np.array(tl)
                tl_det = int(np.abs(np.linalg.det(tl_np)) + 0.001)

                if params.natoms is not None:
                    natoms = tl_det * params.natoms
                else:
                    natoms = len(super.elem)
                #end if
                if params.rcut:
                    rcut = params.rcut[tl_num]
                else:
                    rcut = super.rwigner() - 0.00001
                #end if
                if params.tot_mag is not None and params.qp is False:
                    system = generate_physical_system(
                        structure=prim,
                        tiling=tl,
                        kgrid=k,
                        kshift=params.kshift,  #(0, 0, 0),
                        net_charge=params.charge,
                        net_spin=params.tot_mag,
                        use_prim=False,
                        **params.system.valency)
                elif params.qp is False:
                    system = generate_physical_system(
                        structure=prim,
                        tiling=tl,
                        kgrid=k,
                        shift=params.kshift,  #(0, 0, 0),
                        net_charge=params.charge,
                        **params.system.valency)
                else:
                    system = generate_physical_system(
                        structure=prim,
                        tiling=tl,
                        kgrid=k,
                        kshift=params.kshift,  #(0, 0, 0),
                        use_prim=False,
                        **params.system.valency)
                #end if
                # DFT NSCF To Generate Wave Function At Specified K-points

                if params.dft_grid == params.qmc_grids[0] and len(
                        params.qmc_grids) == 1:
                    params.nscf_skip = True

                if not params.nscf_skip:
                    if params.relax:
                        nscf_dep = [(scf_inf, 'charge_density'),
                                    (relax, 'structure')]
                    else:
                        nscf_dep = [(scf_inf, 'charge_density')]
                    #end if
                    nscf_path = './nscf-u-' + str(u) + '-' + str(
                        knum) + '-' + str(natoms)
                    p2q_path = nscf_path
                    nscf = generate_pwscf(
                        identifier='nscf',
                        path=nscf_path,
                        system=system,
                        #nosym = True,
                        nogamma=True,
                        dependencies=nscf_dep,
                        calculation='nscf',
                        **shared_qe)
                    sims.append(nscf)

                    if params.relax:
                        p2q_dep = [(nscf, 'orbitals'), (relax, 'structure')]
                    else:
                        p2q_dep = [(nscf, 'orbitals')]
                    #end if
                else:
                    p2q_path = scf_path
                    if params.relax:
                        p2q_dep = [(scf_inf, 'orbitals'), (relax, 'structure')]
                    else:
                        p2q_dep = [(scf_inf, 'orbitals')]
                    #end if
                #end if
                # Convert DFT Wavefunction Into HDF5 File For QMCPACK
                p2q = generate_pw2qmcpack(
                    identifier='p2q',
                    path=p2q_path,
                    job=p2q_job,
                    write_psir=False,
                    dependencies=p2q_dep,
                )
                sims.append(p2q)

                if params.print_ke_corr and not params.nscf_skip:
                    import h5py
                    nscf_dir = nscf.remdir
                    pwscf_output = nscf.input.control.outdir
                    h5_file = nscf_dir + '/' + pwscf_output + '/pwscf.pwscf.h5'
                    #Assume equal weight for all k-points
                    eig_tot = 0
                    nkpts = 0
                    if os.path.isfile(h5_file):
                        f = h5py.File(h5_file, 'r+')
                        nelect = f['electrons']['number_of_electrons'][:]

                        for group_e in f['electrons'].keys():
                            if group_e.startswith('kpoint'):
                                nkpts += 1
                                f_temp = f['electrons'][group_e]
                                for group_k in f_temp.keys():
                                    k_s_eig = [0]
                                    w = 0
                                    if group_k.startswith('spin_0'):
                                        k_s_eig = f_temp[group_k][
                                            'eigenvalues'][:]
                                        k_s_eig = k_s_eig[0:nelect[
                                            0]]  #fixed occupations from the number of electrons
                                        w = f_temp['weight'][0]
                                    elif group_k.startswith('spin_1'):
                                        k_s_eig = f_temp[group_k][
                                            'eigenvalues'][:]
                                        k_s_eig = k_s_eig[0:nelect[1]]
                                        w = f_temp['weight'][0]
                                        #pdb.set_trace()
                                    #end if
                                    eig_tot += sum(k_s_eig) * w / 2
                                #end for
                            #end if
                        #end fof
                        print nscf_dir, "e_tot eigenvalues in Ha", eig_tot / 2 - scf_ks_energy, "wigner " + str(
                            system['structure'].rwigner())
                    #end if
                #end if

                # DFT is complete, rest is QMC

                # change here for other AFM atoms
                system.rename(Co1='Co', Co2='Co', Co3='Co', folded=False)
                system.rename(Ni1='Ni', Ni2='Ni', Ni3='Ni', folded=False)

                # VMC Optimization
                linopt1 = linear(
                    energy=0.0,  # 0.95
                    unreweightedvariance=1.0,
                    reweightedvariance=0.0,  # 0.05
                    timestep=0.3,
                    samples=samples,
                    walkers=walkers,
                    warmupsteps=10,
                    blocks=blocks,
                    steps=1,
                    substeps=10,
                    maxweight=1e9,
                    gpu=True,
                    minmethod='OneShiftOnly',
                    minwalkers=0.01,
                    usebuffer=True,
                    exp0=-6,
                    bigchange=10.0,
                    alloweddifference=1e-04,
                    stepsize=0.15,
                    nstabilizers=1,
                )

                # Quasiparticle calculation
                if params.qp:
                    etot = system.particles.down_electron.count + system.particles.up_electron.count
                    upe = (etot + params.tot_mag * tl_det) / 2 - params.charge
                    downe = etot - params.charge - upe
                    system.particles.down_electron.count = downe
                    system.particles.up_electron.count = upe
                #end if

                # 1. VMC optimization is requested
                # 2. VMC optimization is done on the first element uf ulist
                # 3. VMC optimization is done on the first element of qmc_grids

                if params.vmc_opt and u == params.ulist[
                        0] and k == params.qmc_grids[0]:

                    # VMC Variance minimization

                    opt_varmin = generate_qmcpack(
                        identifier='opt-varmin',
                        path='./opt-u-' + str(u) + '-' + str(natoms) +
                        '-varmin-' + str(params.j),
                        job=opt_job,
                        input_type='basic',
                        system=system,
                        spin_polarized=True,  # jtk: needs this
                        meshfactor=1.0,
                        hybrid_rcut=params.hybrid_rcut,
                        hybrid_lmax=params.hybrid_lmax,
                        #spline_radius  = params.spline_radius,
                        twistnum=params.twistnum,
                        #bconds         = 'ppp',
                        pseudos=params.qmc_pps,
                        jastrows=[('J1', 'bspline', params.j, rcut),
                                  ('J2', 'bspline', params.j, rcut, 'init',
                                   'zero')],
                        calculations=[
                            loop(max=6, qmc=linopt1),
                            loop(max=6, qmc=linopt1)
                        ],
                        dependencies=(p2q, 'orbitals'))
                    sims.append(opt_varmin)

                    # QMC Optimization Parameters - Finer Sampling Set -- Energy Minimization
                    linopt2 = linopt1.copy()
                    linopt2.minwalkers = 0.5
                    linopt2.energy = 0.95
                    linopt2.unreweightedvariance = 0.0
                    linopt2.reweightedvariance = 0.05
                    linopt3 = linopt2.copy()
                    linopt3.minwalkers = 0.5
                    ##
                    emin_dep = []

                    # Use preliminary optimization step made of two steps
                    if not params.nopre:
                        preopt_emin = generate_qmcpack(
                            identifier='opt-emin',
                            path='./preopt-u-' + str(u) + '-' + str(natoms) +
                            '-emin-' + str(params.j),
                            job=opt_job,
                            input_type='basic',
                            system=system,
                            spin_polarized=True,  # jtk: needs this
                            meshfactor=params.meshfactor,
                            hybrid_rcut=params.hybrid_rcut,
                            hybrid_lmax=params.hybrid_lmax,
                            #spline_radius  = params.spline_radius,
                            twistnum=params.twistnum,
                            #bconds         = 'ppp',
                            pseudos=params.qmc_pps,
                            jastrows=[],
                            calculations=[loop(max=2, qmc=linopt2)],
                            dependencies=[(p2q, 'orbitals'),
                                          (opt_varmin, 'jastrow')])
                        sims.append(preopt_emin)
                        emin_dep = preopt_emin
                    else:
                        emin_dep = opt_varmin
                    #end if

                    opt_emin = generate_qmcpack(
                        identifier='opt-emin',
                        path='./opt-u-' + str(u) + '-' + str(natoms) +
                        '-emin-' + str(params.j),
                        job=opt_job,
                        input_type='basic',
                        system=system,
                        spin_polarized=True,  # jtk: needs this
                        meshfactor=params.meshfactor,
                        hybrid_rcut=params.hybrid_rcut,
                        hybrid_lmax=params.hybrid_lmax,
                        #spline_radius  = params.spline_radius,
                        twistnum=params.twistnum,
                        #bconds         = 'ppp',
                        pseudos=params.qmc_pps,
                        jastrows=[],
                        calculations=[
                            loop(max=4, qmc=linopt2),
                            loop(max=4, qmc=linopt3)
                        ],
                        dependencies=[(p2q, 'orbitals'),
                                      (emin_dep, 'jastrow')])
                    sims.append(opt_emin)

                    # 3-body jastrows

                    if params.j3:
                        j3_dep = []
                        linopt2.walkers = 16
                        linopt2.blocks = linopt2.blocks * 2
                        linopt2.samples = linopt1.samples * 2

                        j3_rcut = min(system['structure'].rwigner() - 0.0001,
                                      4.0)
                        if not params.nopre:
                            preopt_emin_J3 = generate_qmcpack(
                                identifier='opt-emin-J3',
                                path='./preopt-u-' + str(u) + '-' +
                                str(natoms) + '-emin-J3-' + str(params.j),
                                job=opt_job,
                                input_type='basic',
                                system=system,
                                spin_polarized=True,  # jtk: needs this
                                meshfactor=params.meshfactor,
                                hybrid_rcut=params.hybrid_rcut,
                                hybrid_lmax=params.hybrid_lmax,
                                #spline_radius  = params.spline_radius,
                                twistnum=params.twistnum,
                                #bconds         = 'ppp',
                                pseudos=params.qmc_pps,
                                jastrows=[('J3', 'polynomial', 3, 3, j3_rcut)],
                                calculations=[loop(max=2, qmc=linopt2)],
                                dependencies=[(p2q, 'orbitals'),
                                              (opt_emin, 'jastrow')])
                            sims.append(preopt_emin_J3)
                            j3_dep = preopt_emin_J3
                        else:
                            j3_dep = opt_emin
                        #end if

                        opt_emin_J3 = generate_qmcpack(
                            identifier='opt-emin-J3',
                            path='./opt-u-' + str(u) + '-' + str(natoms) +
                            '-emin-J3-' + str(params.j),
                            job=opt_job,
                            input_type='basic',
                            system=system,
                            spin_polarized=True,  # jtk: needs this
                            meshfactor=params.meshfactor,
                            hybrid_rcut=params.hybrid_rcut,
                            hybrid_lmax=params.hybrid_lmax,
                            #spline_radius  = params.spline_radius,
                            twistnum=params.twistnum,
                            #bconds         = 'ppp',
                            pseudos=params.qmc_pps,
                            jastrows=[('J3', 'polynomial', 3, 3, j3_rcut)],
                            calculations=[
                                loop(max=4, qmc=linopt2),
                                loop(max=4, qmc=linopt2)
                            ],
                            dependencies=[(p2q, 'orbitals'),
                                          (j3_dep, 'jastrow')])
                        sims.append(opt_emin_J3)
                    #end if
                #end if

                # VMC is complete, run DMC

                dmc_nodes = np.round(
                    np.ceil(knum * dmcnodespertwist) / minnodes) * minnodes
                dmc_job = Job(nodes=int(dmc_nodes),
                              hours=dmc_hours,
                              threads=qmc_threads,
                              app=qmcapp,
                              presub=qmc_presub)

                # Add any future estimators here
                from qmcpack_input import spindensity, skall, density
                if params.density is not None:
                    est = [spindensity(grid=params.density)]
                else:
                    est = None
                #end if

                #Initial VMC calculation to generate walkers for DMC
                calculations = [
                    vmc(
                        warmupsteps=25,
                        blocks=vmcblocks,
                        steps=1,
                        stepsbetweensamples=1,
                        walkers=walkers,
                        timestep=vmcdt,
                        substeps=4,
                        samplesperthread=int(dmcwalkers /
                                             (dmcnodespertwist * walkers)),
                    ),
                    #                                                dmc(
                    #                                                        warmupsteps =0,
                    #                                                        blocks      =dmceqblocks/4,
                    #                                                        steps       =5,
                    #                                                        timestep    =0.04,
                    #                                                        nonlocalmoves=params.tmoves,
                    #                                                        ),
                    #                                                dmc(
                    #                                                        warmupsteps =0,
                    #                                                        blocks      =dmceqblocks/4,
                    #                                                        steps       =5,
                    #                                                        timestep    =0.02,
                    #                                                        nonlocalmoves=params.tmoves,
                    #                                                        ),
                ]
                # Scan over timesteps
                if params.timesteps is None:
                    params.timesteps = [0.01]
                #end if
                for t in params.timesteps:
                    calculations.append(
                        dmc(
                            warmupsteps=dmceqblocks / 2,
                            blocks=int(dmcblocks / (np.sqrt(t) * 10)),
                            steps=10,
                            timestep=t,
                            nonlocalmoves=params.tmoves,
                        ))
                #end for

                # Prepanding name for the path
                pathpre = 'dmc'
                if params.vmc:
                    pathpre = 'vmc'
                #end if

                deps = [(p2q, 'orbitals')]

                has_jastrow = False
                # 3-body jastrow calculation with VMC or DMC
                if params.j3:
                    has_jastrow = True
                    # add j3 dependenciies
                    if params.vmc_opt:
                        deps.append((opt_emin_J3, 'jastrow'))
                    #end if

                    if params.tmoves:
                        path = './' + pathpre + '-j3-tm-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    else:
                        path = './' + pathpre + '-j3-nl-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    #end if
                #end if
                # 2-body jastrow calculation with VMC or DMC
                if params.j2:
                    has_jastrow = True
                    #add j2 dependencies
                    if params.vmc_opt:
                        deps.append((opt_emin, 'jastrow'))
                    #end if
                    if params.tmoves:
                        path = './' + pathpre + '-j2-tm-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    else:
                        path = './' + pathpre + '-j2-nl-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    #end if
                #end if
                # No jastrow calculation with VMC or DMC
                if not has_jastrow:
                    if params.tmoves:
                        path = './' + pathpre + '-j0-tm-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    else:
                        path = './' + pathpre + '-j0-nl-u-' + str(
                            u) + '-' + str(knum) + '-' + str(natoms)
                    #end if
                #end if

                det_format = 'new'
                # Optical excitation
                if params.excitation is not None:
                    path += '_' + params.excitation[
                        0] + '_' + params.excitation[1].replace(" ", "_")
                    det_format = 'old'
                #end if
                # Charged cell
                if params.charge != 0:
                    path += '_' + str(params.charge)
                #end if

                if params.qmc:
                    qmc = generate_qmcpack(seed=params.seed,
                                           skip_submit=params.qmc_skip_submit,
                                           det_format=det_format,
                                           identifier=pathpre,
                                           path=path,
                                           job=dmc_job,
                                           input_type='basic',
                                           system=system,
                                           estimators=est,
                                           meshfactor=params.meshfactor,
                                           hybrid_rcut=params.hybrid_rcut,
                                           hybrid_lmax=params.hybrid_lmax,
                                           excitation=params.excitation,
                                           pseudos=params.qmc_pps,
                                           jastrows=[],
                                           spin_polarized=True,
                                           calculations=calculations,
                                           dependencies=deps)
                    qmcs.append(qmc)
                #end if
            #end if
        #end for
    #end for
    if params.bundle:
        from bundle import bundle
        qmcb = bundle(qmcs)
        sims.append(qmcb)
    else:
        sims = sims + qmcs
        return sims
Exemplo n.º 20
0
from nexus import settings,job,run_project,obj
from nexus import generate_physical_system
from nexus import generate_pyscf

settings(
    results = '',
    sleep   = 3,
    machine = 'ws16',
    )

system = generate_physical_system(
    structure = 'H2O.xyz',
    O         = 6,
    H         = 1,
    )

scf = generate_pyscf(
    identifier = 'scf',               # log output goes to scf.out
    path       = 'h2o_pp_hf',         # directory to run in
    job        = job(serial=True),    # pyscf must run serially         
    template   = './scf_template.py', # pyscf template file
    system     = system,
    mole       = obj(                 # used to make Mole() inputs
        basis    = 'bfd-vtz',
        ecp      = 'bfd',
        symmetry = True,
        ),
    )

run_project()
Exemplo n.º 21
0
    elem_pos='''
               C  0.00000000  0.00000000  0.00000000
               H  0.00000000  0.00000000  1.10850000
               H  1.04510382  0.00000000 -0.36950000
               H -0.52255191  0.90508646 -0.36950000
               H -0.52255191 -0.90508646 -0.36950000
               ''',
)

scf = generate_pyscf(
    identifier='scf',
    path='rhf',
    job=job(serial=True),
    template='./scf_template.py',
    system=system,
    mole=obj(basis='sto-3g', ),
    checkpoint=True,
)

p2a = generate_pyscf_to_afqmc(
    identifier='p2a',
    path='rhf',
    job=job(serial=True),
    cholesky_threshold=1e-5,
    verbose=True,
    dependencies=(scf, 'wavefunction'),
)

qmc = generate_qmcpack(
    identifier='qmc',
    path='afqmc',
Exemplo n.º 22
0
    machine = 'ws16',
    )

system = generate_physical_system(
    units    = 'A',
    elem_pos = 'Ne 0 0 0',
    )

scf = generate_pyscf(
    identifier = 'scf',
    path       = 'rhf',
    job        = job(serial=True),
    template   = './scf_template.py',
    system     = system,
    mole       = obj(
        verbose  = 4,
        basis    = 'aug-cc-pvdz',
        ),
    checkpoint = True,
    )

p2a = generate_pyscf_to_afqmc(
    identifier         = 'p2a',
    path               = 'rhf',
    job                = job(serial=True),
    cholesky_threshold = 1e-5,
    dependencies       = (scf,'wavefunction'),
    )

qmc = generate_qmcpack(
    identifier   = 'qmc',
    path         = 'afqmc',
Exemplo n.º 23
0
    job        = gms_job,
    system     = h2o,
    pseudos    = ['O.BFD_V5Z.gms','H.BFD_V5Z_ANO.gms'],
    scftyp     = 'mcscf',
    runtyp     = 'energy',
    exetyp     = 'run',
    ispher     = 1,
    maxit      = 200,
    memory     = 150000000,
    dirscf     = True,
    symmetry   = 'Cnv 2',
    drt = obj(
        group  = 'C2v',
        nmcc   = 0,
        ndoc   = 4,
        nalp   = 0,
        nval   = 4,
        istsym = 1,
        mxnint = 500000,
        fors   = True,
        ),
    mcscf = obj(
        cistep = 'guga',
        maxit  = 1000,
        fullnr = True,
        acurcy = 1e-5,
        ),
    dependencies = (rhf,'orbitals')
    )
sims.append(cas)

run_project(sims)
Exemplo n.º 24
0
    elem=('C', 'C'),
    pos=[[0, 0, 0], [a / 4, a / 4, a / 4]],
    tiling=(2, 2, 2),
    kgrid=(1, 1, 1),
    kshift=(0, 0, 0),
)

scf = generate_pyscf(
    identifier='scf',
    path='rhf',
    job=job(serial=True),
    template='./scf_template.py',
    system=system,
    cell=obj(
        basis='gth-szv',
        pseudo='gth-pade',
        mesh=[25, 25, 25],
        verbose=5,
    ),
    checkpoint=True,
)

p2a = generate_pyscf_to_afqmc(
    identifier='p2a',
    path='rhf',
    job=job(serial=True),
    cholesky_threshold=1e-5,
    ao=True,
    kpoint=True,
    verbose=True,
    dependencies=(scf, 'wavefunction'),
)
Exemplo n.º 25
0
    pseudos    = ['O.BFD_V5Z.gms','H.BFD_V5Z_ANO.gms'],
    scftyp     = 'none',
    cityp      = 'guga',
    runtyp     = 'energy',
    exetyp     = 'run',
    ispher     = 1,
    maxit      = 200,
    memory     = 150000000,
    dirscf     = True,
    symmetry   = 'Cnv 2',
    cidrt = obj(
        group  = 'C2v',
        nfzc   = 0,
        ndoc   = 4,
        nalp   = 0,
        nval   = 60,
        nprt   = 2,
        istsym = 1,
        iexcit = 2,
        mxnint = 500000,
        ),
    gugdia = obj(
        prttol = 0.001,
        cvgtol = 1.0e-5,
        itermx = 1000,
        ),
    dependencies = (rhf,'orbitals')
    )

run_project()
Exemplo n.º 26
0
)

system = generate_physical_system(
    units='A',
    elem_pos='C 0 0 0',
    net_spin=2,
)

scf = generate_pyscf(
    identifier='scf',
    path='uhf',
    job=job(serial=True),
    template='./scf_template.py',
    system=system,
    mole=obj(
        verbose=4,
        basis='cc-pvtz',
    ),
    checkpoint=True,
)

p2a = generate_pyscf_to_afqmc(
    identifier='p2a',
    path='uhf',
    job=job(serial=True),
    cholesky_threshold=1e-5,
    ao=True,
    verbose=True,
    dependencies=(scf, 'wavefunction'),
)

qmc = generate_qmcpack(