示例#1
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # Set the theoretical method
    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    # Build the geometry
    geo_str, zmat_val_str, _ = fill.geometry_strings(geo, frozen_coordinates)

    # Check options
    scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)
    _ = mol_options
    _ = machine_options
    _ = gen_lines

    # Set the coordinate system
    if automol.geom.is_valid(geo):
        coord_sys = 'xyz'
    elif automol.zmat.is_valid(geo):
        coord_sys = 'zmat'

    # No TS optimizer based on manual
    assert not saddle

    # No Frozen coordinates allowed based on manual
    assert not frozen_coordinates

    # Set the gen lines blocks
    # if gen_lines is not None:
    #     gen_lines = '\n'.join(gen_lines[1]) if 1 in gen_lines else ''
    # else:
    #     gen_lines = ''

    fill_dct = {
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VALS: zmat_val_str,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.SCF_METHOD: prog_reference,
        fill.TemplateKey.SCF_OPTIONS: '\n'.join(scf_options),
        fill.TemplateKey.CORR_METHOD: prog_method,
        fill.TemplateKey.CORR_OPTIONS: '\n'.join(corr_options),
        fill.TemplateKey.JOB_OPTIONS: '\n'.join(job_options),
        fill.TemplateKey.COORD_SYS: coord_sys
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct)
示例#2
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # Set the theoretical method
    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    geo_str, zmat_var_val_str, zmat_const_val_str = fill.geometry_strings(
        geo, frozen_coordinates)

    _ = machine_options
    _ = casscf_options
    _ = job_options
    _ = zmat_var_val_str
    _ = zmat_const_val_str
    _ = gen_lines

    memory = memory * 1000.0

    if elstruct.par.Method.is_correlated(method):
        assert not corr_options

    numerical = False
    nprocs = 1
    coord_sys = 'xyz'

    if saddle:
        raise NotImplementedError

    fill_dct = {
        fill.TemplateKey.NPROCS: nprocs,
        fill.TemplateKey.NUMERICAL: numerical,
        fill.TemplateKey.COORD_SYS: coord_sys,
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.REFERENCE: prog_reference,
        fill.TemplateKey.METHOD: prog_method,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.SCF_OPTIONS: ','.join(scf_options),
        fill.TemplateKey.MOL_OPTIONS: ','.join(mol_options),
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.JOB_KEY: job_key,
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct,
                          remove_whitespace=False)
示例#3
0
def write_input(job_key, geo, charge, mult, method, basis, orb_restricted,
                # molecule options
                mol_options=(),
                # machine options
                memory=1, comment='', machine_options=(),
                # theory options
                scf_options=(), casscf_options=(), corr_options=(),
                # generic options
                gen_lines=None,
                # job options
                job_options=(), frozen_coordinates=(), saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # reset jobtype for saddle point
    job_typ = JOB_DCT[job_key]
    job_typ = 'ts' if job_typ == 'opt' and saddle else job_typ
    # For TS with inital Hessian we might have to run a combined job...

    # set correlated method; check if multiref
    prog_method, _, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    if method == '':
        '   METHOD       {}'.format(prog_method)
    else:
        method = (
            'EXCHANGE  <>\n'
            'CORRELATION <>'
        )
    # maybe just add grid here for now?
    unres = 'false' if orb_restricted else 'true'

    # set the guess options (look at gauss)

    # Set the geometry
    geo_str, zmat_val_str, _ = fill.geometry_strings(geo, frozen_coordinates)

    # Set coords for optimization (job options I guess?)
    # opt_coords = {
    #     'cart': 0,
    #     'red-intl': 1,
    #     'zma-intl': 2
    # }
    # LINE = 'GEOM_OPT_COORDS   ${opt_coords}'

    # Set the memory; convert from GB to MB
    memory_mb = int(memory * 1000.0)

    # Evaluate options
    # scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    # casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    # corr_options = fill.evaluate_options(corr_options, OPTION_EVAL_DCT)
    # job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)
    # mol_options = fill.evaluate_options(mol_options, OPTION_EVAL_DCT)
    # machine_options = fill.evaluate_options(machine_options, OPTION_EVAL_DCT)
    _ = scf_options
    _ = casscf_options
    _ = corr_options
    _ = job_options
    _ = mol_options
    _ = machine_options
    _ = gen_lines

    # Create a dictionary to fille the template
    fill_dct = {
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VALS: zmat_val_str,
        fill.TemplateKey.JOB_KEY: job_typ,
        'method': method,
        'unrestricted': unres,
        fill.TemplateKey.MEMORY: memory_mb,
    }

    return build_mako_str(
        template_file_name='all.mako',
        template_src_path=TEMPLATE_DIR,
        template_keys=fill_dct,
        remove_whitespace=False)
示例#4
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # Build the geometry object for the job
    geo_str, zmat_var_val_str, zmat_const_val_str = fill.geometry_strings(
        geo, frozen_coordinates)

    # Set theory methods and options
    if elstruct.par.Method.is_correlated(method):
        assert not corr_options
    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    if (prog_reference == elstruct.par.Reference.ROHF and job_key
            in (elstruct.par.Job.GRADIENT, elstruct.par.Job.HESSIAN)):
        job_options = list(job_options)
        job_options.insert(0, 'EnOnly')

    # Build various options
    scf_guess_options, scf_options = fill.intercept_scf_guess_option(
        scf_options, OPTION_EVAL_DCT)
    casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)
    if saddle:
        job_options += ('CALCFC', 'TS', 'NOEIGEN', 'MAXCYCLES=60')

    # Set the gen lines blocks
    gen_lines_1, _, _ = fill.build_gen_lines(gen_lines)

    # Build the dictionary to fill the Mako template
    fill_dct = {
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.MACHINE_OPTIONS: '\n'.join(machine_options),
        fill.TemplateKey.REFERENCE: prog_reference,
        fill.TemplateKey.METHOD: prog_method,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.SCF_OPTIONS: ','.join(scf_options),
        fill.TemplateKey.SCF_GUESS_OPTIONS: ','.join(scf_guess_options),
        fill.TemplateKey.MOL_OPTIONS: ','.join(mol_options),
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VAR_VALS: zmat_var_val_str,
        fill.TemplateKey.ZMAT_CONST_VALS: zmat_const_val_str,
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.JOB_OPTIONS: ','.join(job_options),
        fill.TemplateKey.GEN_LINES: gen_lines_1,
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct,
                          remove_whitespace=False)
