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)
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)
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)
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)