[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6M03X2072FPRQ4VWV8H67AN":3,"skill-same:01M6M03X2072FPRQ4VWV8H67AN":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":13,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":68},"01M6M03X2072FPRQ4VWV8H67AN","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.","endman100\u002Fskill-router-nexus","endman100","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F31997019?v=4","01M6KPDX17BYDWW4RRB0TNGGMX","01M6KPDX64Y2QBEWVFG5W5PWPF",0,"MIT","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fchemistry-and-drug-discovery\u002Fmolecular-dynamics\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"molecular dynamics","molecular","dynamics","define","Simulations","Protein","energy","openmm","for","with","trajectories","biology","binding","free","run","structural","structural biology","force fields","biophysics","surfaces","maps","up","analyze","SET","2026-11-10 10:12:30",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":14,"metadata":47,"description":7},{"skill-author":48},"Kuan-lin Huang","main","f19b254e8975d0bfddb394686706106930d7964d","Science\u002Fchemistry-and-drug-discovery\u002Fmolecular-dynamics","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus","https:\u002F\u002Fgithub.com\u002Fendman100","2026-11-12 18:13:37",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add endman100\u002Fskill-router-nexus --skill molecular-dynamics",{"tool":61,"command":62},"bunx","bunx skills add endman100\u002Fskill-router-nexus --skill molecular-dynamics",{"tool":64,"command":65},"pnpm","pnpm dlx skills add endman100\u002Fskill-router-nexus --skill molecular-dynamics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fchemistry-and-drug-discovery\u002Fmolecular-dynamics\u002FSKILL.md",true,[69],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fmdanalysis_analysis.md","REFERENCE","参考文档",5643,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fchemistry-and-drug-discovery\u002Fmolecular-dynamics\u002Freferences\u002Fmdanalysis_analysis.md",[76,100,137,160,169,193],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":88,"publishedAt":42},"01M6MPCT5BXVER8HQZTW3QE9AS","create-master","基于佛教经典文献，生成特定高僧大德的 AI 教学角色","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FSKILL.md",[83],{"categoryNo":84,"categoryName":85,"taxonomyType":86,"taxonomyTypeDesc":87},"01JBSEEDCAT000000000000039","教师与教育","PROFESSION","适用职业",[89,90,91,92,93,94,95,96,97,98,99],"create master","master","create","生成","true","webfetch","edit","write","read","grep","Bash",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":118,"publishedAt":42},"01M6M43AKE95Y64E1JRXEF5QQ3","writing-dna-skill","从至少 20 篇完整文章中蒸馏可复用的写作 DNA，分析语言、文章结构、选题逻辑、素材策略、认知框架和视觉风格，并生成 Writing-DNA.md；按该 DNA 写作时会读取全部蒸馏产物和 5 篇相关原文。用于中英文作者、账号、品牌或出版物的风格分析与一致性写作。 Distill reusable Writing DNA from at least 20 complete articles for Chinese or English authors, publications, brands, and accounts; use for language, structure, topic logic, source strategy, cognitive-frame, and visual-style analysis.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FSKILL.md",[107,112,115],{"categoryNo":108,"categoryName":109,"taxonomyType":110,"taxonomyTypeDesc":111},"01JBSEEDCAT000000000000018","写作与文案","SCENARIO","使用场景",{"categoryNo":113,"categoryName":114,"taxonomyType":110,"taxonomyTypeDesc":111},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":116,"categoryName":117,"taxonomyType":86,"taxonomyTypeDesc":87},"01JBSEEDCAT000000000000036","内容创作者",[119,120,121,122,123,124,125,126,127,128,129,130,131,92,132,133,134,26,135,136],"writing dna skill","DNA","writing","strategy","english","logic","visual","structure","chinese","reusable","use","style","distill","analysis","frame","source","at","complete",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":141,"sourceHtmlUrl":142,"categories":143,"keywords":146,"publishedAt":42},"01M6M428TTCGQ4ME3KY99VN037","stop-slop","Remove AI writing patterns from prose. Use when drafting, editing, or reviewing text to eliminate predictable AI tells.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FSKILL.md",[144,145],{"categoryNo":108,"categoryName":109,"taxonomyType":110,"taxonomyTypeDesc":111},{"categoryNo":116,"categoryName":117,"taxonomyType":86,"taxonomyTypeDesc":87},[147,148,149,150,151,152,153,154,155,129,156,157,158,26,159,121],"slop","stop slop","stop","drafting","when","drafts","https","patterns","prose","remove","editing","text","content",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":164,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":42},"01M6M41X0B7EBX42TK435DMGGR","shuorenhua","检查和清理中英文文本里的 AI 套路，适用于“去 AI 味”“说人话”“自然一点”“别像模板”“先标问题”这类改写和审稿需求；按场景控制力度，同时保留事实、术语、语域和责任主体。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FSKILL.md",[],[162,168],"文本",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":173,"sourceHtmlUrl":174,"categories":175,"keywords":176,"publishedAt":42},"01M6M3ZD12WBEW5KXKDM4N6DFG","naming","Name products, SaaS, brands, open source projects, bots, and apps. Use when the user needs to name something, find a brand name, or pick a product name. Metaphor-driven process that produces memorable, meaningful names and avoids AI slop.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FSKILL.md",[],[171,177,178,179,180,181,129,182,97,134,183,184,185,186,99,187,188,189,190,151,191,192,147],"repo","websearch","product name","apps","bots","view","brand","pick","gh","projects","open","saas","open source","product","describe","ai slop",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":197,"sourceHtmlUrl":198,"categories":199,"keywords":201,"publishedAt":42},"01M6M3YVXAFAAWJ7F6JMPFREYE","humanizer-zh","去除文本中的 AI 生成痕迹。适用于编辑或审阅文本，使其听起来更自然、更像人类书写。\n基于维基百科的\"AI 写作特征\"综合指南。检测并修复以下模式：夸大的象征意义、\n宣传性语言、以 -ing 结尾的肤浅分析、模糊的归因、破折号过度使用、三段式法则、\nAI 词汇、否定式排比、过多的连接性短语。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FSKILL.md",[200],{"categoryNo":108,"categoryName":109,"taxonomyType":110,"taxonomyTypeDesc":111},[202,203,204,97,96,95,121,92,168,205,147,149],"humanizer","zh","humanizer zh","翻译"]