示例#5
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # Set the spin
    spin = mult - 1

    # set correlated method; check if multiref
    core_method, method1, corr_options, gen_lines = set_method_and_options(
        method, corr_options, gen_lines)
    method2, prog_reference, prog_basis = fill.program_method_names(
        PROG, core_method, basis, mult, orb_restricted)

    # Set the program method to one of the following
    prog_method = method1 if method1 else method2

    # Reset the prog_method again to account for hf, cassf (this is dumb...)
    if prog_method not in ('hf', 'rhf', 'uhf', 'casscf'):
        corr_method = prog_method
    else:
        corr_method = ''
    # print('molpro method test since I cant write code...')
    # print(prog_reference, corr_method)

    # Set the geometry (combine opt+constrainted coordinates
    geo_str, zmat_vval_str, zmat_cval_str = fill.geometry_strings(
        geo, frozen_coordinates)
    zmat_val_str = zmat_vval_str + '\n' + zmat_cval_str

    # Set the memory; convert from GB to MW
    memory_mw = int(memory * (1024.0 / 8.0))

    # Set the job directives and options
    # mol_options = fill.evaluate_options(mol_options, OPTION_EVAL_DCT)
    scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    corr_options = fill.evaluate_options(corr_options, OPTION_EVAL_DCT)
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)

    # Make no scf method if calling a multiref method
    ismultiref = elstruct.par.Method.is_multiref(method)
    if ismultiref:
        scf_options = []
        prog_reference = ''

    if saddle:
        job_options += ('root=2', )

    job_directives = [','.join(job_options)]
    if frozen_coordinates:
        job_directives.append('inactive,' + ','.join(frozen_coordinates))

    if job_key == 'hessian':
        job_directives.append('print,hessian,low=5')

    # Set the gen lines blocks
    gen_lines_1, gen_lines_2, gen_lines_3 = fill.build_gen_lines(
        gen_lines, line3='molpro_energy=energy\nshow[1,e25.15],molpro_energy')

    # Create a dictionary to fille the template
    fill_dct = {
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.MEMORY: memory_mw,
        fill.TemplateKey.MACHINE_OPTIONS: '\n'.join(machine_options),
        fill.TemplateKey.MOL_OPTIONS: '\n'.join(mol_options),
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VALS: zmat_val_str,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.SPIN: spin,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.SCF_METHOD: prog_reference,
        fill.TemplateKey.SCF_OPTIONS: ','.join(scf_options),
        fill.TemplateKey.ISMULTIREF: ismultiref,
        fill.TemplateKey.CASSCF_OPTIONS: '\n'.join(casscf_options),
        fill.TemplateKey.CORR_METHOD: corr_method,
        fill.TemplateKey.CORR_OPTIONS: ','.join(corr_options),
        fill.TemplateKey.JOB_OPTIONS: ';'.join(job_directives),
        fill.TemplateKey.GEN_LINES_1: gen_lines_1,
        fill.TemplateKey.GEN_LINES_2: gen_lines_2,
        fill.TemplateKey.GEN_LINES_3: gen_lines_3
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct,
                          remove_whitespace=False)
