Examples#

Excited States RPA/CIS#

Once initialized, a SCF calculation can be run directly to compute total energy:

import torch
from seqm.seqm_functions import anal_grad
from seqm.seqm_functions.constants import Constants
from seqm.Molecule import Molecule
from seqm.ElectronicStructure import Electronic_Structure
from seqm.seqm_functions.read_xyz import read_xyz
import time
import warnings


torch.set_default_dtype(torch.float64)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

Add import statements for PyTorch, PySEQM and its seqm modules. Set the floating point precision to 64 bit and set device to GPU.

species, coordinates = read_xyz(['../../data.xyz'])

species = torch.as_tensor(species, dtype=torch.int64, device=device)[:]
coordinates = torch.tensor(coordinates, device=device)[:]
const = Constants().to(device)

elements = [0] + sorted(set(species.reshape(-1).tolist()))

Load data in xyz form collecting species and coordinates and move both of them to the GPU.

seqm_parameters = {
   'method': 'AM1',
   'scf_eps': 1.0e-8,
   'scf_converger': [2, 0.0],
   'sp2': [False, 1.0e-5],
   'elements': elements,
   'learned': [],
   'pair_outer_cutoff': 1.0e8,
   'eig': True,
   'excited_states': {'n_states':10, 'method':'rpa' #set either rpa/cis},
}

User-defined parameters for calculations are set using the seqm_parameters dictionary.

method: Austin Model 1

scf_eps: If the energy change between two SCF steps is smaller than this value, then the simulation stops and considers it converged.

scf_converger: Converger tolerance for SCF.

sp2: Planarity correction on/off, threshold.

elements: Atomic numbers in the data from species.

learned: Learned parameters name list.

pair_outer_cutoff: The value for how far apart two atoms can be before their interaction is ignored.

eig: Whether or not to calcuate final eigenvalues.

excited_states:

number of states: The number of excited states to calcuate.

method: Set to run either rpa or cis.

molecules = Molecule(const, seqm_parameters, coordinates, species).to(device)
esdriver = Electronic_Structure(seqm_parameters).to(device)
esdriver(molecules)

Sends all information collected so far to the GPU and runs the calculation.

BOMD#

molecules = Molecule(const, seqm_parameters, coordinates, species).to(device)
esdriver = Electronic_Structure(seqm_parameters).to(device)
esdriver(molecules)

Sends all information collected so far to the GPU and runs the calculation.

Molecular Dynamics#

You can run molecular dynamics using Born-Oppenheimer or Extended-Lagrangian BOMD:

import torch
from seqm.seqm_functions.constants import Constants
from seqm.Molecule import Molecule
from seqm.MolecularDynamics import Molecular_Dynamics_Basic, Molecular_Dynamics_Langevin
from seqm.seqm_functions.read_xyz import read_xyz
import warnings

torch.set_default_dtype(torch.float64)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

Add import import statements for PyTorch, PySEQM and its seqm modules. Set the float size to 64 for more memory and set device to GPU.

species, coordinates = read_xyz(['../../data.xyz'])

species = torch.as_tensor(species, dtype=torch.int64, device=device)[:]
coordinates = torch.tensor(coordinates, device=device)[:]
const = Constants().to(device)

elements = [0] + sorted(set(species.reshape(-1).tolist()))

Load data in xyz form collecting species and coordinates and move both of them to the GPU.

seqm_parameters = {
   'method': 'AM1',
   'scf_eps': 1.0e-6,
   'scf_converger': [2, 0.0],
   'sp2': [False, 1.0e-5],
   'elements': elements,
   'learned': [],
   'pair_outer_cutoff': 1.0e10,
   'eig': True
}

User-defined parameters for calculations are set using the seqm_parameters dictionary.

method: Austin Model 1

scf_eps: If the energy change between two SCF steps is smaller than this value, then the simulation stops and considers it converged.

scf_converger: Converger tolerance for SCF.

sp2: Planarity correction on/off, threshold.

elements: Atomic numbers in the data from species.

learned: Learned parameters name list.

pair_outer_cutoff: The value for how far apart two atoms can be before their interaction is ignored.

eig: Whether or not to calcuate final eigenvalues.

output = {
'molid': [0],
'thermo': 1,
'dump': 1,
'prefix':
'../../Outputs_location'
}

Set the molecule ID to allow simulation of multiple molecules by passing different IDs.

xxx

xxx

Set the output file path.

molecule = Molecule(const, seqm_parameters, coordinates, species).to(device)
md = Molecular_Dynamics_Basic(seqm_parameters=seqm_parameters, Temp=300.0, timestep=0.4, output=output).to(device)
md.initialize_velocity(molecule)

Temp specifies the simulation temperature in Kelvin.

Timestep specifies the time step in femtoseconds.

Sends all collected information to the GPU.

_ = md.run(molecule, 10, remove_com=[True, 1], Info_log=True)

The number of MD steps.

Removes center of mass velocity every set number of step to prevent drifting.

Info_log determines whether to save additional information.

Then runs the calculation.