增加扩胞逻辑
This commit is contained in:
@@ -214,103 +214,103 @@ class DatabaseAnalyzer:
|
||||
return self.scheduler.submit_slurm_job(script, script_path)
|
||||
|
||||
|
||||
# 更新 _compute_statistics 方法
|
||||
# 更新 _compute_statistics 方法
|
||||
|
||||
def _compute_statistics(self, report: DatabaseReport):
|
||||
"""计算统计数据(含扩胞分析)"""
|
||||
def _compute_statistics(self, report: DatabaseReport):
|
||||
"""计算统计数据(含扩胞分析)"""
|
||||
|
||||
for info in report.all_structures:
|
||||
if info.is_valid:
|
||||
report.valid_files += 1
|
||||
else:
|
||||
report.invalid_files += 1
|
||||
continue
|
||||
|
||||
if not info.contains_target_cation:
|
||||
continue
|
||||
|
||||
report.cation_containing_count += 1
|
||||
|
||||
for anion in info.anion_types:
|
||||
report.anion_distribution[anion] = \
|
||||
report.anion_distribution.get(anion, 0) + 1
|
||||
|
||||
if info.anion_mode == "single":
|
||||
report.single_anion_count += 1
|
||||
elif info.anion_mode == "mixed":
|
||||
report.mixed_anion_count += 1
|
||||
|
||||
# 根据阴离子模式过滤
|
||||
if self.anion_mode == "single" and info.anion_mode != "single":
|
||||
continue
|
||||
if self.anion_mode == "mixed" and info.anion_mode != "mixed":
|
||||
continue
|
||||
if info.anion_mode == "none":
|
||||
continue
|
||||
|
||||
# 各项统计
|
||||
if info.has_oxidation_states:
|
||||
report.with_oxidation_states += 1
|
||||
else:
|
||||
report.without_oxidation_states += 1
|
||||
|
||||
# Li共占位统计(修改)
|
||||
if info.cation_with_vacancy:
|
||||
report.cation_with_vacancy_count += 1
|
||||
if info.cation_with_other_cation:
|
||||
report.cation_with_other_cation_count += 1
|
||||
|
||||
if info.anion_has_partial_occupancy:
|
||||
report.anion_partial_occupancy_count += 1
|
||||
if info.is_binary_compound:
|
||||
report.binary_compound_count += 1
|
||||
if info.has_water_molecule:
|
||||
report.has_water_count += 1
|
||||
if info.has_radioactive_elements:
|
||||
report.has_radioactive_count += 1
|
||||
|
||||
# 可处理性
|
||||
if info.can_process:
|
||||
if info.needs_expansion:
|
||||
report.needs_preprocessing += 1
|
||||
for info in report.all_structures:
|
||||
if info.is_valid:
|
||||
report.valid_files += 1
|
||||
else:
|
||||
report.directly_processable += 1
|
||||
else:
|
||||
report.cannot_process += 1
|
||||
if info.skip_reason:
|
||||
for reason in info.skip_reason.split("; "):
|
||||
report.skip_reasons_summary[reason] = \
|
||||
report.skip_reasons_summary.get(reason, 0) + 1
|
||||
report.invalid_files += 1
|
||||
continue
|
||||
|
||||
# 扩胞统计(新增)
|
||||
exp_info = info.expansion_info
|
||||
factor = exp_info.expansion_factor
|
||||
if not info.contains_target_cation:
|
||||
continue
|
||||
|
||||
if not exp_info.needs_expansion:
|
||||
report.expansion_stats['no_expansion_needed'] += 1
|
||||
elif not exp_info.can_expand:
|
||||
report.expansion_stats['cannot_expand'] += 1
|
||||
elif factor == 2:
|
||||
report.expansion_stats['expansion_factor_2'] += 1
|
||||
elif factor == 3:
|
||||
report.expansion_stats['expansion_factor_3'] += 1
|
||||
elif 4 <= factor <= 8:
|
||||
report.expansion_stats['expansion_factor_4_8'] += 1
|
||||
else:
|
||||
report.expansion_stats['expansion_factor_large'] += 1
|
||||
report.cation_containing_count += 1
|
||||
|
||||
# 详细分布
|
||||
if exp_info.needs_expansion and exp_info.can_expand:
|
||||
report.expansion_factor_distribution[factor] = \
|
||||
report.expansion_factor_distribution.get(factor, 0) + 1
|
||||
report.needs_expansion_count += 1
|
||||
for anion in info.anion_types:
|
||||
report.anion_distribution[anion] = \
|
||||
report.anion_distribution.get(anion, 0) + 1
|
||||
|
||||
# 计算比例
|
||||
if report.valid_files > 0:
|
||||
report.cation_containing_ratio = \
|
||||
report.cation_containing_count / report.valid_files
|
||||
if info.anion_mode == "single":
|
||||
report.single_anion_count += 1
|
||||
elif info.anion_mode == "mixed":
|
||||
report.mixed_anion_count += 1
|
||||
|
||||
if report.cation_containing_count > 0:
|
||||
for anion, count in report.anion_distribution.items():
|
||||
report.anion_ratios[anion] = \
|
||||
count / report.cation_containing_count
|
||||
# 根据阴离子模式过滤
|
||||
if self.anion_mode == "single" and info.anion_mode != "single":
|
||||
continue
|
||||
if self.anion_mode == "mixed" and info.anion_mode != "mixed":
|
||||
continue
|
||||
if info.anion_mode == "none":
|
||||
continue
|
||||
|
||||
# 各项统计
|
||||
if info.has_oxidation_states:
|
||||
report.with_oxidation_states += 1
|
||||
else:
|
||||
report.without_oxidation_states += 1
|
||||
|
||||
# Li共占位统计(修改)
|
||||
if info.cation_with_vacancy:
|
||||
report.cation_with_vacancy_count += 1
|
||||
if info.cation_with_other_cation:
|
||||
report.cation_with_other_cation_count += 1
|
||||
|
||||
if info.anion_has_partial_occupancy:
|
||||
report.anion_partial_occupancy_count += 1
|
||||
if info.is_binary_compound:
|
||||
report.binary_compound_count += 1
|
||||
if info.has_water_molecule:
|
||||
report.has_water_count += 1
|
||||
if info.has_radioactive_elements:
|
||||
report.has_radioactive_count += 1
|
||||
|
||||
# 可处理性
|
||||
if info.can_process:
|
||||
if info.needs_expansion:
|
||||
report.needs_preprocessing += 1
|
||||
else:
|
||||
report.directly_processable += 1
|
||||
else:
|
||||
report.cannot_process += 1
|
||||
if info.skip_reason:
|
||||
for reason in info.skip_reason.split("; "):
|
||||
report.skip_reasons_summary[reason] = \
|
||||
report.skip_reasons_summary.get(reason, 0) + 1
|
||||
|
||||
# 扩胞统计(新增)
|
||||
exp_info = info.expansion_info
|
||||
factor = exp_info.expansion_factor
|
||||
|
||||
if not exp_info.needs_expansion:
|
||||
report.expansion_stats['no_expansion_needed'] += 1
|
||||
elif not exp_info.can_expand:
|
||||
report.expansion_stats['cannot_expand'] += 1
|
||||
elif factor == 2:
|
||||
report.expansion_stats['expansion_factor_2'] += 1
|
||||
elif factor == 3:
|
||||
report.expansion_stats['expansion_factor_3'] += 1
|
||||
elif 4 <= factor <= 8:
|
||||
report.expansion_stats['expansion_factor_4_8'] += 1
|
||||
else:
|
||||
report.expansion_stats['expansion_factor_large'] += 1
|
||||
|
||||
# 详细分布
|
||||
if exp_info.needs_expansion and exp_info.can_expand:
|
||||
report.expansion_factor_distribution[factor] = \
|
||||
report.expansion_factor_distribution.get(factor, 0) + 1
|
||||
report.needs_expansion_count += 1
|
||||
|
||||
# 计算比例
|
||||
if report.valid_files > 0:
|
||||
report.cation_containing_ratio = \
|
||||
report.cation_containing_count / report.valid_files
|
||||
|
||||
if report.cation_containing_count > 0:
|
||||
for anion, count in report.anion_distribution.items():
|
||||
report.anion_ratios[anion] = \
|
||||
count / report.cation_containing_count
|
||||
Reference in New Issue
Block a user