from ase import Atoms import numpy as np cell = np.eye(3) * 20 # Set up a cubic box of size 20 Angstrom positions = np.random.rand(100, 3) * 20 # Generate random coordinates of 100 atoms symbols = ['C'] * 100 # Set all atoms to carbon atoms atoms = Atoms(symbols=symbols, positions=positions, cell=cell) # Create Atoms object
from ase import Atoms import numpy as np # Create an Atoms object with random coordinates cell = np.eye(3) * 10 positions = np.random.rand(10, 3) * 10 symbols = ['H'] * 10 atoms = Atoms(symbols=symbols, positions=positions, cell=cell) # Calculate the center of mass of the system total_mass = sum(atoms.get_masses()) com = sum([atoms.positions[i] * atoms.get_masses()[i] for i in range(len(atoms))]) / total_mass
from ase import Atoms import numpy as np # Create an Atoms object with random coordinates cell = np.eye(3) * 10 positions = np.random.rand(10, 3) * 10 symbols = ['He'] * 10 atoms = Atoms(symbols=symbols, positions=positions, cell=cell) # Move all atoms to the origin atoms.center()In these examples, the ASE package library is used to create and manipulate atomic systems. The Atoms class provided by the ase.atoms module is used to represent and operate on these atomic systems.