def Task3d_ii(): print("TASK : Task3d_i") maxTime = 5 #should be 3 t, N, T = SetTime(maxTime, increments) nthFrame = 10 dist = 1.7 v0 = np.array([0, 0, 0]) particles = [ MDParticle.Particle('left', 'Ar', np.array([0., 0., 0.]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([dist, 0.0, 0.0]), v0, N, constants.mass) ] MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDFunctions.MoveToCentreOfBox(particles) MDPlot.plotAllEnergies(particles, t, "Total Energy (Velocity Verlet) 1.5 sigma", "3dii_energy_two") MDFileWriter.WriteXYZFile(particles, "3dii_two", N) particles = MDGenerators.PopulateCreateCrystalStructure( 1, "AR", dist, N, constants.mass) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDPlot.plotAllEnergies( particles, t, "Total Energy (Velocity Verlet) 4 particles, random", "3dii_energy_four") MDFileWriter.WriteXYZFile(particles, "3dii_four", N, nthFrame)
def Task2FasterCompare2(): print("TASK : Task2FasterCompare2") maxTime = 0.7 t, N, T = SetTime(maxTime, increments) v0 = np.array([0, 0, 0]) particles = [ MDParticle.Particle('left', 'Ar', np.array([0.0, 0.0, 0.0]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([1.5, 0.0, 0.0]), v0, N, constants.mass) ] #particles = [MDParticle.Particle('left', 'Ar', np.array([0.0,0.0,0.0] ), v0, N, constants.mass)] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.velocityVerlet, particles, T, N) #MDSolver.solve(MDSolver.eulerCromer, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Test slow", "testSlow") MDFileWriter.WriteXYZFile(particles, "twoparticlesVelVerSlow", N, 50) particles = [ MDParticle.Particle('left', 'Ar', np.array([0.0, 0.0, 0.0]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([1.5, 0.0, 0.0]), v0, N, constants.mass) ] #particles = [MDParticle.Particle('left', 'Ar', np.array([0.0,0.0,0.0] ), v0, N, constants.mass)] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Test fast", "testFast") MDFileWriter.WriteXYZFile(particles, "twoparticlesVelVerFast", N, 50)
def Task4b_iv_avg(): print("TASK : Task4b_iv_avg") maxTime = 0.7 t, N, T = SetTime(maxTime, increments) vac = [] sampling = 5 for i in range(0, sampling): particles = MDGenerators.PopulateCreateCrystalStructure( 4, "Ar", 1.7, N, constants.mass, 190) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) vag, diffu_coeff = MDFunctions.ComputeVelocityAutoCorrelation( t, particles) vac.append(vag) avgVag = vac[0] for i in range(0, sampling): avgVag += vac[i] avgVag[0] /= sampling chartName = f"Avg Vel AUtocorrelation {sampling}" MDPlot.plot([avgVag], t, N, chartName, ["vac"], "time (s)", "4biv_avg") MDFileWriter.WriteXYZFile(particles, "4b_ii", N) MDFileWriter.WriteLastFrame(particles, "4b_iiii_lastFrame", N)
def Task3b_ii(): print("TASK : Task3b_ii") maxTime = 5 t, N, T = SetTime(maxTime, increments) v0 = np.array([0, 0, 0]) print("Simulating four atom") ## Create particless particles = [ MDParticle.Particle('one', 'Ar', np.array([1., 0.0, 0.]), v0, N, constants.mass), MDParticle.Particle('two', 'Ar', np.array([0., 1., 0.]), v0, N, constants.mass), MDParticle.Particle('three', 'Ar', np.array([-1., 0., 0.]), v0, N, constants.mass), MDParticle.Particle('four', 'Ar', np.array([0., -1., 0.]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Velocity Verlet)(fast) 1.0 sigma", "allEnergies15velocityVerlet15fast") MDFileWriter.WriteXYZFile(particles, "fourparticlesVelVer1Fast", N)
def Task4b_simAndWrite(): print("TASK : Task4b_ii_write") maxTime = 1.5 t, N, T = SetTime(maxTime, increments) particles = MDGenerators.PopulateCreateCrystalStructure( 4, "Ar", 1.7, N, constants.mass, 190) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDFileWriter.WriteEverything(particles, "4b_ii_everything", N)
def Task4d_i_write(nGrid, sigmaDistance, initTemperature, filename): print("TASK : Task4b_ii_write+ ") maxTime = 2 t, N, T = SetTime(maxTime, increments) particles = MDGenerators.PopulateCreateCrystalStructure( nGrid, "Ar", sigmaDistance, N, constants.mass, initTemperature) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDFileWriter.WriteEverything(particles, filename, N)
def Task3d_i(): print("TASK : Task3d_i") maxTime = 3 #should be 3 t, N, T = SetTime(maxTime, increments) nthFrame = 10 particles = MDGenerators.PopulateCreateCrystalStructure( 4, "AR", 1.7, N, constants.mass) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDPlot.plotAllEnergies( particles, t, "Total Energy (Velocity Verlet) 256 particles, random", "3d_ii") MDFileWriter.WriteXYZFile(particles, "256_random", N, nthFrame)
def Task4a_iii_fast(): print("TASK : Task4a_iii") maxTime = 10 t, N, T = SetTime(maxTime, increments) t_initial = 190 particles = MDGenerators.PopulateCreateCrystalStructure( 3, "Ar", 1.7, N, constants.mass, t_initial) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) #temp = MDFunctions.ComputeTemperatureReduced(N-1, particles, constants.eps) #print(f"AT time {maxTime} temperature is {temp} kelvin") chartName = f"4a) iii Temp ({t_initial} K) (fast)" MDPlot.plotTemperature(particles, t, N, chartName, "4a_iii_fast")
def Task3e_ii(): print("TASK : Task3e_ii") maxTime = 1 #should be 3 nthFrame = 1 t, N, T = SetTime(maxTime, increments) particles = MDGenerators.PopulateCreateCrystalStructure( 2, "AR", 1.7, N, constants.mass) MDFunctions.MoveToCentreOfBox(particles) #MDFileWriter.WriteXYZFile(particles, "108_initial", N, nthFrame) #MDSolver.solve(MDSolver.velocityVerlet, particles, T, N) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDFileWriter.WriteXYZFile(particles, "108_initial", N, nthFrame)
def Task4c_ii(): print("TASK : Task4c_ii") maxTime = 0.7 t, N, T = SetTime(maxTime, increments) particles = MDGenerators.PopulateCreateCrystalStructure( 6, "Ar", 1.7, N, constants.mass, 190) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDPlot.plotMeanSquaredDisplacement(particles, t, N, constants.eps, "4c) i - Mean squared displacement", True, "4c_ii") MDFileWriter.WriteXYZFile(particles, "4c_ii", N) MDFileWriter.WriteLastFrame(particles, "4c_ii_lastFrame", N)
def Task4b_v(): print("TASK : Task4b_v") maxTime = 0.7 t, N, T = SetTime(maxTime, increments) particles = MDGenerators.PopulateCreateCrystalStructure( 4, "Ar", 1.7, N, constants.mass, 190) MDFunctions.MoveToCentreOfBox(particles) MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, maxTime, N) MDPlot.plotVelocityAutoCorrelation(particles, t, N, "4b) ii - Vel.Corr / Diff.coeff ", "4b_v") MDFileWriter.WriteXYZFile(particles, "4b_v", N) MDFileWriter.WriteLastFrame(particles, "4b_v_lastFrame", N)
def Task2c_iv(): print("TASK : Task2c_iv") maxTime = 5 t, N, T = SetTime(maxTime, increments) v0 = np.array([0, 0, 0]) particles = [ MDParticle.Particle('left', 'Ar', np.array([0., 0., 0.]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([1.5, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.euler, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler) 1.5 sigma", "2civ_allEnergiesEuler15") MDFileWriter.WriteXYZFile(particles, "twoparticlesEuler15", N) particles = [ MDParticle.Particle('left', 'Ar', np.array([0., 0., 0.]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([1.5, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.eulerCromer, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler Cromer) 1.5 sigma", "2civ_allEnergiesEulerCromer15") MDFileWriter.WriteXYZFile(particles, "twoparticlesEulerCromer15", N) particles = [ MDParticle.Particle('left', 'Ar', np.array([0., 0., 0.]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([1.5, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.velocityVerlet, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Velocity Verlet) 1.5 sigma", "2civ_allEnergiesVelocityVerlet15") MDFileWriter.WriteXYZFile(particles, "twoparticlesVelVer15", N) particles = [ MDParticle.Particle('left', 'Ar', np.array([0.0, 0.0, 0.0]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([0.95, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.eulerCromer, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler) 0.95 sigma", "2civ_allEnergiesEuler095") MDFileWriter.WriteXYZFile(particles, "twoparticlesEuler095", N) particles = [ MDParticle.Particle('left', 'Ar', np.array([0.0, 0.0, 0.0]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([0.95, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDFileWriter.WriteXYZFile(particles, "twoparticlesEulerCromer095", N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler Cromer) 0.95 sigma", "2civ_allEnergiesEulerCromer095") MDFileWriter.WriteXYZFile(particles, "twoparticlesEulerCromer095", N) particles = [ MDParticle.Particle('left', 'Ar', np.array([0.0, 0.0, 0.0]), v0, N, constants.mass), MDParticle.Particle('right', 'Ar', np.array([0.95, 0.0, 0.0]), v0, N, constants.mass) ] MDFunctions.MoveToCentreOfBox(particles) MDSolver.solve(MDSolver.velocityVerlet, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Velocity Verlet) 0.95 sigma", "2civ_allEnergiesVelocityVerlet095") MDFileWriter.WriteXYZFile(particles, "twoparticlesVelVer095", N)