-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathThomson.py
597 lines (439 loc) · 32.3 KB
/
Thomson.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
import customtkinter
import tkinter
from tkinter import *
from numpy import pi
from math import sqrt
from numpy import random
import numpy as np
from tkinter.filedialog import asksaveasfile
import os , sys
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("green") # Themes: "blue" (standard), "green", "dark-blue"
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("1400x700")
self.title("Thomson Input generator")
self.minsize(1400, 700)
self.textbox = customtkinter.CTkTextbox(master=self , width = 500)
self.textbox.grid(row=0, column=2, padx=20, pady=(40, 20) , sticky="ns")
self.textbox.configure(state='disabled')
self.tabview=customtkinter.CTkTabview(master=self)
self.tabview.grid(row=0,column=0,padx=20, columnspan=2 , pady=(20,20), sticky="ns")
left = self.tabview.add("Custom")
right = self.tabview.add("Preload")
self.tabview.set("Custom")
self.continer1 = customtkinter.CTkFrame(master=left)
self.continer1.grid(row = 0 , column=0, padx=20, columnspan=2 , pady=(20,20), sticky="ns")
self.continer3 = customtkinter.CTkFrame(master=right)
self.continer3.grid(row = 0 , column=0, padx=20, columnspan=2 , pady=(20,20), sticky="ns")
#################################### tab one ######################################################
self.label_Di = customtkinter.CTkLabel(master=self.continer1 , text="Dimension :" )
self.label_Di.grid(row=0 ,column=0, padx=10, pady=5 ,sticky="nsew" )
self.combobox = customtkinter.CTkComboBox(master=self.continer1, values=["1", "2" , "3"])
self.combobox.grid(row=0, column=1, padx=50, pady=5 , sticky="w" )
self.combobox.configure(width = 100 , justify = "center" )
self.combobox.set("3")
self.label_Di = customtkinter.CTkLabel(master=self.continer1 , text=" Number of electrons :" )
self.label_Di.grid(row=1 ,column=0, padx=10, pady=5, sticky="nsew" )
self.electron_N = customtkinter.CTkTextbox(master=self.continer1)
self.electron_N.grid(row=1 , column=1 , padx=10, pady=5)
self.electron_N.configure(width = 60, height = 20 )
self.electron_N.insert("0.0", "10")
self.label_tolerance = customtkinter.CTkLabel(master=self.continer1 , text=" Tolerance :" )
self.label_tolerance.grid(row=2 ,column=0, padx=10, pady=5, sticky="nsew" )
self.tolerance_N = customtkinter.CTkTextbox(master=self.continer1)
self.tolerance_N.grid(row=2 , column=1 , padx=10, pady=5)
self.tolerance_N.configure(width = 60, height = 20 )
self.tolerance_N.insert("0.0", "1e-8")
self.label_itermax = customtkinter.CTkLabel(master=self.continer1 , text=" Max. number of iteration :" )
self.label_itermax.grid(row=3 ,column=0, padx=10, pady=5, sticky="nsew" )
self.itermax_N = customtkinter.CTkTextbox(master=self.continer1)
self.itermax_N.grid(row=3 , column=1 , padx=10, pady=5)
self.itermax_N.configure(width = 60, height = 20 )
self.itermax_N.insert("0.0", "10000")
############################### the size of the box #################################
self.continer2 = customtkinter.CTkFrame(master=self.continer1)
self.continer2.grid(row = 4 , column=0 ,columnspan=2 , padx=(20,20), pady=(20,20), sticky="we")
self.label_size = customtkinter.CTkLabel(master=self.continer2 , text=" The Box Size" )
self.label_size.grid(row=0 ,column=0, padx=(10,10), pady=5 )
self.label_Lx = customtkinter.CTkLabel(master=self.continer2 , text=" Lx" )
self.label_Lx.grid(row=1 ,column=0, padx=(10,10), pady=5 )
self.Lx = customtkinter.CTkTextbox(master=self.continer2)
self.Lx.grid(row=1 ,column=1, padx=10, pady=5)
self.Lx.configure(width = 150, height = 20 )
self.Lx.insert("0.0", 2*pi)
self.label_Ly = customtkinter.CTkLabel(master=self.continer2 , text=" Ly" )
self.label_Ly.grid(row=2 ,column=0, padx=(10,10), pady=5 )
self.Ly = customtkinter.CTkTextbox(master=self.continer2)
self.Ly.grid(row=2 ,column=1, padx=10, pady=5)
self.Ly.configure(width = 150, height = 20 )
self.Ly.insert("0.0", 2*pi)
self.label_Lz = customtkinter.CTkLabel(master=self.continer2 , text=" Lz" )
self.label_Lz.grid(row=3 ,column=0, padx=(10,10), pady=5 )
self.Lz = customtkinter.CTkTextbox(master=self.continer2)
self.Lz.grid(row=3 ,column=1, padx=10, pady=(5,20))
self.Lz.configure(width = 150, height = 20 )
self.Lz.insert("0.0", 2*pi)
##########################################################################################
###################################### check box #########################################
self.checkbox_R = customtkinter.CTkCheckBox(master=self.continer1, text="Random Geometry", onvalue="random", offvalue="")
self.checkbox_R.grid(row=5 ,column=1, padx=10, pady=(0,10) , sticky="w" )
self.checkbox_A = customtkinter.CTkCheckBox(master=self.continer1, text="Animation", onvalue="animation", offvalue="")
self.checkbox_A.grid(row=5 ,column=0, padx=10, pady=(0,10) , sticky="w" )
self.checkbox_H = customtkinter.CTkCheckBox(master=self.continer1, text="Show Hessian Matrix", onvalue="hessian", offvalue="")
self.checkbox_H.grid(row=6 ,column=0, padx=10, pady=10 , sticky="w" )
self.checkbox_S = customtkinter.CTkCheckBox(master=self.continer1, text="Show All Result", onvalue="show", offvalue="")
self.checkbox_S.grid(row=7 ,column=0, padx=10, pady=10 , sticky="w" )
self.checkbox_M = customtkinter.CTkCheckBox(master=self.continer1, text="Multiply by the Box size", onvalue="multiply", offvalue="")
self.checkbox_M.grid(row=6 ,column=1,columnspan=3, padx=10, pady=10 , sticky="w" )
self.checkbox_D = customtkinter.CTkCheckBox(master=self.continer1, text="Show distance matrix", onvalue="distance", offvalue="")
self.checkbox_D.grid(row=7 ,column=1,columnspan=3, padx=10, pady=10 , sticky="w" )
self.checkbox_FD = customtkinter.CTkCheckBox(master=self.continer1, text="Fixed density", onvalue="density", offvalue="")
self.checkbox_FD.grid(row=0 ,column=2,columnspan=3, padx=20, pady=10 , sticky="w" )
self.label_FDT = customtkinter.CTkLabel(master=self.continer1 , text="one electron per unit of length \n(Ignore the box size)" )
self.label_FDT.grid(row=0 ,column=3, padx=20, pady=10, sticky="nsew" )
############################################################################################
self.button_write = customtkinter.CTkButton(master=self.continer1, command=self.button_write_callback, text="Write")
self.button_write.grid(row=1, column=2 , padx=20, pady=(20,20), sticky="nsew")
self.button_clear = customtkinter.CTkButton(master=self.continer1, command=self.button_clear_callback, text="Clear")
self.button_clear.grid(row=1, column=3 , padx=20, pady=(20,20), sticky="nsew")
self.button_save = customtkinter.CTkButton(master=self.continer1, command=self.button_save_callback, text="Save")
self.button_save.grid(row=2, column=2, columnspan=3 , padx=20, pady=(0,20), sticky="nsew")
self.button_run = customtkinter.CTkButton(master=self.continer1, command=self.button_run_callback, text="Run")
self.button_run.grid(row=3, column=2, columnspan=3 , padx=20, pady=(0,20), sticky="nsew")
self.tabview=customtkinter.CTkTabview(master=self)
################################################ tab two ##################################
self.label_CS = customtkinter.CTkLabel(master=self.continer3 , text="Crystal Structure " )
self.label_CS.grid(row=0 ,column=0, padx=10, pady=5 ,sticky="nsew" )
self.combobox_CS = customtkinter.CTkComboBox(master=self.continer3, values=["FCC (3D)", "BCC (3D)" , "SC (3D)" ,"HEX (2D)" , "SL (2D)" , "ED (1D)"])
self.combobox_CS.grid(row=0, column=1, padx=50, pady=5 , sticky="w" )
self.combobox_CS.configure(width = 100 , justify = "center" )
self.combobox_CS.set("FCC (3D)")
self.label_CS_EN = customtkinter.CTkLabel(master=self.continer3 , text="Unit-cell per dimension" )
self.label_CS_EN.grid(row=1 ,column=0, padx=10, pady=5 ,sticky="nsew" )
self.electron_N_EN = customtkinter.CTkTextbox(master=self.continer3)
self.electron_N_EN.grid(row=1 , column=1 , padx=10, pady=5)
self.electron_N_EN.configure(width = 60, height = 20 )
self.electron_N_EN.insert("0.0", "1")
self.label_tolerance_EN = customtkinter.CTkLabel(master=self.continer3 , text=" Tolerance :" )
self.label_tolerance_EN.grid(row=2 ,column=0, padx=10, pady=5, sticky="nsew" )
self.tolerance_N_EN = customtkinter.CTkTextbox(master=self.continer3)
self.tolerance_N_EN.grid(row=2 , column=1 , padx=10, pady=5)
self.tolerance_N_EN.configure(width = 60, height = 20 )
self.tolerance_N_EN.insert("0.0", "1e-8")
self.label_itermax_EN = customtkinter.CTkLabel(master=self.continer3 , text=" Max. number of iteration :" )
self.label_itermax_EN.grid(row=3 ,column=0, padx=10, pady=5, sticky="nsew" )
self.itermax_N_EN = customtkinter.CTkTextbox(master=self.continer3)
self.itermax_N_EN.grid(row=3 , column=1 , padx=10, pady=5)
self.itermax_N_EN.configure(width = 60, height = 20 )
self.itermax_N_EN.insert("0.0", "10000")
self.continer4 = customtkinter.CTkFrame(master=self.continer3)
self.continer4.grid(row = 4 , column=0 ,columnspan=2 , padx=(20,20), pady=(20,20), sticky="we")
self.label_size = customtkinter.CTkLabel(master=self.continer4 , text=" The Box Size" )
self.label_size.grid(row=0 ,column=0, padx=(10,10), pady=5 )
self.label_Lx_EN = customtkinter.CTkLabel(master=self.continer4 , text=" Lx" )
self.label_Lx_EN.grid(row=1 ,column=0, padx=(10,10), pady=5 )
self.Lx_EN = customtkinter.CTkTextbox(master=self.continer4)
self.Lx_EN.grid(row=1 ,column=1, padx=10, pady=5)
self.Lx_EN.configure(width = 150, height = 20 )
self.Lx_EN.insert("0.0", 2*pi)
self.label_Ly_EN = customtkinter.CTkLabel(master=self.continer4 , text=" Ly" )
self.label_Ly_EN.grid(row=2 ,column=0, padx=(10,10), pady=5 )
self.Ly_EN = customtkinter.CTkTextbox(master=self.continer4)
self.Ly_EN.grid(row=2 ,column=1, padx=10, pady=5)
self.Ly_EN.configure(width = 150, height = 20 )
self.Ly_EN.insert("0.0", 2*pi)
self.label_Lz_EN = customtkinter.CTkLabel(master=self.continer4 , text=" Lz" )
self.label_Lz_EN.grid(row=3 ,column=0, padx=(10,10), pady=5 )
self.Lz_EN = customtkinter.CTkTextbox(master=self.continer4)
self.Lz_EN.grid(row=3 ,column=1, padx=10, pady=(5,20))
self.Lz_EN.configure(width = 150, height = 20 )
self.Lz_EN.insert("0.0", 2*pi)
self.checkbox_A_EN = customtkinter.CTkCheckBox(master=self.continer3, text="Animation", onvalue="animation", offvalue="")
self.checkbox_A_EN.grid(row=5 ,column=0, padx=10, pady=(0,10) , sticky="w" )
self.checkbox_H_EN = customtkinter.CTkCheckBox(master=self.continer3, text="Show Hessian Matrix", onvalue="hessian", offvalue="")
self.checkbox_H_EN.grid(row=6 ,column=0, padx=10, pady=10 , sticky="w" )
self.checkbox_D_EN = customtkinter.CTkCheckBox(master=self.continer3, text="Show distance Matrix", onvalue="distance", offvalue="")
self.checkbox_D_EN.grid(row=6 ,column=1, padx=10, pady=10 , sticky="w" )
self.checkbox_S_EN = customtkinter.CTkCheckBox(master=self.continer3, text="Show All Result", onvalue="show", offvalue="")
self.checkbox_S_EN.grid(row=7 ,column=0, padx=10, pady=10 , sticky="w" )
self.checkbox_FD_EN = customtkinter.CTkCheckBox(master=self.continer3, text="Fixed density", onvalue="density", offvalue="")
self.checkbox_FD_EN.grid(row=0 ,column=2,columnspan=3, padx=20, pady=10 , sticky="w" )
self.label_FDT_EN = customtkinter.CTkLabel(master=self.continer3 , text="one electron per unit of length \n(Ignore the box size)" )
self.label_FDT_EN.grid(row=0 ,column=3, padx=20, pady=10, sticky="nsew" )
self.button_write_EN = customtkinter.CTkButton(master=self.continer3, command=self.button_write_EN_callback, text="Write")
self.button_write_EN.grid(row=1, column=2 , padx=20, pady=(20,20), sticky="nsew")
self.button_clear_EN = customtkinter.CTkButton(master=self.continer3, command=self.button_clear_EN_callback, text="Clear")
self.button_clear_EN.grid(row=1, column=3 , padx=20, pady=(20,20), sticky="nsew")
self.button_save_EN = customtkinter.CTkButton(master=self.continer3, command=self.button_save_EN_callback, text="Save")
self.button_save_EN.grid(row=2, column=2, columnspan=3 , padx=20, pady=(0,20), sticky="nsew")
self.button_run_EN = customtkinter.CTkButton(master=self.continer3, command=self.button_run_EN_callback, text="Run")
self.button_run_EN.grid(row=3, column=2, columnspan=3 , padx=20, pady=(0,20), sticky="nsew")
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
###########################################################################################
###################### functions ########################
def button_write_callback(self):
self.textbox.configure(state='normal')
self.textbox.insert("insert",self.combobox.get() +"\t"+"# Dimension" + "\n")
self.textbox.insert("insert",self.electron_N.get("0.0", "end-1c") +"\t"+"# Number of electron" + "\n" )
self.textbox.insert("insert",self.tolerance_N.get("0.0", "end-1c") +"\t"+"# The tolerance" + "\n" )
self.textbox.insert("insert",self.itermax_N.get("0.0", "end-1c") +"\t"+"# The maximum number of iteration" + "\n")
self.textbox.insert("insert","box: " + self.Lx.get("0.0", "end-1c") +" "+ self.Ly.get("0.0", "end-1c") +" "+ self.Lz.get("0.0", "end"))
if self.checkbox_FD.get() == "density":
self.textbox.insert("insert", self.checkbox_FD.get() + "\n") # type: ignore
if self.checkbox_R.get() == "random":
self.textbox.insert("insert", self.checkbox_R.get() + "\n") # type: ignore
if self.checkbox_M.get() == "multiply":
self.textbox.insert("insert", self.checkbox_M.get() + "\n") # type: ignore
if self.checkbox_S.get() == "show":
self.textbox.insert("insert", self.checkbox_S.get() + "\n") # type: ignore
if self.checkbox_A.get() == "animation":
self.textbox.insert("insert", self.checkbox_A.get() + "\n") # type: ignore
if self.checkbox_H.get() == "hessian":
self.textbox.insert("insert", self.checkbox_H.get() + "\n") # type: ignore
if self.checkbox_D.get() == "distance":
self.textbox.insert("insert", self.checkbox_D.get() + "\n") # type: ignore
if self.checkbox_R.get() == "random":
self.textbox.insert("insert","geometry" + "\n")
x = random.rand(int(self.electron_N.get("0.0", "end-1c")))
y = random.rand(int(self.electron_N.get("0.0", "end-1c")))
z = random.rand(int(self.electron_N.get("0.0", "end-1c")))
if str(self.combobox.get()) == "3":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + " " + str(y[i]).replace('[',' ').replace(']',' ') + " " + str(z[i]).replace('[',' ').replace(']',' ') + "\n") # type: ignore
elif str(self.combobox.get()) == "2":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + " " + str(y[i]).replace('[',' ').replace(']',' ') + "\n") # type: ignore
elif str(self.combobox.get()) == "1":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + "\n") # type: ignore
else:
self.textbox.insert("insert","# Change the geometry as you want" + "\n")
self.textbox.insert("insert","geometry" + "\n")
x = np.zeros(int(self.electron_N.get("0.0", "end-1c")))
y = np.zeros(int(self.electron_N.get("0.0", "end-1c")))
z = np.zeros(int(self.electron_N.get("0.0", "end-1c")))
if str(self.combobox.get()) == "3":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + " " + str(y[i]).replace('[',' ').replace(']',' ') + " " + str(z[i]).replace('[',' ').replace(']',' ') + "\n")
elif str(self.combobox.get()) == "2":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + " " + str(y[i]).replace('[',' ').replace(']',' ') + "\n")
elif str(self.combobox.get()) == "1":
for i in range(int(self.electron_N.get("0.0", "end-1c"))):
self.textbox.insert("insert", " " + str(i+1) + " " + str(x[i]).replace('[',' ').replace(']',' ') + "\n")
self.textbox.insert("insert", "\n")
self.textbox.insert("insert", "______________________________________________________" + "\n")
self.textbox.insert("insert", "\n")
self.textbox.configure(state='disabled')
def button_write_EN_callback(self):
self.textbox.configure(state='normal')
if self.combobox_CS.get() == "FCC (3D)" or self.combobox_CS.get() == "BCC (3D)" or self.combobox_CS.get() == "SC (3D)":
self.textbox.insert("insert","3" +"\t"+"# Dimension" + "\n")
elif self.combobox_CS.get() == "SL (2D)" or self.combobox_CS.get() == "HEX (2D)":
self.textbox.insert("insert","2" +"\t"+"# Dimension" + "\n")
elif self.combobox_CS.get() == "ED (1D)":
self.textbox.insert("insert","1" +"\t"+"# Dimension" + "\n")
if self.combobox_CS.get() == "FCC (3D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", 2*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=4*int(self.electron_N_EN.get("0.0", "end"))**3
elif self.combobox_CS.get() == "BCC (3D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", 2*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=2*int(self.electron_N_EN.get("0.0", "end"))**3
elif self.combobox_CS.get() == "SC (3D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", 2*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=int(self.electron_N_EN.get("0.0", "end"))**3
elif self.combobox_CS.get() == "HEX (2D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", sqrt(3)*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=4*int(self.electron_N_EN.get("0.0", "end"))**2
elif self.combobox_CS.get() == "SL (2D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", 2*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=int(self.electron_N_EN.get("0.0", "end"))**2
elif self.combobox_CS.get() == "ED (1D)":
self.Lx_EN.configure(state='normal')
self.Ly_EN.configure(state='normal')
self.Lz_EN.configure(state='normal')
self.Ly_EN.delete("0.0","end")
self.Ly_EN.insert("0.0", 2*pi)
self.Lx_EN.configure(state='disabled')
self.Ly_EN.configure(state='disabled')
self.Lz_EN.configure(state='disabled')
x=int(self.electron_N_EN.get("0.0", "end"))
self.textbox.insert("insert",str(x) +"\t"+"# Number of electron" + "\n")
self.textbox.insert("insert",self.tolerance_N_EN.get("0.0", "end-1c") +"\t"+"# The tolerance" + "\n")
self.textbox.insert("insert",self.itermax_N_EN.get("0.0", "end-1c") +"\t"+"# The maximum number of iteration" + "\n")
self.textbox.insert("insert","box: " + self.Lx_EN.get("0.0", "end-1c") +" "+ self.Ly_EN.get("0.0", "end-1c") +" "+ self.Lz_EN.get("0.0", "end"))
if self.checkbox_FD_EN.get() == "density":
if self.combobox_CS.get() == "HEX (2D)":
self.textbox.insert("insert", self.checkbox_FD_EN.get() +" rectangle"+ "\n") # type: ignore
else:
self.textbox.insert("insert", self.checkbox_FD_EN.get() + "\n") # type: ignore
if self.checkbox_S_EN.get() == "show":
self.textbox.insert("insert", self.checkbox_S_EN.get() + "\n") # type: ignore
if self.checkbox_A_EN.get() == "animation":
self.textbox.insert("insert", self.checkbox_A_EN.get() + "\n") # type: ignore
if self.checkbox_H_EN.get() == "hessian":
self.textbox.insert("insert", self.checkbox_H_EN.get() + "\n") # type: ignore
if self.checkbox_D_EN.get() == "distance":
self.textbox.insert("insert", self.checkbox_D_EN.get() + "\n") # type: ignore
if self.combobox_CS.get() == "FCC (3D)":
d1 = 1/int(self.electron_N_EN.get("0.0", "end"))
d2 = d1/2
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i,18)) + "\t \t" + str(round(d1*j,18)) + "\t \t" + str(round(d1*k,18)) + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i+d2,18)) + "\t \t" + str(round(d1*j+d2,18)) + "\t \t" + str(round(d1*k,18)) + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i,18)) + "\t \t" + str(round(d1*j+d2,18)) + "\t \t" + str(round(d1*k+d2,18)) + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i+d2,18)) + "\t \t" + str(round(d1*j,18)) + "\t \t" + str(round(d1*k+d2,18)) + "\n")
if self.combobox_CS.get() == "BCC (3D)":
d1 = 1/int(self.electron_N_EN.get("0.0", "end"))
d2 = d1/2
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i,18)) + "\t \t" + str(round(d1*j,18)) + "\t \t" + str(round(d1*k,18)) + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i+d2,18)) + "\t \t" + str(round(d1*j+d2,18)) + "\t \t" + str(round(d1*k+d2,18)) + "\n")
if self.combobox_CS.get() == "SC (3D)":
d1 = 1/int(self.electron_N_EN.get("0.0", "end"))
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for k in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i,18)) + "\t \t" + str(round(d1*j,18)) + "\t \t" + str(round(d1*k,18)) + "\n")
if self.combobox_CS.get() == "SL (2D)":
d1 = 1/int(self.electron_N_EN.get("0.0", "end"))
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for i in range(int(self.electron_N_EN.get("0.0", "end"))):
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(d1*i,20)) + "\t \t \t" + str(round(d1*j,20)) + "\t" + "\n")
if self.combobox_CS.get() == "HEX (2D)":
dx = pi/int(self.electron_N_EN.get("0.0", "end"))
dy = dx*sqrt(3)/2
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for j in range(int(self.electron_N_EN.get("0.0", "end"))):
for i in range(2*int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(dx*i/(2*pi),20)) + "\t \t \t" + str(round(2*dy*j/(sqrt(3)*pi),20)) + "\t" + "\n")
for i in range(2*int(self.electron_N_EN.get("0.0", "end"))):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round((dx*(i+0.5)/(2*pi)),20)) + "\t \t \t" + str(round(((2*j+1)*dy/(sqrt(3)*pi)),20)) + "\t" + "\n")
if self.combobox_CS.get() == "ED (1D)":
dx = 1/int(self.electron_N_EN.get("0.0", "end"))
icount = 0
self.textbox.insert("insert", "multiply" + "\n") # type: ignore
self.textbox.insert("insert","geometry" + "\n")
for i in range(1,int(self.electron_N_EN.get("0.0", "end"))+1):
icount += 1
self.textbox.insert("insert", str(icount) + "\t" + str(round(dx*i,20))+ "\n")
self.textbox.insert("insert", "\n")
self.textbox.insert("insert", "______________________________________________________" + "\n")
self.textbox.insert("insert", "\n")
self.textbox.configure(state='disabled')
def button_clear_callback(self):
self.textbox.configure(state='normal')
self.textbox.delete("0.0","end")
self.textbox.configure(state='disabled')
def button_clear_EN_callback(self):
self.textbox.configure(state='normal')
self.textbox.delete("0.0","end")
self.textbox.configure(state='disabled')
def button_save_callback(self):
self.dialog = customtkinter.CTkInputDialog(text="Type The name without extension:", title="Input file save")
file = open(str(self.dialog.get_input()) + ".inp", "w")
file.write(self.textbox.get("0.0","end-1c"))
file.close()
def button_save_EN_callback(self):
self.dialog = customtkinter.CTkInputDialog(text="Type The name without extension:", title="Input file save")
file = open(str(self.dialog.get_input()) + ".inp", "w")
file.write(self.textbox.get("0.0","end-1c"))
file.close()
def button_run_callback(self):
file = open("null.inp","w")
file.write(self.textbox.get("0.0","end-1c"))
file.close()
os.system("./Thomson null.inp")
os.system("rm -rf null.inp")
os.system("echo '\n'")
os.system("echo '((Finished, you could continue for another calculation ))' ")
def button_run_EN_callback(self):
file = open("null.inp","w")
file.write(self.textbox.get("0.0","end-1c"))
file.close()
os.system("./Thomson null.inp")
os.system("rm -rf null.inp")
os.system("echo '\n'")
os.system("echo '((Finished, you could continue for another calculation ))' ")
if __name__ == "__main__":
app = App()
app.mainloop()