homework 1
python程序 Science backgroundA cluster of atoms interacting via the Lennard Jones potential is known as a Lennard-Jones (LJ) cluster. is the distance···
Day 4 python程序
Science background
A cluster of atoms interacting via the Lennard Jones potential
is known as a Lennard-Jones (LJ) cluster. is the distance between two atoms. The parameter is an energy representing the strength of the interaction and a distance representing the size of the atom. A cluster of Argon atoms for example is well be described by this model. These clusters can be formed and studied experimentally. For some pictures and extra information see https://en.wikipedia.org/wiki/Lennard-Jones_potential .
The total energy of a LJ cluster is the sum of the interaction between all particles:
If the distances are expressed in units of the parameter and the energy in units of , one can express the LJ potential in reduced units as
Important note. Unlike other labs, you are not expected to complete all the tasks for a good mark. Here, the A/B boundary can be achieved by completing 4.1 and the majority of 4.2. Demonstrators will help until task 4.2.
Task 4.1. Build a function that performs the following task
- Read coordinates of a LJ cluster from a file
- Returns the total energy of this cluster
- Returns the shortest distance between atoms of this cluster
python程序
(Note that you can recycle some codes of tasks 3.2, 2.5, 2.6, 2.3 – if such codes are not clear it is best to understand them first)
This web page contains coordinates and energy for clusters of different size:
http://www-wales.ch.cam.ac.uk/~jon/structures/LJ/tables.150.html
You can use it to download a given cluster and check that the total energy is the one you compute. The geometry and energy in the link above is of a minimum energy configuration, e.g. displacing any atom by any amount will increase the total energy.
Task 4.2. Build a function that takes as input an arbitrary geometry of a LJ cluster (C0) and its energy (E0) and performs the following tasks.
- Select a random atom of the cluster
- Generate a new set of coordinates C1 where the selected atom is displaced by a small amount in one random Cartesian direction
- Compute the new energy E1 of the new set of coordinates
- If the new energy is smaller than the old energy (E1<E0) the function returns the new coordinates C1 and the new energy E1. If E1=>E0 the function returns the old coordinates and energy (C0, E0)
Note: use the web to find how to generate random numbers. Remember that to copy one numpy array ‘b’ into ‘a’ you should use a=np.copy(b) {a=b will do something different}.
python程序
The algorithm above represents an attempt to find a more stable (lower energy) geometry for a given cluster. If the random move has found a more stable cluster that can be used as a starting point to find an even better, lower energy, cluster geometry. Repeating this process allows the identification of the ‘local potential energy minimum’, i.e. a stable structure such that any geometric change will increase the energy. This algorithm is known as Monte Carlo minimization. It is completed by the next task.
Task 4.3.
- Modify the code in Task 4.2 so that the process is repeated many times. A set of coordinates and energy give a new set of coordinates and energy which are the input of a new step.
- Use this code to find the geometry of the lowest energy cluster starting with these coordinates.
0.230 1.146 -0.331
-0.428 -0.622 0.706
-0.966 -0.239 -0.169
0.609 -0.362 0.709
0.835 0.164 -0.263
-0.104 0.241 -0.807
0.039 -0.664 -0.208
-0.135 0.306 0.306 …..
Please follow these instructions for your submission (compliance will be also assessed);
- Your submission should be a zip folder named LASTNAMEfirstname.zip, e.g. SMITHJohn.zip
- The folder should contains all codes and all data needed to test the codes.
- One file called ‘testme.py’ should be present
- Opening the code ‘testme.py’ and running it, all the codes written to address tasks above will be executed correctly.