[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71JWXW0WHWV34YVN90VRR2N":3,"skill-same:01M71JWXW0WHWV34YVN90VRR2N":112},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M71JWXW0WHWV34YVN90VRR2N","pymatgen",null,"Materials science toolkit. Crystal structures (CIF, POSCAR), phase diagrams, band structure, DOS, Materials Project integration, format conversion, for computational materials science.","iDorgham\u002FWorkspace-Factory","iDorgham","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F136521493?v=4","01M6CNGBDAHE4ARW3YJEF4X2FD","Dorgham","01M71E8H3CXZ7DJX59MTM9JEB2",1,"MIT","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"computational","dos","Materials Project","phase","materials","for","phase diagrams","crystal","Materials Science","toolkit","project","structure","diagrams","conversion","format","science","integration","2026-11-10 10:12:30",false,"---\nname: pymatgen\ndescription: Materials science toolkit. Crystal structures (CIF, POSCAR), phase diagrams, band structure, DOS, Materials Project integration, format conversion, for computational materials science.\nlicense: MIT license\nmetadata:\n    skill-author: K-Dense Inc.\n---\n\n# Pymatgen - Python Materials Genomics\n\n## Overview\n\nPymatgen is a comprehensive Python library for materials analysis that powers the Materials Project. Create, analyze, and manipulate crystal structures and molecules, compute phase diagrams and thermodynamic properties, analyze electronic structure (band structures, DOS), generate surfaces and interfaces, and access Materials Project's database of computed materials. Supports 100+ file formats from various computational codes.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Working with crystal structures or molecular systems in materials science\n- Converting between structure file formats (CIF, POSCAR, XYZ, etc.)\n- Analyzing symmetry, space groups, or coordination environments\n- Computing phase diagrams or assessing thermodynamic stability\n- Analyzing electronic structure data (band gaps, DOS, band structures)\n- Generating surfaces, slabs, or studying interfaces\n- Accessing the Materials Project database programmatically\n- Setting up high-throughput computational workflows\n- Analyzing diffusion, magnetism, or mechanical properties\n- Working with VASP, Gaussian, Quantum ESPRESSO, or other computational codes\n\n## Quick Start Guide\n\n### Installation\n\n```bash\n# Core pymatgen\nuv pip install pymatgen\n\n# With Materials Project API access\nuv pip install pymatgen mp-api\n\n# Optional dependencies for extended functionality\nuv pip install pymatgen[analysis]  # Additional analysis tools\nuv pip install pymatgen[vis]       # Visualization tools\n```\n\n### Basic Structure Operations\n\n```python\nfrom pymatgen.core import Structure, Lattice\n\n# Read structure from file (automatic format detection)\nstruct = Structure.from_file(\"POSCAR\")\n\n# Create structure from scratch\nlattice = Lattice.cubic(3.84)\nstruct = Structure(lattice, [\"Si\", \"Si\"], [[0,0,0], [0.25,0.25,0.25]])\n\n# Write to different format\nstruct.to(filename=\"structure.cif\")\n\n# Basic properties\nprint(f\"Formula: {struct.composition.reduced_formula}\")\nprint(f\"Space group: {struct.get_space_group_info()}\")\nprint(f\"Density: {struct.density:.2f} g\u002Fcm³\")\n```\n\n### Materials Project Integration\n\n```bash\n# Set up API key\nexport MP_API_KEY=\"your_api_key_here\"\n```\n\n```python\nfrom mp_api.client import MPRester\n\nwith MPRester() as mpr:\n    # Get structure by material ID\n    struct = mpr.get_structure_by_material_id(\"mp-149\")\n\n    # Search for materials\n    materials = mpr.materials.summary.search(\n        formula=\"Fe2O3\",\n        energy_above_hull=(0, 0.05)\n    )\n```\n\n## Core Capabilities\n\n### 1. Structure Creation and Manipulation\n\nCreate structures using various methods and perform transformations.\n\n**From files:**\n```python\n# Automatic format detection\nstruct = Structure.from_file(\"structure.cif\")\nstruct = Structure.from_file(\"POSCAR\")\nmol = Molecule.from_file(\"molecule.xyz\")\n```\n\n**From scratch:**\n```python\nfrom pymatgen.core import Structure, Lattice\n\n# Using lattice parameters\nlattice = Lattice.from_parameters(a=3.84, b=3.84, c=3.84,\n                                  alpha=120, beta=90, gamma=60)\ncoords = [[0, 0, 0], [0.75, 0.5, 0.75]]\nstruct = Structure(lattice, [\"Si\", \"Si\"], coords)\n\n# From space group\nstruct = Structure.from_spacegroup(\n    \"Fm-3m\",\n    Lattice.cubic(3.5),\n    [\"Si\"],\n    [[0, 0, 0]]\n)\n```\n\n**Transformations:**\n```python\nfrom pymatgen.transformations.standard_transformations import (\n    SupercellTransformation,\n    SubstitutionTransformation,\n    PrimitiveCellTransformation\n)\n\n# Create supercell\ntrans = SupercellTransformation([[2,0,0],[0,2,0],[0,0,2]])\nsupercell = trans.apply_transformation(struct)\n\n# Substitute elements\ntrans = SubstitutionTransformation({\"Fe\": \"Mn\"})\nnew_struct = trans.apply_transformation(struct)\n\n# Get primitive cell\ntrans = PrimitiveCellTransformation()\nprimitive = trans.apply_transformation(struct)\n```\n\n**Reference:** See `references\u002Fcore_classes.md` for comprehensive documentation of Structure, Lattice, Molecule, and related classes.\n\n### 2. File Format Conversion\n\nConvert between 100+ file formats with automatic format detection.\n\n**Using convenience methods:**\n```python\n# Read any format\nstruct = Structure.from_file(\"input_file\")\n\n# Write to any format\nstruct.to(filename=\"output.cif\")\nstruct.to(filename=\"POSCAR\")\nstruct.to(filename=\"output.xyz\")\n```\n\n**Using the conversion script:**\n```bash\n# Single file conversion\npython scripts\u002Fstructure_converter.py POSCAR structure.cif\n\n# Batch conversion\npython scripts\u002Fstructure_converter.py *.cif --output-dir .\u002Fposcar_files --format poscar\n```\n\n**Reference:** See `references\u002Fio_formats.md` for detailed documentation of all supported formats and code integrations.\n\n### 3. Structure Analysis and Symmetry\n\nAnalyze structures for symmetry, coordination, and other properties.\n\n**Symmetry analysis:**\n```python\nfrom pymatgen.symmetry.analyzer import SpacegroupAnalyzer\n\nsga = SpacegroupAnalyzer(struct)\n\n# Get space group information\nprint(f\"Space group: {sga.get_space_group_symbol()}\")\nprint(f\"Number: {sga.get_space_group_number()}\")\nprint(f\"Crystal system: {sga.get_crystal_system()}\")\n\n# Get conventional\u002Fprimitive cells\nconventional = sga.get_conventional_standard_structure()\nprimitive = sga.get_primitive_standard_structure()\n```\n\n**Coordination environment:**\n```python\nfrom pymatgen.analysis.local_env import CrystalNN\n\ncnn = CrystalNN()\nneighbors = cnn.get_nn_info(struct, n=0)  # Neighbors of site 0\n\nprint(f\"Coordination number: {len(neighbors)}\")\nfor neighbor in neighbors:\n    site = struct[neighbor['site_index']]\n    print(f\"  {site.species_string} at {neighbor['weight']:.3f} Å\")\n```\n\n**Using the analysis script:**\n```bash\n# Comprehensive analysis\npython scripts\u002Fstructure_analyzer.py POSCAR --symmetry --neighbors\n\n# Export results\npython scripts\u002Fstructure_analyzer.py structure.cif --symmetry --export json\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` for detailed documentation of all analysis capabilities.\n\n### 4. Phase Diagrams and Thermodynamics\n\nConstruct phase diagrams and analyze thermodynamic stability.\n\n**Phase diagram construction:**\n```python\nfrom mp_api.client import MPRester\nfrom pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter\n\n# Get entries from Materials Project\nwith MPRester() as mpr:\n    entries = mpr.get_entries_in_chemsys(\"Li-Fe-O\")\n\n# Build phase diagram\npd = PhaseDiagram(entries)\n\n# Check stability\nfrom pymatgen.core import Composition\ncomp = Composition(\"LiFeO2\")\n\n# Find entry for composition\nfor entry in entries:\n    if entry.composition.reduced_formula == comp.reduced_formula:\n        e_above_hull = pd.get_e_above_hull(entry)\n        print(f\"Energy above hull: {e_above_hull:.4f} eV\u002Fatom\")\n\n        if e_above_hull > 0.001:\n            # Get decomposition\n            decomp = pd.get_decomposition(comp)\n            print(\"Decomposes to:\", decomp)\n\n# Plot\nplotter = PDPlotter(pd)\nplotter.show()\n```\n\n**Using the phase diagram script:**\n```bash\n# Generate phase diagram\npython scripts\u002Fphase_diagram_generator.py Li-Fe-O --output li_fe_o.png\n\n# Analyze specific composition\npython scripts\u002Fphase_diagram_generator.py Li-Fe-O --analyze \"LiFeO2\" --show\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Phase Diagrams section) and `references\u002Ftransformations_workflows.md` (Workflow 2) for detailed examples.\n\n### 5. Electronic Structure Analysis\n\nAnalyze band structures, density of states, and electronic properties.\n\n**Band structure:**\n```python\nfrom pymatgen.io.vasp import Vasprun\nfrom pymatgen.electronic_structure.plotter import BSPlotter\n\n# Read from VASP calculation\nvasprun = Vasprun(\"vasprun.xml\")\nbs = vasprun.get_band_structure()\n\n# Analyze\nband_gap = bs.get_band_gap()\nprint(f\"Band gap: {band_gap['energy']:.3f} eV\")\nprint(f\"Direct: {band_gap['direct']}\")\nprint(f\"Is metal: {bs.is_metal()}\")\n\n# Plot\nplotter = BSPlotter(bs)\nplotter.save_plot(\"band_structure.png\")\n```\n\n**Density of states:**\n```python\nfrom pymatgen.electronic_structure.plotter import DosPlotter\n\ndos = vasprun.complete_dos\n\n# Get element-projected DOS\nelement_dos = dos.get_element_dos()\nfor element, element_dos_obj in element_dos.items():\n    print(f\"{element}: {element_dos_obj.get_gap():.3f} eV\")\n\n# Plot\nplotter = DosPlotter()\nplotter.add_dos(\"Total DOS\", dos)\nplotter.show()\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Electronic Structure section) and `references\u002Fio_formats.md` (VASP section).\n\n### 6. Surface and Interface Analysis\n\nGenerate slabs, analyze surfaces, and study interfaces.\n\n**Slab generation:**\n```python\nfrom pymatgen.core.surface import SlabGenerator\n\n# Generate slabs for specific Miller index\nslabgen = SlabGenerator(\n    struct,\n    miller_index=(1, 1, 1),\n    min_slab_size=10.0,      # Å\n    min_vacuum_size=10.0,    # Å\n    center_slab=True\n)\n\nslabs = slabgen.get_slabs()\n\n# Write slabs\nfor i, slab in enumerate(slabs):\n    slab.to(filename=f\"slab_{i}.cif\")\n```\n\n**Wulff shape construction:**\n```python\nfrom pymatgen.analysis.wulff import WulffShape\n\n# Define surface energies\nsurface_energies = {\n    (1, 0, 0): 1.0,\n    (1, 1, 0): 1.1,\n    (1, 1, 1): 0.9,\n}\n\nwulff = WulffShape(struct.lattice, surface_energies)\nprint(f\"Surface area: {wulff.surface_area:.2f} Ų\")\nprint(f\"Volume: {wulff.volume:.2f} ų\")\n\nwulff.show()\n```\n\n**Adsorption site finding:**\n```python\nfrom pymatgen.analysis.adsorption import AdsorbateSiteFinder\nfrom pymatgen.core import Molecule\n\nasf = AdsorbateSiteFinder(slab)\n\n# Find sites\nads_sites = asf.find_adsorption_sites()\nprint(f\"On-top sites: {len(ads_sites['ontop'])}\")\nprint(f\"Bridge sites: {len(ads_sites['bridge'])}\")\nprint(f\"Hollow sites: {len(ads_sites['hollow'])}\")\n\n# Add adsorbate\nadsorbate = Molecule(\"O\", [[0, 0, 0]])\nads_struct = asf.add_adsorbate(adsorbate, ads_sites[\"ontop\"][0])\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Surface and Interface section) and `references\u002Ftransformations_workflows.md` (Workflows 3 and 9).\n\n### 7. Materials Project Database Access\n\nProgrammatically access the Materials Project database.\n\n**Setup:**\n1. Get API key from https:\u002F\u002Fnext-gen.materialsproject.org\u002F\n2. Set environment variable: `export MP_API_KEY=\"your_key_here\"`\n\n**Search and retrieve:**\n```python\nfrom mp_api.client import MPRester\n\nwith MPRester() as mpr:\n    # Search by formula\n    materials = mpr.materials.summary.search(formula=\"Fe2O3\")\n\n    # Search by chemical system\n    materials = mpr.materials.summary.search(chemsys=\"Li-Fe-O\")\n\n    # Filter by properties\n    materials = mpr.materials.summary.search(\n        chemsys=\"Li-Fe-O\",\n        energy_above_hull=(0, 0.05),  # Stable\u002Fmetastable\n        band_gap=(1.0, 3.0)            # Semiconducting\n    )\n\n    # Get structure\n    struct = mpr.get_structure_by_material_id(\"mp-149\")\n\n    # Get band structure\n    bs = mpr.get_bandstructure_by_material_id(\"mp-149\")\n\n    # Get entries for phase diagram\n    entries = mpr.get_entries_in_chemsys(\"Li-Fe-O\")\n```\n\n**Reference:** See `references\u002Fmaterials_project_api.md` for comprehensive API documentation and examples.\n\n### 8. Computational Workflow Setup\n\nSet up calculations for various electronic structure codes.\n\n**VASP input generation:**\n```python\nfrom pymatgen.io.vasp.sets import MPRelaxSet, MPStaticSet, MPNonSCFSet\n\n# Relaxation\nrelax = MPRelaxSet(struct)\nrelax.write_input(\".\u002Frelax_calc\")\n\n# Static calculation\nstatic = MPStaticSet(struct)\nstatic.write_input(\".\u002Fstatic_calc\")\n\n# Band structure (non-self-consistent)\nnscf = MPNonSCFSet(struct, mode=\"line\")\nnscf.write_input(\".\u002Fbandstructure_calc\")\n\n# Custom parameters\ncustom = MPRelaxSet(struct, user_incar_settings={\"ENCUT\": 600})\ncustom.write_input(\".\u002Fcustom_calc\")\n```\n\n**Other codes:**\n```python\n# Gaussian\nfrom pymatgen.io.gaussian import GaussianInput\n\ngin = GaussianInput(\n    mol,\n    functional=\"B3LYP\",\n    basis_set=\"6-31G(d)\",\n    route_parameters={\"Opt\": None}\n)\ngin.write_file(\"input.gjf\")\n\n# Quantum ESPRESSO\nfrom pymatgen.io.pwscf import PWInput\n\npwin = PWInput(struct, control={\"calculation\": \"scf\"})\npwin.write_file(\"pw.in\")\n```\n\n**Reference:** See `references\u002Fio_formats.md` (Electronic Structure Code I\u002FO section) and `references\u002Ftransformations_workflows.md` for workflow examples.\n\n### 9. Advanced Analysis\n\n**Diffraction patterns:**\n```python\nfrom pymatgen.analysis.diffraction.xrd import XRDCalculator\n\nxrd = XRDCalculator()\npattern = xrd.get_pattern(struct)\n\n# Get peaks\nfor peak in pattern.hkls:\n    print(f\"2θ = {peak['2theta']:.2f}°, hkl = {peak['hkl']}\")\n\npattern.plot()\n```\n\n**Elastic properties:**\n```python\nfrom pymatgen.analysis.elasticity import ElasticTensor\n\n# From elastic tensor matrix\nelastic_tensor = ElasticTensor.from_voigt(matrix)\n\nprint(f\"Bulk modulus: {elastic_tensor.k_voigt:.1f} GPa\")\nprint(f\"Shear modulus: {elastic_tensor.g_voigt:.1f} GPa\")\nprint(f\"Young's modulus: {elastic_tensor.y_mod:.1f} GPa\")\n```\n\n**Magnetic ordering:**\n```python\nfrom pymatgen.transformations.advanced_transformations import MagOrderingTransformation\n\n# Enumerate magnetic orderings\ntrans = MagOrderingTransformation({\"Fe\": 5.0})\nmag_structs = trans.apply_transformation(struct, return_ranked_list=True)\n\n# Get lowest energy magnetic structure\nlowest_energy_struct = mag_structs[0]['structure']\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` for comprehensive analysis module documentation.\n\n## Bundled Resources\n\n### Scripts (`scripts\u002F`)\n\nExecutable Python scripts for common tasks:\n\n- **`structure_converter.py`**: Convert between structure file formats\n  - Supports batch conversion and automatic format detection\n  - Usage: `python scripts\u002Fstructure_converter.py POSCAR structure.cif`\n\n- **`structure_analyzer.py`**: Comprehensive structure analysis\n  - Symmetry, coordination, lattice parameters, distance matrix\n  - Usage: `python scripts\u002Fstructure_analyzer.py structure.cif --symmetry --neighbors`\n\n- **`phase_diagram_generator.py`**: Generate phase diagrams from Materials Project\n  - Stability analysis and thermodynamic properties\n  - Usage: `python scripts\u002Fphase_diagram_generator.py Li-Fe-O --analyze \"LiFeO2\"`\n\nAll scripts include detailed help: `python scripts\u002Fscript_name.py --help`\n\n### References (`references\u002F`)\n\nComprehensive documentation loaded into context as needed:\n\n- **`core_classes.md`**: Element, Structure, Lattice, Molecule, Composition classes\n- **`io_formats.md`**: File format support and code integration (VASP, Gaussian, etc.)\n- **`analysis_modules.md`**: Phase diagrams, surfaces, electronic structure, symmetry\n- **`materials_project_api.md`**: Complete Materials Project API guide\n- **`transformations_workflows.md`**: Transformations framework and common workflows\n\nLoad references when detailed information is needed about specific modules or workflows.\n\n## Common Workflows\n\n### High-Throughput Structure Generation\n\n```python\nfrom pymatgen.transformations.standard_transformations import SubstitutionTransformation\nfrom pymatgen.io.vasp.sets import MPRelaxSet\n\n# Generate doped structures\nbase_struct = Structure.from_file(\"POSCAR\")\ndopants = [\"Mn\", \"Co\", \"Ni\", \"Cu\"]\n\nfor dopant in dopants:\n    trans = SubstitutionTransformation({\"Fe\": dopant})\n    doped_struct = trans.apply_transformation(base_struct)\n\n    # Generate VASP inputs\n    vasp_input = MPRelaxSet(doped_struct)\n    vasp_input.write_input(f\".\u002Fcalcs\u002FFe_{dopant}\")\n```\n\n### Band Structure Calculation Workflow\n\n```python\n# 1. Relaxation\nrelax = MPRelaxSet(struct)\nrelax.write_input(\".\u002F1_relax\")\n\n# 2. Static (after relaxation)\nrelaxed = Structure.from_file(\"1_relax\u002FCONTCAR\")\nstatic = MPStaticSet(relaxed)\nstatic.write_input(\".\u002F2_static\")\n\n# 3. Band structure (non-self-consistent)\nnscf = MPNonSCFSet(relaxed, mode=\"line\")\nnscf.write_input(\".\u002F3_bandstructure\")\n\n# 4. Analysis\nfrom pymatgen.io.vasp import Vasprun\nvasprun = Vasprun(\"3_bandstructure\u002Fvasprun.xml\")\nbs = vasprun.get_band_structure()\nbs.get_band_gap()\n```\n\n### Surface Energy Calculation\n\n```python\n# 1. Get bulk energy\nbulk_vasprun = Vasprun(\"bulk\u002Fvasprun.xml\")\nbulk_E_per_atom = bulk_vasprun.final_energy \u002F len(bulk)\n\n# 2. Generate and calculate slabs\nslabgen = SlabGenerator(bulk, (1,1,1), 10, 15)\nslab = slabgen.get_slabs()[0]\n\nMPRelaxSet(slab).write_input(\".\u002Fslab_calc\")\n\n# 3. Calculate surface energy (after calculation)\nslab_vasprun = Vasprun(\"slab_calc\u002Fvasprun.xml\")\nE_surf = (slab_vasprun.final_energy - len(slab) * bulk_E_per_atom) \u002F (2 * slab.surface_area)\nE_surf *= 16.021766  # Convert eV\u002FŲ to J\u002Fm²\n```\n\n**More workflows:** See `references\u002Ftransformations_workflows.md` for 10 detailed workflow examples.\n\n## Best Practices\n\n### Structure Handling\n\n1. **Use automatic format detection**: `Structure.from_file()` handles most formats\n2. **Prefer immutable structures**: Use `IStructure` when structure shouldn't change\n3. **Check symmetry**: Use `SpacegroupAnalyzer` to reduce to primitive cell\n4. **Validate structures**: Check for overlapping atoms or unreasonable bond lengths\n\n### File I\u002FO\n\n1. **Use convenience methods**: `from_file()` and `to()` are preferred\n2. **Specify formats explicitly**: When automatic detection fails\n3. **Handle exceptions**: Wrap file I\u002FO in try-except blocks\n4. **Use serialization**: `as_dict()`\u002F`from_dict()` for version-safe storage\n\n### Materials Project API\n\n1. **Use context manager**: Always use `with MPRester() as mpr:`\n2. **Batch queries**: Request multiple items at once\n3. **Cache results**: Save frequently used data locally\n4. **Filter effectively**: Use property filters to reduce data transfer\n\n### Computational Workflows\n\n1. **Use input sets**: Prefer `MPRelaxSet`, `MPStaticSet` over manual INCAR\n2. **Check convergence**: Always verify calculations converged\n3. **Track transformations**: Use `TransformedStructure` for provenance\n4. **Organize calculations**: Use clear directory structures\n\n### Performance\n\n1. **Reduce symmetry**: Use primitive cells when possible\n2. **Limit neighbor searches**: Specify reasonable cutoff radii\n3. **Use appropriate methods**: Different analysis tools have different speed\u002Faccuracy tradeoffs\n4. **Parallelize when possible**: Many operations can be parallelized\n\n## Units and Conventions\n\nPymatgen uses atomic units throughout:\n- **Lengths**: Angstroms (Å)\n- **Energies**: Electronvolts (eV)\n- **Angles**: Degrees (°)\n- **Magnetic moments**: Bohr magnetons (μB)\n- **Time**: Femtoseconds (fs)\n\nConvert units using `pymatgen.core.units` when needed.\n\n## Integration with Other Tools\n\nPymatgen integrates seamlessly with:\n- **ASE** (Atomic Simulation Environment)\n- **Phonopy** (phonon calculations)\n- **BoltzTraP** (transport properties)\n- **Atomate\u002FFireworks** (workflow management)\n- **AiiDA** (provenance tracking)\n- **Zeo++** (pore analysis)\n- **OpenBabel** (molecule conversion)\n\n## Troubleshooting\n\n**Import errors**: Install missing dependencies\n```bash\nuv pip install pymatgen[analysis,vis]\n```\n\n**API key not found**: Set MP_API_KEY environment variable\n```bash\nexport MP_API_KEY=\"your_key_here\"\n```\n\n**Structure read failures**: Check file format and syntax\n```python\n# Try explicit format specification\nstruct = Structure.from_file(\"file.txt\", fmt=\"cif\")\n```\n\n**Symmetry analysis fails**: Structure may have numerical precision issues\n```python\n# Increase tolerance\nfrom pymatgen.symmetry.analyzer import SpacegroupAnalyzer\nsga = SpacegroupAnalyzer(struct, symprec=0.1)\n```\n\n## Additional Resources\n\n- **Documentation**: https:\u002F\u002Fpymatgen.org\u002F\n- **Materials Project**: https:\u002F\u002Fmaterialsproject.org\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fmaterialsproject\u002Fpymatgen\n- **Forum**: https:\u002F\u002Fmatsci.org\u002F\n- **Example notebooks**: https:\u002F\u002Fmatgenb.materialsvirtuallab.org\u002F\n\n## Version Notes\n\nThis skill is designed for pymatgen 2024.x and later. For the Materials Project API, use the `mp-api` package (separate from legacy `pymatgen.ext.matproj`).\n\nRequirements:\n- Python 3.10 or higher\n- pymatgen >= 2023.x\n- mp-api (for Materials Project access)\n\n","# Pymatgen - Python Materials Genomics\n\n## Overview\n\nPymatgen is a comprehensive Python library for materials analysis that powers the Materials Project. Create, analyze, and manipulate crystal structures and molecules, compute phase diagrams and thermodynamic properties, analyze electronic structure (band structures, DOS), generate surfaces and interfaces, and access Materials Project's database of computed materials. Supports 100+ file formats from various computational codes.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Working with crystal structures or molecular systems in materials science\n- Converting between structure file formats (CIF, POSCAR, XYZ, etc.)\n- Analyzing symmetry, space groups, or coordination environments\n- Computing phase diagrams or assessing thermodynamic stability\n- Analyzing electronic structure data (band gaps, DOS, band structures)\n- Generating surfaces, slabs, or studying interfaces\n- Accessing the Materials Project database programmatically\n- Setting up high-throughput computational workflows\n- Analyzing diffusion, magnetism, or mechanical properties\n- Working with VASP, Gaussian, Quantum ESPRESSO, or other computational codes\n\n## Quick Start Guide\n\n### Installation\n\n```bash\n# Core pymatgen\nuv pip install pymatgen\n\n# With Materials Project API access\nuv pip install pymatgen mp-api\n\n# Optional dependencies for extended functionality\nuv pip install pymatgen[analysis]  # Additional analysis tools\nuv pip install pymatgen[vis]       # Visualization tools\n```\n\n### Basic Structure Operations\n\n```python\nfrom pymatgen.core import Structure, Lattice\n\n# Read structure from file (automatic format detection)\nstruct = Structure.from_file(\"POSCAR\")\n\n# Create structure from scratch\nlattice = Lattice.cubic(3.84)\nstruct = Structure(lattice, [\"Si\", \"Si\"], [[0,0,0], [0.25,0.25,0.25]])\n\n# Write to different format\nstruct.to(filename=\"structure.cif\")\n\n# Basic properties\nprint(f\"Formula: {struct.composition.reduced_formula}\")\nprint(f\"Space group: {struct.get_space_group_info()}\")\nprint(f\"Density: {struct.density:.2f} g\u002Fcm³\")\n```\n\n### Materials Project Integration\n\n```bash\n# Set up API key\nexport MP_API_KEY=\"your_api_key_here\"\n```\n\n```python\nfrom mp_api.client import MPRester\n\nwith MPRester() as mpr:\n    # Get structure by material ID\n    struct = mpr.get_structure_by_material_id(\"mp-149\")\n\n    # Search for materials\n    materials = mpr.materials.summary.search(\n        formula=\"Fe2O3\",\n        energy_above_hull=(0, 0.05)\n    )\n```\n\n## Core Capabilities\n\n### 1. Structure Creation and Manipulation\n\nCreate structures using various methods and perform transformations.\n\n**From files:**\n```python\n# Automatic format detection\nstruct = Structure.from_file(\"structure.cif\")\nstruct = Structure.from_file(\"POSCAR\")\nmol = Molecule.from_file(\"molecule.xyz\")\n```\n\n**From scratch:**\n```python\nfrom pymatgen.core import Structure, Lattice\n\n# Using lattice parameters\nlattice = Lattice.from_parameters(a=3.84, b=3.84, c=3.84,\n                                  alpha=120, beta=90, gamma=60)\ncoords = [[0, 0, 0], [0.75, 0.5, 0.75]]\nstruct = Structure(lattice, [\"Si\", \"Si\"], coords)\n\n# From space group\nstruct = Structure.from_spacegroup(\n    \"Fm-3m\",\n    Lattice.cubic(3.5),\n    [\"Si\"],\n    [[0, 0, 0]]\n)\n```\n\n**Transformations:**\n```python\nfrom pymatgen.transformations.standard_transformations import (\n    SupercellTransformation,\n    SubstitutionTransformation,\n    PrimitiveCellTransformation\n)\n\n# Create supercell\ntrans = SupercellTransformation([[2,0,0],[0,2,0],[0,0,2]])\nsupercell = trans.apply_transformation(struct)\n\n# Substitute elements\ntrans = SubstitutionTransformation({\"Fe\": \"Mn\"})\nnew_struct = trans.apply_transformation(struct)\n\n# Get primitive cell\ntrans = PrimitiveCellTransformation()\nprimitive = trans.apply_transformation(struct)\n```\n\n**Reference:** See `references\u002Fcore_classes.md` for comprehensive documentation of Structure, Lattice, Molecule, and related classes.\n\n### 2. File Format Conversion\n\nConvert between 100+ file formats with automatic format detection.\n\n**Using convenience methods:**\n```python\n# Read any format\nstruct = Structure.from_file(\"input_file\")\n\n# Write to any format\nstruct.to(filename=\"output.cif\")\nstruct.to(filename=\"POSCAR\")\nstruct.to(filename=\"output.xyz\")\n```\n\n**Using the conversion script:**\n```bash\n# Single file conversion\npython scripts\u002Fstructure_converter.py POSCAR structure.cif\n\n# Batch conversion\npython scripts\u002Fstructure_converter.py *.cif --output-dir .\u002Fposcar_files --format poscar\n```\n\n**Reference:** See `references\u002Fio_formats.md` for detailed documentation of all supported formats and code integrations.\n\n### 3. Structure Analysis and Symmetry\n\nAnalyze structures for symmetry, coordination, and other properties.\n\n**Symmetry analysis:**\n```python\nfrom pymatgen.symmetry.analyzer import SpacegroupAnalyzer\n\nsga = SpacegroupAnalyzer(struct)\n\n# Get space group information\nprint(f\"Space group: {sga.get_space_group_symbol()}\")\nprint(f\"Number: {sga.get_space_group_number()}\")\nprint(f\"Crystal system: {sga.get_crystal_system()}\")\n\n# Get conventional\u002Fprimitive cells\nconventional = sga.get_conventional_standard_structure()\nprimitive = sga.get_primitive_standard_structure()\n```\n\n**Coordination environment:**\n```python\nfrom pymatgen.analysis.local_env import CrystalNN\n\ncnn = CrystalNN()\nneighbors = cnn.get_nn_info(struct, n=0)  # Neighbors of site 0\n\nprint(f\"Coordination number: {len(neighbors)}\")\nfor neighbor in neighbors:\n    site = struct[neighbor['site_index']]\n    print(f\"  {site.species_string} at {neighbor['weight']:.3f} Å\")\n```\n\n**Using the analysis script:**\n```bash\n# Comprehensive analysis\npython scripts\u002Fstructure_analyzer.py POSCAR --symmetry --neighbors\n\n# Export results\npython scripts\u002Fstructure_analyzer.py structure.cif --symmetry --export json\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` for detailed documentation of all analysis capabilities.\n\n### 4. Phase Diagrams and Thermodynamics\n\nConstruct phase diagrams and analyze thermodynamic stability.\n\n**Phase diagram construction:**\n```python\nfrom mp_api.client import MPRester\nfrom pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter\n\n# Get entries from Materials Project\nwith MPRester() as mpr:\n    entries = mpr.get_entries_in_chemsys(\"Li-Fe-O\")\n\n# Build phase diagram\npd = PhaseDiagram(entries)\n\n# Check stability\nfrom pymatgen.core import Composition\ncomp = Composition(\"LiFeO2\")\n\n# Find entry for composition\nfor entry in entries:\n    if entry.composition.reduced_formula == comp.reduced_formula:\n        e_above_hull = pd.get_e_above_hull(entry)\n        print(f\"Energy above hull: {e_above_hull:.4f} eV\u002Fatom\")\n\n        if e_above_hull > 0.001:\n            # Get decomposition\n            decomp = pd.get_decomposition(comp)\n            print(\"Decomposes to:\", decomp)\n\n# Plot\nplotter = PDPlotter(pd)\nplotter.show()\n```\n\n**Using the phase diagram script:**\n```bash\n# Generate phase diagram\npython scripts\u002Fphase_diagram_generator.py Li-Fe-O --output li_fe_o.png\n\n# Analyze specific composition\npython scripts\u002Fphase_diagram_generator.py Li-Fe-O --analyze \"LiFeO2\" --show\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Phase Diagrams section) and `references\u002Ftransformations_workflows.md` (Workflow 2) for detailed examples.\n\n### 5. Electronic Structure Analysis\n\nAnalyze band structures, density of states, and electronic properties.\n\n**Band structure:**\n```python\nfrom pymatgen.io.vasp import Vasprun\nfrom pymatgen.electronic_structure.plotter import BSPlotter\n\n# Read from VASP calculation\nvasprun = Vasprun(\"vasprun.xml\")\nbs = vasprun.get_band_structure()\n\n# Analyze\nband_gap = bs.get_band_gap()\nprint(f\"Band gap: {band_gap['energy']:.3f} eV\")\nprint(f\"Direct: {band_gap['direct']}\")\nprint(f\"Is metal: {bs.is_metal()}\")\n\n# Plot\nplotter = BSPlotter(bs)\nplotter.save_plot(\"band_structure.png\")\n```\n\n**Density of states:**\n```python\nfrom pymatgen.electronic_structure.plotter import DosPlotter\n\ndos = vasprun.complete_dos\n\n# Get element-projected DOS\nelement_dos = dos.get_element_dos()\nfor element, element_dos_obj in element_dos.items():\n    print(f\"{element}: {element_dos_obj.get_gap():.3f} eV\")\n\n# Plot\nplotter = DosPlotter()\nplotter.add_dos(\"Total DOS\", dos)\nplotter.show()\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Electronic Structure section) and `references\u002Fio_formats.md` (VASP section).\n\n### 6. Surface and Interface Analysis\n\nGenerate slabs, analyze surfaces, and study interfaces.\n\n**Slab generation:**\n```python\nfrom pymatgen.core.surface import SlabGenerator\n\n# Generate slabs for specific Miller index\nslabgen = SlabGenerator(\n    struct,\n    miller_index=(1, 1, 1),\n    min_slab_size=10.0,      # Å\n    min_vacuum_size=10.0,    # Å\n    center_slab=True\n)\n\nslabs = slabgen.get_slabs()\n\n# Write slabs\nfor i, slab in enumerate(slabs):\n    slab.to(filename=f\"slab_{i}.cif\")\n```\n\n**Wulff shape construction:**\n```python\nfrom pymatgen.analysis.wulff import WulffShape\n\n# Define surface energies\nsurface_energies = {\n    (1, 0, 0): 1.0,\n    (1, 1, 0): 1.1,\n    (1, 1, 1): 0.9,\n}\n\nwulff = WulffShape(struct.lattice, surface_energies)\nprint(f\"Surface area: {wulff.surface_area:.2f} Ų\")\nprint(f\"Volume: {wulff.volume:.2f} ų\")\n\nwulff.show()\n```\n\n**Adsorption site finding:**\n```python\nfrom pymatgen.analysis.adsorption import AdsorbateSiteFinder\nfrom pymatgen.core import Molecule\n\nasf = AdsorbateSiteFinder(slab)\n\n# Find sites\nads_sites = asf.find_adsorption_sites()\nprint(f\"On-top sites: {len(ads_sites['ontop'])}\")\nprint(f\"Bridge sites: {len(ads_sites['bridge'])}\")\nprint(f\"Hollow sites: {len(ads_sites['hollow'])}\")\n\n# Add adsorbate\nadsorbate = Molecule(\"O\", [[0, 0, 0]])\nads_struct = asf.add_adsorbate(adsorbate, ads_sites[\"ontop\"][0])\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` (Surface and Interface section) and `references\u002Ftransformations_workflows.md` (Workflows 3 and 9).\n\n### 7. Materials Project Database Access\n\nProgrammatically access the Materials Project database.\n\n**Setup:**\n1. Get API key from https:\u002F\u002Fnext-gen.materialsproject.org\u002F\n2. Set environment variable: `export MP_API_KEY=\"your_key_here\"`\n\n**Search and retrieve:**\n```python\nfrom mp_api.client import MPRester\n\nwith MPRester() as mpr:\n    # Search by formula\n    materials = mpr.materials.summary.search(formula=\"Fe2O3\")\n\n    # Search by chemical system\n    materials = mpr.materials.summary.search(chemsys=\"Li-Fe-O\")\n\n    # Filter by properties\n    materials = mpr.materials.summary.search(\n        chemsys=\"Li-Fe-O\",\n        energy_above_hull=(0, 0.05),  # Stable\u002Fmetastable\n        band_gap=(1.0, 3.0)            # Semiconducting\n    )\n\n    # Get structure\n    struct = mpr.get_structure_by_material_id(\"mp-149\")\n\n    # Get band structure\n    bs = mpr.get_bandstructure_by_material_id(\"mp-149\")\n\n    # Get entries for phase diagram\n    entries = mpr.get_entries_in_chemsys(\"Li-Fe-O\")\n```\n\n**Reference:** See `references\u002Fmaterials_project_api.md` for comprehensive API documentation and examples.\n\n### 8. Computational Workflow Setup\n\nSet up calculations for various electronic structure codes.\n\n**VASP input generation:**\n```python\nfrom pymatgen.io.vasp.sets import MPRelaxSet, MPStaticSet, MPNonSCFSet\n\n# Relaxation\nrelax = MPRelaxSet(struct)\nrelax.write_input(\".\u002Frelax_calc\")\n\n# Static calculation\nstatic = MPStaticSet(struct)\nstatic.write_input(\".\u002Fstatic_calc\")\n\n# Band structure (non-self-consistent)\nnscf = MPNonSCFSet(struct, mode=\"line\")\nnscf.write_input(\".\u002Fbandstructure_calc\")\n\n# Custom parameters\ncustom = MPRelaxSet(struct, user_incar_settings={\"ENCUT\": 600})\ncustom.write_input(\".\u002Fcustom_calc\")\n```\n\n**Other codes:**\n```python\n# Gaussian\nfrom pymatgen.io.gaussian import GaussianInput\n\ngin = GaussianInput(\n    mol,\n    functional=\"B3LYP\",\n    basis_set=\"6-31G(d)\",\n    route_parameters={\"Opt\": None}\n)\ngin.write_file(\"input.gjf\")\n\n# Quantum ESPRESSO\nfrom pymatgen.io.pwscf import PWInput\n\npwin = PWInput(struct, control={\"calculation\": \"scf\"})\npwin.write_file(\"pw.in\")\n```\n\n**Reference:** See `references\u002Fio_formats.md` (Electronic Structure Code I\u002FO section) and `references\u002Ftransformations_workflows.md` for workflow examples.\n\n### 9. Advanced Analysis\n\n**Diffraction patterns:**\n```python\nfrom pymatgen.analysis.diffraction.xrd import XRDCalculator\n\nxrd = XRDCalculator()\npattern = xrd.get_pattern(struct)\n\n# Get peaks\nfor peak in pattern.hkls:\n    print(f\"2θ = {peak['2theta']:.2f}°, hkl = {peak['hkl']}\")\n\npattern.plot()\n```\n\n**Elastic properties:**\n```python\nfrom pymatgen.analysis.elasticity import ElasticTensor\n\n# From elastic tensor matrix\nelastic_tensor = ElasticTensor.from_voigt(matrix)\n\nprint(f\"Bulk modulus: {elastic_tensor.k_voigt:.1f} GPa\")\nprint(f\"Shear modulus: {elastic_tensor.g_voigt:.1f} GPa\")\nprint(f\"Young's modulus: {elastic_tensor.y_mod:.1f} GPa\")\n```\n\n**Magnetic ordering:**\n```python\nfrom pymatgen.transformations.advanced_transformations import MagOrderingTransformation\n\n# Enumerate magnetic orderings\ntrans = MagOrderingTransformation({\"Fe\": 5.0})\nmag_structs = trans.apply_transformation(struct, return_ranked_list=True)\n\n# Get lowest energy magnetic structure\nlowest_energy_struct = mag_structs[0]['structure']\n```\n\n**Reference:** See `references\u002Fanalysis_modules.md` for comprehensive analysis module documentation.\n\n## Bundled Resources\n\n### Scripts (`scripts\u002F`)\n\nExecutable Python scripts for common tasks:\n\n- **`structure_converter.py`**: Convert between structure file formats\n  - Supports batch conversion and automatic format detection\n  - Usage: `python scripts\u002Fstructure_converter.py POSCAR structure.cif`\n\n- **`structure_analyzer.py`**: Comprehensive structure analysis\n  - Symmetry, coordination, lattice parameters, distance matrix\n  - Usage: `python scripts\u002Fstructure_analyzer.py structure.cif --symmetry --neighbors`\n\n- **`phase_diagram_generator.py`**: Generate phase diagrams from Materials Project\n  - Stability analysis and thermodynamic properties\n  - Usage: `python scripts\u002Fphase_diagram_generator.py Li-Fe-O --analyze \"LiFeO2\"`\n\nAll scripts include detailed help: `python scripts\u002Fscript_name.py --help`\n\n### References (`references\u002F`)\n\nComprehensive documentation loaded into context as needed:\n\n- **`core_classes.md`**: Element, Structure, Lattice, Molecule, Composition classes\n- **`io_formats.md`**: File format support and code integration (VASP, Gaussian, etc.)\n- **`analysis_modules.md`**: Phase diagrams, surfaces, electronic structure, symmetry\n- **`materials_project_api.md`**: Complete Materials Project API guide\n- **`transformations_workflows.md`**: Transformations framework and common workflows\n\nLoad references when detailed information is needed about specific modules or workflows.\n\n## Common Workflows\n\n### High-Throughput Structure Generation\n\n```python\nfrom pymatgen.transformations.standard_transformations import SubstitutionTransformation\nfrom pymatgen.io.vasp.sets import MPRelaxSet\n\n# Generate doped structures\nbase_struct = Structure.from_file(\"POSCAR\")\ndopants = [\"Mn\", \"Co\", \"Ni\", \"Cu\"]\n\nfor dopant in dopants:\n    trans = SubstitutionTransformation({\"Fe\": dopant})\n    doped_struct = trans.apply_transformation(base_struct)\n\n    # Generate VASP inputs\n    vasp_input = MPRelaxSet(doped_struct)\n    vasp_input.write_input(f\".\u002Fcalcs\u002FFe_{dopant}\")\n```\n\n### Band Structure Calculation Workflow\n\n```python\n# 1. Relaxation\nrelax = MPRelaxSet(struct)\nrelax.write_input(\".\u002F1_relax\")\n\n# 2. Static (after relaxation)\nrelaxed = Structure.from_file(\"1_relax\u002FCONTCAR\")\nstatic = MPStaticSet(relaxed)\nstatic.write_input(\".\u002F2_static\")\n\n# 3. Band structure (non-self-consistent)\nnscf = MPNonSCFSet(relaxed, mode=\"line\")\nnscf.write_input(\".\u002F3_bandstructure\")\n\n# 4. Analysis\nfrom pymatgen.io.vasp import Vasprun\nvasprun = Vasprun(\"3_bandstructure\u002Fvasprun.xml\")\nbs = vasprun.get_band_structure()\nbs.get_band_gap()\n```\n\n### Surface Energy Calculation\n\n```python\n# 1. Get bulk energy\nbulk_vasprun = Vasprun(\"bulk\u002Fvasprun.xml\")\nbulk_E_per_atom = bulk_vasprun.final_energy \u002F len(bulk)\n\n# 2. Generate and calculate slabs\nslabgen = SlabGenerator(bulk, (1,1,1), 10, 15)\nslab = slabgen.get_slabs()[0]\n\nMPRelaxSet(slab).write_input(\".\u002Fslab_calc\")\n\n# 3. Calculate surface energy (after calculation)\nslab_vasprun = Vasprun(\"slab_calc\u002Fvasprun.xml\")\nE_surf = (slab_vasprun.final_energy - len(slab) * bulk_E_per_atom) \u002F (2 * slab.surface_area)\nE_surf *= 16.021766  # Convert eV\u002FŲ to J\u002Fm²\n```\n\n**More workflows:** See `references\u002Ftransformations_workflows.md` for 10 detailed workflow examples.\n\n## Best Practices\n\n### Structure Handling\n\n1. **Use automatic format detection**: `Structure.from_file()` handles most formats\n2. **Prefer immutable structures**: Use `IStructure` when structure shouldn't change\n3. **Check symmetry**: Use `SpacegroupAnalyzer` to reduce to primitive cell\n4. **Validate structures**: Check for overlapping atoms or unreasonable bond lengths\n\n### File I\u002FO\n\n1. **Use convenience methods**: `from_file()` and `to()` are preferred\n2. **Specify formats explicitly**: When automatic detection fails\n3. **Handle exceptions**: Wrap file I\u002FO in try-except blocks\n4. **Use serialization**: `as_dict()`\u002F`from_dict()` for version-safe storage\n\n### Materials Project API\n\n1. **Use context manager**: Always use `with MPRester() as mpr:`\n2. **Batch queries**: Request multiple items at once\n3. **Cache results**: Save frequently used data locally\n4. **Filter effectively**: Use property filters to reduce data transfer\n\n### Computational Workflows\n\n1. **Use input sets**: Prefer `MPRelaxSet`, `MPStaticSet` over manual INCAR\n2. **Check convergence**: Always verify calculations converged\n3. **Track transformations**: Use `TransformedStructure` for provenance\n4. **Organize calculations**: Use clear directory structures\n\n### Performance\n\n1. **Reduce symmetry**: Use primitive cells when possible\n2. **Limit neighbor searches**: Specify reasonable cutoff radii\n3. **Use appropriate methods**: Different analysis tools have different speed\u002Faccuracy tradeoffs\n4. **Parallelize when possible**: Many operations can be parallelized\n\n## Units and Conventions\n\nPymatgen uses atomic units throughout:\n- **Lengths**: Angstroms (Å)\n- **Energies**: Electronvolts (eV)\n- **Angles**: Degrees (°)\n- **Magnetic moments**: Bohr magnetons (μB)\n- **Time**: Femtoseconds (fs)\n\nConvert units using `pymatgen.core.units` when needed.\n\n## Integration with Other Tools\n\nPymatgen integrates seamlessly with:\n- **ASE** (Atomic Simulation Environment)\n- **Phonopy** (phonon calculations)\n- **BoltzTraP** (transport properties)\n- **Atomate\u002FFireworks** (workflow management)\n- **AiiDA** (provenance tracking)\n- **Zeo++** (pore analysis)\n- **OpenBabel** (molecule conversion)\n\n## Troubleshooting\n\n**Import errors**: Install missing dependencies\n```bash\nuv pip install pymatgen[analysis,vis]\n```\n\n**API key not found**: Set MP_API_KEY environment variable\n```bash\nexport MP_API_KEY=\"your_key_here\"\n```\n\n**Structure read failures**: Check file format and syntax\n```python\n# Try explicit format specification\nstruct = Structure.from_file(\"file.txt\", fmt=\"cif\")\n```\n\n**Symmetry analysis fails**: Structure may have numerical precision issues\n```python\n# Increase tolerance\nfrom pymatgen.symmetry.analyzer import SpacegroupAnalyzer\nsga = SpacegroupAnalyzer(struct, symprec=0.1)\n```\n\n## Additional Resources\n\n- **Documentation**: https:\u002F\u002Fpymatgen.org\u002F\n- **Materials Project**: https:\u002F\u002Fmaterialsproject.org\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Fmaterialsproject\u002Fpymatgen\n- **Forum**: https:\u002F\u002Fmatsci.org\u002F\n- **Example notebooks**: https:\u002F\u002Fmatgenb.materialsvirtuallab.org\u002F\n\n## Version Notes\n\nThis skill is designed for pymatgen 2024.x and later. For the Materials Project API, use the `mp-api` package (separate from legacy `pymatgen.ext.matproj`).\n\nRequirements:\n- Python 3.10 or higher\n- pymatgen >= 2023.x\n- mp-api (for Materials Project access)\n\n",{"name":5,"license":46,"metadata":47,"description":7},"MIT license",{"skill-author":48},"K-Dense Inc.","master","c2e410e11df4d80d885e0ecf0583ef3c926df736","factory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen",0,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory","https:\u002F\u002Fgithub.com\u002FiDorgham","Dorgham.me","hey I'm Dorgham \r\nI code, I create, and AI codes back. \r\nMaybe we can give AI the chance!! now we begin. 🚀🤖\r\n... . . . git commit -m \"Hello, Future\" ","2026-05-04 18:39:09",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add iDorgham\u002FWorkspace-Factory --skill pymatgen",{"tool":64,"command":65},"bunx","bunx skills add iDorgham\u002FWorkspace-Factory --skill pymatgen",{"tool":67,"command":68},"pnpm","pnpm dlx skills add iDorgham\u002FWorkspace-Factory --skill pymatgen","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002FSKILL.md",true,[72,78,82,86,90,94,98,104,108],{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"_AIWF_IMPORT.json","REFERENCE","参考文档",344,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002F_AIWF_IMPORT.json",{"path":79,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fanalysis_modules.md",12942,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Freferences\u002Fanalysis_modules.md",{"path":83,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fcore_classes.md",9445,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Freferences\u002Fcore_classes.md",{"path":87,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fio_formats.md",10518,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Freferences\u002Fio_formats.md",{"path":91,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fmaterials_project_api.md",12770,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Freferences\u002Fmaterials_project_api.md",{"path":95,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Ftransformations_workflows.md",16805,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Freferences\u002Ftransformations_workflows.md",{"path":99,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"scripts\u002Fphase_diagram_generator.py","SCRIPT","脚本",7353,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Fscripts\u002Fphase_diagram_generator.py",{"path":105,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":106,"sourceHtmlUrl":107},"scripts\u002Fstructure_analyzer.py",8452,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Fscripts\u002Fstructure_analyzer.py",{"path":109,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":110,"sourceHtmlUrl":111},"scripts\u002Fstructure_converter.py",5179,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpymatgen\u002Fscripts\u002Fstructure_converter.py",[113,144,166,188,208,229],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":122,"publishedAt":143},"01M71P8WVBMB2X3D24R0YT0B0E","vercel-react-view-transitions","Guide for implementing smooth, native-feeling animations using React's View Transition API (`\u003CViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter\u002Fexit of components, animate list reorder, implement directional (forward\u002Fback) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_view_transitions\u002Fskill.md",[119],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142],"react","vercel react view transitions","view","react view transitions","vercel","transitions","shared","back","Animation","css","types","states","element","implementing","when","components","api","route","create","libraries","2026-11-10 13:02:02",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":151,"publishedAt":143},"01M71P8TDGHZ289TSAC5VTG2EW","vercel-react-native-skills","React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_native_skills\u002Fskill.md",[150],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},[123,152,153,127,154,155,156,157,136,158,137,159,138,160,161,162,163,164,165,29],"react native","native","vercel react native skills","react native skills","modules","performance","apps","tasks","mobile","expo","list","mobile performance","platform","animations",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":173,"publishedAt":143},"01M71P8QK4JF5BYRGYDDGPZQG9","vercel-react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_best_practices\u002Fskill.md",[172],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},[123,174,175,127,176,157,177,137,178,159,138,179,180,181,182,183,184,185,186,187],"react best practices","vercel react best practices","best practices","writing","code","data fetching","react components","next","refactoring","data","patterns","Optimization","guidelines","triggers",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":195,"publishedAt":143},"01M71P8HVEA70K5N6ZVJCG2ED3","vercel-composition-patterns","React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_composition_patterns\u002Fskill.md",[194],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},[196,127,197,184,198,199,200,201,187,202,203,204,137,205,159,138,206,207,139,123],"Composition","composition patterns","vercel composition patterns","react composition patterns","react 19","render","boolean","component architecture","use","reusable","architecture","react composition",{"skillNo":209,"name":210,"nameZh":6,"description":211,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":212,"categories":213,"keywords":215,"publishedAt":143},"01M71P60XXKKP222ZFJRG7R373","supabase-postgres-best-practices","Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_supabase_supabase_postgres_best_practices\u002Fskill.md",[214],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[216,217,218,219,176,220,221,222,29,185,157,223,224,177,225,204,226,227,228,137],"postgres best practices","supabase","postgres","supabase postgres best practices","categories","postgres performance","advanced","correct","schema","impact","Rules","critical","database",{"skillNo":230,"name":231,"nameZh":6,"description":232,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":233,"categories":234,"keywords":236,"publishedAt":252},"01M71P2ZCEJD0PKC458YTP1FJW","portable-text-serialization","Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, extracting plain text from Portable Text, or troubleshooting rendering issues with marks, blocks, lists, or custom types.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_sanity_io_portable_text_serialization\u002Fskill.md",[235],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},[237,238,239,240,241,133,242,201,243,136,244,245,137,123,246,247,248,249,250,251],"text","portable text serialization","portable","serialization","extracting","strings","issues","frontend","svelte","sanity","astro","server","markdown","rendering","vue","2026-11-10 10:56:23"]