A rapid modeling method and library for molecular dynamics
By defining molecular dynamics rapid modeling methods based on molecule and material data types, this approach solves the problems of operational complexity and high learning costs in constructing models of complex molecular systems. It achieves a fast and concise modeling process and efficient model transfer capabilities, and is suitable for exporting model files from software such as LAMMPS, Ovito, and VMD.
Patent Information
- Application Number
- CN202310295356.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-03-24
AI Technical Summary
Existing technologies for building models of complex molecular systems suffer from problems such as complex operation, high learning costs, frequent script syntax errors, and difficulty in transfer and modification, especially for large molecules and unconventional compound systems, making it difficult to achieve rapid modeling.
This invention provides a rapid molecular dynamics modeling method and library. By defining molecule and material data types and utilizing Python basics, it automatically generates particle numbers and sets atomic information. It enables the combination of molecular models and the construction of system models through commands, and supports the merging and modification of multiple models. It also supports the export of model files to visualization software such as LAMMPS, Ovito, and VMD.
It implements a simple and easy-to-understand rapid modeling method, reduces the learning cost, supports the model building of complex systems, improves the transferability and visualization of models, simplifies the modeling process, reduces script errors, and improves modeling efficiency.
Smart Images

Figure CN116092589B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of dissipative particle dynamics technology, specifically to a rapid modeling method and library for molecular dynamics. Background Technology
[0002] Dissipative particle dynamics (DPD) is a molecular dynamics-based simulation method suitable for studying fluid and soft matter systems, typically modeled using LAMMPS software. The initial model file required for LAMMPS simulations must provide detailed information about the atoms in the initial system, such as the types and masses of atoms, which atoms are bonded and which are angularly connected, and the initial coordinates of each particle must be given.
[0003] In traditional technical solutions, one approach is to use modeling software like VMD for modeling. However, this approach suffers from fixed functionality, complex operation, and a high learning curve. Modeling is particularly difficult, even impossible, for large molecules, complex systems, or systems containing unconventional compounds, making it hard to perfectly match the envisioned system model. Another approach involves using languages like C, Fortran, or Python to generate atom types and model positions through custom scripts. However, generating initial atom type and position models using custom scripts requires considerable programming experience and skills, which may be challenging for users unfamiliar with programming. Furthermore, for complex systems, such as those with a large number of atoms or unconventional structures, manually writing scripts and generating initial models becomes extremely difficult. There is also a high degree of binding between the script and the modeling system, making it difficult to transfer and modify existing model files. Additionally, when using scripts to model complex systems, syntax errors or logical errors often occur, resulting in initial models that do not accurately reflect reality and difficult-to-read code, hindering later modifications. Summary of the Invention
[0004] To address the shortcomings of existing technologies, the present invention aims to provide a rapid molecular dynamics modeling method and library. This modeling method is simple, easy to understand, fast, has a low learning cost, and can complete the modeling of complex systems.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a rapid molecular dynamics modeling method, comprising a molecular model and a system model, wherein the system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems.
[0006] As a preferred approach: In molecular model construction, a molecule data type is defined, using the three basic data structures required by the modeling file: Atoms (atomic type and coordinate information), Bonds (atomic bonding information), and Angles (atomic angular information). Specifically, Atoms data includes atomic number (id), atomic type (type), and atomic coordinates (x, y, z); Bonds data includes atomic number (id), atomic type (type), and atomic coordinates (x, y, z); Bonds data includes bonding number, bonding type (type), and the IDs of two bonding particles; and Angles data includes angular number, angular type (type), and the IDs of three bonding particles.
[0007] As a preferred approach: During construction, first use the defined xyz coordinate information of atoms to obtain the molecular model by calling the function type molecule(xyz). Based on the coordinate order of each particle, sort the particles sequentially starting from 1, automatically generating particle numbers. Then, use the molecule.set_atoms command to batch set the atom type corresponding to the atom ID, the molecule.set_bonds command to batch set the bonding and bonding type between atoms, and the molecule.set_angles command to batch set the angles and angle types between atoms. Square brackets and parentheses are used to represent individual bonding angles and continuous bonding angles, respectively. Multiple molecular models can be merged by overloading the + method, or existing molecular models can be appended using the molecule.append command. Molecular coordinates can be modified or the entire model can be offset using the molecule.space_change command, and the original atom coordinates can be returned using the molecule.space command. The molecule.to_material command is defined to switch between molecule and material data types.
[0008] As a preferred approach: build a system model, define a material data structure, and add a Group data set to the Atoms molecular model data structure.
[0009] As a preferred method: After the molecular model is constructed, each molecular unit is added to the system model using the `material.append` command. When adding a molecule type to the system, the value of the data group can be specified. By default, the number of existing groups in the system is incremented by one, and the indices of the remaining Atoms, Bonds, and Angles are automatically re-corresponded to the atom ID offsets. The `material.space_change` command is used to modify the system coordinates or perform an overall offset. The `material.space` command returns the original coordinates of each atom. The `material.loc_id` command extracts the Atoms, Bonds, and Angles values corresponding to a specified atom ID into a new material data type. The `material.loc_typ` command... The `e` instruction extracts the Atoms, Bonds, and Angles values of all atom IDs corresponding to a specified atom type, bond type, and angle type, and returns them as a new `material` data type. The `material.loc_group` instruction extracts the Atoms, Bonds, and Angles values of a specified group. Simultaneously, the overloaded `+` method merges multiple system representations, automatically re-matching the atom ID offsets corresponding to the Atoms, Bonds, and Angles values in each system. The `load` instruction imports existing model file data and returns it as a `material` data type. The `material.to_molecule` instruction switches between `material` and `molecule` data types.
[0010] As a preferred approach: Define a general method `check` to check whether the constructed molecule or material data type has abnormal Atoms, Bonds, and Angles values. This includes checking whether all atom types are defined, checking for undefined atom IDs in Bonds and Angles, and checking for discontinuous atom type values in Atoms, Bonds, and Angles. Return the ID and type of the abnormal data. If the checks are normal, output the total number of particles, bonds, and corners in the model, as well as the space occupied by the system.
[0011] As a preferred approach, a general method `save` is defined to export molecule or material data types, saving them as general model files that can be recognized by LAMMPS, Ovito, and VMD, and can be visualized and observed through Ovito or VMD.
[0012] Preferably, the model can be imported from an existing modeling file. Alternatively, it can be built entirely from scratch by calling the corresponding commands to add or delete data in the molecule and material data types, thus completing the custom model construction.
[0013] The present invention will also provide a molecular dynamics library, which includes the above-mentioned rapid modeling method, namely, including molecular models and system models. The system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems.
[0014] By adopting the above technical solution, the present invention has the following beneficial effects:
[0015] This invention divides the rapid modeling process into two parts: molecular model construction and system model building. It provides a simple and easy-to-understand rapid modeling method and a new rapid modeling library based on Python. It has a low learning cost and can complete the model construction of complex systems, making it highly practical.
[0016] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the molecular model construction process in an embodiment of the present invention;
[0018] Figure 2 This is a schematic diagram of the system model construction process in an embodiment of the present invention;
[0019] Figure 3 This is a schematic diagram of the modeling file import process according to an embodiment of the present invention;
[0020] Figure 4 This is a schematic diagram of the complex system model comprehensive construction process according to an embodiment of the present invention. Detailed Implementation
[0021] See Figures 1 to 4 The present invention discloses a rapid molecular dynamics modeling method, which includes a molecular model and a system model. The system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems.
[0022] In molecular model construction, the molecule data type is defined, and the three basic data structures of the molecule data type are the atom type and coordinate information (Atoms), the interatomic bonding information (Bonds), and the interatomic angular information (Angles) required by the modeling file. Among them, the Atoms data includes the atom number (id), the atom type (type), and the atom coordinates (xyz); the Bonds data includes the atom number (id), the atom type (type), and the atom coordinates (xyz); the Bonds data includes the bonding number, the bonding type (type), and the IDs of the two bonding particles; and the Angles data includes the angular number, the angular type (type), and the IDs of the three bonding particles.
[0023] As a preferred approach: During construction, first use the defined xyz coordinate information of atoms to obtain the molecular model by calling the function type molecule(xyz). Based on the coordinate order of each particle, sort the particles sequentially starting from 1, automatically generating particle numbers. Then, use the molecule.set_atoms command to batch set the atom type corresponding to the atom ID, the molecule.set_bonds command to batch set the bonding and bonding type between atoms, and the molecule.set_angles command to batch set the angles and angle types between atoms. Square brackets and parentheses are used to represent individual bonding angles and continuous bonding angles, respectively. Multiple molecular models can be merged by overloading the + method, or existing molecular models can be appended using the molecule.append command. Molecular coordinates can be modified or the entire model can be offset using the molecule.space_change command, and the original atom coordinates can be returned using the molecule.space command. The molecule.to_material command is defined to switch between molecule and material data types.
[0024] As a preferred approach: build a system model, define a material data structure, and add a Group data set to the Atoms molecular model data structure.
[0025] As a preferred method: After the molecular model is constructed, each molecular unit is added to the system model using the `material.append` command. When adding a molecule type to the system, the value of the data group can be specified. By default, the number of existing groups in the system is incremented by one, and the indices of the remaining Atoms, Bonds, and Angles are automatically re-corresponded to the atom ID offsets. The `material.space_change` command is used to modify the system coordinates or perform an overall offset. The `material.space` command returns the original coordinates of each atom. The `material.loc_id` command extracts the Atoms, Bonds, and Angles values corresponding to a specified atom ID into a new material data type. The `material.loc_typ` command... The `e` instruction extracts the Atoms, Bonds, and Angles values of all atom IDs corresponding to a specified atom type, bond type, and angle type, and returns them as a new `material` data type. The `material.loc_group` instruction extracts the Atoms, Bonds, and Angles values of a specified group. Simultaneously, the overloaded `+` method merges multiple representations within the system, automatically re-aligning the atom ID offsets corresponding to the Atoms, Bonds, and Angles values. The `load` instruction imports existing model file data and returns it as a `material` data type. The `material.to_molecule` instruction switches between `material` and `molecule` data types.
[0026] As a preferred approach: Define a general method `check` to check whether the constructed molecule or material data type has abnormal Atoms, Bonds, and Angles values. This includes checking whether all atom types are defined, checking for undefined atom IDs in Bonds and Angles, and checking for discontinuous atom type values in Atoms, Bonds, and Angles. Return the ID and type of the abnormal data. If the checks are normal, output the total number of particles, bonds, and corners in the model, as well as the space occupied by the system.
[0027] As a preferred approach, a general method `save` is defined to export molecule or material data types, saving them as general model files that can be recognized by LAMMPS, Ovito, and VMD, and can be visualized and observed through Ovito or VMD.
[0028] Preferably, the model can be imported from an existing modeling file. Alternatively, it can be built entirely from scratch by calling the corresponding commands to add or delete data in the molecule and material data types, thus completing the custom model construction.
[0029] The following section details the methods for constructing molecular models; see [link to relevant documentation]. Figure 1 ,
[0030] x, y, z represent the input particle coordinates, which can be generated by NumPy, Excel, or any other method. `molecule` is the defined molecule data type. `set_atmos` is the `molecule.set_atmos` directive used to specify the particle type. `set_bonds` is the `molecule.set_bonds` directive used to specify the bonding rules between particles. `set_angles` is the `molecule.set_angles` directive used to specify the angular rules between particles.
[0031] After using the three commands mentioned above, the molecular model is completed. The `check` command is used to initially check the molecular model. If it doesn't meet the requirements, the model is modified according to the output prompts. The `save` command is used to output the model file and save it as a .txt file. The .txt file is then visualized using Ovito or VMD software to check if it matches the envisioned model style. If it doesn't match, modifications are made; if it does, the molecular model construction is complete.
[0032] See Figure 2 System model construction method:
[0033] The system model consists of one or more molecule data. `molecule_0`, `molecule_0'`, and `molecule_n` all represent the molecule data after the molecular model is built. `space_change` refers to the `molecule.space_change` command, which shifts the coordinates of the entire `molecule_0` molecular model to create the new `molecule_0'` data. `molecule_n` represents a different type of molecule data. `material` is the defined `material` data type. `append` refers to the `material.append` command, used to add the molecule model data to the `material` system. `material` can be constructed from multiple molecular models, including `molecule_0`, `molecule_0'`, and `molecule_n`. `check` is the `check` command, used to initially check the model of the `material` system. If it does not meet the requirements, the model is modified according to the output prompts. `save` is the `save` command, used to output the model file and save it as a .txt file. The .txt model file is then visualized using Ovito or VMD visualization software to observe whether it matches the envisioned model style. If it does not match, modifications are made; if it matches, the molecular model construction is complete. The functions shown above may not be fully utilized in a single modeling process; they only provide an idea and supported methods.
[0034] See Figure 3 Methods for utilizing existing model files:
[0035] Existing model files can be generated by any software or previously generated using this modeling solution. `load` indicates that any format file can be imported as a material data type. Taking the most basic LAMMPS model as an example, the imported material data type includes three basic data categories: Atoms, Bonds, and Angles. `loc_id` refers to the `material.loc_id` command, which extracts the Atoms, Bonds, and Angles values corresponding to a specified atom ID into a new material data type. `loc_type` refers to the `material.loc_type` command, which extracts the Atoms, Bonds, and Angles values of all atom IDs corresponding to a specified atom type, bond type, or angle type, and returns them as a new material data type. `loc_group` is the `material.loc_group` command, which extracts the Atoms, Bonds, and Angles values of a specified group and returns them as a new material data type. The generated material data type is identical to that generated by manual modeling and can be used directly. The functions shown above may not be fully utilized in a single modeling process; they only provide an approach and supported methods.
[0036] See Figure 4 Comprehensive construction scheme for complex system models:
[0037] Complex systems are composed of multiple subsystems called "material". "Molecule" represents the molecule data after the molecular model is built. "Append" refers to the `material.append` command, "space_change" refers to the `material.space_change` command, and "load" refers to the `load` command. A subsystem can be composed of multiple molecules using the `material.append` command, or it can be a new material obtained by offsetting the entire coordinates of the material using the `material.space_change` command, or it can be a material obtained by importing an existing model file using the `load` command. The "+" operator represents the overloaded "+" operator in the material data type, allowing combinations of two or more subsystems through `material + material + ...`, completing the final system modeling. "Check" is the `check` command, used to initially check the final system material model after modeling. If it does not meet the requirements, the model is modified according to the output prompts. "Save" is the `save` command, used to output the model file and save it as a .txt file. The .txt model file is then visualized using Ovito or VMD visualization software to observe whether it matches the envisioned model style. If it does not match, modifications are made; if it matches, the molecular model construction is complete. The functions shown above may not be fully utilized in a single modeling process; they only provide an approach and supported methods.
[0038] In practical applications, users only need to master a few basic commands to achieve rapid modeling, resulting in a low learning curve. The modeling process is divided into two parts: molecular model construction and system model building. For large and complex systems, it allows for large-scale system construction through the combination of multiple subsystems, resulting in clear modeling logic, simple modeling schemes, and concise and aesthetically pleasing code. It also adds support for generated modeling files, enabling the integration of previous modeling results or those from other software. Rapid addition, deletion, modification, and querying of generated model files facilitates model reuse and rapid modeling, greatly enhancing the model's transferability. Quick statistical analysis of the number of model particles, boundary positions, and atomic bonding angles allows for easy post-modeling checks. Based on script-based modeling, it achieves rapid integration with visualization software during the modeling process, allowing for visual observation of whether the model's construction meets expectations.
[0039] The present invention also provides a molecular dynamics library, which includes the above-mentioned rapid modeling method, namely, including molecular models and system models. The system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems.
[0040] The above embodiments, which describe the specific features of the present invention, are only used to further illustrate the present invention and should not be construed as limiting the scope of protection of the present invention. Any non-essential improvements and adjustments made to the present invention by those skilled in the art based on the above description of the invention shall fall within the scope of protection of the present invention.
Claims
1. A rapid molecular dynamics modeling method, characterized in that: It includes molecular models and system models. The system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems. In molecular model construction, a molecule data type is defined, using three basic data structures: Atoms (atomic type and coordinate information), Bonds (inter-atomic bonding information), and Angles (inter-atomic angular information). Specifically, Atoms data includes atom ID, atom type, and atom coordinates (x, y, z); Bonds data includes atom ID, atom type, and atom coordinates (x, y, z); Bonds data includes bonding ID, bonding type, and the IDs of two bonding particles; and Angles data includes angular number, angular type, and the IDs of three bonding particles. During construction, the xyz coordinates of the atoms are defined first. The molecular model is obtained by calling the function type molecule(xyz). Based on the coordinate order of each particle, the particles are sorted sequentially starting from 1, and particle numbers are automatically generated. Then, the atom type corresponding to the atom ID is set in batches using the molecule.set_atoms instruction. The bonding and bonding type between atoms are set in batches using the molecule.set_bonds instruction. The angles between atoms are set in batches using the molecule.set_angles instruction. Square brackets and parentheses are used to represent individual bonding angles and continuous bonding angles, respectively. The molecule model can be merged by overloading the + method, or an existing molecular model can be appended using the molecule.append instruction. The molecular coordinates can be modified or the entire molecular model can be offset using the molecule.space_change instruction. The original coordinates of each atom are returned using the molecule.space instruction. The molecule.to_material instruction is defined to switch between molecule data types and material data types.
2. The rapid molecular dynamics modeling method according to claim 1, characterized in that: The system model is built, the material data structure is defined, and a new group, Group, is added to the molecular model data structure Atoms.
3. The rapid molecular dynamics modeling method according to claim 2, characterized in that: After the molecular model is built, the `material.append` command adds each molecular unit to the system model. When adding a molecule type to the system, the value of the data group can be specified. By default, the number of existing groups in the system is incremented by one, and the indices of the remaining atoms, bonds, and angles are automatically reassigned to the corresponding atom IDs. The `material.space_change` command modifies the system coordinates or performs an overall offset. The `material.space` command returns the original coordinates of each atom. The `material.loc_id` command extracts the atom, bond, and angle values corresponding to a specified atom ID into a new material data type. The `material.loc_type` command... The instructions extract the Atoms, Bonds, and Angles values of all atom IDs corresponding to a specified atom type, bond type, and angle type, and return them as a new material data type. The three instructions, material.loc_group, extract the Atoms, Bonds, and Angles values of a specified group. Simultaneously, through overloaded + methods, multiple systems can be merged, and the atom ID offsets corresponding to the Atoms, Bonds, and Angles values in each system are automatically re-matched. The defined load instruction imports existing model file data and returns it as a material data type. The defined material.to_molecule instruction switches between the material data type and the molecule data type.
4. The rapid molecular dynamics modeling method according to claim 3, characterized in that: Define a general method check to check whether the constructed molecule or material data type has abnormal Atoms, Bonds, and Angles values. This includes checking whether all atom types are defined, checking for undefined atom IDs in Bonds and Angles, and checking for discontinuous atom type values in Atoms, Bonds, and Angles. Return the ID and abnormality type of the abnormal data. If the detection is normal, the system will output the total number of particles, bonds, and corners in the model, as well as the spatial location occupied by the system.
5. The rapid molecular dynamics modeling method according to claim 4, characterized in that: Define a general method `save` to export molecule or material data types and save them as general model files that can be recognized by LAMMPS, Ovito, and VMD, and can be visualized and observed through Ovito or VMD.
6. A rapid molecular dynamics modeling method according to claim 1 or 5, characterized in that: The model can be imported from an existing modeling file; or it can be built entirely from scratch by calling the corresponding instructions to add or delete data in the molecule and material data types, thus completing the custom model construction.
7. A molecular dynamics library, characterized in that: The rapid modeling method according to any one of claims 1-6 includes a molecular model and a system model, wherein the system model is composed of molecular models, and the system model is a collection of molecular models or a final system model composed of multiple subsystems.
Citation Information
Patent Citations
Construction method for molecular dynamics geometric model of spinodal decomposition distribution
CN111816261A
Method and system for simulating spatial structure characteristics of aluminum oxide film through molecular dynamics
CN114528713A