-
Book Overview & Buying
-
Table Of Contents
GPU-Accelerated Computing with Python 3 and CUDA
By :
A large amount of data is generated from an MD system, including atomic positions, velocities, and forces. This information can be used to track atomic motions, identify interactions, and calculate physical properties such as energies, temperature, and pressure. However, so far, we don't have any way to save the output of our simulation.
To allow us to post-process and visualize our data, we define a save function, which dumps the atomic position data into a file in the XYZ format. This is a standard way to represent molecular structures, making it compatible with molecular visualization tools:
def save(position: Array, file: TextIO) -> None:
num_atoms = position.shape[0]
file.write(f"{num_atoms}\n\n")
for i in range(num_atoms):
file.write(f"{'He'}\t{position[i, 0]} {position[i, 1]} {0}\n")
file.flush()
The line with file.flush() ensures that all data is immediately written to the file.
Additionally, we calculate...