ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/samples/Madelung/dipoles/fieldValues
Revision: 1918
Committed: Wed Jul 31 15:43:17 2013 UTC (12 years, 1 month ago) by gezelter
File size: 5051 byte(s)
Log Message:
Added a fieldValues script, updated some text in the README file

File Contents

# Content
1 #! /usr/bin/env python
2
3 from __future__ import division,print_function
4
5 __doc__ = """Luttinger and Tisza Field values
6
7 Computes the sums for the field values (and also the energy constants
8 for the low energy lattices) from the paper by Luttinger and Tisza
9 paper:
10
11 J. M. Luttinger and L. Tisza, "Theory of Dipole Interaction in
12 Crystals," Phys. Rev. 70, 954-964 (1946) doi: 10.1103/PhysRev.70.954
13
14 Also note the errata: Phys. Rev. 72 257 (1947) doi: 10.1103/PhysRev.72.257
15
16 This script can obtain a much higher degree of accuracy than the
17 original paper (simply by going to many more terms). Using the option
18 -c 350 appears to converge the energy constants to approximately 1
19 part in 10^9 (but takes a long time).
20
21 Usage: fieldValues
22
23 Options:
24
25 -h, --help show this help
26 -c use the specified cutoff in inverse space
27
28 Example:
29 fieldValues -c 100
30 """
31
32 __author__ = "Dan Gezelter (gezelter@nd.edu) and Kathie Newman (newman@nd.edu)"
33 __version__ = "$Rev: 1917 $"
34 __date__ = "$LastChangedDate: 2013-07-31 08:58:35 -0400 (Wed, 31 Jul 2013) $"
35 __copyright__ = "Copyright (c) 2013 by the University of Notre Dame"
36 __license__ = "OpenMD"
37
38 import sys
39 import getopt
40 import string
41 import math as m
42
43 def usage():
44 print(__doc__)
45
46
47 def doSums(r_c):
48
49 sum1=0 # Sz( 0, 1/2, 1/2)
50 sum2=0 # Sz(1/2, 0, 0)
51 sum3=0 # Sz( 0, 1/4, 1/4)
52 sum4=0 # Sy(1/4, 1/4, 1/4)
53 sum5=0 # Sy( 0, 1/4, 1/4)
54 sum6=0 # Sy(1/2, 1/4, 1/4)
55
56 x = -r_c-1
57
58 while x <= r_c:
59 x = x + 1
60 dx = x
61 dx2 = 1/2 - x
62 dx4 = 1/4 - x
63
64 y = -r_c-1
65 while y <= r_c:
66 y = y + 1
67 dy = y
68 dy2 = 1/2 - y
69 dy4 = 1/4 - y
70
71 z = -r_c-1
72 while z <= r_c:
73 z = z + 1
74 dz = z
75 dz2 = 1/2 - z
76 dz4 = 1/4 - z
77
78 r = m.sqrt( dx*dx + dy*dy + dz*dz)
79 r1 =m.sqrt( dx*dx + dy2*dy2 + dz2*dz2)
80 r2 =m.sqrt( dx2*dx2 + dy*dy + dz*dz)
81 r3 =m.sqrt( dx*dx + dy4*dy4 + dz4*dz4)
82 r4 =m.sqrt( dx4*dx4 + dy4*dy4 + dz4*dz4)
83 r5 =r3
84 r6 =m.sqrt( dx2*dx2 + dy4*dy4 + dz4*dz4)
85
86 if r <= r_c:
87 r15 = pow(r1,5)
88 r25 = pow(r2,5)
89 r35 = pow(r3,5)
90 r45 = pow(r4,5)
91 r55 = pow(r5,5)
92 r65 = pow(r6,5)
93
94 term1 = (2 * dz2 * dz2 - dx*dx - dy2*dy2)/r15
95 term2 = (2 * dz*dz - dx2*dx2 - dy*dy)/r25
96 term3 = (2 * dz4*dz4 - dx*dx - dy4*dy4)/r35
97 term4 = 3 * dy4 * dz4 / r45
98 term5 = 3 * dy4 * dz4 / r55
99 term6 = 3 * dy4 * dz4 / r65
100
101 sum1 += term1
102 sum2 += term2
103 sum3 += term3
104 sum4 += term4
105 sum5 += term5
106 sum6 += term6
107
108 f2 = -(sum1 - sum2) / 2
109 f3 = -(sum1 - sum2) / 4
110 f4 = -(sum1 - sum2) / 4
111 f5 = -(sum1 + sum2) / 2
112 f6 = (sum1 + sum2) / 4
113 f7 = (sum1 + sum2) / 4
114 g = sum4
115 h1 = sum1
116 h2 = sum3 - sum1
117 h3 = (sum5+sum6)/2
118 h4 = (sum5-sum6)/2
119
120 print ("Raw Sums:")
121 print ("Sz( 0, 1/2, 1/2) = ", sum1)
122 print ("Sz(1/2, 0, 0) = ", sum2)
123 print ("Sz( 0, 1/4, 1/4) = ", sum3)
124 print ("Sy(1/4, 1/4, 1/4) = ", sum4)
125 print ("Sy( 0, 1/4, 1/4) = ", sum5)
126 print ("Sy(1/2, 1/4, 1/4) = ", sum6)
127 print ("")
128 print ("Field Values:")
129 print ("f2 = ", f2)
130 print ("f3 = ", f3)
131 print ("f4 = ", f4)
132 print ("f5 = ", f5)
133 print ("f6 = ", f6)
134 print ("f7 = ", f7)
135 print (" g = ", g)
136 print ("h1 = ", h1)
137 print ("h2 = ", h2)
138 print ("h3 = ", h3)
139 print ("h4 = ", h4)
140 print ("")
141 print ("Energy Constants for selected lattices:")
142 print ("A_sc_001 :", -f5 / 2 )
143 print ("A_bcc_001 :", 0 )
144 print ("A_bcc_111 :", -g / 6 )
145 print ("A_bcc_min :", -(g+f6) / 4)
146 print ("A_fcc_001 :", h1 / 2)
147 print ("A_fcc_011 :", -h1 / 4)
148 print ("B_sc_001 :", -f5 / 2)
149 print ("B_bcc_001 :", -f5 / 4)
150 print ("B_bcc_111 :", -g / 6 )
151 print ("B_fcc_001 :", -h1 / 4)
152 print ("B_fcc_011 :", -h4 / 8)
153
154
155 def main(argv):
156
157 r_c = 100
158 try:
159 opts, args = getopt.getopt(argv, "hc:", ["help","r_c="])
160 except getopt.GetoptError:
161 usage()
162 sys.exit(2)
163 for opt, arg in opts:
164 if opt in ("-h", "--help"):
165 usage()
166 sys.exit()
167 elif opt in ("-c", "--r_c"):
168 r_c = int(arg)
169
170 doSums(r_c)
171
172 if __name__ == "__main__":
173 if len(sys.argv) == 1:
174 usage()
175 sys.exit()
176 main(sys.argv[1:])
177

Properties

Name Value
svn:executable *