kups.md.integrators
¶
CSVRStep
¶
Bases: Propagator[State]
Canonical Sampling through Velocity Rescaling (CSVR) thermostat step.
Implements the Bussi-Donadio-Parrinello algorithm for canonical sampling by stochastically rescaling velocities to maintain the target temperature. This produces correct canonical ensemble sampling unlike deterministic velocity rescaling (Berendsen thermostat).
The scaling factor \(\alpha^2\) is sampled from the conditional distribution:
The algorithm uses:
where:
- \(c_1 = e^{-\Delta t/\tau}\) — exponential decay factor
- \(c_2 = (1-c_1) \cdot K_{\text{target}}/(K_{\text{current}} \cdot N_{\text{dof}})\) — correction factor
- \(R_1 \sim \mathcal{N}(0,1)\) — Gaussian random variable
- \(R_2 \sim \chi^2(N_{\text{dof}}-1)\) — chi-squared random variable
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Lens[State, Table[ParticleId, IsCSVRParticleData]]
|
Lens to get/set indexed particle data (momenta \(\\mathbf{p}\), masses \(m\)) |
systems |
View[State, Table[SystemId, IsCSVRParams]]
|
View to extract system data (time step \(\\Delta t\), temperature \(T\), degrees of freedom \(N_{\\text{dof}}\), thermostat time constant \(\\tau\)) |
References
Bussi, G., Donadio, D., & Parrinello, M. (2007). Canonical sampling through velocity rescaling. J. Chem. Phys., 126(1), 014101. DOI: 10.1063/1.2408420
Source code in src/kups/md/integrators.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
__call__(key, state)
¶
Apply CSVR stochastic velocity rescaling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key for generating random noise |
required |
state
|
State
|
Current simulation state |
required |
Returns:
| Type | Description |
|---|---|
State
|
Updated state with rescaled momenta matching target temperature distribution |
Source code in src/kups/md/integrators.py
CellMomentumKick
¶
Bases: Propagator[State]
B\(^h\) kick (Gao Algorithm lines 2 & 13).
Updates the cell-momentum tensor by the pressure-deviation virial. In paper convention (Eq. 8d) the deterministic term is
In kUPS convention \(V = h^T\), so \(h^{-T} = V^{-1}\), and \(p^h_{\text{kUPS}} = (p^h_{\text{paper}})^T\). Transposing the kick and projecting to the lower triangle gives the kUPS-side update applied here:
The integration uses \(\Delta t / 2\) — the algorithm calls this kick four times per step, twice at the start and twice at the end of the BAOAB palindrome, each at a half time-step. \(P_{\text{ins}}\) is the symmetric pressure tensor from instantaneous_pressure_tensor and includes the lattice-gradient contribution. \(\chi = 1\) for the 3D lower-triangular cell parameterisation (Appendix A, \(\nu/d-1\)).
Source code in src/kups/md/integrators.py
CellPositionStep
¶
Bases: Propagator[State]
A\(^h\) drift (Gao Algorithm lines 4 & 9): cell-only drift.
Implements the paper's :math:\mathcal{F}^h_K = \sum_{\alpha\beta}
(p^h_{\alpha\beta}/M_{\alpha\beta})\,\partial/\partial h_{\alpha\beta},
which moves only \(h\):
Atomic positions are not modified here. The convective response of
particle positions to cell motion (\(\dot{h} h^{-1} r\), paper Eq. 8a) is
handled in :class:CoupledPositionStep via the analytic ODE solver;
rescaling positions in this step too would double-count the convective
term and break the symplectic Trotter splitting.
The new cell is reconstructed as a :class:TriclinicFrame from the
drifted lower-triangular vectors, which forces a fresh volume cache.
Source code in src/kups/md/integrators.py
CellStochasticStep
¶
Bases: Propagator[State]
O\(^h\) Ornstein–Uhlenbeck thermostat on the cell-momentum tensor (Gao Algorithm line 6).
Exact OU solution per lower-triangular component:
with \(R_{\alpha\beta} \sim \mathcal{N}(0, 1)\). Noise is masked to the lower triangle so strict-upper components of \(p^h\) remain zero.
Source code in src/kups/md/integrators.py
CoupledMomentumStep
¶
Bases: Propagator[State]
B kick with cell coupling (Gao Algorithm lines 3 & 11).
Solves \(\dot{p}_i = F_i - h^{-\top}\dot{h}^{\top} p_i\) exactly over the
params time-step via :func:solve_affine_ode. In kUPS row-vector form
the coupling becomes \(\dot{p}_{\text{row}} = F_{\text{row}} - p_{\text{row}}\cdot M^{\top}\)
with \(M = V^{-1}\dot{V}\) (lower-triangular); the equivalent column-vector
ODE has \(A = -M\).
Half time-step: the BAOAB palindrome calls this kick four times per full step, each at \(\Delta t / 2\).
Source code in src/kups/md/integrators.py
CoupledPositionStep
¶
Bases: Propagator[State]
A drift with cell coupling (Gao Algorithm lines 5 & 8).
Solves \(\dot{r}_i = p_i/m_i + \dot{h}h^{-1} r_i\) exactly over the params
time-step via :func:solve_affine_ode. In kUPS row-vector form the
coupling becomes \(\dot{r}_{\text{row}} = v_{\text{row}} + r_{\text{row}}\cdot M\)
with \(M = V^{-1}\dot{V}\) (lower-triangular); the column-vector ODE has
\(A = M^{\top}\) (upper-triangular).
Half time-step: the BAOAB palindrome calls this drift four times per full step, each at \(\Delta t / 2\).
Source code in src/kups/md/integrators.py
Flow
¶
Bases: Protocol
Protocol for position update flows with boundary conditions.
A flow defines how positions evolve under velocity updates, potentially including boundary conditions like periodic wrapping or reflections.
Source code in src/kups/md/integrators.py
__call__(state, dt, primal, tangent)
¶
Apply flow to update positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
State
|
Current simulation state. |
required |
dt
|
Time
|
Timestep \(\Delta t\) (units: time). |
required |
primal
|
PyTree
|
Position \(\mathbf{r}\) (units: length). |
required |
tangent
|
PyTree
|
Velocity \(\mathbf{v}\) (units: length/time). |
required |
Returns:
| Type | Description |
|---|---|
PyTree
|
Updated position (units: length). |
Source code in src/kups/md/integrators.py
IsBAOABLangevinParams
¶
Bases: HasTimeStep, HasTemperature, HasFrictionCoefficient, Protocol
Integrator-params shape for :func:make_baoab_langevin_step.
Source code in src/kups/md/integrators.py
IsBAOABNPTLangevinParams
¶
Bases: HasTimeStep, HasTemperature, HasFrictionCoefficient, HasTargetPressure, HasPressureCouplingTime, HasCompressibility, HasBarostatMass, HasBarostatFriction, Protocol
Integrator-params shape for :func:make_baoab_npt_langevin_step.
Source code in src/kups/md/integrators.py
IsBAOABNPTLangevinSystem
¶
Bases: IsBAOABNPTLangevinSystemBase, HasIntegratorParams[IsBAOABNPTLangevinParams], Protocol
NPT Langevin MD system row: :class:IsBAOABNPTLangevinSystemBase plus integrator params.
Source code in src/kups/md/integrators.py
IsBAOABNPTLangevinSystemBase
¶
Bases: HasCell[Periodic3D], HasCellMomentum, Protocol
Params-free NPT Langevin MD system row: periodic cell, cell-momentum tensor, and a cell-gradient leaf for the virial.
Source code in src/kups/md/integrators.py
IsCSVRNPTParams
¶
Bases: HasTimeStep, HasTemperature, HasThermostatTimeConstant, HasTargetPressure, HasPressureCouplingTime, HasCompressibility, HasMinimumScaleFactor, Protocol
Integrator-params shape for :func:make_csvr_npt_step.
Source code in src/kups/md/integrators.py
IsCSVRParams
¶
Bases: HasTimeStep, HasTemperature, HasThermostatTimeConstant, Protocol
Integrator-params shape for :func:make_csvr_step.
Source code in src/kups/md/integrators.py
IsMDSystem
¶
Bases: HasCell[Periodic3D], HasIntegratorParams[P], Protocol
Protocol for an MD system row: a periodic cell plus bundled integrator parameters.
Source code in src/kups/md/integrators.py
IsMDSystemNPT
¶
Bases: IsMDSystemNPTBase, HasIntegratorParams[IsCSVRNPTParams], Protocol
NPT MD system row: :class:IsMDSystemNPTBase plus bundled integrator parameters.
Source code in src/kups/md/integrators.py
IsMDSystemNPTBase
¶
Bases: HasCell[Periodic3D], Protocol
Params-free NPT MD system row: a periodic cell plus the barostat cell-gradient leaf.
Source code in src/kups/md/integrators.py
IsVerletParams
¶
Bases: HasTimeStep, Protocol
Integrator-params shape for :func:make_velocity_verlet_step.
Source code in src/kups/md/integrators.py
MomentumStep
¶
Bases: Propagator[State]
Update momenta using forces according to Newton's second law.
Implements the 'B' operator in splitting schemes, applying forces to update particle momenta. This is the dynamical update step that couples to the potential energy landscape.
The momentum update follows:
where \(\mathbf{F} = -\nabla U\) is the force derived from potential energy \(U\).
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Lens[State, Table[ParticleId, IsMomentumStepData]]
|
Lens to get/set indexed particle data (momenta \(\mathbf{p}\), forces \(\mathbf{F}\)) |
systems |
View[State, Table[SystemId, HasTimeStep]]
|
View to extract system data with time step \(\Delta t\) |
Source code in src/kups/md/integrators.py
__call__(key, state)
¶
Apply momentum update step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key (unused in this deterministic step). |
required |
state
|
State
|
Current simulation state. |
required |
Returns:
| Type | Description |
|---|---|
State
|
Updated state with new momenta. |
Source code in src/kups/md/integrators.py
PositionStep
¶
Bases: Propagator[State]
Update positions using velocities in molecular dynamics.
Implements the 'A' operator in splitting schemes, propagating positions forward in time using the current velocities. This is the kinematic update step in velocity Verlet and related integrators.
The position update follows:
where \(\mathbf{v} = \mathbf{p}/m\) is the velocity derived from momentum.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Lens[State, Table[ParticleId, _PositionStepData]]
|
Lens to get/set indexed particle data (momenta \(\mathbf{p}\), positions \(\mathbf{r}\), masses \(m\)) |
systems |
View[State, Table[SystemId, HasTimeStep]]
|
View to extract system data with time step \(\Delta t\) |
flow |
Flow[State, Array]
|
Flow operator defining how positions evolve (handles boundary conditions) |
Source code in src/kups/md/integrators.py
__call__(key, state)
¶
Apply position update step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key (unused in this deterministic step). |
required |
state
|
State
|
Current simulation state. |
required |
Returns:
| Type | Description |
|---|---|
State
|
Updated state with new positions. |
Source code in src/kups/md/integrators.py
StochasticCellRescalingStep
¶
Bases: Propagator[State]
Stochastic cell rescaling barostat for NPT ensemble sampling.
Implements the isotropic stochastic cell rescaling algorithm (Bernetti & Bussi, 2020) that correctly samples the NPT ensemble. This first-order barostat includes a stochastic term to ensure proper volume fluctuations, unlike the Berendsen barostat which artificially suppresses fluctuations.
The algorithm scales both the simulation box and particle positions by a factor \(\mu\) determined by:
where:
- \(\tau_P\) = pressure coupling time constant
- \(P\) = instantaneous pressure
- \(P_0\) = target pressure
- \(\beta\) = isothermal compressibility
- \(k_B T\) = thermal energy
- \(V\) = box volume
- \(R \sim \mathcal{N}(0,1)\) = Gaussian random noise
The scaling is applied to both box and positions:
Important: The Cell must be reconstructed after scaling to ensure the cached volume is recomputed correctly.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Lens[State, Table[ParticleId, _BarostatParticleData]]
|
Lens to get/set indexed particle data (positions \(\mathbf{r}\), momenta \(\mathbf{p}\), masses \(m\)) |
systems |
Lens[State, Table[SystemId, IsMDSystemNPT]]
|
Lens to get/set system data (lattice vectors \(\mathbf{L}\), stress tensor \(\mathbf{W}\), time step \(\Delta t\), temperature \(T\), target pressure \(P_0\), barostat time constant \(\tau_P\), compressibility \(\beta\), minimum scale factor \(\mu_{\text{min}}\)) |
References
Bernetti, M., & Bussi, G. (2020). Pressure control using stochastic cell rescaling. J. Chem. Phys., 153(11), 114107. DOI: 10.1063/5.0020514
Source code in src/kups/md/integrators.py
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
__call__(key, state)
¶
Apply stochastic cell rescaling for pressure control.
Scales the simulation box and particle positions by a factor determined from pressure deviation and stochastic fluctuations. The Cell is reconstructed to ensure cached volume is updated correctly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key for generating volume fluctuation noise |
required |
state
|
State
|
Current simulation state |
required |
Returns:
| Type | Description |
|---|---|
State
|
Updated state with rescaled box and positions matching NPT ensemble |
Source code in src/kups/md/integrators.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
StochasticStep
¶
Bases: Propagator[State]
Langevin thermostat stochastic step with exact Ornstein-Uhlenbeck solution.
Implements the 'O' operator in the BAOAB splitting scheme. This step exactly solves the Ornstein-Uhlenbeck stochastic differential equation:
The exact solution for timestep \(\Delta t\) is:
where \(\eta \sim \mathcal{N}(0,1)\) is Gaussian white noise. This preserves the correct Maxwell-Boltzmann distribution at temperature \(T\).
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Lens[State, Table[ParticleId, IsStochasticParticleData]]
|
Lens to get/set indexed particle data (momenta \(\mathbf{p}\), masses \(m\)) |
system |
View[State, Table[SystemId, IsBAOABLangevinParams]]
|
View to extract system data (time step \(\Delta t\), temperature \(T\), friction coefficient \(\gamma\)) |
References
Leimkuhler, B., & Matthews, C. (2013). Rational construction of stochastic numerical methods for molecular sampling. Appl. Math. Res. Express, 2013(1), 34-56. DOI: 10.1093/amrx/abs010
Source code in src/kups/md/integrators.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
__call__(key, state)
¶
Apply stochastic Ornstein-Uhlenbeck thermostat step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key for generating random noise |
required |
state
|
State
|
Current simulation state |
required |
Returns:
| Type | Description |
|---|---|
State
|
Updated state with thermostated momenta |
Source code in src/kups/md/integrators.py
WrapFlow
¶
Bases: Flow[State, PyTree]
Flow that applies the cell's wrap to updated positions.
After the base flow updates positions, applies the cell's wrap method.
On periodic axes this folds positions back into the box (minimum image
convention); on non-periodic axes wrap is the identity and positions
pass through unchanged.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
State
|
Simulation state type |
required | |
PyTree
|
JAX PyTree type for positions |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
cell |
View[State, Cell[AnyPeriodicity]]
|
View to extract the Cell from state |
flow |
Flow[State, PyTree]
|
Underlying flow operator (typically euclidean_flow) |
Example
Source code in src/kups/md/integrators.py
WrapStep
¶
Bases: Propagator[State]
Apply the cell's wrap operation to particle positions.
Standalone version of :class:WrapFlow for use at the end of a coupled
integration step where the per-A-step wrap would break the analytic
affine-ODE solution.
Source code in src/kups/md/integrators.py
euclidean_flow(state, dt, primal, tangent)
¶
Flow in unbounded Euclidean space without boundary conditions.
Implements simple kinematic update:
Use this for non-periodic systems or when positions are handled differently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Any
|
Current simulation state (unused but required by Flow protocol) |
required |
dt
|
Time
|
Timestep \(\Delta t\) (units: time) |
required |
primal
|
Array
|
Position \(\mathbf{r}\) (units: length) |
required |
tangent
|
Array
|
Velocity \(\mathbf{v}\) (units: length/time) |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Updated position \(\mathbf{r}_{\text{new}}\) (units: length) |
Source code in src/kups/md/integrators.py
make_baoab_langevin_step(particles, systems, derivative_computation, flow)
¶
Create BAOAB Langevin integrator for canonical (NVT) ensemble sampling.
BAOAB is a second-order splitting scheme for Langevin dynamics that provides efficient sampling of the canonical ensemble. The name comes from the sequence of operators: B (momentum kick), A (position update), O (Ornstein-Uhlenbeck), A (position update), B (momentum kick).
Algorithm steps:
- B: \(\mathbf{p}(t+\Delta t/4) = \mathbf{p}(t) + \mathbf{F}(t) \cdot \Delta t/2\) — half momentum step
- A: \(\mathbf{r}(t+\Delta t/2) = \mathbf{r}(t) + \mathbf{p}(t+\Delta t/4)/m \cdot \Delta t/2\) — half position step
- O: $\mathbf{p}(t+3\Delta t/4) = $ exact OU solution — stochastic thermostat
- A: \(\mathbf{r}(t+\Delta t) = \mathbf{r}(t+\Delta t/2) + \mathbf{p}(t+3\Delta t/4)/m \cdot \Delta t/2\) — half position step
- Compute \(\mathbf{F}(t+\Delta t)\) — force evaluation
- B: \(\mathbf{p}(t+\Delta t) = \mathbf{p}(t+3\Delta t/4) + \mathbf{F}(t+\Delta t) \cdot \Delta t/2\) — half momentum step
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Lens[State, Table[ParticleId, _MDParticleData]]
|
Lens to get/set indexed particle data (momenta \(\\mathbf{p}\), positions \(\\mathbf{r}\), forces \(\\mathbf{F}\), masses \(m\)) |
required |
systems
|
View[State, Table[SystemId, HasIntegratorParams[IsBAOABLangevinParams]]]
|
View to extract system data (time step \(\\Delta t\), thermal energy \(k_B T\), friction coefficient \(\\gamma\)) |
required |
derivative_computation
|
Propagator[State]
|
Propagator to compute forces \(\\mathbf{F}\) from state |
required |
flow
|
Flow[State, Array]
|
Flow operator for position updates (handles boundary conditions) |
required |
Returns:
| Type | Description |
|---|---|
SequentialPropagator[State]
|
SequentialPropagator implementing the BAOAB algorithm |
References
Leimkuhler, B., & Matthews, C. (2013). Rational construction of stochastic numerical methods for molecular sampling. Appl. Math. Res. Express, 2013(1), 34-56. DOI: 10.1093/amrx/abs010
Source code in src/kups/md/integrators.py
make_baoab_npt_langevin_step(particles, systems, derivative_computation, flow)
¶
Create the fully-flexible-cell BAOAB NPT Langevin integrator.
Implements the Trotter-split scheme of Gao, Fang & Wang (Sampling the isothermal-isobaric ensemble by Langevin dynamics, arxiv 1601.01044, JCP 2016). Each step is a palindrome of 12 sub-operators around a single OU pair, with one force/stress evaluation per step:
B^h ▸ B ▸ A^h ▸ A ▸ O^h ▸ O ▸ A ▸ A^h ▸ wrap ▸ F ▸ B ▸ B^h
Algorithm (paper §III lines 2–13):
- B^h (\(\Delta t/2\)): kick cell-momentum by the pressure deviation.
- B (\(\Delta t/2\)): coupled atom-momentum kick, \(\dot p = F - h^{-T}\dot h^{T} p\).
- A^h (\(\Delta t/2\)): drift the cell matrix only.
- A (\(\Delta t/2\)): coupled atom-position drift, \(\dot r = p/m + \dot h h^{-1} r\).
- O^h (\(\Delta t\)): exact OU thermostat on cell-momentum.
- O (\(\Delta t\)): exact OU thermostat on atom-momentum (reuses
:class:
StochasticStep). - A (\(\Delta t/2\)): repeat.
- A^h (\(\Delta t/2\)): repeat.
- wrap: single periodic wrap of all positions.
- F: recompute forces and cell-gradients at the wrapped coordinates retained in the state.
- B (\(\Delta t/2\)): repeat.
- B^h (\(\Delta t/2\)): repeat.
The atom-side OU step is the existing :class:StochasticStep
(unchanged); only the cell-side machinery is new.
The flow argument is unused (kept for signature compatibility with
the other make_*_step factories); periodic wrapping is handled
in-step by a single :class:WrapStep just before the force evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Lens[State, Table[ParticleId, _BarostatParticleData]]
|
Lens onto the per-particle table (momenta, positions, forces, masses, system). |
required |
systems
|
Lens[State, Table[SystemId, IsBAOABNPTLangevinSystem]]
|
Lens onto the per-system table providing the cell, the
extended-variable cell-momentum, |
required |
derivative_computation
|
Propagator[State]
|
Propagator that updates |
required |
flow
|
Flow[State, Array]
|
Unused — present only for API parity with sibling factories. |
required |
Returns:
| Type | Description |
|---|---|
SequentialPropagator[State]
|
class: |
References
Gao, X., Fang, J., & Wang, H. (2016). Sampling the isothermal-isobaric ensemble by Langevin dynamics. J. Chem. Phys., 144, 124113. arxiv 1601.01044.
Source code in src/kups/md/integrators.py
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | |
make_csvr_npt_step(particles, systems, derivative_computation, flow)
¶
Create NPT integrator for isothermal-isobaric (NPT) ensemble sampling.
Combines CSVR thermostat for temperature control with stochastic cell rescaling (Bernetti-Bussi 2020) for pressure control, integrated with velocity Verlet dynamics. This correctly samples the NPT ensemble with proper volume fluctuations.
Algorithm sequence per timestep:
- Apply CSVR velocity rescaling (temperature control)
- Velocity Verlet integration:
- \(\mathbf{p}(t+\Delta t/2) = \mathbf{p}(t) + \mathbf{F}(t) \cdot \Delta t/2\) — half momentum step
- \(\mathbf{r}(t+\Delta t) = \mathbf{r}(t) + \mathbf{p}(t+\Delta t/2)/m \cdot \Delta t\) — full position step
- Compute \(\mathbf{F}(t+\Delta t)\) — force evaluation
- \(\mathbf{p}(t+\Delta t) = \mathbf{p}(t+\Delta t/2) + \mathbf{F}(t+\Delta t) \cdot \Delta t/2\) — half momentum step
- Stochastic cell rescaling (pressure control)
- Recompute forces and stress after box/position scaling
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Lens[State, Table[ParticleId, _BarostatParticleData]]
|
Lens to get/set indexed particle data (momenta \(\\mathbf{p}\), positions \(\\mathbf{r}\), forces \(\\mathbf{F}\), masses \(m\)) |
required |
systems
|
Lens[State, Table[SystemId, IsMDSystemNPT]]
|
Lens to get/set system data (lattice vectors \(\\mathbf{L}\), stress tensor \(\\mathbf{W}\), time step \(\\Delta t\), temperature \(T\), target pressure \(P_0\), barostat time constant \(\\tau_P\), compressibility \(\\beta\), minimum scale factor \(\\mu_{\\text{min}}\), degrees of freedom \(N_{\\text{dof}}\), thermostat time constant \(\\tau_T\)) |
required |
derivative_computation
|
Propagator[State]
|
Propagator to compute forces \(\\mathbf{F}\) and stress tensor \(\\mathbf{W}\) from state |
required |
flow
|
Flow[State, Array]
|
Flow operator for position updates (handles boundary conditions) |
required |
Returns:
| Type | Description |
|---|---|
SequentialPropagator[State]
|
SequentialPropagator implementing the CSVR-NPT algorithm |
References
CSVR: Bussi, G., Donadio, D., & Parrinello, M. (2007). Canonical sampling through velocity rescaling. J. Chem. Phys., 126(1), 014101. DOI: 10.1063/1.2408420 SCR: Bernetti, M., & Bussi, G. (2020). Pressure control using stochastic cell rescaling. J. Chem. Phys., 153(11), 114107. DOI: 10.1063/5.0020514
Source code in src/kups/md/integrators.py
make_csvr_step(particles, systems, derivative_computation, flow)
¶
Create CSVR integrator for canonical (NVT) ensemble sampling.
Combines the CSVR thermostat with velocity Verlet integration to sample the canonical ensemble at constant temperature. The algorithm applies stochastic velocity rescaling before each velocity Verlet step.
Algorithm steps:
- Apply CSVR velocity rescaling (thermostat)
- Velocity Verlet integration:
- \(\mathbf{p}(t+\Delta t/2) = \mathbf{p}(t) + \mathbf{F}(t) \cdot \Delta t/2\) — half momentum step
- \(\mathbf{r}(t+\Delta t) = \mathbf{r}(t) + \mathbf{p}(t+\Delta t/2)/m \cdot \Delta t\) — full position step
- Compute \(\mathbf{F}(t+\Delta t)\) — force evaluation
- \(\mathbf{p}(t+\Delta t) = \mathbf{p}(t+\Delta t/2) + \mathbf{F}(t+\Delta t) \cdot \Delta t/2\) — half momentum step
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Lens[State, Table[ParticleId, _MDParticleData]]
|
Lens to get/set indexed particle data (momenta \(\\mathbf{p}\), positions \(\\mathbf{r}\), forces \(\\mathbf{F}\), masses \(m\)) |
required |
systems
|
View[State, Table[SystemId, HasIntegratorParams[IsCSVRParams]]]
|
View to extract system data (time step \(\\Delta t\), temperature \(T\), degrees of freedom \(N_{\\text{dof}}\), thermostat time constant \(\\tau\)) |
required |
derivative_computation
|
Propagator[State]
|
Propagator to compute forces \(\\mathbf{F}\) from state |
required |
flow
|
Flow[State, Array]
|
Flow operator for position updates (handles boundary conditions) |
required |
Returns:
| Type | Description |
|---|---|
SequentialPropagator[State]
|
SequentialPropagator implementing the CSVR+Verlet algorithm |
References
Bussi, G., Donadio, D., & Parrinello, M. (2007). Canonical sampling through velocity rescaling. J. Chem. Phys., 126(1), 014101. DOI: 10.1063/1.2408420
Source code in src/kups/md/integrators.py
make_velocity_verlet_step(particles, systems, derivative_computation, flow)
¶
Create a velocity Verlet integrator for molecular dynamics (NVE ensemble).
The velocity Verlet algorithm is a symplectic, time-reversible integrator that provides second-order accuracy in both positions and velocities. It conserves total energy and samples the microcanonical (NVE) ensemble.
Algorithm steps:
- \(\mathbf{p}(t+\Delta t/2) = \mathbf{p}(t) + \mathbf{F}(t) \cdot \Delta t/2\) — momentum half-step
- \(\mathbf{r}(t+\Delta t) = \mathbf{r}(t) + \mathbf{p}(t+\Delta t/2)/m \cdot \Delta t\) — position full-step
- Compute \(\mathbf{F}(t+\Delta t)\) — force evaluation
- \(\mathbf{p}(t+\Delta t) = \mathbf{p}(t+\Delta t/2) + \mathbf{F}(t+\Delta t) \cdot \Delta t/2\) — momentum half-step
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Lens[State, Table[ParticleId, _MDParticleData]]
|
Lens to get/set indexed particle data (momenta \(\\mathbf{p}\), positions \(\\mathbf{r}\), forces \(\\mathbf{F}\), masses \(m\)) |
required |
systems
|
View[State, Table[SystemId, HasIntegratorParams[IsVerletParams]]]
|
View to extract system data with time step \(\\Delta t\) |
required |
derivative_computation
|
Propagator[State]
|
Propagator to compute forces \(\\mathbf{F}\) from state |
required |
flow
|
Flow[State, Array]
|
Flow operator for position updates (handles boundary conditions) |
required |
Returns:
| Type | Description |
|---|---|
SequentialPropagator[State]
|
SequentialPropagator implementing the velocity Verlet algorithm |
References
Swope, W. C., Andersen, H. C., Berens, P. H., & Wilson, K. R. (1982). A computer simulation method for the calculation of equilibrium constants for the formation of physical clusters of molecules: Application to small water clusters. J. Chem. Phys., 76(1), 637-649. DOI: 10.1063/1.442716