Group Homework Discussion Day 4

Overview

Teaching: 0 min
Exercises: 120 min
Questions
  • What’s the homework discussion for day 4?

Objectives
  • Rewrite simulation to use NumPy

  • Compare the timing of the two versions of code.

Lesson Contents

NumPy Monte Carlo

Take an hour or so to discuss with your teammates what changes you can make to your code to take advantage of the features of NumPy arrays. For this portion, take the first 30 minutes to think about this by yourself, then discuss for half an hour with your group. We will tell you one option for rewriting your code at the end of this discussion period.

Consider each function in our code - which ones could benefit from using numpy arrays? Consider each function and include thoughts for each one in your blog post for today.

NumPy Monte Carlo

Expand this section for an explanation of functions which should be rewritten.

Answer

The two functions you should rewrite are :

  1. calculate_total_energy
  2. calculate_pair_energy

You will also need to modify some other functions like calculate_LJ slightly so we can use numpy arrays.

Key Points