-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCython_LebwohlLasher.py
44 lines (36 loc) · 1.45 KB
/
Cython_LebwohlLasher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
Basic Python Lebwohl-Lasher code. Based on the paper
P.A. Lebwohl and G. Lasher, Phys. Rev. A, 6, 426-429 (1972).
This version in 2D.
Run at the command line by typing:
python LebwohlLasher.py <ITERATIONS> <SIZE> <TEMPERATURE> <PLOTFLAG>
where:
ITERATIONS = number of Monte Carlo steps, where 1MCS is when each cell
has attempted a change once on average (i.e. SIZE*SIZE attempts)
SIZE = side length of square lattice
TEMPERATURE = reduced temperature in range 0.0 - 2.0.
PLOTFLAG = 0 for no plot, 1 for energy plot and 2 for angle plot.
The initial configuration is set at random. The boundaries
are periodic throughout the simulation. During the
time-stepping, an array containing two domains is used; these
domains alternate between old data and new data.
SH 16-Oct-23
"""
import sys
import time
#import Cython.CythonLebwohlLasher as cythonLL
from cythonized.cythonized.CythonLebwohlLasher import main
if int(len(sys.argv)) == 5:
PROGNAME = sys.argv[0]
ITERATIONS = int(sys.argv[1])
SIZE = int(sys.argv[2])
TEMPERATURE = float(sys.argv[3])
PLOTFLAG = int(sys.argv[4])
initial = time.time()
main(PROGNAME,ITERATIONS,SIZE,TEMPERATURE,PLOTFLAG)
final = time.time()
time_taken = final - initial
print(f"Time taken: {time_taken:.5f}s")
else:
print("Usage: python {} <ITERATIONS> <SIZE> <TEMPERATURE> <PLOTFLAG>".format(sys.argv[0]))
#=======================================================================