def calcConductivity(self, molcharges, trjfilename, logfilename, datfilename, T, output): lrun = LammpsRun(datfilename, trjfilename, logfilename) dt = lrun.timestep tsjump = lrun.jump(trjfilename) (num_lines, n, num_timesteps, count, line) = self.getnum(trjfilename) atommass = self.getmass(datfilename) V = self.getdimensions(trjfilename[0]) (vx, vy, vz, mol, atype, j, J) = self.createarrays(n, num_timesteps) (vxcol, vycol, vzcol, idcol, molcol, typecol) = self.getcolumns(trjfilename[0]) for i in range(0, len(trjfilename)): trjfile = open(trjfilename[i]) while line[i] < num_lines[i]: (vx, vy, vz, line, mol, atype) = self.readdata(trjfile, n, line, vx, vy, vz, vxcol, vycol, vzcol, idcol, i, mol, molcol, atype, typecol) if count == 0: (comvx, comvy, comvz, nummol, molmass) = self.COMprep(mol, atype, atommass, n) (comvx, comvy, comvz) = self.calcCOMv(comvx, comvy, comvz, vx, vy, vz, mol, atype, atommass, molmass, n, nummol) (j, count) = self.calcj(molcharges, comvx, comvy, comvz, j, count) J = self.clacJ(j, J) integral = self.integrateJ(J, tsjump * dt) time = [] for i in range(0, len(integral)): time.append(i * tsjump * dt) popt = self.fitcurve(time, integral) cond = self.greenkubo(popt, T, V) output['Conductivity']['Green_Kubo'] = cond file = open('integral.dat', 'w') for i in range(0, len(integral)): file.write(str(integral[i]) + '\n') return output
def test_other(): """ Sample driver file to calculate the MSD and diffusivity for all molecules in a system as well as the center of mass radial distribution function for all pairs of molecules in the system. Will also integrate the rdf to get the coordination number and calculate the ion pair lifetime for the system Requires the following comments in the lammps data file starting at the third line # 'number' 'molecule' molecules where 'number' is the number of that molecule type and 'molecule' is a name for that molecule Do not include blank lines in between the molecule types Outputs are stored in a dictionary called output to later be stored in JSON format """ trjfilename = [ os.path.join(MODULE_DIR, 'tests/sample_files/NaSCN.lammpstrj') ] datfilename = os.path.join(MODULE_DIR, 'tests/sample_files/data.water_1NaSCN') logfilename = os.path.join(MODULE_DIR, 'tests/sample_files/mol.log') lrun = LammpsRun(datfilename, trjfilename, logfilename) c = CenterOfMass() m = MeanSquareDisplacement() crd = RadialDistributionPure() ne = NernstEinsteinConductivity() cn = CoordinationNumber() ip = IonPair() output = {} output['RDF'] = {} output['RDF']['units'] = 'unitless and angstroms' output['Conductivity'] = {} output['Conductivity']['units'] = 'S/m' T = 298 # get from lammpsio tsjump = lrun.jump() (nummoltype, moltypel, moltype) = lrun.get_mols() dt = lrun.timestep n = lrun.natoms() (molcharges, atomcharges, n) = lrun.get_mol_charges(n) molcharge = lrun.get_mol_charge_dict(molcharges, moltypel, moltype) (comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2) = c.calcCOM(trjfilename, datfilename) output = m.runMSD(comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, moltype, moltypel, dt, tsjump, output) output = ne.calcNEconductivity(output, molcharge, Lx, Ly, Lz, nummoltype, moltypel, T) ip.runionpair(comx, comy, comz, Lx, Ly, Lz, moltypel, moltype, tsjump, dt, output, skipframes=0) output = crd.runradial(datfilename, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, output, nummoltype, moltypel, moltype, firststep=1) output = cn.compute(output, nummoltype, moltypel, Lx * Ly * Lz)
def lampps_properties(self, trjfile, datafile, logfile): """ calculate the MSD and diffusivity for all molecules in a system as well as the center of mass radial distribution function for all pairs of molecules in the system Requires the following comments in the lammps data file starting at the third line # "number" "molecule" molecules where "number" is the number of that molecule type and "molecule" is a name for that molecule Do not include blank lines in between the molecule types Outputs are stored in a dictionary called output to later be stored in JSON format :return: Output """ lrun = LammpsRun(datafile, trjfile, logfile) c = CenterOfMass() m = MeanSquareDisplacement() crd = RadialDistributionPure() ne = NernstEinsteinConductivity() output = {} output['RDF'] = {} output['RDF']['units'] = 'unitless and angstroms' output['Conductivity'] = {} output['Conductivity']['units'] = 'S/m' T = 298 # get from lammpsio tsjump = lrun.jump() (nummoltype, moltypel, moltype) = lrun.get_mols() dt = lrun.timestep n = lrun.natoms() (molcharges, atomcharges, n) = lrun.get_mol_charges(n) molcharge = lrun.get_mol_charge_dict(molcharges, moltypel, moltype) (comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2) = c.calcCOM([trjfile], datafile) output = m.runMSD(comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, moltype, moltypel, dt, tsjump, output) output = ne.calcNEconductivity(output, molcharge, Lx, Ly, Lz, nummoltype, moltypel, T) output = crd.runradial(datafile, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, output, nummoltype, moltypel, moltype, firststep=1) return output