Skip to content

Commit

Permalink
Log now only cleaned AFTER LAMMPS instance is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed May 31, 2024
1 parent 92831ff commit fe911a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions mala/descriptors/atomic_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def __calculate_lammps(self, outdir, **kwargs):

# Do the LAMMPS calculation and clean up.
lmp.file(self.parameters.lammps_compute_file)
self._clean_calculation(keep_logs)

# Extract the data.
nrows_ggrid = extract_compute_np(
Expand All @@ -209,7 +208,7 @@ def __calculate_lammps(self, outdir, **kwargs):
array_shape=(nrows_ggrid, ncols_ggrid),
use_fp64=use_fp64,
)
lmp.close()
self._clean_calculation(lmp, keep_logs)

# In comparison to SNAP, the atomic density always returns
# in the "local mode". Thus we have to make some slight adjustments
Expand Down
5 changes: 2 additions & 3 deletions mala/descriptors/bispectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def __calculate_lammps(self, outdir, **kwargs):

# Do the LAMMPS calculation and clean up.
lmp.file(self.parameters.lammps_compute_file)
self._clean_calculation(keep_logs)

# Set things not accessible from LAMMPS
# First 3 cols are x, y, z, coords
Expand Down Expand Up @@ -228,7 +227,7 @@ def __calculate_lammps(self, outdir, **kwargs):
array_shape=(nrows_local, ncols_local),
use_fp64=use_fp64,
)
lmp.close()
self._clean_calculation(lmp, keep_logs)

# Copy the grid dimensions only at the end.
self.grid_dimensions = [nx, ny, nz]
Expand All @@ -244,7 +243,7 @@ def __calculate_lammps(self, outdir, **kwargs):
(nz, ny, nx, self.fingerprint_length),
use_fp64=use_fp64,
)
lmp.close()
self._clean_calculation(lmp, keep_logs)

# switch from x-fastest to z-fastest order (swaps 0th and 2nd
# dimension)
Expand Down
3 changes: 2 additions & 1 deletion mala/descriptors/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ def _setup_lammps(self, nx, ny, nz, lammps_dict):

return lmp

def _clean_calculation(self, keep_logs):
def _clean_calculation(self, lmp, keep_logs):
lmp.close()
if not keep_logs:
if get_rank() == 0:
os.remove(self.lammps_temporary_log)
Expand Down
12 changes: 6 additions & 6 deletions mala/descriptors/minterpy_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,15 @@ def _calculate(self, atoms, outdir, grid_dimensions, **kwargs):
)

# Create LAMMPS instance.
lammps_dict = {}
lammps_dict["sigma"] = self.parameters.atomic_density_sigma
lammps_dict["rcutfac"] = self.parameters.atomic_density_cutoff
lammps_dict = {
"sigma": self.parameters.atomic_density_sigma,
"rcutfac": self.parameters.atomic_density_cutoff,
}
self.lammps_temporary_log = os.path.join(
outdir,
"lammps_bgrid_log_" + self.calculation_timestamp + ".tmp",
)
lmp = self._setup_lammps(nx, ny, nz, lammps_dict, log_path)
lmp = self._setup_lammps(nx, ny, nz, lammps_dict)

# For now the file is chosen automatically, because this is used
# mostly under the hood anyway.
Expand All @@ -199,7 +200,6 @@ def _calculate(self, atoms, outdir, grid_dimensions, **kwargs):

# Do the LAMMPS calculation and clean up.
lmp.file(self.parameters.lammps_compute_file)
self._clean_calculation(keep_logs)

# Extract the data.
nrows_ggrid = extract_compute_np(
Expand All @@ -223,7 +223,7 @@ def _calculate(self, atoms, outdir, grid_dimensions, **kwargs):
array_shape=(nrows_ggrid, ncols_ggrid),
)

lmp.close()
self._clean_calculation(lmp, keep_logs)

gaussian_descriptors_np = gaussian_descriptors_np.reshape(
(
Expand Down

0 comments on commit fe911a2

Please sign in to comment.