1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| import yaml import pandas as pd import numpy as np from glob import glob
def main(): with open(glob("*.result.yaml")[0], "r") as file: data = yaml.safe_load(file)
configurations_data = data["configurations"] is_index_list = [] for index, configuration_id in enumerate(configurations_data.keys(), 1): configuration_list = configurations_data[configuration_id]["configuration"] pd_data = pd.DataFrame(configuration_list) is_index = (pd_data[pd_data.iloc[:, 0] != "0"].index).to_list()
is_index_list.append(is_index)
print("configuration 1-10 interstitial index list:") print(np.array(is_index_list)) print("\n")
print("same interstitial index between two configuration:") same_count_list = [] for j in range(0, 9): for k in range(j + 1, 10): common_elements = set(is_index_list[j]) & set(is_index_list[k]) count = len(common_elements) same_count_list.append(count) print( f"configuration {j+1}, {k+1}, the number of same vacancy index is: {count}." )
count_series = pd.Series(same_count_list) print(f"\nTotal interstitial num is {len(is_index_list[0])};") print(count_series.describe())
if __name__ == "__main__": main()
|