Skip to content

Commit

Permalink
quick fix for changing structure positions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpvandermause committed Jun 16, 2020
1 parent 125c08f commit 1829b0c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion flare/ase/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from copy import deepcopy

def parse_dft_input(atoms):
pos = atoms.positions
pos = np.copy(atoms.positions)
spc = atoms.get_chemical_symbols()
cell = np.array(atoms.get_cell())

Expand Down
2 changes: 2 additions & 0 deletions flare/ase/otf.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def md_step(self):
Get new position in molecular dynamics based on the forces predicted by
FLARE_Calculator or DFT calculator
'''
pos = np.copy(self.structure.positions)
self.md.step()
self.structure.positions = pos
return self.atoms.positions

# TODO: fix the temperature output in the log file
Expand Down
35 changes: 18 additions & 17 deletions flare/otf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self,
force_source: str = "qe",
npool: int = None, mpi: str = "srun", dft_loc: str = None,
dft_input: str = None, dft_output='dft.out', dft_kwargs=None,
store_dft_output: Tuple[Union[str, List[str]],str] = None,
store_dft_output: Tuple[Union[str, List[str]], str] = None,
# par args
n_cpus: int = 1,
):
Expand Down Expand Up @@ -201,8 +201,7 @@ def run(self):

while self.curr_step < self.number_of_steps:
# run DFT and train initial model if first step and DFT is on
if self.curr_step == 0 and self.std_tolerance != 0 and \
len(self.gp.training_data) == 0:
if self.curr_step == 0 and self.std_tolerance != 0 and len(self.gp.training_data) == 0:

self.initialize_train()
new_pos = self.md_step()
Expand All @@ -214,7 +213,13 @@ def run(self):
# compute forces and stds with GP
self.dft_step = False
self.compute_properties()
# print('positions pre:')
# print(self.structure.positions)
new_pos = self.md_step()
# print('positions post:')
# print(self.structure.positions)
# print('new pos:')
# print(new_pos)

# get max uncertainty atoms
std_in_bound, target_atoms = \
Expand Down Expand Up @@ -278,8 +283,7 @@ def md_step(self):
'''
In ASE-OTF, it will be replaced by subclass method
'''
return md.update_positions(self.dt, self.noa,
self.structure)
return md.update_positions(self.dt, self.noa, self.structure)

def run_dft(self):
"""Calculates DFT forces on atoms in the current structure.
Expand All @@ -294,13 +298,11 @@ def run_dft(self):
f.info('\nCalling DFT...\n')

# calculate DFT forces
forces = self.dft_module.run_dft_par(self.dft_input, self.structure,
self.dft_loc,
n_cpus=self.n_cpus,
dft_out=self.dft_output,
npool=self.npool,
mpi=self.mpi,
dft_kwargs=self.dft_kwargs)
forces = self.dft_module.run_dft_par(
self.dft_input, self.structure, self.dft_loc, n_cpus=self.n_cpus,
dft_out=self.dft_output, npool=self.npool, mpi=self.mpi,
dft_kwargs=self.dft_kwargs)

self.structure.forces = forces

# write wall time of DFT calculation
Expand Down Expand Up @@ -395,8 +397,7 @@ def update_temperature(self, new_pos: 'ndarray'):
self.velocities = velocities

def record_state(self):
self.output.write_md_config(self.dt, self.curr_step, self.structure,
self.temperature, self.KE,
self.local_energies, self.start_time,
self.dft_step,
self.velocities)
self.output.write_md_config(
self.dt, self.curr_step, self.structure, self.temperature,
self.KE, self.local_energies, self.start_time, self.dft_step,
self.velocities)

0 comments on commit 1829b0c

Please sign in to comment.