def Task4b_ii(): print("TASK : Task4b_ii") 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) particles = MDFileWriter.ReadEverything("4b_ii_everything", N) MDPlot.plotVelocityAutoCorrelation(particles, t, N, "4b) ii", True, "4b_ii") MDFileWriter.WriteXYZFile(particles, "4b_ii", N) MDFileWriter.WriteLastFrame(particles, "4b_ii_lastFrame", N)
def Task4_di_read(t, filename): num_bins = 10 bin_edges = np.linspace(0, 5, num_bins + 1) bin_centres = 0.5 * (bin_edges[1:] + bin_edges[:-1]) V = constants.box**3 #Read the file prepared by the previous particles, maxTindex = MDFileWriter.ReadEverything(filename, N) #Convert x-axis units from sigma to Ångstrøm bin_centres = MDFunctions.SigmaToAngstrom(bin_centres) if t is None: t = maxTindex elif t > maxTindex: raise Exception( "Trying to read out rdf from frame {t} which only simulated {maxTindex} frames" ) tInSeconds = MDFunctions.ArgonTimeToSeconds(t) count = len(particles) x = np.array([[0., 0., 0.] for i in range(count)]) # Velocity j = 0 counter = 0 for j in range(0, count): x[counter] = particles[j].x[t] counter += 1 #x = np.where(x > 0) #Bin the distance counts data = MDFunctions.rdf(bin_edges, x, V) chartName = f"Ar N={count} RDF after {tInSeconds[0]:11.6} {tInSeconds[1]}" # def barchart(data, xlabels, chartName, filename = "barChart"): MDPlot.barchart(data, bin_centres, "RDF", chartName, f"RDF_{filename}") strLabels = [] for lb in bin_centres[0]: strLabels.append(f"{lb:11.1f}")