[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75BCWPJDR71HB0FDTM6CMEA":3,"skill-same:01M75BCWPJDR71HB0FDTM6CMEA":54},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M75BCWPJDR71HB0FDTM6CMEA","molecular-dynamics",null,"Run and analyze molecular dynamics simulations with OpenMM and MDAnalysis. Set up protein\u002Fsmall molecule systems, define force fields, run energy minimization and production MD, analyze trajectories (RMSD, RMSF, contact maps, free energy surfaces). For structural biology, drug binding, and biophysics.","Lord1Egypt\u002Fai-skillforge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M7597M9CBBVAPX1CYE1KFTSM",2,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fjs\u002Fskills\u002Fscientific\u002Fmolecular-dynamics\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: molecular-dynamics\ndescription: Run and analyze molecular dynamics simulations with OpenMM and MDAnalysis. Set up protein\u002Fsmall molecule systems, define force fields, run energy minimization and production MD, analyze trajectories (RMSD, RMSF, contact maps, free energy surfaces). For structural biology, drug binding, and biophysics.\nlicense: MIT\nmetadata:\n    skill-author: Kuan-lin Huang\n---\n\n# Molecular Dynamics\n\n## Overview\n\nMolecular dynamics (MD) simulation computationally models the time evolution of molecular systems by integrating Newton's equations of motion. This skill covers two complementary tools:\n\n- **OpenMM** (https:\u002F\u002Fopenmm.org\u002F): High-performance MD simulation engine with GPU support, Python API, and flexible force field support\n- **MDAnalysis** (https:\u002F\u002Fmdanalysis.org\u002F): Python library for reading, writing, and analyzing MD trajectories from all major simulation packages\n\n**Installation:**\n```bash\nconda install -c conda-forge openmm mdanalysis nglview\n# or\npip install openmm mdanalysis\n```\n\n## When to Use This Skill\n\nUse molecular dynamics when:\n\n- **Protein stability analysis**: How does a mutation affect protein dynamics?\n- **Drug binding simulations**: Characterize binding mode and residence time of a ligand\n- **Conformational sampling**: Explore protein flexibility and conformational changes\n- **Protein-protein interaction**: Model interface dynamics and binding energetics\n- **RMSD\u002FRMSF analysis**: Quantify structural fluctuations from a reference structure\n- **Free energy estimation**: Compute binding free energy or conformational free energy\n- **Membrane simulations**: Model proteins in lipid bilayers\n- **Intrinsically disordered proteins**: Study IDR conformational ensembles\n\n## Core Workflow: OpenMM Simulation\n\n### 1. System Preparation\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\nimport sys\n\ndef prepare_system_from_pdb(pdb_file, forcefield_name=\"amber14-all.xml\",\n                              water_model=\"amber14\u002Ftip3pfb.xml\"):\n    \"\"\"\n    Prepare an OpenMM system from a PDB file.\n\n    Args:\n        pdb_file: Path to cleaned PDB file (use PDBFixer for raw PDB files)\n        forcefield_name: Force field XML file\n        water_model: Water model XML file\n\n    Returns:\n        pdb, forcefield, system, topology\n    \"\"\"\n    # Load PDB\n    pdb = PDBFile(pdb_file)\n\n    # Load force field\n    forcefield = ForceField(forcefield_name, water_model)\n\n    # Add hydrogens and solvate\n    modeller = Modeller(pdb.topology, pdb.positions)\n    modeller.addHydrogens(forcefield)\n\n    # Add solvent box (10 Å padding, 150 mM NaCl)\n    modeller.addSolvent(\n        forcefield,\n        model='tip3p',\n        padding=10*angstroms,\n        ionicStrength=0.15*molar\n    )\n\n    print(f\"System: {modeller.topology.getNumAtoms()} atoms, \"\n          f\"{modeller.topology.getNumResidues()} residues\")\n\n    # Create system\n    system = forcefield.createSystem(\n        modeller.topology,\n        nonbondedMethod=PME,         # Particle Mesh Ewald for long-range electrostatics\n        nonbondedCutoff=1.0*nanometer,\n        constraints=HBonds,           # Constrain hydrogen bonds (allows 2 fs timestep)\n        rigidWater=True,\n        ewaldErrorTolerance=0.0005\n    )\n\n    return modeller, system\n```\n\n### 2. Energy Minimization\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\n\ndef minimize_energy(modeller, system, output_pdb=\"minimized.pdb\",\n                     max_iterations=1000, tolerance=10.0):\n    \"\"\"\n    Energy minimize the system to remove steric clashes.\n\n    Args:\n        modeller: Modeller object with topology and positions\n        system: OpenMM System\n        output_pdb: Path to save minimized structure\n        max_iterations: Maximum minimization steps\n        tolerance: Convergence criterion in kJ\u002Fmol\u002Fnm\n\n    Returns:\n        simulation object with minimized positions\n    \"\"\"\n    # Set up integrator (doesn't matter for minimization)\n    integrator = LangevinMiddleIntegrator(300*kelvin, 1\u002Fpicosecond, 0.004*picoseconds)\n\n    # Create simulation\n    # Use GPU if available (CUDA or OpenCL), fall back to CPU\n    try:\n        platform = Platform.getPlatformByName('CUDA')\n        properties = {'DeviceIndex': '0', 'Precision': 'mixed'}\n    except Exception:\n        try:\n            platform = Platform.getPlatformByName('OpenCL')\n            properties = {}\n        except Exception:\n            platform = Platform.getPlatformByName('CPU')\n            properties = {}\n\n    simulation = Simulation(\n        modeller.topology, system, integrator,\n        platform, properties\n    )\n    simulation.context.setPositions(modeller.positions)\n\n    # Check initial energy\n    state = simulation.context.getState(getEnergy=True)\n    print(f\"Initial energy: {state.getPotentialEnergy()}\")\n\n    # Minimize\n    simulation.minimizeEnergy(\n        tolerance=tolerance*kilojoules_per_mole\u002Fnanometer,\n        maxIterations=max_iterations\n    )\n\n    state = simulation.context.getState(getEnergy=True, getPositions=True)\n    print(f\"Minimized energy: {state.getPotentialEnergy()}\")\n\n    # Save minimized structure\n    with open(output_pdb, 'w') as f:\n        PDBFile.writeFile(simulation.topology, state.getPositions(), f)\n\n    return simulation\n```\n\n### 3. NVT Equilibration\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\n\ndef run_nvt_equilibration(simulation, n_steps=50000, temperature=300,\n                            report_interval=1000, output_prefix=\"nvt\"):\n    \"\"\"\n    NVT equilibration: constant N, V, T.\n    Equilibrate velocities to target temperature.\n\n    Args:\n        simulation: OpenMM Simulation (after minimization)\n        n_steps: Number of MD steps (50000 × 2fs = 100 ps)\n        temperature: Temperature in Kelvin\n        report_interval: Steps between data reports\n        output_prefix: File prefix for trajectory and log\n    \"\"\"\n    # Add position restraints for backbone during NVT\n    # (Optional: restraint heavy atoms)\n\n    # Set temperature\n    simulation.context.setVelocitiesToTemperature(temperature*kelvin)\n\n    # Add reporters\n    simulation.reporters = []\n\n    # Log file\n    simulation.reporters.append(\n        StateDataReporter(\n            f\"{output_prefix}_log.txt\",\n            report_interval,\n            step=True,\n            potentialEnergy=True,\n            kineticEnergy=True,\n            temperature=True,\n            volume=True,\n            speed=True\n        )\n    )\n\n    # DCD trajectory (compact binary format)\n    simulation.reporters.append(\n        DCDReporter(f\"{output_prefix}_traj.dcd\", report_interval)\n    )\n\n    print(f\"Running NVT equilibration: {n_steps} steps ({n_steps*2\u002F1000:.1f} ps)\")\n    simulation.step(n_steps)\n    print(\"NVT equilibration complete\")\n\n    return simulation\n```\n\n### 4. NPT Equilibration and Production\n\n```python\ndef run_npt_production(simulation, n_steps=500000, temperature=300, pressure=1.0,\n                        report_interval=5000, output_prefix=\"npt\"):\n    \"\"\"\n    NPT production run: constant N, P, T.\n\n    Args:\n        n_steps: Production steps (500000 × 2fs = 1 ns)\n        temperature: Temperature in Kelvin\n        pressure: Pressure in bar\n        report_interval: Steps between reports\n    \"\"\"\n    # Add Monte Carlo barostat for pressure control\n    system = simulation.context.getSystem()\n    system.addForce(MonteCarloBarostat(pressure*bar, temperature*kelvin, 25))\n    simulation.context.reinitialize(preserveState=True)\n\n    # Update reporters\n    simulation.reporters = []\n    simulation.reporters.append(\n        StateDataReporter(\n            f\"{output_prefix}_log.txt\",\n            report_interval,\n            step=True,\n            potentialEnergy=True,\n            temperature=True,\n            density=True,\n            speed=True\n        )\n    )\n    simulation.reporters.append(\n        DCDReporter(f\"{output_prefix}_traj.dcd\", report_interval)\n    )\n\n    # Save checkpoints\n    simulation.reporters.append(\n        CheckpointReporter(f\"{output_prefix}_checkpoint.chk\", 50000)\n    )\n\n    print(f\"Running NPT production: {n_steps} steps ({n_steps*2\u002F1000000:.2f} ns)\")\n    simulation.step(n_steps)\n    print(\"Production MD complete\")\n    return simulation\n```\n\n## Trajectory Analysis with MDAnalysis\n\n### 1. Load Trajectory\n\n```python\nimport MDAnalysis as mda\nfrom MDAnalysis.analysis import rms, align, contacts\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef load_trajectory(topology_file, trajectory_file):\n    \"\"\"\n    Load an MD trajectory with MDAnalysis.\n\n    Args:\n        topology_file: PDB, PSF, or other topology file\n        trajectory_file: DCD, XTC, TRR, or other trajectory\n    \"\"\"\n    u = mda.Universe(topology_file, trajectory_file)\n    print(f\"Universe: {u.atoms.n_atoms} atoms, {u.trajectory.n_frames} frames\")\n    print(f\"Time range: 0 to {u.trajectory.totaltime:.0f} ps\")\n    return u\n```\n\n### 2. RMSD Analysis\n\n```python\ndef compute_rmsd(u, selection=\"backbone\", reference_frame=0):\n    \"\"\"\n    Compute RMSD of selected atoms relative to reference frame.\n\n    Args:\n        u: MDAnalysis Universe\n        selection: Atom selection string (MDAnalysis syntax)\n        reference_frame: Frame index for reference structure\n\n    Returns:\n        numpy array of (time, rmsd) values\n    \"\"\"\n    # Align trajectory to minimize RMSD\n    aligner = align.AlignTraj(u, u, select=selection, in_memory=True)\n    aligner.run()\n\n    # Compute RMSD\n    R = rms.RMSD(u, select=selection, ref_frame=reference_frame)\n    R.run()\n\n    rmsd_data = R.results.rmsd  # columns: frame, time, RMSD\n    return rmsd_data\n\ndef plot_rmsd(rmsd_data, title=\"RMSD over time\", output_file=\"rmsd.png\"):\n    \"\"\"Plot RMSD over simulation time.\"\"\"\n    fig, ax = plt.subplots(figsize=(10, 4))\n    ax.plot(rmsd_data[:, 1] \u002F 1000, rmsd_data[:, 2], 'b-', linewidth=0.5)\n    ax.set_xlabel(\"Time (ns)\")\n    ax.set_ylabel(\"RMSD (Å)\")\n    ax.set_title(title)\n    ax.axhline(rmsd_data[:, 2].mean(), color='r', linestyle='--',\n               label=f'Mean: {rmsd_data[:, 2].mean():.2f} Å')\n    ax.legend()\n    plt.tight_layout()\n    plt.savefig(output_file, dpi=150)\n    return fig\n```\n\n### 3. RMSF Analysis (Per-Residue Flexibility)\n\n```python\ndef compute_rmsf(u, selection=\"backbone\", start_frame=0):\n    \"\"\"\n    Compute per-residue RMSF (flexibility).\n\n    Returns:\n        resids, rmsf_values arrays\n    \"\"\"\n    # Select atoms\n    atoms = u.select_atoms(selection)\n\n    # Compute RMSF\n    R = rms.RMSF(atoms)\n    R.run(start=start_frame)\n\n    # Average by residue\n    resids = []\n    rmsf_per_res = []\n    for res in u.select_atoms(selection).residues:\n        res_atoms = res.atoms.intersection(atoms)\n        if len(res_atoms) > 0:\n            resids.append(res.resid)\n            rmsf_per_res.append(R.results.rmsf[res_atoms.indices].mean())\n\n    return np.array(resids), np.array(rmsf_per_res)\n```\n\n### 4. Protein-Ligand Contacts\n\n```python\ndef analyze_contacts(u, protein_sel=\"protein\", ligand_sel=\"resname LIG\",\n                      radius=4.5, start_frame=0):\n    \"\"\"\n    Track protein-ligand contacts over trajectory.\n\n    Args:\n        radius: Contact distance cutoff in Angstroms\n    \"\"\"\n    protein = u.select_atoms(protein_sel)\n    ligand = u.select_atoms(ligand_sel)\n\n    contact_frames = []\n    for ts in u.trajectory[start_frame:]:\n        # Find protein atoms within radius of ligand\n        distances = contacts.contact_matrix(\n            protein.positions, ligand.positions, radius\n        )\n        contact_residues = set()\n        for i in range(distances.shape[0]):\n            if distances[i].any():\n                contact_residues.add(protein.atoms[i].resid)\n        contact_frames.append(contact_residues)\n\n    return contact_frames\n```\n\n## Force Field Selection Guide\n\n| System | Recommended Force Field | Water Model |\n|--------|------------------------|-------------|\n| Standard proteins | AMBER14 (`amber14-all.xml`) | TIP3P-FB |\n| Proteins + small molecules | AMBER14 + GAFF2 | TIP3P-FB |\n| Membrane proteins | CHARMM36m | TIP3P |\n| Nucleic acids | AMBER99-bsc1 or AMBER14 | TIP3P |\n| Disordered proteins | ff19SB or CHARMM36m | TIP3P |\n\n## System Preparation Tools\n\n### PDBFixer (for raw PDB files)\n\n```python\nfrom pdbfixer import PDBFixer\nfrom openmm.app import PDBFile\n\ndef fix_pdb(input_pdb, output_pdb, ph=7.0):\n    \"\"\"Fix common PDB issues: missing residues, atoms, add H, standardize.\"\"\"\n    fixer = PDBFixer(filename=input_pdb)\n    fixer.findMissingResidues()\n    fixer.findNonstandardResidues()\n    fixer.replaceNonstandardResidues()\n    fixer.removeHeterogens(True)    # Remove water\u002Fligands\n    fixer.findMissingAtoms()\n    fixer.addMissingAtoms()\n    fixer.addMissingHydrogens(ph)\n\n    with open(output_pdb, 'w') as f:\n        PDBFile.writeFile(fixer.topology, fixer.positions, f)\n\n    return output_pdb\n```\n\n### GAFF2 for Small Molecules (via OpenFF Toolkit)\n\n```python\n# For ligand parameterization, use OpenFF toolkit or ACPYPE\n# pip install openff-toolkit\nfrom openff.toolkit import Molecule, ForceField as OFFForceField\nfrom openff.interchange import Interchange\n\ndef parameterize_ligand(smiles, ff_name=\"openff-2.0.0.offxml\"):\n    \"\"\"Generate GAFF2\u002FOpenFF parameters for a small molecule.\"\"\"\n    mol = Molecule.from_smiles(smiles)\n    mol.generate_conformers(n_conformers=1)\n\n    off_ff = OFFForceField(ff_name)\n    interchange = off_ff.create_interchange(mol.to_topology())\n    return interchange\n```\n\n## Best Practices\n\n- **Always minimize before MD**: Raw PDB structures have steric clashes\n- **Equilibrate before production**: NVT (50–100 ps) → NPT (100–500 ps) → Production\n- **Use GPU**: Simulations are 10–100× faster on GPU (CUDA\u002FOpenCL)\n- **2 fs timestep with HBonds constraints**: Standard; use 4 fs with HMR (hydrogen mass repartitioning)\n- **Analyze only equilibrated trajectory**: Discard first 20–50% as equilibration\n- **Save checkpoints**: MD runs can fail; checkpoints allow restart\n- **Periodic boundary conditions**: Required for solvated systems\n- **PME for electrostatics**: More accurate than cutoff methods for charged systems\n\n## Additional Resources\n\n- **OpenMM documentation**: https:\u002F\u002Fopenmm.org\u002Fdocumentation.html\n- **MDAnalysis user guide**: https:\u002F\u002Fdocs.mdanalysis.org\u002F\n- **GROMACS** (alternative MD engine): https:\u002F\u002Fmanual.gromacs.org\u002F\n- **NAMD** (alternative): https:\u002F\u002Fwww.ks.uiuc.edu\u002FResearch\u002Fnamd\u002F\n- **CHARMM-GUI** (web-based system builder): https:\u002F\u002Fcharmm-gui.org\u002F\n- **AmberTools** (free Amber tools): https:\u002F\u002Fambermd.org\u002FAmberTools.php\n- **OpenMM paper**: Eastman P et al. (2017) PLOS Computational Biology. PMID: 28278240\n- **MDAnalysis paper**: Michaud-Agrawal N et al. (2011) J Computational Chemistry. PMID: 21500218\n","# Molecular Dynamics\n\n## Overview\n\nMolecular dynamics (MD) simulation computationally models the time evolution of molecular systems by integrating Newton's equations of motion. This skill covers two complementary tools:\n\n- **OpenMM** (https:\u002F\u002Fopenmm.org\u002F): High-performance MD simulation engine with GPU support, Python API, and flexible force field support\n- **MDAnalysis** (https:\u002F\u002Fmdanalysis.org\u002F): Python library for reading, writing, and analyzing MD trajectories from all major simulation packages\n\n**Installation:**\n```bash\nconda install -c conda-forge openmm mdanalysis nglview\n# or\npip install openmm mdanalysis\n```\n\n## When to Use This Skill\n\nUse molecular dynamics when:\n\n- **Protein stability analysis**: How does a mutation affect protein dynamics?\n- **Drug binding simulations**: Characterize binding mode and residence time of a ligand\n- **Conformational sampling**: Explore protein flexibility and conformational changes\n- **Protein-protein interaction**: Model interface dynamics and binding energetics\n- **RMSD\u002FRMSF analysis**: Quantify structural fluctuations from a reference structure\n- **Free energy estimation**: Compute binding free energy or conformational free energy\n- **Membrane simulations**: Model proteins in lipid bilayers\n- **Intrinsically disordered proteins**: Study IDR conformational ensembles\n\n## Core Workflow: OpenMM Simulation\n\n### 1. System Preparation\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\nimport sys\n\ndef prepare_system_from_pdb(pdb_file, forcefield_name=\"amber14-all.xml\",\n                              water_model=\"amber14\u002Ftip3pfb.xml\"):\n    \"\"\"\n    Prepare an OpenMM system from a PDB file.\n\n    Args:\n        pdb_file: Path to cleaned PDB file (use PDBFixer for raw PDB files)\n        forcefield_name: Force field XML file\n        water_model: Water model XML file\n\n    Returns:\n        pdb, forcefield, system, topology\n    \"\"\"\n    # Load PDB\n    pdb = PDBFile(pdb_file)\n\n    # Load force field\n    forcefield = ForceField(forcefield_name, water_model)\n\n    # Add hydrogens and solvate\n    modeller = Modeller(pdb.topology, pdb.positions)\n    modeller.addHydrogens(forcefield)\n\n    # Add solvent box (10 Å padding, 150 mM NaCl)\n    modeller.addSolvent(\n        forcefield,\n        model='tip3p',\n        padding=10*angstroms,\n        ionicStrength=0.15*molar\n    )\n\n    print(f\"System: {modeller.topology.getNumAtoms()} atoms, \"\n          f\"{modeller.topology.getNumResidues()} residues\")\n\n    # Create system\n    system = forcefield.createSystem(\n        modeller.topology,\n        nonbondedMethod=PME,         # Particle Mesh Ewald for long-range electrostatics\n        nonbondedCutoff=1.0*nanometer,\n        constraints=HBonds,           # Constrain hydrogen bonds (allows 2 fs timestep)\n        rigidWater=True,\n        ewaldErrorTolerance=0.0005\n    )\n\n    return modeller, system\n```\n\n### 2. Energy Minimization\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\n\ndef minimize_energy(modeller, system, output_pdb=\"minimized.pdb\",\n                     max_iterations=1000, tolerance=10.0):\n    \"\"\"\n    Energy minimize the system to remove steric clashes.\n\n    Args:\n        modeller: Modeller object with topology and positions\n        system: OpenMM System\n        output_pdb: Path to save minimized structure\n        max_iterations: Maximum minimization steps\n        tolerance: Convergence criterion in kJ\u002Fmol\u002Fnm\n\n    Returns:\n        simulation object with minimized positions\n    \"\"\"\n    # Set up integrator (doesn't matter for minimization)\n    integrator = LangevinMiddleIntegrator(300*kelvin, 1\u002Fpicosecond, 0.004*picoseconds)\n\n    # Create simulation\n    # Use GPU if available (CUDA or OpenCL), fall back to CPU\n    try:\n        platform = Platform.getPlatformByName('CUDA')\n        properties = {'DeviceIndex': '0', 'Precision': 'mixed'}\n    except Exception:\n        try:\n            platform = Platform.getPlatformByName('OpenCL')\n            properties = {}\n        except Exception:\n            platform = Platform.getPlatformByName('CPU')\n            properties = {}\n\n    simulation = Simulation(\n        modeller.topology, system, integrator,\n        platform, properties\n    )\n    simulation.context.setPositions(modeller.positions)\n\n    # Check initial energy\n    state = simulation.context.getState(getEnergy=True)\n    print(f\"Initial energy: {state.getPotentialEnergy()}\")\n\n    # Minimize\n    simulation.minimizeEnergy(\n        tolerance=tolerance*kilojoules_per_mole\u002Fnanometer,\n        maxIterations=max_iterations\n    )\n\n    state = simulation.context.getState(getEnergy=True, getPositions=True)\n    print(f\"Minimized energy: {state.getPotentialEnergy()}\")\n\n    # Save minimized structure\n    with open(output_pdb, 'w') as f:\n        PDBFile.writeFile(simulation.topology, state.getPositions(), f)\n\n    return simulation\n```\n\n### 3. NVT Equilibration\n\n```python\nfrom openmm.app import *\nfrom openmm import *\nfrom openmm.unit import *\n\ndef run_nvt_equilibration(simulation, n_steps=50000, temperature=300,\n                            report_interval=1000, output_prefix=\"nvt\"):\n    \"\"\"\n    NVT equilibration: constant N, V, T.\n    Equilibrate velocities to target temperature.\n\n    Args:\n        simulation: OpenMM Simulation (after minimization)\n        n_steps: Number of MD steps (50000 × 2fs = 100 ps)\n        temperature: Temperature in Kelvin\n        report_interval: Steps between data reports\n        output_prefix: File prefix for trajectory and log\n    \"\"\"\n    # Add position restraints for backbone during NVT\n    # (Optional: restraint heavy atoms)\n\n    # Set temperature\n    simulation.context.setVelocitiesToTemperature(temperature*kelvin)\n\n    # Add reporters\n    simulation.reporters = []\n\n    # Log file\n    simulation.reporters.append(\n        StateDataReporter(\n            f\"{output_prefix}_log.txt\",\n            report_interval,\n            step=True,\n            potentialEnergy=True,\n            kineticEnergy=True,\n            temperature=True,\n            volume=True,\n            speed=True\n        )\n    )\n\n    # DCD trajectory (compact binary format)\n    simulation.reporters.append(\n        DCDReporter(f\"{output_prefix}_traj.dcd\", report_interval)\n    )\n\n    print(f\"Running NVT equilibration: {n_steps} steps ({n_steps*2\u002F1000:.1f} ps)\")\n    simulation.step(n_steps)\n    print(\"NVT equilibration complete\")\n\n    return simulation\n```\n\n### 4. NPT Equilibration and Production\n\n```python\ndef run_npt_production(simulation, n_steps=500000, temperature=300, pressure=1.0,\n                        report_interval=5000, output_prefix=\"npt\"):\n    \"\"\"\n    NPT production run: constant N, P, T.\n\n    Args:\n        n_steps: Production steps (500000 × 2fs = 1 ns)\n        temperature: Temperature in Kelvin\n        pressure: Pressure in bar\n        report_interval: Steps between reports\n    \"\"\"\n    # Add Monte Carlo barostat for pressure control\n    system = simulation.context.getSystem()\n    system.addForce(MonteCarloBarostat(pressure*bar, temperature*kelvin, 25))\n    simulation.context.reinitialize(preserveState=True)\n\n    # Update reporters\n    simulation.reporters = []\n    simulation.reporters.append(\n        StateDataReporter(\n            f\"{output_prefix}_log.txt\",\n            report_interval,\n            step=True,\n            potentialEnergy=True,\n            temperature=True,\n            density=True,\n            speed=True\n        )\n    )\n    simulation.reporters.append(\n        DCDReporter(f\"{output_prefix}_traj.dcd\", report_interval)\n    )\n\n    # Save checkpoints\n    simulation.reporters.append(\n        CheckpointReporter(f\"{output_prefix}_checkpoint.chk\", 50000)\n    )\n\n    print(f\"Running NPT production: {n_steps} steps ({n_steps*2\u002F1000000:.2f} ns)\")\n    simulation.step(n_steps)\n    print(\"Production MD complete\")\n    return simulation\n```\n\n## Trajectory Analysis with MDAnalysis\n\n### 1. Load Trajectory\n\n```python\nimport MDAnalysis as mda\nfrom MDAnalysis.analysis import rms, align, contacts\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef load_trajectory(topology_file, trajectory_file):\n    \"\"\"\n    Load an MD trajectory with MDAnalysis.\n\n    Args:\n        topology_file: PDB, PSF, or other topology file\n        trajectory_file: DCD, XTC, TRR, or other trajectory\n    \"\"\"\n    u = mda.Universe(topology_file, trajectory_file)\n    print(f\"Universe: {u.atoms.n_atoms} atoms, {u.trajectory.n_frames} frames\")\n    print(f\"Time range: 0 to {u.trajectory.totaltime:.0f} ps\")\n    return u\n```\n\n### 2. RMSD Analysis\n\n```python\ndef compute_rmsd(u, selection=\"backbone\", reference_frame=0):\n    \"\"\"\n    Compute RMSD of selected atoms relative to reference frame.\n\n    Args:\n        u: MDAnalysis Universe\n        selection: Atom selection string (MDAnalysis syntax)\n        reference_frame: Frame index for reference structure\n\n    Returns:\n        numpy array of (time, rmsd) values\n    \"\"\"\n    # Align trajectory to minimize RMSD\n    aligner = align.AlignTraj(u, u, select=selection, in_memory=True)\n    aligner.run()\n\n    # Compute RMSD\n    R = rms.RMSD(u, select=selection, ref_frame=reference_frame)\n    R.run()\n\n    rmsd_data = R.results.rmsd  # columns: frame, time, RMSD\n    return rmsd_data\n\ndef plot_rmsd(rmsd_data, title=\"RMSD over time\", output_file=\"rmsd.png\"):\n    \"\"\"Plot RMSD over simulation time.\"\"\"\n    fig, ax = plt.subplots(figsize=(10, 4))\n    ax.plot(rmsd_data[:, 1] \u002F 1000, rmsd_data[:, 2], 'b-', linewidth=0.5)\n    ax.set_xlabel(\"Time (ns)\")\n    ax.set_ylabel(\"RMSD (Å)\")\n    ax.set_title(title)\n    ax.axhline(rmsd_data[:, 2].mean(), color='r', linestyle='--',\n               label=f'Mean: {rmsd_data[:, 2].mean():.2f} Å')\n    ax.legend()\n    plt.tight_layout()\n    plt.savefig(output_file, dpi=150)\n    return fig\n```\n\n### 3. RMSF Analysis (Per-Residue Flexibility)\n\n```python\ndef compute_rmsf(u, selection=\"backbone\", start_frame=0):\n    \"\"\"\n    Compute per-residue RMSF (flexibility).\n\n    Returns:\n        resids, rmsf_values arrays\n    \"\"\"\n    # Select atoms\n    atoms = u.select_atoms(selection)\n\n    # Compute RMSF\n    R = rms.RMSF(atoms)\n    R.run(start=start_frame)\n\n    # Average by residue\n    resids = []\n    rmsf_per_res = []\n    for res in u.select_atoms(selection).residues:\n        res_atoms = res.atoms.intersection(atoms)\n        if len(res_atoms) > 0:\n            resids.append(res.resid)\n            rmsf_per_res.append(R.results.rmsf[res_atoms.indices].mean())\n\n    return np.array(resids), np.array(rmsf_per_res)\n```\n\n### 4. Protein-Ligand Contacts\n\n```python\ndef analyze_contacts(u, protein_sel=\"protein\", ligand_sel=\"resname LIG\",\n                      radius=4.5, start_frame=0):\n    \"\"\"\n    Track protein-ligand contacts over trajectory.\n\n    Args:\n        radius: Contact distance cutoff in Angstroms\n    \"\"\"\n    protein = u.select_atoms(protein_sel)\n    ligand = u.select_atoms(ligand_sel)\n\n    contact_frames = []\n    for ts in u.trajectory[start_frame:]:\n        # Find protein atoms within radius of ligand\n        distances = contacts.contact_matrix(\n            protein.positions, ligand.positions, radius\n        )\n        contact_residues = set()\n        for i in range(distances.shape[0]):\n            if distances[i].any():\n                contact_residues.add(protein.atoms[i].resid)\n        contact_frames.append(contact_residues)\n\n    return contact_frames\n```\n\n## Force Field Selection Guide\n\n| System | Recommended Force Field | Water Model |\n|--------|------------------------|-------------|\n| Standard proteins | AMBER14 (`amber14-all.xml`) | TIP3P-FB |\n| Proteins + small molecules | AMBER14 + GAFF2 | TIP3P-FB |\n| Membrane proteins | CHARMM36m | TIP3P |\n| Nucleic acids | AMBER99-bsc1 or AMBER14 | TIP3P |\n| Disordered proteins | ff19SB or CHARMM36m | TIP3P |\n\n## System Preparation Tools\n\n### PDBFixer (for raw PDB files)\n\n```python\nfrom pdbfixer import PDBFixer\nfrom openmm.app import PDBFile\n\ndef fix_pdb(input_pdb, output_pdb, ph=7.0):\n    \"\"\"Fix common PDB issues: missing residues, atoms, add H, standardize.\"\"\"\n    fixer = PDBFixer(filename=input_pdb)\n    fixer.findMissingResidues()\n    fixer.findNonstandardResidues()\n    fixer.replaceNonstandardResidues()\n    fixer.removeHeterogens(True)    # Remove water\u002Fligands\n    fixer.findMissingAtoms()\n    fixer.addMissingAtoms()\n    fixer.addMissingHydrogens(ph)\n\n    with open(output_pdb, 'w') as f:\n        PDBFile.writeFile(fixer.topology, fixer.positions, f)\n\n    return output_pdb\n```\n\n### GAFF2 for Small Molecules (via OpenFF Toolkit)\n\n```python\n# For ligand parameterization, use OpenFF toolkit or ACPYPE\n# pip install openff-toolkit\nfrom openff.toolkit import Molecule, ForceField as OFFForceField\nfrom openff.interchange import Interchange\n\ndef parameterize_ligand(smiles, ff_name=\"openff-2.0.0.offxml\"):\n    \"\"\"Generate GAFF2\u002FOpenFF parameters for a small molecule.\"\"\"\n    mol = Molecule.from_smiles(smiles)\n    mol.generate_conformers(n_conformers=1)\n\n    off_ff = OFFForceField(ff_name)\n    interchange = off_ff.create_interchange(mol.to_topology())\n    return interchange\n```\n\n## Best Practices\n\n- **Always minimize before MD**: Raw PDB structures have steric clashes\n- **Equilibrate before production**: NVT (50–100 ps) → NPT (100–500 ps) → Production\n- **Use GPU**: Simulations are 10–100× faster on GPU (CUDA\u002FOpenCL)\n- **2 fs timestep with HBonds constraints**: Standard; use 4 fs with HMR (hydrogen mass repartitioning)\n- **Analyze only equilibrated trajectory**: Discard first 20–50% as equilibration\n- **Save checkpoints**: MD runs can fail; checkpoints allow restart\n- **Periodic boundary conditions**: Required for solvated systems\n- **PME for electrostatics**: More accurate than cutoff methods for charged systems\n\n## Additional Resources\n\n- **OpenMM documentation**: https:\u002F\u002Fopenmm.org\u002Fdocumentation.html\n- **MDAnalysis user guide**: https:\u002F\u002Fdocs.mdanalysis.org\u002F\n- **GROMACS** (alternative MD engine): https:\u002F\u002Fmanual.gromacs.org\u002F\n- **NAMD** (alternative): https:\u002F\u002Fwww.ks.uiuc.edu\u002FResearch\u002Fnamd\u002F\n- **CHARMM-GUI** (web-based system builder): https:\u002F\u002Fcharmm-gui.org\u002F\n- **AmberTools** (free Amber tools): https:\u002F\u002Fambermd.org\u002FAmberTools.php\n- **OpenMM paper**: Eastman P et al. (2017) PLOS Computational Biology. PMID: 28278240\n- **MDAnalysis paper**: Michaud-Agrawal N et al. (2011) J Computational Chemistry. PMID: 21500218\n",{"name":5,"license":15,"metadata":24,"description":7},{"skill-author":25},"Kuan-lin Huang","main","3f88e1b76af67701a6405069a542e21a997d2868","js\u002Fskills\u002Fscientific\u002Fmolecular-dynamics",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-05 10:16:24",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Lord1Egypt\u002Fai-skillforge --skill molecular-dynamics",{"tool":40,"command":41},"bunx","bunx skills add Lord1Egypt\u002Fai-skillforge --skill molecular-dynamics",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fai-skillforge --skill molecular-dynamics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fjs\u002Fskills\u002Fscientific\u002Fmolecular-dynamics\u002FSKILL.md",true,[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fmdanalysis_analysis.md","REFERENCE","参考文档",5643,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fjs\u002Fskills\u002Fscientific\u002Fmolecular-dynamics\u002Freferences\u002Fmdanalysis_analysis.md",[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M75GWTHWA52GYQKS347FF6CD","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M75GW9FBP9NAFBSNVJ23RHSX","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Fwhat-if-oracle\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M75GW351MZZQ1V7207PDCX5D","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Fvenue-templates\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M75GVYGMAZDV2NHWSV6PP6TK","vaex","Use this skill for processing and analyzing large tabular datasets (billions of rows) that exceed available RAM. Vaex excels at out-of-core DataFrame operations, lazy evaluation, fast aggregations, efficient visualization of big data, and machine learning on large datasets. Apply when users need to work with large CSV\u002FHDF5\u002FArrow\u002FParquet files, perform fast statistics on massive datasets, create visualizations of big data, or build ML pipelines that do not fit in memory.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Fvaex\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M75GVS0ADH3DZ3QB564EVYC9","usfiscaldata","Query the U.S. Treasury Fiscal Data API for federal financial data including national debt, government spending, revenue, interest rates, exchange rates, and savings bonds. Access 54 datasets and 182 data tables with no API key required. Use when working with U.S. federal fiscal data, national debt tracking (Debt to the Penny), Daily Treasury Statements, Monthly Treasury Statements, Treasury securities auctions, interest rates on Treasury securities, foreign exchange rates, savings bonds, or any U.S. government financial statistics.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Fusfiscaldata\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M75GVDTBSXRQ4Q11RVJQC56M","treatment-plans","Generate concise (3-4 page), focused medical treatment plans in LaTeX\u002FPDF format for all clinical specialties. Supports general medical treatment, rehabilitation therapy, mental health care, chronic disease management, perioperative care, and pain management. Includes SMART goal frameworks, evidence-based interventions with minimal text citations, regulatory compliance (HIPAA), and professional formatting. Prioritizes brevity and clinical actionability.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fai-skillforge\u002Fblob\u002Fmain\u002Fskills\u002Fscientific\u002Ftreatment-plans\u002FSKILL.md",[],[]]