예제 #1
0
파일: run.py 프로젝트: sjklipp/mechdriver
def _check_tsks(tsk_lsts, thy_dct):
    """ Loop over all of the tasks, add default keywords and parameters
        and assesses if all the input is valid
    """

    if tsk_lsts is not None:

        for tsk_lst in tsk_lsts:

            # Unpack the task
            _tsk = tsk_lst[:-1]
            if len(_tsk) == 2:
                # Case(1): spc task keywords (ESDriver)
                obj, tsk = _tsk[0], _tsk[1]
            else:
                # Case(2): task keywords (ThermoDriver, kTPDriver)
                obj, tsk = None, _tsk[0]
            key_dct = tsk_lst[-1]

            # Check if the obj is allowed
            if obj is not None:
                # Have to make lst to handle case where obj == 'all'
                obj_lst = SUPP_OBJS if obj == 'all' else (obj, )
                for _obj in obj_lst:
                    if _obj not in TSK_KEY_DCT[tsk][0]:
                        print('obj {}, not allowed for {}'.format(obj, tsk))
                        print('')
                        sys.exit()

            # Check if keyword values are allowed
            check_dct1(key_dct, TSK_VAL_DCT, (), 'Task')

            # Check keywords with thylvls as values use lvls defined in thy dct
            check_thy_lvls(key_dct, thy_dct)
예제 #2
0
def theory_dictionary(thy_str):
    """ Parse the theory.dat input for all of the user-defined level blocks.
        These blocks are formatted into several keyword-value dictionaries
        consisting of user-defined keywords as well as defaults:

            {'user-defined level name': {keyword-value dictionary for level}}

        These indiviual level dicts are packaged into an overall `thy_dct`.

        :param thy_str: theory.dat input file string
        :type thy_str: str
        :rtype: dict[str: dict[str:obj]]
    """

    # Format input to keyword-value theory dcts
    thy_blocks = ioformat.ptt.named_end_blocks(
        thy_str, 'level', footer='level')
    thy_dct = ioformat.ptt.keyword_dcts_from_blocks(thy_blocks)

    # Add defaults to each thy dictionary
    full_thy_dct = {}
    for lvl, dct in thy_dct.items():
        full_thy_dct[lvl] = automol.util.dict_.right_update(
            defaults_from_val_dct(THY_VAL_DCT), dct)

    # Check each dictionary
    for lvl, dct in full_thy_dct.items():
        check_dct1(dct, THY_VAL_DCT, THY_REQ, 'Thy-{}'.format(lvl))

    return full_thy_dct
예제 #3
0
def species_dictionary(spc_str, dat_str, geo_dct, spc_type):
    """ Read each of the species input files:
            (1) species.csv: CSV file with basic info like names,inchis,mults
            (2) species.dat:
            (3) *.xyz: XYZ-files with geometries

        :param job_path: directory path where the input file(s) exist
        :type job_path: str
        :rtype dict[str: dict]
    """

    # Parse out the dcts from the strings
    spc_dct = mechanalyzer.parser.spc.build_spc_dct(spc_str, spc_type)

    dat_blocks = ioformat.ptt.named_end_blocks(dat_str, 'spc', footer='spc')
    dat_dct = ioformat.ptt.keyword_dcts_from_blocks(dat_blocks)

    # Merge all of the species inputs into a dictionary
    mod_spc_dct, glob_dct = modify_spc_dct(spc_dct, dat_dct, geo_dct)

    # Assess if the species.dat information is valid
    for name, dct in mod_spc_dct.items():
        # last comment breaks since TS only partially built at this stage
        # i.e. there is not a mult, that comes from the build later
        # prolly fine, since we add required stuff for TS ourselves
        # probably just check if stuff provided that is not supported
        # req_lst = SPC_REQ if 'ts' not in name else SPC_REQ+TS_REQ
        req_lst = SPC_REQ if 'ts' not in name else ()
        val_dct = SPC_VAL_DCT if 'ts' not in name else TS_VAL_DCT
        check_dct1(dct, val_dct, req_lst, 'Spc-{}'.format(name))

    return mod_spc_dct, glob_dct
예제 #4
0
파일: run.py 프로젝트: sjklipp/mechdriver
def input_dictionary(run_str):
    """ Parses the `input` block and builds a
        dictionary of keywords and their corresponding values.

        :param run_str: input string of the run.dat block
        :type run_str: str
        :rtype: dict[str: obj]
    """

    # Read the input block
    inp_block = ioformat.ptt.end_block(run_str, 'input', footer='input')
    inp_dct = ioformat.ptt.keyword_dct_from_block(inp_block)

    # Add defaults to the dictionary
    inp_dct = automol.util.dict_.right_update(
        defaults_from_val_dct(RUN_INP_VAL_DCT), inp_dct)

    # Check the dictionary
    check_dct1(inp_dct, RUN_INP_VAL_DCT, RUN_INP_REQ, 'Run-Input')

    return inp_dct
예제 #5
0
파일: thy.py 프로젝트: sjklipp/mechdriver
def theory_dictionary(thy_str):
    """ Parse the theory.dat file
    """

    # Format input to keyword-value theory dcts
    thy_blocks = ioformat.ptt.named_end_blocks(thy_str,
                                               'level',
                                               footer='level')
    thy_dct = ioformat.ptt.keyword_dcts_from_blocks(thy_blocks)

    # Add defaults to each thy dictionary
    full_thy_dct = {}
    for lvl, dct in thy_dct.items():
        full_thy_dct[lvl] = automol.util.dict_.right_update(
            defaults_from_val_dct(THY_VAL_DCT), dct)

    # Check each dictionary
    for lvl, dct in full_thy_dct.items():
        check_dct1(dct, THY_VAL_DCT, THY_REQ, 'Thy-{}'.format(lvl))

    return full_thy_dct