feat(md): add CSVR thermostat for NVT molecular dynamics#7461
feat(md): add CSVR thermostat for NVT molecular dynamics#7461mintleaf84 wants to merge 6 commits into
Conversation
Implement the Canonical Sampling through Velocity Rescaling (CSVR) thermostat as described in: G. Bussi, D. Donadio, M. Parrinello, J. Chem. Phys. 126, 014101 (2007) Features: - New thermostat option: md_thermostat = csvr - New parameter: md_csvr_tau (characteristic time scale) - Properly samples the canonical (NVT) ensemble - Simple implementation with only one parameter Implements deepmodeling#6941
- Add csvr option to md_thermostat parameter description - Add md_csvr_tau parameter documentation Implements deepmodeling#6941
Add CSVR thermostat test case to verlet_test.cpp: - Test position update correctness - Verify temperature is in reasonable range Implements deepmodeling#6941
| } | ||
|
|
||
| // Get degrees of freedom | ||
| int ndeg = frozen_freedom_; |
There was a problem hiding this comment.
frozen_freedom_ is FROZEN degree instead of atom degree.
There was a problem hiding this comment.
Fixed. Changed to 3 * ucell.nat - frozen_freedom_.
| factor = exp(-1.0 / taut); | ||
| } | ||
|
|
||
| // Generate Gaussian random number |
There was a problem hiding this comment.
MD_func::gaussrand() can be used to generate Gaussian random number.
There was a problem hiding this comment.
Fixed. Replaced with MD_func::gaussrand().
| sumnoises += r * r; | ||
| } | ||
|
|
||
| // CSVR core formula |
There was a problem hiding this comment.
This part can be more concise.
Add another factor:
double factor2 = (1-factor)*kin_target/kin_energy/ndeg;
......
double resample = factor + factor2 * (rr*rr+sumnoises ) + 2.0*rr*sqrt(factor*factor2);
There was a problem hiding this comment.
Fixed. Simplified with factor2 variable.
- Fix degrees of freedom: use 3N - frozen_freedom instead of frozen_freedom - Use MD_func::gaussrand() instead of std::random for consistency - Simplify CSVR core formula with factor2 variable - Remove unused #include <random> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
a26615f to
0ce1d85
Compare
Code Change SummaryAll review comments have been addressed:
double factor2 = (1.0 - factor) * kin_target / kin_energy / ndeg;
double resample = factor + factor2 * (rr * rr + sumnoises) + 2.0 * rr * sqrt(factor * factor2); |
Reminder
Linked Issue
Implements #6941
Unit Tests and/or Case Tests for my changes
source/source_md/test/verlet_test.cpp[PASSED] 1 testWhat's changed?
Implement the Canonical Sampling through Velocity Rescaling (CSVR) thermostat as described in:
G. Bussi, D. Donadio, M. Parrinello, J. Chem. Phys. 126, 014101 (2007)
Features:
md_thermostat = csvrmd_csvr_tau(characteristic time scale, default: 100.0 fs)Usage:
Changed Files
source/source_io/module_parameter/md_parameter.hmd_csvr_tauparametersource/source_io/module_parameter/read_input_item_md.cppmd_csvr_tausource/source_md/verlet.happly_csvr()function declarationsource/source_md/verlet.cppsource/source_md/test/verlet_test.cppdocs/advanced/input_files/input-main.mdAny changes of core modules? (ignore if not applicable)
No changes to core modules. The modification is only in the MD module.