示例#6
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    _ = saddle

    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    geo_str, zmat_val_str, _ = fill.geometry_strings(geo, frozen_coordinates)

    scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    _ = casscf_options
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)

    # Set the gen lines blocks
    gen_lines_1, _, _ = fill.build_gen_lines(gen_lines)

    fill_dct = {
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.MACHINE_OPTIONS: '\n'.join(machine_options),
        fill.TemplateKey.MOL_OPTIONS: '\n'.join(mol_options),
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VALS: zmat_val_str,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.SCF_METHOD: prog_reference,
        fill.TemplateKey.SCF_OPTIONS: ','.join(scf_options),
        fill.TemplateKey.CORR_METHOD: prog_method,
        fill.TemplateKey.CORR_OPTIONS: ','.join(corr_options),
        fill.TemplateKey.JOB_OPTIONS: ';'.join(job_options),
        fill.TemplateKey.GEN_LINES: gen_lines_1,
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct,
                          remove_whitespace=False)
示例#7
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    frozen_dis_strs, frozen_ang_strs, frozen_dih_strs = (
        _frozen_coordinate_strings(geo, frozen_coordinates))

    # Set the theoretical method
    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    geo_str, zmat_vval_str, zmat_cval_str = fill.geometry_strings(
        geo, frozen_coordinates)
    zmat_val_str = zmat_vval_str + '\n' + zmat_cval_str

    if not elstruct.par.Method.is_correlated(method):
        assert not corr_options

    # scf_type pk breaks for H atom b3lyp
    # print('OPTDCT', OPTION_EVAL_DCT)
    # print('mol_options1', mol_options)
    # mol_options = fill.evaluate_options(mol_options, OPTION_EVAL_DCT)
    scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)
    # print('mol_options2', mol_options)

    if saddle:
        job_options += (
            'set full_hess_every 0',
            'set opt_type ts',
        )

    # Set the SCF Type
    if 'df-' in method:
        scf_typ = 'df'
        mp2_typ = 'df'
    else:
        if automol.zmat.is_valid(geo):
            is_atom = bool(automol.zmat.count(geo) == 1)
            is_diatom = bool(automol.zmat.count(geo) == 2)
        else:
            is_atom = automol.geom.is_atom(geo)
            is_diatom = automol.geom.is_atom(geo)
        scf_typ = 'pk' if not (is_atom or is_diatom) else 'direct'
        mp2_typ = 'conv'

    # Set the gen lines blocks
    if gen_lines is not None:
        gen_lines = '\n'.join(gen_lines[1]) if 1 in gen_lines else ''
    else:
        gen_lines = ''

    fill_dct = {
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.MACHINE_OPTIONS: '\n'.join(machine_options),
        fill.TemplateKey.MOL_OPTIONS: '\n'.join(mol_options),
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.ZMAT_VALS: zmat_val_str,
        fill.TemplateKey.BASIS: prog_basis,
        fill.TemplateKey.METHOD: prog_method,
        fill.TemplateKey.REFERENCE: prog_reference,
        fill.TemplateKey.SCF_OPTIONS: '\n'.join(scf_options),
        'scf_typ': scf_typ,
        'mp2_typ': mp2_typ,
        fill.TemplateKey.CORR_OPTIONS: '\n'.join(corr_options),
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.JOB_OPTIONS: '\n'.join(job_options),
        fill.TemplateKey.FROZEN_DIS_STRS: frozen_dis_strs,
        fill.TemplateKey.FROZEN_ANG_STRS: frozen_ang_strs,
        fill.TemplateKey.FROZEN_DIH_STRS: frozen_dih_strs,
        fill.TemplateKey.GEN_LINES: '\n'.join(gen_lines),
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct,
                          remove_whitespace=False)
