Skip to content

Commit

Permalink
Fixed parallel case and ASE
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed Oct 25, 2024
1 parent 0f3ea55 commit db86eb9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
2 changes: 0 additions & 2 deletions external_modules/total_energy_module/total_energy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ SUBROUTINE initialize(file_name, y_planes_in, calculate_eigts_in)
ENDIF
ENDIF

print *, file_name

!! checks if first string is contained in the second
!
CALL mp_startup ( start_images=.true., images_only=.true.)
Expand Down
27 changes: 10 additions & 17 deletions mala/interfaces/ase_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,30 +154,23 @@ def calculate(
# Get the LDOS from the NN.
ldos = self.predictor.predict_for_atoms(atoms)

# forces = np.zeros([len(atoms), 3], dtype=np.float64)

# If an MPI environment is detected, ASE will use it for writing.
# Therefore we have to do this before forking.
self.data_handler.target_calculator.write_tem_input_file(
atoms,
self.data_handler.target_calculator.qe_input_data,
self.data_handler.target_calculator.qe_pseudopotentials,
self.data_handler.target_calculator.grid_dimensions,
self.data_handler.target_calculator.kpoints,
get_comm(),
get_rank(),
)

# Use the LDOS determined DOS and density to get energy and forces.
ldos_calculator: LDOS = self.data_handler.target_calculator

ldos_calculator.read_from_array(ldos)
self.results["energy"] = ldos_calculator.total_energy
energy, self.last_energy_contributions = (
ldos_calculator.get_total_energy(return_energy_contributions=True)
)
self.last_energy_contributions = (
ldos_calculator._density_calculator.total_energy_contributions.copy()
)
self.last_energy_contributions["e_band"] = ldos_calculator.band_energy
self.last_energy_contributions["e_entropy_contribution"] = (
ldos_calculator.entropy_contribution
)
barrier()

# Use the LDOS determined DOS and density to get energy and forces.
self.results["energy"] = energy
# forces = np.zeros([len(atoms), 3], dtype=np.float64)
# if "forces" in properties:
# self.results["forces"] = forces

Expand Down
3 changes: 2 additions & 1 deletion mala/targets/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ def __setup_total_energy_module(
barrier()

# Right after setup we can delete the file.
os.remove(tem_input_name)
if get_rank() == 0:
os.remove(tem_input_name)

printout(
"Total energy module: Time used by total energy initialization: {:.8f}s".format(
Expand Down

0 comments on commit db86eb9

Please sign in to comment.