human
I am working on the file "02_numpy_md/numpy_md.ipynb".
The first task is:
Your first own numpy MD code
Now you have learned enough to test your numpy knowledge in an exciting example. You will write your own basic MD code. For a start it will be so basic it won't even be able to simulate 256 Argon atoms. For visualization purposes and to keep it simple we will performe our simulation in a 2D square box. 
Task 1: Add atoms!
When we create an object from our simulation class the init function will be called. So far init adds the attributes n_atoms (number of atoms) and box_size. The simulation object also needs all the atom positions and velocities.
self.positions and self.velocities should both be 2D numpy arrays. The first dimension should have one element per atom and the second dimension should have 2 elements representing an x and y values. To distribute atoms randomly in the whole box the self.positons should contain random numbers between 0 and box_size. Velocities should contain random numbers between -0.005 and +0.005. Add positions and velocities to the class definition below and execute the cell. Hint: If you restart the cell while it was still runnig you wont see any output. Use the stop button first. 
(If you have done everything correctly you should see randomly distributed atoms in the appearing plot.)
Task 2: Make them move!
So far our atoms are not moving. We need to fix that in our run function. The velocities array contains velocities in the unit distance/step. All you need to do each step is to add the velocities to the current positions to get the new positions and to overwrite self.positions with these new postions. Make the atoms move!  
(If you have done everything correctly you should see the atoms move. However they wont stop at the boarders of the box.)
Task 3: Keep them in the box!
Obviously we don't want our atoms to go outside of the box. We want to keep them in the box by enforcing periodic boundary conditions. That is where our keep_in_box function comes into play. Use fancy indexing with boolean arrays to detect which atoms are outside the box and...
Can you write Python program for it?
assistant
#Here is Python program to fix that in our run function.

import matplotlib.pyplot as plt
from IPython.display import clear_output, display
%matplotlib inline
import numpy as np

class Simulation:
    def __init__(self, n_atoms, box_size):
        self.n_atoms = n_atoms
        self.box_size = box_size
        self.positions = # Task 1
        self.velocities =  # Task 1
        self.fig, self.ax = plt.subplots()
    
    def run(self, n_steps):
        for step in range(n_steps):
            self.positions = self.positions  # Task 2
            self.keep_in_box()
            
            self.show(step)
    
    def keep_in_box(self):
        self.positions[...] += 0 # Task 3
        self.positions[...] -= 0 # Task 3
    
    def show(self, step):
        self.ax.scatter(self.positions[:, 0], self.positions[:, 1])
        self.ax.set_ylim((0, self.box_size))
        self.ax.set_xlim((0, self.box_size))
        self.ax.text(0.4, 0.9, 'step ' + str(step),
                     bbox={'facecolor':'white', 'alpha':0.5, 'pad':7})
        self.ax.set_aspect('equal', adjustable='box')
        clear_output(True)
        display(self.fig)
        self.ax.cla()
        

            
sim = Simulation(n_atoms=100, box_size=1)
sim.run(n_steps=500)