Exemplo n.º 1
0
def save_cscan(cscn_run_fs, cscn_save_fs, scn_typ,
               constraint_dct, mod_thy_info, in_zma_fs=True):
    """ save the scans that have been run so far
    """

    if not cscn_run_fs[1].exists([constraint_dct]):
        print("No scan to save. Skipping...")
    else:
        locs_lst = []
        for locs1 in cscn_run_fs[2].existing([constraint_dct]):
            if cscn_run_fs[2].exists(locs1):
                for locs2 in cscn_run_fs[3].existing(locs1):

                    # Set run filesys
                    run_path = cscn_run_fs[-1].path(locs2)
                    run_fs = autofile.fs.run(run_path)
                    print("Reading from scan run at {}".format(run_path))

                    # Save the structure
                    saved = filesys.save_struct(
                        run_fs, cscn_save_fs, locs2, _set_job(scn_typ),
                        mod_thy_info, in_zma_fs=in_zma_fs)

                    # Add to locs lst if the structure is saved
                    if saved:
                        locs_lst.append(locs2)
            else:
                print("No scan to save. Skipping...")

        # Build the trajectory file
        if locs_lst:
            _write_traj(constraint_dct, cscn_save_fs, mod_thy_info, locs_lst)
Exemplo n.º 2
0
def save_scan(scn_run_fs, scn_save_fs, scn_typ,
              coo_names, mod_thy_info, in_zma_fs=False):
    """ save the scans that have been run so far
    """

    if not scn_run_fs[1].exists([coo_names]):
        print("No scan to save. Skipping...")
    else:
        locs_lst = []
        for locs in scn_run_fs[-1].existing([coo_names]):

            # Set run filesys
            run_path = scn_run_fs[-1].path(locs)
            run_fs = autofile.fs.run(run_path)
            print("Reading from scan run at {}".format(run_path))

            # Save the structure
            saved = filesys.save_struct(
                run_fs, scn_save_fs, locs, _set_job(scn_typ),
                mod_thy_info, in_zma_fs=in_zma_fs)

            # Add to locs lst if the structure is saved
            if saved:
                locs_lst.append(locs)

        # Build the trajectory file
        if locs_lst:
            _write_traj(coo_names, scn_save_fs, mod_thy_info, locs_lst)
Exemplo n.º 3
0
def _optimize_atom(spc_info, zma_init, mod_thy_info, thy_run_fs, cnf_save_fs,
                   run_fs, overwrite, opt_script_str, **opt_kwargs):
    """ Deal with an atom separately
    """

    geo, zma = _init_geom_opt(zma_init, spc_info, mod_thy_info, run_fs,
                              thy_run_fs, opt_script_str, overwrite,
                              **opt_kwargs)

    if geo is not None and zma is not None:
        locs = [autofile.schema.generate_new_conformer_id()]
        job = elstruct.Job.OPTIMIZATION
        filesys.save_struct(run_fs,
                            cnf_save_fs,
                            locs,
                            job,
                            mod_thy_info,
                            zma_locs=(0, ),
                            in_zma_fs=False)
        conf_found = True
    else:
        conf_found = False

    return conf_found
Exemplo n.º 4
0
def _optimize_molecule(spc_info,
                       zma_init,
                       mod_thy_info,
                       thy_run_fs,
                       thy_save_fs,
                       cnf_save_fs,
                       run_fs,
                       opt_script_str,
                       overwrite,
                       kickoff_size=0.1,
                       kickoff_backward=False,
                       **opt_kwargs):
    """ Optimize a proper geometry
    """

    # Optimize the initial geometry
    geo, zma = _init_geom_opt(zma_init, spc_info, mod_thy_info, run_fs,
                              thy_run_fs, opt_script_str, overwrite,
                              **opt_kwargs)

    # If connected, check for imaginary modes and fix them if possible
    if automol.geom.connected(geo):

        # Remove the imaginary mode
        geo, imag_fix_needed = _remove_imag(spc_info,
                                            geo,
                                            mod_thy_info,
                                            thy_run_fs,
                                            run_fs,
                                            kickoff_size,
                                            kickoff_backward,
                                            overwrite=overwrite)

        # Recheck connectivity for imag-checked geometry
        if geo is not None:

            conf_found = True
            if automol.geom.connected(geo):

                print('\nSaving structure as the first conformer...')
                locs = [autofile.schema.generate_new_conformer_id()]
                job = elstruct.Job.OPTIMIZATION
                filesys.save_struct(run_fs,
                                    cnf_save_fs,
                                    locs,
                                    job,
                                    mod_thy_info,
                                    zma_locs=(0, ),
                                    in_zma_fs=False,
                                    cart_to_zma=imag_fix_needed)

            else:

                print('Saving disconnected species...')
                _, opt_ret = es_runner.read_job(job=elstruct.Job.OPTIMIZATION,
                                                run_fs=run_fs)
                structure.instab.write_instab(zma_init,
                                              zma,
                                              thy_save_fs,
                                              mod_thy_info[1:4],
                                              opt_ret,
                                              zma_locs=(0, ),
                                              save_cnf=True)

        else:

            print('\n No geom found...')
            conf_found = False

    else:

        print('Saving disconnected species...')
        conf_found = False
        _, opt_ret = es_runner.read_job(job=elstruct.Job.OPTIMIZATION,
                                        run_fs=run_fs)
        structure.instab.write_instab(zma_init,
                                      zma,
                                      thy_save_fs,
                                      mod_thy_info[1:4],
                                      opt_ret,
                                      zma_locs=(0, ),
                                      save_cnf=True)

    # Save geom in thy filesys if a good geom is found
    if conf_found:
        thy_save_fs[-1].create(mod_thy_info[1:4])
        thy_save_path = thy_save_fs[-1].path(mod_thy_info[1:4])
        thy_save_fs[-1].file.geometry.write(geo, mod_thy_info[1:4])

        print('Saving reference geometry')
        print(" - Save path: {}".format(thy_save_path))

    return conf_found