Today we learned how to take our python code and create an editable package which would allow us to import the package and use the functions within it. To do this we created a directory mcsim which would contain the files we wish to include in the package. We then used the pip command to install the local folder as an editable python package. We created an init file to specify how we would like the computer to import our code.

Today as a group my team has created the file monte-carlo-np-trevor.py which uses the NumPy library to accelerate the efficiency of our code by using operations on np.array objects. We added this file to mcsim and used pytest to automate the testing phase of our project. We wrote nine test functions comparing our observed output to the expected values we discussed in lecture.

For the next task we added the analysis.py file to use our simulation to calculate the pressure given when given a random configuration at certain values for number density, temperature, and number of particles. We also calculated the tail correction and provided that as output from our function as well.

To do this we used two functions, calculate_distance_np() to calculate the distance between coordinates and configure_initial_random() which initializes a randomly placed array of particles within a given box length. Our main function is shown below:

def calculate_pressure(coordinates, temperature, box_length, cut_off):

Here coordinates is given as an np.array containing the array of particles at a randomized [x, y, z] position. The box length is a function of the number density and the number of particles. Cutoff is used in the calculation of the tail correction.

Our code can be found on github and has been integrated into our package, but we did not write our pytest functions yet because we have not yet calculated the correct answer, when compared to the values given by NIST. Our calculated pressure is orders of magnitude more than the values we are expecting, but we are also uncertain about our understanding of the units and how to calculate the values in the function.

Our code works by looping through the coordinate values, and calculating the force between each particle i and all other particles j. We then use the sum of these forces in our calculation of pressure. We still have work to do debugging the corde and comparing it with standard values.