def write_relaxed_poscar(target, pot_type): from module_amp2_input import read_poscar, write_poscar [axis_ori, atom_pos_ori] = read_poscar(target + '/INPUT0/POSCAR') [axis_rlx, atom_pos_rlx] = read_poscar(target + '/relax_' + pot_type + '/CONTCAR') new_atom_pos = [] for i in range(len(atom_pos_rlx)): new_atom_pos.append(atom_pos_rlx[i][0:3] + atom_pos_ori[i][3:]) write_poscar(axis_rlx, new_atom_pos, target + '/INPUT0/POSCAR_rlx_' + pot_type, 'relaxed poscar')
def set_ediffg(poscar, force, pressure, energy): if pressure < 0 and force < 0 and energy < 0: return 0 elif pressure < 0 and force < 0 and enegy > 0: return energy else: [axis, atom_pos] = read_poscar(poscar) volume = calc_volume(axis) nion = len(atom_pos) conv_press = pressure * volume / nion / 1602.17733 # it is identical to VASP precision. if conv_press < force: return -1.0 * conv_press else: return -1.0 * force