You are on page 1of 1

Homework 3

or Assignment 0.1

Due Date: February 13

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.

• comment on the code generously.

• try to show the flowchart (hand-drawn is ok.)

1
Many of you have already finished this problem
2
Set Jij = 1
1

You might also like