def write_final_xyz(self, unixmd_dir, istep): """ Write final positions and velocities :param string unixmd_dir: Directory where MD output files are written :param integer istep: Current MD step """ # Write FINAL.xyz file including positions and velocities tmp = f'{self.mol.nat:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Position(A){"":34s}Velocity(au)' for iat in range(self.mol.nat): tmp += "\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.mol.pos[iat, isp] * au_to_A:15.8f}' for isp in range(self.mol.ndim)]) \ + "".join([f"{self.mol.vel[iat, isp]:15.8f}" for isp in range(self.mol.ndim)]) typewriter(tmp, unixmd_dir, "FINAL.xyz", "w")
def write_deco(self, unixmd_dir, istep): """ Write XF-based decoherence information :param string unixmd_dir: PyUNIxMD directory :param integer istep: Current MD step """ # Write time-derivative density matrix elements in DOTPOTD tmp = f'{istep + 1:9d}' + "".join( [f'{pop:15.8f}' for pop in self.dotpopd]) typewriter(tmp, unixmd_dir, "DOTPOPD", "a") # Write auxiliary trajectories if (self.verbosity >= 2 and True in self.l_coh): # Write quantum momenta tmp = f'{self.aux.nat:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Momentum (au)' + \ "".join(["\n" + f'{self.aux.symbols[iat]:5s}' + \ "".join([f'{self.qmom[iat, isp]:15.8f}' for isp in range(self.aux.ndim)]) for iat in range(self.aux.nat)]) typewriter(tmp, unixmd_dir, f"QMOM", "a") # Write auxiliary variables for ist in range(self.mol.nst): if (self.l_coh[ist]): # Write auxiliary phase tmp = f'{self.aux.nat:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Phase (au)' + \ "".join(["\n" + f'{self.aux.symbols[iat]:5s}' + \ "".join([f'{self.phase[ist, iat, isp]:15.8f}' for isp in range(self.aux.ndim)]) for iat in range(self.aux.nat)]) typewriter(tmp, unixmd_dir, f"AUX_PHASE_{ist}", "a") # Write auxiliary trajectory movie files tmp = f'{self.aux.nat:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Position(A){"":34s}Velocity(au)' + \ "".join(["\n" + f'{self.aux.symbols[iat]:5s}' + \ "".join([f'{self.aux.pos[ist, iat, isp] * au_to_A:15.8f}' for isp in range(self.aux.ndim)]) + \ "".join([f"{self.aux.vel[ist, iat, isp]:15.8f}" for isp in range(self.aux.ndim)]) for iat in range(self.aux.nat)]) typewriter(tmp, unixmd_dir, f"AUX_MOVIE_{ist}.xyz", "a")
def write_sh(self, unixmd_dir, istep): """ Write hopping-related quantities into files :param string unixmd_dir: PyUNIxMD directory :param integer istep: Current MD step """ # Write SHSTATE file tmp = f'{istep + 1:9d}{"":14s}{self.rstate}' typewriter(tmp, unixmd_dir, "SHSTATE", "a") # Write SHPROB file tmp = f'{istep + 1:9d}' + "".join( [f'{self.prob[ist]:15.8f}' for ist in range(self.mol.nst)]) typewriter(tmp, unixmd_dir, "SHPROB", "a")
def write_deco(self, itrajectory, unixmd_dir, istep): """ Write CT-based decoherence information :param integer itrajectory: Index for trajectories :param string unixmd_dir: PyUNIxMD directory :param integer istep: Current MD step """ # TODO # Write time-derivative density matrix elements in DOTPOTD #tmp = f'{istep + 1:9d}' + "".join([f'{pop:15.8f}' for pop in self.dotpopd]) #typewriter(tmp, unixmd_dir, "DOTPOPD", "a") # Write auxiliary trajectories if (self.verbosity >= 2): tmp = f'{self.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}sigma_x{"":5s}sigma_y{"":5s}sigma_z{"":5s}count_ntrajs' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.sigma_lk[itrajectory, 0, iat, idim]:15.8f}' for idim in range(self.ndim)]) + \ f'{self.count_ntrajs[itrajectory, iat]:15.8f}' for iat in range(self.nat_qm)]) typewriter(tmp, unixmd_dir, f"SIGMA", "a") tmp = f'{self.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}slope' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.slope_i[itrajectory, iat, idim]:15.8f}' for idim in range(self.ndim)]) for iat in range(self.nat_qm)]) typewriter(tmp, unixmd_dir, f"SLOPE", "a") # Write quantum momenta index_lk = -1 for ist in range(self.nst): for jst in range(ist + 1, self.nst): index_lk += 1 tmp = f'{self.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Momentum center (au)' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.center_lk[itrajectory, index_lk, iat, idim]:15.8f}' for idim in range(self.ndim)]) for iat in range(self.nat_qm)]) typewriter(tmp, unixmd_dir, f"CENTER_{ist}_{jst}", "a") tmp = f'{self.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Momentum (au)' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.qmom[itrajectory, index_lk, iat, idim]:15.8f}' for idim in range(self.ndim)]) for iat in range(self.nat_qm)]) typewriter(tmp, unixmd_dir, f"QMOM_{ist}_{jst}", "a") for ist in range(self.nst): for jst in range(self.nst): if (ist != jst): tmp = f'{istep + 1:9d}{self.K_lk[itrajectory, ist, jst]:15.8f}' typewriter(tmp, unixmd_dir, f"K_lk_{ist}_{jst}", "a") # Write auxiliary variables for ist in range(self.mol.nst): # Write auxiliary phase tmp = f'{self.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Phase (au)' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.phase[itrajectory, ist, iat, idim]:15.8f}' for idim in range(self.ndim)]) for iat in range(self.nat_qm)]) typewriter(tmp, unixmd_dir, f"PHASE_{ist}", "a")
def write_md_output(self, unixmd_dir, istep): """ Write output files :param string unixmd_dir: Directory where MD output files are written :param integer istep: Current MD step """ # Write MOVIE.xyz file including positions and velocities tmp = f'{self.mol.nat:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}Position(A){"":34s}Velocity(au)' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.mol.pos[iat, isp] * au_to_A:15.8f}' for isp in range(self.mol.ndim)]) + \ "".join([f"{self.mol.vel[iat, isp]:15.8f}" for isp in range(self.mol.ndim)]) for iat in range(self.mol.nat)]) typewriter(tmp, unixmd_dir, "MOVIE.xyz", "a") # Write MDENERGY file including several energy information tmp = f'{istep + 1:9d}{self.mol.ekin:15.8f}{self.mol.epot:15.8f}{self.mol.etot:15.8f}' \ + "".join([f'{states.energy:15.8f}' for states in self.mol.states]) typewriter(tmp, unixmd_dir, "MDENERGY", "a") if (self.md_type != "BOMD"): # Write BOCOEF, BOPOP, BOCOH files if (self.elec_object == "density"): tmp = f'{istep + 1:9d}' + "".join([ f'{self.mol.rho.real[ist, ist]:15.8f}' for ist in range(self.mol.nst) ]) typewriter(tmp, unixmd_dir, "BOPOP", "a") tmp = f'{istep + 1:9d}' + "".join([f"{self.mol.rho.real[ist, jst]:15.8f}{self.mol.rho.imag[ist, jst]:15.8f}" \ for ist in range(self.mol.nst) for jst in range(ist + 1, self.mol.nst)]) typewriter(tmp, unixmd_dir, "BOCOH", "a") elif (self.elec_object == "coefficient"): tmp = f'{istep + 1:9d}' + "".join([f'{states.coef.real:15.8f}{states.coef.imag:15.8f}' \ for states in self.mol.states]) typewriter(tmp, unixmd_dir, "BOCOEF", "a") if (self.l_print_dm): tmp = f'{istep + 1:9d}' + "".join([ f'{self.mol.rho.real[ist, ist]:15.8f}' for ist in range(self.mol.nst) ]) typewriter(tmp, unixmd_dir, "BOPOP", "a") tmp = f'{istep + 1:9d}' + "".join([f"{self.mol.rho.real[ist, jst]:15.8f}{self.mol.rho.imag[ist, jst]:15.8f}" \ for ist in range(self.mol.nst) for jst in range(ist + 1, self.mol.nst)]) typewriter(tmp, unixmd_dir, "BOCOH", "a") # Write NACME file tmp = f'{istep + 1:10d}' + "".join([f'{self.mol.nacme[ist, jst]:15.8f}' \ for ist in range(self.mol.nst) for jst in range(ist + 1, self.mol.nst)]) typewriter(tmp, unixmd_dir, "NACME", "a") # Write NACV file if (not self.mol.l_nacme and self.verbosity >= 2): for ist in range(self.mol.nst): for jst in range(ist + 1, self.mol.nst): tmp = f'{self.mol.nat_qm:6d}\n{"":2s}Step:{istep + 1:6d}{"":12s}NACV' + \ "".join(["\n" + f'{self.mol.symbols[iat]:5s}' + \ "".join([f'{self.mol.nac[ist, jst, iat, isp]:15.8f}' for isp in range(self.mol.ndim)]) for iat in range(self.mol.nat_qm)]) typewriter(tmp, unixmd_dir, f"NACV_{ist}_{jst}", "a")
def touch_file(self, unixmd_dir): """ Routine to write PyUNIxMD output files :param string unixmd_dir: Directory where MD output files are written """ # Energy information file header tmp = f'{"#":5s}{"Step":9s}{"Kinetic(H)":15s}{"Potential(H)":15s}{"Total(H)":15s}' + \ "".join([f'E({ist})(H){"":8s}' for ist in range(self.mol.nst)]) typewriter(tmp, unixmd_dir, "MDENERGY", "w") if (self.md_type != "BOMD"): # BO coefficents, densities file header if (self.elec_object == "density"): tmp = f'{"#":5s} Density Matrix: population Re; see the manual for detail orders' typewriter(tmp, unixmd_dir, "BOPOP", "w") tmp = f'{"#":5s} Density Matrix: coherence Re-Im; see the manual for detail orders' typewriter(tmp, unixmd_dir, "BOCOH", "w") elif (self.elec_object == "coefficient"): tmp = f'{"#":5s} BO State Coefficients: state Re-Im; see the manual for detail orders' typewriter(tmp, unixmd_dir, "BOCOEF", "w") if (self.l_print_dm): tmp = f'{"#":5s} Density Matrix: population Re; see the manual for detail orders' typewriter(tmp, unixmd_dir, "BOPOP", "w") tmp = f'{"#":5s} Density Matrix: coherence Re-Im; see the manual for detail orders' typewriter(tmp, unixmd_dir, "BOCOH", "w") # NACME file header tmp = f'{"#":5s}Non-Adiabatic Coupling Matrix Elements: off-diagonal' typewriter(tmp, unixmd_dir, "NACME", "w") # file header for SH-based methods if (self.md_type == "SH" or self.md_type == "SHXF"): tmp = f'{"#":5s}{"Step":8s}{"Running State":10s}' typewriter(tmp, unixmd_dir, "SHSTATE", "w") tmp = f'{"#":5s}{"Step":12s}' + "".join( [f'Prob({ist}){"":8s}' for ist in range(self.mol.nst)]) typewriter(tmp, unixmd_dir, "SHPROB", "w") # file header for XF-based methods if (self.md_type == "SHXF" or self.md_type == "EhXF"): tmp = f'{"#":5s} Time-derivative Density Matrix by decoherence: population; see the manual for detail orders' typewriter(tmp, unixmd_dir, "DOTPOPD", "w")