Skip to content

Commit

Permalink
Merge branch 'master' into job_copy_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
liamhuber committed Jan 7, 2020
2 parents d109a9b + fe501e6 commit 392ca25
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 221 deletions.
110 changes: 40 additions & 70 deletions pyiron/atomistics/job/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pyiron.atomistics.structure.atoms import Atoms
from pyiron.atomistics.structure.periodic_table import PeriodicTable
from pyiron.atomistics.job.atomistic import AtomisticGenericJob, GenericOutput
from collections import defaultdict

__author__ = "Osamu Waseda, Jan Janssen"
__copyright__ = (
Expand All @@ -31,24 +32,23 @@ def __init__(self, project, job_name):
self._interactive_fetch_completed = True
self._interactive_species_lst = np.array([])
self._periodic_table = PeriodicTable()
self.interactive_cache = {
"cells": [],
"energy_pot": [],
"energy_tot": [],
"forces": [],
"positions": [],
"pressures": [],
"stress": [],
"steps": [],
"temperature": [],
"indices": [],
"computation_time": [],
"unwrapped_positions": [],
"atom_spin_constraints": [],
"atom_spins": [],
"magnetic_forces": [],
"volume": [],
}
self.interactive_output_functions = {'cells': self.interactive_cells_getter,
'energy_pot': self.interactive_energy_pot_getter,
'energy_tot': self.interactive_energy_tot_getter,
'forces': self.interactive_forces_getter,
'positions': self.interactive_positions_getter,
'pressures': self.interactive_pressures_getter,
'stress': self.interactive_stress_getter,
'steps': self.interactive_steps_getter,
'temperature': self.interactive_temperatures_getter,
'indices': self.interactive_indices_getter,
'computation_time': self.interactive_computation_time_getter,
'unwrapped_positions': self.interactive_unwrapped_positions_getter,
'atom_spin_constraints': self.interactive_atom_spin_constraints_getter,
'atom_spins': self.interactive_atom_spins_getter,
'magnetic_forces': self.interactive_magnetic_forces_getter,
'volume': self.interactive_volume_getter}
self.interactive_cache = defaultdict(list)

@property
def interactive_enforce_structure_reset(self):
Expand Down Expand Up @@ -180,58 +180,15 @@ def interactive_cells_getter(self):
return self.initial_structure.cell

def interactive_collect(self):
if "cells" in self.interactive_cache.keys():
self.interactive_cache["cells"].append(self.interactive_cells_getter())
if "energy_pot" in self.interactive_cache.keys():
self.interactive_cache["energy_pot"].append(
self.interactive_energy_pot_getter()
)
if "energy_tot" in self.interactive_cache.keys():
self.interactive_cache["energy_tot"].append(
self.interactive_energy_tot_getter()
)
if "forces" in self.interactive_cache.keys():
self.interactive_cache["forces"].append(self.interactive_forces_getter())
if "positions" in self.interactive_cache.keys():
self.interactive_cache["positions"].append(
self.interactive_positions_getter()
)
if "pressures" in self.interactive_cache.keys():
self.interactive_cache["pressures"].append(
self.interactive_pressures_getter()
)
if "stress" in self.interactive_cache.keys():
self.interactive_cache["stress"].append(self.interactive_stress_getter())
if "steps" in self.interactive_cache.keys():
self.interactive_cache["steps"].append(self.interactive_steps_getter())
if "temperature" in self.interactive_cache.keys():
self.interactive_cache["temperature"].append(
self.interactive_temperatures_getter()
)
if "computation_time" in self.interactive_cache.keys():
self.interactive_cache["computation_time"].append(
self.interactive_time_getter()
)
if "indices" in self.interactive_cache.keys():
self.interactive_cache["indices"].append(self.interactive_indices_getter())
if "atom_spins" in self.interactive_cache.keys():
self.interactive_cache["atom_spins"].append(self.interactive_spins_getter())
if "atom_spin_constraints" in self.interactive_cache.keys():
if self._generic_input["fix_spin_constraint"]:
self.interactive_cache["atom_spin_constraints"].append(
self.interactive_spin_constraints_getter()
)
if "magnetic_forces" in self.interactive_cache.keys():
if self._generic_input["fix_spin_constraint"]:
self.interactive_cache["magnetic_forces"].append(
self.interactive_magnetic_forces_getter()
)
if "unwrapped_positions" in self.interactive_cache.keys():
self.interactive_cache["unwrapped_positions"].append(
self.interactive_unwrapped_positions_getter()
)
if "volume" in self.interactive_cache.keys():
self.interactive_cache["volume"].append(self.interactive_volume_getter())
del_key_lst = []
for k,v in self.interactive_output_functions.items():
try:
self.interactive_cache[k].append(v())
except NotImplementedError:
del_key_lst.append(k)
for k in del_key_lst:
del self.interactive_output_functions[k]
del self.interactive_cache[k]
if (
len(list(self.interactive_cache.keys())) > 0
and len(self.interactive_cache[list(self.interactive_cache.keys())[0]])
Expand Down Expand Up @@ -376,6 +333,16 @@ def interactive_spin_constraints_getter(self):
"interactive_spin_constraints_getter() is not implemented!"
)

def interactive_atom_spin_constraints_getter(self):
raise NotImplementedError(
"interactive_atom_spin_constraints_getter() is not implemented!"
)

def interactive_atom_spins_getter(self):
raise NotImplementedError(
"interactive_atom_spins_getter() is not implemented!"
)

def interactive_magnetic_forces_getter(self):
raise NotImplementedError(
"interactive_magnetic_forces_getter() is not implemented!"
Expand Down Expand Up @@ -403,6 +370,9 @@ def interactive_stress_getter(self):
def interactive_structure_setter(self, structure):
raise NotImplementedError("interactive_structure_setter() is not implemented!")

def interactive_computation_time_getter(self):
raise NotImplementedError("interactive_computation_time_getter() is not implemented!")

def interactive_temperatures_getter(self):
raise NotImplementedError(
"interactive_temperatures_getter() is not implemented!"
Expand Down
8 changes: 7 additions & 1 deletion pyiron/atomistics/structure/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,13 @@ def wrap(self, center=(0.5, 0.5, 0.5), pbc=None, eps=1e-7):

if pbc is None:
pbc = self.pbc
self.positions = wrap_positions(self.positions, self.cell, pbc, center, eps)
self.positions = wrap_positions(
positions=self.positions,
cell=self.cell,
pbc=pbc,
center=center,
eps=eps
)

def write(self, filename, format=None, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion pyiron/base/project/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def remove(self, enable=False, enforce=False):
enforce (bool): [True/False] delete jobs even though they are used in other projects - default=False
enable (bool): [True/False] enable this command.
"""
if not enable:
if enable is not True:
raise ValueError(
"To prevent users from accidentally deleting files - enable has to be set to True."
)
Expand Down
6 changes: 6 additions & 0 deletions pyiron/lammps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,12 @@ def collect_dump_file(self, file_name="dump.out", cwd=None):
)
output["forces"] = np.matmul(forces, rotation_lammps2orig)

if np.all([flag in content[0].columns.values for flag in ["vx", "vy", "vz"]]):
velocities = np.array(
[np.stack((cc["vx"], cc["vy"], cc["vz"]), axis=-1) for cc in content]
)
output["velocities"] = np.matmul(velocities, rotation_lammps2orig)

direct_unwrapped_positions = np.array(
[np.stack((cc["xsu"], cc["ysu"], cc["zsu"]), axis=-1) for cc in content]
)
Expand Down
7 changes: 3 additions & 4 deletions pyiron/lammps/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def load_default(self, file_content=None):
+ "include potential.inp\n"
+ "fix___ensemble all nve\n"
+ "variable___dumptime equal 100\n"
+ "dump___1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz\n"
+ 'dump_modify___1 sort id format line "%d %d %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g"\n'
+ "dump___1 all custom ${dumptime} dump.out id type xsu ysu zsu fx fy fz vx vy vz\n"
+ "dump_modify___1 sort id format line \"%d %d %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g %20.15g\"\n"
+ "thermo_style custom step temp pe etotal pxx pxy pxz pyy pyz pzz vol\n"
+ "thermo_modify format float %20.15g\n"
+ "thermo 100\n"
Expand Down Expand Up @@ -249,8 +249,7 @@ def calc_minimize(
elif len(str_press) > 1:
str_press += " couple none"
self.set(fix___ensemble=r"all box/relax" + str_press)
else:
self.remove_keys(["fix___nve"])
self.remove_keys(["fix___nve"])
self.set(min_style=style)
self.set(
minimize=str(e_tol)
Expand Down
15 changes: 2 additions & 13 deletions pyiron/lammps/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,8 @@ def __init__(self, project, job_name):
self._check_opened = False
self._interactive_run_command = None
self._interactive_grand_canonical = True
self.interactive_cache = {
"cells": [],
"energy_pot": [],
"energy_tot": [],
"forces": [],
"positions": [],
"pressures": [],
"steps": [],
"indices": [],
"temperature": [],
"computation_time": [],
"volume": [],
}
if "stress" in self.interactive_output_functions.keys():
del self.interactive_output_functions["stress"]

@property
def structure(self):
Expand Down
2 changes: 1 addition & 1 deletion pyiron/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ def to_hdf(self, hdf, force_update=False):

if len(self._parse_dict["scf_energy_zero"]) == 0:
self._parse_dict["scf_energy_zero"] = [
0.5 * (np.array(fr) + np.array(en))
(0.5 * (np.array(fr) + np.array(en))).tolist()
for fr, en in zip(
self._parse_dict["scf_energy_free"],
self._parse_dict["scf_energy_int"],
Expand Down
14 changes: 0 additions & 14 deletions pyiron/sphinx/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ def __init__(self, project, job_name):
self._interactive_write_input_files = True
self._interactive_library_read = None
self._interactive_fetch_completed = True
self.interactive_cache = {
"cells": [],
"energy_tot": [],
"energy_pot": [],
"forces": [],
"positions": [],
"indices": [],
"atom_spin_constraints": [],
"atom_spins": [],
"magnetic_forces": [],
"steps": [],
"computation_time": [],
"volume": [],
}

@property
def structure(self):
Expand Down
11 changes: 0 additions & 11 deletions pyiron/vasp/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ def __init__(self, project, job_name):
super(VaspInteractive, self).__init__(project, job_name)
self._interactive_write_input_files = True
self._interactive_vasprun = None
self.interactive_cache = {
"cells": [],
"energy_pot": [],
"energy_tot": [],
"forces": [],
"positions": [],
"indices": [],
"steps": [],
"computation_time": [],
"volume": [],
}

@property
def structure(self):
Expand Down
Loading

0 comments on commit 392ca25

Please sign in to comment.