Skip to content

Commit

Permalink
Additinoal fixes to trajectories.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgt16-LANL committed Sep 15, 2023
1 parent dbc6ac6 commit 952376d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 4 additions & 3 deletions architector/io_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, structure, parameters={}, init_sanity_check=False,
fmax=0.1, maxsteps=1000, ff_preopt_run=False,
detect_spin_charge=False, fix_m_neighbors=False,
default_params=params, ase_opt_method=None, ase_opt_kwargs={}, species_run=False,
intermediate=False,skip_spin_assign=False,
intermediate=False, skip_spin_assign=False, save_trajectories=False,
calculator=None, debug=False):
"""CalcExecutor is the class handling all calculations of full metal-ligand complexes.
Expand Down Expand Up @@ -150,6 +150,7 @@ def __init__(self, structure, parameters={}, init_sanity_check=False,
self.method = method
default_params = params.copy()
default_params['debug'] = debug
default_params['save_trajectories'] = save_trajectories
default_params.update(parameters)
self.parameters = default_params
self.init_sanity_check = init_sanity_check
Expand Down Expand Up @@ -430,7 +431,7 @@ def calculate(self):
if self.replace_trics:
self.ase_opt_kwargs['sella_internal_trics'] = True

if self.parameters['save_trajectories'] and (self.trajectory is not None):
if self.parameters['save_trajectories'] and (self.trajectory is not None) and (self.parameters['dump_ase_atoms']):
self.dump_traj()
elif self.parameters['save_trajectories']:
pass
Expand All @@ -442,7 +443,7 @@ def calculate(self):
def read_traj(self):
pwd = os.path.abspath('.')
traj = Trajectory(os.path.join(pwd,'temp.traj'))
self.trajectory = traj
self.trajectory = [x for x in traj] # Convert to atoms

def dump_traj(self):
for i,ats in enumerate(self.trajectory):
Expand Down
10 changes: 8 additions & 2 deletions architector/io_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

import ase
from ase.io import read
from ase.io import (read, Trajectory)
from ase.atoms import Atoms
from ase.atom import Atom
import numpy as np
Expand All @@ -18,7 +18,7 @@
import itertools
import architector
from architector import io_obabel
from architector.io_core import (Geometries,calc_all_coord_atom_angles)
from architector.io_core import (Geometries, calc_all_coord_atom_angles)
import architector.io_ptable as io_ptable
from io import StringIO
from scipy.sparse.csgraph import (csgraph_from_dense, connected_components)
Expand Down Expand Up @@ -62,6 +62,12 @@ def convert_io_molecule(structure,
# mol2 filename
elif structure[-5:] == '.mol2':
mol.read_mol2(structure,readstring=False)
elif structure[-5:] == '.traj': # Read in trajectory file.
traj = Trajectory(structure)
output = []
for ats in traj:
output.append(convert_io_molecule(ats))
return output
elif isinstance(structure,str) and (len(structure.split('\n')) > 3) and (structure.split('\n')[0].replace(' ','').isnumeric()) \
and ('FORCES' in structure) and ('ENERGY' in structure): # RXYZ string.
mol.read_rxyz(structure,readstring=True)
Expand Down
6 changes: 5 additions & 1 deletion architector/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def type_convert(structures):
"""
outlist = []
if isinstance(structures,str):
structures = [convert_io_molecule(structures)]
out = convert_io_molecule(structures)
if isinstance(out,(np.ndarray,list)): # Read in traj.
structures=out
else:
structures = [out]
elif isinstance(structures,(ase.atoms.Atoms,architector.io_molecule.Molecule)):
structures = [convert_io_molecule(structures)]
elif isinstance(structures,dict):
Expand Down

0 comments on commit 952376d

Please sign in to comment.