Skip to content

feat(forge): Implement Hybrid Electrostatics with Environmental Field Polarization#12

Merged
TKanX merged 77 commits intomainfrom
feature/11-refactor-charge-engine-for-hybrid-biological-electrostatics
Jan 11, 2026
Merged

feat(forge): Implement Hybrid Electrostatics with Environmental Field Polarization#12
TKanX merged 77 commits intomainfrom
feature/11-refactor-charge-engine-for-hybrid-biological-electrostatics

Conversation

@TKanX
Copy link
Copy Markdown
Member

@TKanX TKanX commented Jan 11, 2026

Summary:

Refactored the charge calculation system to support a "Hybrid" mode, enabling high-fidelity electrostatics for biological systems. This engine integrates the ffcharge crate to assign classical force field charges (AMBER/CHARMM/TIP3P) to standard biomolecules (proteins, nucleic acids, water, ions), while reserving QEq charge equilibration for ligands and hetero groups. This approach combines the accuracy of established force fields for macromolecules with the flexibility of QEq for novel drug-like molecules.

Changes:

  • Integrated ffcharge Crate:

    • Added ffcharge dependency to provide a database of standard partial charges from major force fields (AMBER ff99SB/ff14SB, CHARMM36, TIP3P/SPC water models).
    • Implemented HybridConfig to allow user selection of protein, nucleic acid, and water charge schemes.
  • Implemented Hybrid Charge Strategy:

    • Developed src/forge/charge/hybrid.rs to classify atoms as Protein, Nucleic Acid, Water, Ion, or Ligand based on BioMetadata.
    • Created logic to assign fixed charges from ffcharge to standard residues, respecting pH-dependent terminal protonation states (N-terminus/C-terminus).
    • Designed a fallback mechanism that routes unclassified atoms (ligands) to the QEq solver.
  • Developed Embedded QEq:

    • Implemented an "Embedded" QEq mode (LigandQeqMethod::Embedded) where ligand charges are polarized by the electrostatic field of the surrounding protein environment.
    • Created src/forge/charge/spatial.rs with a SpatialGrid for efficient O(1) neighbor lookups to identify environment atoms within a cutoff radius.
    • Connected cheq's solve_in_field API to include external point charges in the equilibration process.
  • Enhanced CLI Support:

    • Updated dforge bio to support --charge hybrid with granular configuration flags:
      • --protein-scheme, --nucleic-scheme, --water-scheme for selecting force fields.
      • --ligand <CHAIN:RESID> syntax for targeting specific ligands with custom QEq settings (vacuum vs. embedded).
    • Added comprehensive QEq solver tuning options (--qeq-tolerance, --qeq-damping, --qeq-hydrogen-scf) exposed to the CLI.
  • Refactored Charge Module:

    • Restructured src/forge/charge/ into submodules (qeq, hybrid, spatial) for better separation of concerns.
    • Updated ForgeConfig and ChargeMethod enums to accommodate the new hybrid configuration structures.
  • Documentation & Examples:

    • Expanded MANUAL.md with detailed explanations of the hybrid charge workflow and configuration examples.
    • Updated ARCHITECTURE.md with diagrams illustrating the hybrid dispatch logic and embedded QEq data flow.
    • Added a new example in examples/complex/ demonstrating hybrid charging of a fullerene-protein complex, including analysis of pH-dependent polarization effects.

TKanX added 30 commits January 5, 2026 15:23
TKanX added 19 commits January 9, 2026 22:14
… charge distribution analysis for 5HKR example
@TKanX TKanX self-assigned this Jan 11, 2026
Copilot AI review requested due to automatic review settings January 11, 2026 03:26
@TKanX TKanX added documentation 📖 Improvements or additions to documentation enhancement ✨ New feature or request labels Jan 11, 2026
@TKanX TKanX linked an issue Jan 11, 2026 that may be closed by this pull request
24 tasks
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a hybrid electrostatics system for biological simulations by combining classical force field charges (AMBER/CHARMM) for standard biomolecules with QEq charge equilibration for ligands and hetero groups. The implementation includes environmental field polarization through an "embedded" QEq mode that accounts for electrostatic potential from surrounding fixed-charge atoms.

Changes:

  • Refactored charge calculation module into separate submodules (qeq, hybrid, spatial)
  • Integrated ffcharge crate for classical force field charge assignment
  • Implemented embedded QEq with spatial grid optimization for efficient neighbor lookups
  • Enhanced CLI with granular hybrid charge configuration options
  • Changed chain_id from char to String and insertion_code from char to Option<char> for better PDB/mmCIF compatibility
  • Added target_ph field to BioMetadata for pH-dependent protonation state handling

Reviewed changes

Copilot reviewed 25 out of 37 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/model/metadata.rs Updated chain_id to String, insertion_code to Option, added target_ph and effective_ph()
src/io/util.rs Propagated chain_id/insertion_code type changes through conversion functions
src/io/pdb/reader.rs Added target_ph propagation from protonation config to BioMetadata
src/io/mmcif/reader.rs Added target_ph propagation from protonation config to BioMetadata
src/io/bgf/writer.rs Updated for chain_id/insertion_code type changes, converts String to char for BGF format
src/forge/config/mod.rs New module structure exposing all config types including hybrid-specific ones
src/forge/config/charge.rs New file defining ChargeMethod, QeqConfig, HybridConfig, and related types
src/forge/config/potential.rs New file separating potential type enums from main config
src/forge/charge/qeq.rs Extracted QEq implementation into dedicated module
src/forge/charge/hybrid.rs New implementation of hybrid charge assignment with atom classification and embedded QEq
src/forge/charge/spatial.rs New spatial grid data structure for O(1) neighbor queries
src/forge/intermediate.rs Added bio_metadata field and effective_ph() helper method
src/forge/error.rs Added MissingBioMetadata and HybridChargeAssignment error variants
src/forge/paramgen.rs Updated to handle Hybrid charge method for hydrogen bond parameters
src/bin/dforge/cli.rs Restructured CLI with ChargeOptions, HybridChargeOptions, QeqSolverOptions, and PotentialOptions
src/bin/dforge/config/forge.rs Split into build_bio_forge_config and build_chem_forge_config
src/bin/dforge/config/bio.rs Updated to pass Option for pH instead of unwrapping
src/bin/dforge/util/convert.rs Added extensive conversion logic for hybrid config and force field schemes
src/bin/dforge/commands/bio.rs Updated to use new config structure and display hybrid charge information
src/bin/dforge/commands/chem.rs Updated to use new config structure
examples/complex/README.md Added comprehensive examples demonstrating hybrid charge calculations with pH effects
README.md Updated with hybrid charge example and dependency information
MANUAL.md Extensive documentation of hybrid charge options and QEq solver tuning
ARCHITECTURE.md Added detailed diagrams and explanations of hybrid charge workflow
Cargo.toml Version bump to 0.3.0, updated dependencies (bio-forge 0.3.1, cheq 0.5.0, ffcharge 0.2.0)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/forge/config/charge.rs
Comment thread Cargo.toml
Comment thread src/forge/config/charge.rs
Comment thread src/forge/charge/hybrid.rs
@TKanX TKanX merged commit 96963f3 into main Jan 11, 2026
2 checks passed
@TKanX TKanX deleted the feature/11-refactor-charge-engine-for-hybrid-biological-electrostatics branch January 11, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📖 Improvements or additions to documentation enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Charge Engine for Hybrid Biological Electrostatics

2 participants