Skip to content

Commit 3df3bb4

Browse files
19helloFei Yang
andauthored
Parallel MD (deepmodeling#7812)
* feat: enable MDCell runtime workflows * Fix MDCell force output and default RNG seeding * Add MDCell output controls * Move MDCell force logging to IO * Update random MD references * Clean up MDCell runtime state * Avoid redundant MDCell force storage * Fix MD test velocity setup * Update Langevin MD test references * Optimize MDCell migration output * Fix rebase integration and parameter metadata * Localize MDCell ghost force communication * Add reusable MDCell neighbor skin * Preserve legacy velocity initialization for MD fallback * Simplify MDCell helper functions * Rerun abacuslite MPI check * Remove legacy UnitCell velocity initialization * Remove unused UnitCell MD helpers * docs: clarify MDCell input availability * fix: add parallel cell to Makefile build --------- Co-authored-by: Fei Yang <2501213217@stu.pku.edu.cn>
1 parent c420b7c commit 3df3bb4

67 files changed

Lines changed: 3859 additions & 2311 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/advanced/input_files/input-main.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [System variables](#system-variables)
99
- [suffix](#suffix)
1010
- [ntype](#ntype)
11+
- [cell\_replica](#cell_replica)
1112
- [calculation](#calculation)
1213
- [esolver\_type](#esolver_type)
1314
- [symmetry](#symmetry)
@@ -356,6 +357,8 @@
356357
- [md\_restart](#md_restart)
357358
- [md\_restartfreq](#md_restartfreq)
358359
- [md\_dumpfreq](#md_dumpfreq)
360+
- [md\_neighbor\_skin](#md_neighbor_skin)
361+
- [md\_out\_force](#md_out_force)
359362
- [dump\_force](#dump_force)
360363
- [dump\_vel](#dump_vel)
361364
- [dump\_virial](#dump_virial)
@@ -601,6 +604,12 @@
601604
- **Description**: Number of different atom species in the calculation.
602605
- **Default**: 0
603606

607+
### cell_replica
608+
609+
- **Type**: Three Integers
610+
- **Description**: Replicate the input STRU by Na, Nb, and Nc along its lattice vectors for distributed MDCell workflows. This parameter is only used for classical potentials or machine-learned interatomic potentials. The default is 1 1 1, which preserves the input structure.
611+
- **Default**: 1 1 1
612+
604613
### calculation
605614

606615
- **Type**: String
@@ -3504,15 +3513,28 @@
35043513
### md_restartfreq
35053514

35063515
- **Type**: Integer
3507-
- **Description**: The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
3516+
- **Description**: The output frequency of OUT.{suffix}/STRU_MD_*, which are used to restart molecular dynamics calculations, see md_restart in detail. Set to 0 to disable MD restart output.
35083517
- **Default**: 5
35093518

35103519
### md_dumpfreq
35113520

35123521
- **Type**: Integer
3513-
- **Description**: The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
3522+
- **Description**: The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which includes lattice and atomic information. Set to 0 to disable MD_dump output.
35143523
- **Default**: 1
35153524

3525+
### md_neighbor_skin
3526+
3527+
- **Type**: Real
3528+
- **Description**: The extra neighbor-list radius in Angstrom for MDCell molecular dynamics. This parameter is only used for classical potentials or machine-learned interatomic potentials. A positive value reuses the cutoff-plus-skin candidate list until an atom has moved by half this distance; 0 rebuilds the list every force evaluation.
3529+
- **Default**: 0.0
3530+
- **Unit**: Angstrom
3531+
3532+
### md_out_force
3533+
3534+
- **Type**: Boolean
3535+
- **Description**: Whether to output the TOTAL-FORCE table in OUT.${suffix}/running_md.log for MDCell molecular dynamics. This does not affect force calculation or molecular dynamics integration.
3536+
- **Default**: True
3537+
35163538
### dump_force
35173539

35183540
- **Type**: Boolean
@@ -3535,8 +3557,8 @@
35353557

35363558
- **Type**: Integer
35373559
- **Description**: The random seed to initialize random numbers used in molecular dynamics calculations.
3538-
- &lt; 0: No srand() function is called.
3539-
- &gt;= 0: The function srand(md_seed) is called.
3560+
- &lt; 0: Each MPI rank uses the default seed 1 plus its rank.
3561+
- &gt;= 0: Each MPI rank uses md_seed plus its rank.
35403562
- **Default**: -1
35413563

35423564
### md_tfreq

docs/parameters.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ parameters:
1717
default_value: "0"
1818
unit: ""
1919
availability: ""
20+
- name: cell_replica
21+
category: System variables
22+
type: Three Integers
23+
description: |
24+
Replicate the input STRU by Na, Nb, and Nc along its lattice vectors for distributed MDCell workflows. This parameter is only used for classical potentials or machine-learned interatomic potentials. The default is 1 1 1, which preserves the input structure.
25+
default_value: 1 1 1
26+
unit: ""
27+
availability: ""
2028
- name: calculation
2129
category: System variables
2230
type: String
@@ -1449,18 +1457,34 @@ parameters:
14491457
category: Molecular dynamics
14501458
type: Integer
14511459
description: |
1452-
The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
1460+
The output frequency of OUT.{suffix}/STRU_MD_*, which are used to restart molecular dynamics calculations, see md_restart in detail. Set to 0 to disable MD restart output.
14531461
default_value: "5"
14541462
unit: ""
14551463
availability: ""
14561464
- name: md_dumpfreq
14571465
category: Molecular dynamics
14581466
type: Integer
14591467
description: |
1460-
The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
1468+
The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which includes lattice and atomic information. Set to 0 to disable MD_dump output.
14611469
default_value: "1"
14621470
unit: ""
14631471
availability: ""
1472+
- name: md_neighbor_skin
1473+
category: Molecular dynamics
1474+
type: Real
1475+
description: |
1476+
The extra neighbor-list radius in Angstrom for MDCell molecular dynamics. This parameter is only used for classical potentials or machine-learned interatomic potentials. A positive value reuses the cutoff-plus-skin candidate list until an atom has moved by half this distance; 0 rebuilds the list every force evaluation.
1477+
default_value: "0.0"
1478+
unit: Angstrom
1479+
availability: ""
1480+
- name: md_out_force
1481+
category: Molecular dynamics
1482+
type: Boolean
1483+
description: |
1484+
Whether to output the TOTAL-FORCE table in OUT.${suffix}/running_md.log for MDCell molecular dynamics. This does not affect force calculation or molecular dynamics integration.
1485+
default_value: "True"
1486+
unit: ""
1487+
availability: ""
14641488
- name: dump_force
14651489
category: Molecular dynamics
14661490
type: Boolean
@@ -1490,8 +1514,8 @@ parameters:
14901514
type: Integer
14911515
description: |
14921516
The random seed to initialize random numbers used in molecular dynamics calculations.
1493-
* < 0: No srand() function is called.
1494-
* >= 0: The function srand(md_seed) is called.
1517+
* < 0: Each MPI rank uses the default seed 1 plus its rank.
1518+
* >= 0: Each MPI rank uses md_seed plus its rank.
14951519
default_value: "-1"
14961520
unit: ""
14971521
availability: ""

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ OBJS_MODULE_RI=conv_coulomb_pot_k.o\
772772
singular_value.o\
773773

774774
OBJS_PARALLEL=parallel_common.o\
775-
communication_domain.o\
775+
parallel_cell.o\
776776
parallel_global.o\
777777
parallel_comm.o\
778778
parallel_grid.o\

source/source_base/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ add_library(
5151
tool_title.cpp
5252
ylm.cpp
5353
parallel_common.cpp
54-
communication_domain.cpp
54+
parallel_cell.cpp
5555
parallel_global.cpp
5656
parallel_comm.cpp
5757
parallel_reduce.cpp

source/source_base/communication_domain.cpp renamed to source/source_base/parallel_cell.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "source_base/communication_domain.h"
1+
#include "source_base/parallel_cell.h"
22

33
namespace ModuleBase
44
{
@@ -12,7 +12,6 @@ CommunicationDomain::CommunicationDomain(MPI_Comm communicator) : communicator_(
1212
if (communicator_ != MPI_COMM_NULL)
1313
{
1414
MPI_Comm_rank(communicator_, &rank_);
15-
MPI_Comm_size(communicator_, &size_);
1615
}
1716
}
1817

@@ -27,11 +26,6 @@ int CommunicationDomain::rank() const
2726
return rank_;
2827
}
2928

30-
int CommunicationDomain::size() const
31-
{
32-
return size_;
33-
}
34-
3529
CommunicationDomain world_communication_domain()
3630
{
3731
#ifdef __MPI
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef COMMUNICATION_DOMAIN_H
2-
#define COMMUNICATION_DOMAIN_H
1+
#ifndef PARALLEL_CELL_H
2+
#define PARALLEL_CELL_H
33

44
#ifdef __MPI
55
#include <mpi.h>
@@ -16,14 +16,12 @@ class CommunicationDomain
1616
MPI_Comm communicator() const;
1717
#endif
1818
int rank() const;
19-
int size() const;
2019

2120
private:
2221
#ifdef __MPI
2322
MPI_Comm communicator_ = MPI_COMM_NULL;
2423
#endif
2524
int rank_ = 0;
26-
int size_ = 1;
2725
};
2826

2927
CommunicationDomain world_communication_domain();

source/source_cell/base_cell.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "source_base/matrix3.h"
55

6+
#include <cstdint>
7+
68
class BaseCell
79
{
810
public:
@@ -19,7 +21,7 @@ class BaseCell
1921
return get_kind();
2022
}
2123

22-
int nat() const
24+
std::int64_t nat() const
2325
{
2426
return get_nat();
2527
}
@@ -48,7 +50,7 @@ class BaseCell
4850

4951
private:
5052
virtual Kind get_kind() const = 0;
51-
virtual int get_nat() const = 0;
53+
virtual std::int64_t get_nat() const = 0;
5254
virtual double get_lat0() const = 0;
5355
virtual double get_omega() const = 0;
5456
virtual const ModuleBase::Matrix3& get_latvec() const = 0;

0 commit comments

Comments
 (0)