Mochify
Image and PDF processing for agents, on a native C++ engine
目录 / 文档处理 / cmi-skill
使用 `diffpy.cmi` 模块编写 Python 代码,对材料结构模型进行精修,使其与实验数据(特别是实验对分布函数 PDF)相匹配。该代码适用于通过实验 PDF 研究材料结构的场景。 ```python from diffpy.srfit.pdf import PDFGenerator, PDFParser from diffpy.srfit.fitbase import FitRecipe, FitContribution, Profile from diffpy.srfit.structure import constrainAsSpaceGroup from diffpy.structure import Structure import numpy as np # 1. 加载实验PDF数据 parser = PDFParser() parser.parseFile("experiment_data.gr") # 替换为实际实验数据文件路径 profile = Profile() profile.loadParsedData(parser) # 2. 创建结构模型(例如从CIF文件) structure = Structure(filename="initial_structure.cif") # 替换为初始结构文件路径 # 3. 创建PDF生成器 generator = PDFGenerator("pdf") generator.setStructure(structure) generator.setQmin(0.5) generator.setQmax(20.0) generator.setQbroad(0.02) # 4. 创建拟合贡献对象 contribution = FitContribution("pdf_contrib") contribution.addProfileGenerator(generator) contribution.setProfile(profile) # 5. 创建拟合配方 recipe = FitRecipe() recipe.addContribution(contribution) # 6. 添加结构参数用于精修(如晶格参数、原子坐标、各向同性位移参数等) recipe.addVar(structure.lattice.a, name="a") recipe.addVar(structure.lattice.b, name="b") recipe.addVar(structure.lattice.c, name="c") recipe.addVar(structure.lattice.alpha, name="alpha") recipe.addVar(structure.lattice.beta, name="beta") recipe.addVar(structure.lattice.gamma, name="gamma") # 添加原子坐标和位移参数(示例:第一个原子的x坐标和Uiso) atom = structure[0] recipe.addVar(atom.x, name="x0") recipe.addVar(atom.Uiso, name="Uiso0") # 7. 可选:施加空间群约束(如果已知空间群) # constrainAsSpaceGroup(structure, "Fm-3m", recipe) # 8. 设置拟合范围(可选) recipe.setVarRange("a", 4.0, 6.0) recipe.setVarRange("Uiso0", 0.005, 0.05) # 9. 执行拟合 recipe.fit() # 10. 输出精修后的结构 print("Refined structure:") print(structure) # 11. 保存精修后的结构(例如保存为CIF) structure.write("refined_structure.cif", "cif") # 12. 可视化拟合结果(可选,需matplotlib) try: import matplotlib.pyplot as plt r_exp, gr_exp = profile.x, profile.y r_calc, gr_calc = generator.rgrid, generator.profile() plt.plot(r_exp, gr_exp, 'k-', label="Experiment") plt.plot(r_calc, gr_calc, 'r--', lab...
| 版本 | 存档时间 | 内容哈希 | 内容 |
|---|---|---|---|
| v1 | 2026-11-15 18:52 | 00e74f4e | 可取 |
版本索引永久保留;内容副本只保留最新 1 份,更早版本仅留索引与哈希(存档时间线的证据链不会因此断裂)。
Image and PDF processing for agents, on a native C++ engine
Generate and manipulate PDFs from Claude Desktop, Cursor, and Windsurf
Convert PDF, Word, PowerPoint, Excel, HTML and EPUB files into clean Markdown for LLMs, including OCR for scanned PDFs a…
PDF Toolkit converts PDFs/images to Word, Excel, and Markdown, splits and merges PDFs, creates PDFs from images, adds te…
Parse and query bank statements — turn PDF statements into structured transactions, accounts, and balances, with balance…
Fill any interactive PDF form from your AI agent — tax forms, HR paperwork, legal documents — in a single tool call
侵权举报经核验成立后,我们会即时下线该条目并删除已存的内容副本。