Skip to content

Commit

Permalink
WIP: Fixed restart bug and added printing different potential atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser-Birks committed Feb 19, 2024
1 parent 027f7ff commit dff5752
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions matscipy/fracture_mechanics/thin_strip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ def write_potential_and_buffer(atoms,lammps_filename):
buffer = atoms.arrays['buffer']
ids = np.arange(1,len(atoms)+1)

#print the number of potential and buffer atoms of each type
for ntype in np.unique(potential):
print(f'Number of potential atoms of type {ntype}: {np.sum(potential==ntype)}')
print(f'Number of potential atoms of type {ntype} including those in buffer: {np.sum((potential==ntype)|(buffer==1))}')


#write to file
#create a vertical array of ids, potential
pot_arr = np.vstack((ids,potential)).T
Expand Down
22 changes: 13 additions & 9 deletions scripts/fracture_mechanics/thin_strip_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
initial_damp = False
warnings.warn('Restarting from checkpoint, initial damping will be skipped')

if restart and initial_kick:
initial_kick = False
warnings.warn('Restarting from checkpoint, initial kick will be skipped')

lmp = lammps()

initial_K = kvals[0]
Expand Down Expand Up @@ -188,15 +192,15 @@
crack_tip_positions = np.array([])
prev_v = 0
unique_v_vals = 0
#unscaled_crack = ase.io.lammpsdata.read_lammps_data(f'{temp_path}/crack.lj',atom_style='atomic')
unscaled_crack = ase.io.read(f'{temp_path}/crack.xyz',format='extxyz',parallel=False)
unscaled_crack.set_pbc([False,False,True])

rescale_crack = tsb.rescale_K(unscaled_crack,K_curr,K,strip_height,tip_pos,approximate=approximate_strain)
#re-write lammps data file
ase.io.lammpsdata.write_lammps_data(f'{temp_path}/crack.lj',rescale_crack,velocities=True,masses=True)
if multi_potential:
write_potential_and_buffer(crack_slab,f'{temp_path}/crack.lj')
if K != K_curr: #we don't need to rescale if K is K_curr
#unscaled_crack = ase.io.lammpsdata.read_lammps_data(f'{temp_path}/crack.lj',atom_style='atomic')
unscaled_crack = ase.io.read(f'{temp_path}/crack.xyz',format='extxyz',parallel=False)
unscaled_crack.set_pbc([False,False,True])
rescale_crack = tsb.rescale_K(unscaled_crack,K_curr,K,strip_height,tip_pos,approximate=approximate_strain)
#re-write lammps data file
ase.io.lammpsdata.write_lammps_data(f'{temp_path}/crack.lj',rescale_crack,velocities=True,masses=True)
if multi_potential:
write_potential_and_buffer(crack_slab,f'{temp_path}/crack.lj')

K_curr = K
if (knum == 0) and initial_damp:
Expand Down

0 comments on commit dff5752

Please sign in to comment.