优化三个工具的返回结果。
This commit is contained in:
@@ -64,8 +64,20 @@ def optimize_structure(atoms: Atoms, output_format: str):
|
||||
atoms.calc = calc
|
||||
|
||||
try:
|
||||
import io
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
# 创建StringIO对象捕获输出
|
||||
f = io.StringIO()
|
||||
dyn = FIRE(FrechetCellFilter(atoms))
|
||||
dyn.run(fmax=settings.fmax)
|
||||
|
||||
# 同时捕获并输出到控制台
|
||||
with redirect_stdout(f):
|
||||
dyn.run(fmax=settings.fmax)
|
||||
# 获取捕获的日志
|
||||
optimization_log = f.getvalue()
|
||||
# 同时输出到控制台
|
||||
print(optimization_log)
|
||||
total_energy = atoms.get_total_energy()
|
||||
|
||||
# 处理对称性
|
||||
@@ -87,6 +99,6 @@ def optimize_structure(atoms: Atoms, output_format: str):
|
||||
|
||||
# 上传到MinIO
|
||||
url = handle_minio_upload(tmp_path, file_name)
|
||||
return total_energy, content, url
|
||||
return total_energy, content, optimization_log, url
|
||||
finally:
|
||||
os.unlink(tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user