def setUp(self): # create a temporary directories self.main_folder = tempfile.mkdtemp() configs = set_configs(main_folder=self.main_folder) self.configs = configs ase_db_file_binaries = get_data_filename( 'data/db_ase/binaries_lowest_energy_ghiringhelli2015.json') results_binaries_lasso = get_data_filename( 'data/viewer_files/l1_l0_dim2_for_viewer.csv') results_metal_non_metal = get_data_filename( 'data/viewer_files/tutorial_metal_non_metal_2017.csv') results_topological_ins = get_data_filename( 'data/viewer_files/tutorial_topological_insulators_2017.csv') control_file_binaries = get_data_filename( 'data/viewer_files/binaries_control.json') self.ase_atoms_binaries = read_ase_db(db_path=ase_db_file_binaries) self.results_binaries_lasso = results_binaries_lasso self.results_metal_non_metal = results_metal_non_metal self.control_file_binaries = control_file_binaries self.results_topological_ins = results_topological_ins
'/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_166.db', '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_194.db', '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_221.db', '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_225.db', '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_227.db', '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_229.db' ] # ase_db_file_vac20 = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_vac0.2.db' # ase_db_file_pristine = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_7_classes.db' # ase_db_file_vac20 = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_vac0.2.db' # ase_atoms_list_vac20 = read_ase_db(db_path=ase_dpb_file_vac20) ase_atoms_list_pristine = [] for db_path in ase_db_file_pristine: ase_atoms_list_pristine.extend(read_ase_db(db_path=db_path)) symprec = 1.e-9 angle_tolerance = -1.0 y_true = [] for idx, ase_atom_pristine in enumerate(ase_atoms_list_pristine): if idx % (int(len(ase_atoms_list_pristine) / 10) + 1) == 0: logger.debug("Reading ASE atom structure: file {0}/{1}".format( idx + 1, len(ase_atoms_list_pristine))) y_true.extend( get_spacegroup(ase_atom_pristine, symprec=symprec, angle_tolerance=angle_tolerance)) true_labels_filename = 'y_true_list' + '_symprec' + str( symprec) + '_angletol' + str(angle_tolerance)
random_rotation=False, random_rotation_before=True, cell_type='standard_no_symmetries', optimal_supercell=False))] # ============================================================================= # Descriptor calculation # ============================================================================= # desc_file_name = 'desc_calc_trial' desc_file_name = 'try1' # ase_db_file = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_1e-9_139.db' ase_db_file = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_7_classes.db' # ase_db_file = '/home/ziletti/Documents/calc_xray/2d_nature_comm/db_ase/elemental_solids_ncomms_1e-3_1e-6_pristine.db' ase_atoms_list = read_ase_db(db_path=ase_db_file) desc_file_path = calc_descriptor( descriptor=descriptor, configs=configs, ase_atoms_list=ase_atoms_list, tmp_folder=tmp_folder, desc_folder=desc_folder, desc_info_file=desc_info_file, desc_file=str(desc_file_name) + '.tar.gz', format_geometry='aims', operations_on_structure=operations_on_structure_list[1], nb_jobs=-1) desc_file_path = '/home/ziletti/Documents/nomadml_docs/desc_folder/try1.tar.gz' target_list, structure_list = load_descriptor(desc_files=desc_file_path,
def setUp(self): ase_db_file_binaries = get_data_filename( 'data/db_ase/binaries_ghiringhelli2015.json') self.ase_atoms_binaries = read_ase_db(db_path=ase_db_file_binaries)
# sys.exit(1) # setup folder and files main_folder = '/home/ziletti/Documents/nomadml_docs/' tmp_folder = os.path.abspath( os.path.normpath(os.path.join(main_folder, 'tmp'))) desc_folder = os.path.abspath( os.path.normpath(os.path.join(main_folder, 'desc_folder'))) desc_info_file = os.path.abspath( os.path.normpath(os.path.join(desc_folder, 'desc_info.json.info'))) descriptor = PRDF(configs=configs) desc_file_name = 'prdf_binaries' ase_db_file_binaries = '/home/ziletti/PycharmProjects/ai4materials/ai4materials/data/db_ase/binaries_ghiringhelli2015.db' ase_atoms_list = read_ase_db(db_path=ase_db_file_binaries) desc_file_path = calc_descriptor(descriptor=descriptor, configs=configs, ase_atoms_list=ase_atoms_list, tmp_folder=tmp_folder, desc_folder=desc_folder, desc_info_file=desc_info_file, desc_file=str(desc_file_name) + '.tar.gz', format_geometry='aims', nb_jobs=-1) desc_file_path = '/home/ziletti/Documents/nomadml_docs/desc_folder/prdf_binaries.tar.gz' target_list, structure_list = load_descriptor(desc_files=desc_file_path, configs=configs)
# write an ase db to file for each spacegroup # ase_db_file = write_ase_db(ase_atoms, main_folder, db_name=proto_names[idx_proto], overwrite=True, # folder_name='db_ase_prototypes') # ase_db_files.append(ase_db_file) # for ase_db_file in ase_db_files: # ase_atoms_list = read_ase_db(db_path=ase_db_file) # print(ase_db_file, len(ase_atoms_list)) # ============================================================================= # Descriptor calculation # ============================================================================= for idx_db, db_proto in enumerate(db_protos): ase_atoms_list = read_ase_db(db_path=ase_db_files[idx_db])[:] print('{} structures for prototype {}'.format(len(ase_atoms_list), db_proto[0])) for idx_rot in range(nb_rotations): desc_file_path = calc_descriptor_in_memory( descriptor=descriptor, configs=configs, ase_atoms_list=ase_atoms_list, tmp_folder=configs['io']['tmp_folder'], desc_folder=configs['io']['desc_folder'], # desc_file='try1.tar.gz', desc_file='{0}_target_nb_atoms{1}_rotid{2}_disp0002.tar.gz'. format(db_proto[0], target_nb_atoms, idx_rot),