Professional Documents
Culture Documents
William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling - Numerical Recipes in Fortran 77 and 90-Cambridge University Press (1992) PDF
William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling - Numerical Recipes in Fortran 77 and 90-Cambridge University Press (1992) PDF
or Assignment 0.1
1. Write a code to generate 2-d lattice system. Use rand() to assign it a symbol and
spin. Put special effort to make it as modularize as possible; i.e., say, read your
input in the main program and generate the lattice system in a subroutine that
the program calls.1
Each element in the lattice will have properties:
integer :: coordinate (3)
integer :: spin (+1/ -1)
character :: name
2. Flip a randomly selected atom (use intrinsic subroutine random number()). Con-
sider only nearest neighbour interaction. Calculate the energy change using equa-
tion: X
Jij si · sj
i,j,i6=j
1 2 3
4 5 6
2 7 8 9
3. What happens when the chosen atom in problem 2 is at the edge e.g. atom 3?
Please:
• Put problem 1, 2 and 3 in a subroutine and call them in a program. Tips: define
atoms derived data type and read all variables in a module, use that in the main
program. Call the subroutines in the main program.
1
Many of you have already finished this problem
2
Set Jij = 1
1