def Task2c_i(): print("TASK : Task2c_i") maxTime = 5 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) ] MDSolver.solve(MDSolver.eulerCromer, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler Cromer) 1.5 sigma", "2ci_allEnergiesCromer095") 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) ] MDSolver.solve(MDSolver.eulerCromer, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Euler Cromer) 0.95 sigma", "2ci_allEnergiesCromer15")
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 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 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 Task3b_iv(): print("TASK : Task3b_iv") maxTime = 5 t, N, T = SetTime(maxTime, increments) v0 = np.array([0, 0, 0]) 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) ] MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, T, N) MDPlot.plotAllEnergies(particles, t, "Total Energy (Velocity Verlet) 4 particles", "3b_iv") MDFileWriter.WriteXYZFile3(particles, "3b_iv", N)
def Task3b_v(): print("TASK : Task3b_v") print("Simulating four atom") nthFrame = 10 v0 = np.array([0, 0, 0]) particles = [ MDParticle.Particle('one', 'Ar', np.array([1., 0.1, 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) ] MDSolver.solveFaster(MDSolver.velocityVerletFast2, particles, T, N) MDPlot.plotAllEnergies( particles, t, "Total Energy (Velocity Verlet) 4 particles, perturbed", "3b_v") MDFileWriter.WriteXYZFile(particles, "fourparticlesVelVer1FastPerturb", N, nthFrame)
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)