示例#8
0
def write_input(
        job_key,
        geo,
        charge,
        mult,
        method,
        basis,
        orb_restricted,
        # molecule options
        mol_options=(),
        # machine options
        memory=1,
        comment='',
        machine_options=(),
        # theory options
        scf_options=(),
        casscf_options=(),
        corr_options=(),
        # generic options
        gen_lines=None,
        # job options
        job_options=(),
        frozen_coordinates=(),
        saddle=False):
    """ Write an input file string for an electronic structure calculation
        by processing all of the information and using it to fill in
        a Mako template of the input file.

        :param job_key: job contained in the input file
        :type job_key: str
        :param geo: cartesian or z-matrix geometry
        :type geo: tuple
        :param charge: molecular charge
        :type charge: int
        :param mult: spin multiplicity
        :type mult: int
        :param method: electronic structure method
        :type method: str
        :param basis: basis set
        :type basis: str
        :param orb_restricted: parameter designating if restriced refrence used
        :type orb_restricted: bool
        :param mol_options: options for the molecule block
        :type mol_options: tuple[str]
        ;param memory: memory in GB
        :type memory: int
        :param comment: a comment string to be placed at the top of the file
        :type comment: str
        :param machine_options: machine directives
            (num procs, num threads, etc.)
        :type machine_options: tuple[str]
        :param scf_options: scf method directives
        :type scf_options: tuple[str]
        :param casscf_options: casscf method directives
        :type casscf_options: tuple[str]
        :param corr_options: correlation method directives
        :type corr_options: tuple[str]
        :param job_options: geometry optimization routine directives
        :type job_options: tuple[str]
        :param frozen_coordinates: only with z-matrix geometries; list of
            coordinate names to freeze
        :type fozen_coordinates: tuple[str]
        :param saddle: parameter signifiying a saddle point calculation
        :type saddle: bool
        :param gen_lines: generic lines for the input file
        :type gen_lines: dict[idx:str]
    """

    # set correlated method; check if multiref
    prog_method, prog_reference, prog_basis = fill.program_method_names(
        PROG, method, basis, mult, orb_restricted)

    # Build the geometry object for the job
    geo_str, zmat_val_str, _ = fill.geometry_strings(geo, frozen_coordinates)

    geo_str = '\n'.join(
        [' '.join(string.split()) for string in geo_str.splitlines()])
    zmat_val_str = '\n'.join(
        [' '.join(string.split()) for string in zmat_val_str.splitlines()])
    zmat_val_str += '\n'

    # Set options for coupled cluster
    corr_options = _set_cc_prog(method, prog_reference)

    # Unused options
    _ = mol_options
    _ = machine_options

    scf_options = fill.evaluate_options(scf_options, OPTION_EVAL_DCT)
    casscf_options = fill.evaluate_options(casscf_options, OPTION_EVAL_DCT)
    job_options = fill.evaluate_options(job_options, OPTION_EVAL_DCT)

    numerical = None

    if automol.geom.is_valid(geo):
        coord_sys = 'CARTESIAN'
    elif automol.zmat.is_valid(geo):
        coord_sys = 'INTERNAL'

    # Set the gen lines blocks
    gen_lines_1, _, _ = fill.build_gen_lines(gen_lines)

    # Write the input file string
    fill_dct = {
        fill.TemplateKey.COMMENT: comment,
        fill.TemplateKey.MEMORY: memory,
        fill.TemplateKey.CHARGE: charge,
        fill.TemplateKey.MULT: mult,
        fill.TemplateKey.GEOM: geo_str,
        fill.TemplateKey.COORD_SYS: coord_sys,
        fill.TemplateKey.ZMAT_VAR_VALS: zmat_val_str,
        fill.TemplateKey.BASIS: prog_basis.upper(),
        fill.TemplateKey.METHOD: prog_method.upper(),
        fill.TemplateKey.REFERENCE: prog_reference.upper(),
        fill.TemplateKey.SCF_OPTIONS: '\n'.join(scf_options),
        fill.TemplateKey.CORR_OPTIONS: '\n'.join(corr_options),
        fill.TemplateKey.JOB_KEY: job_key,
        fill.TemplateKey.JOB_OPTIONS: '\n'.join(job_options),
        fill.TemplateKey.GEN_LINES: gen_lines_1,
        fill.TemplateKey.SADDLE: saddle,
        fill.TemplateKey.NUMERICAL: numerical
    }

    return build_mako_str(template_file_name='all.mako',
                          template_src_path=TEMPLATE_DIR,
                          template_keys=fill_dct)