-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation_performance_t_dep.py
executable file
·169 lines (106 loc) · 3.77 KB
/
simulation_performance_t_dep.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
'''
NOTE:
- è molto meglio se creo A e B prima
- il plot rallenta di brutto
'''
from syslog import LOG_LPR
import numpy as np
import matplotlib.pyplot as plt
import scipy.constants as cost
import sys
import os
from tkinter import *
from tkinter import ttk
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
import time
import threading
from numba import jit
#sys.path.insert(0, '/home/falzo/Scrivania/Sol_eqS')
import DFT
import time_evolution as __
try:
PATH = str(sys.argv[1])
print('check: ',PATH)
sys.path.insert(0, PATH)
from Par import *
except:
print('There are not arguments: picking Default Par')
from Parameters import *
PATH = os.getcwd()
print(PATH)
print('Level = ', Level)
ENDED = False
if STOP_BOUNDARIES:
debug_norma = False
debug_E = False
dx = (x[1] - x[0])
dp = p[1] - p[0]
ll = len(x)
if len(x) != len(p):
print('Error: len(x) != len(p)')
exit()
from numba import jit
#//////////////
#/ Simulation /
#//////////////
#Calcolo delle matrici
ff = DFT.f_matrix(x, p, h, ll, ll, np.ndarray((ll, ll), dtype=complex))
iff = DFT.if_matrix(x, p, h, ll, ll , np.ndarray((ll, ll), dtype=complex))
#stato iniziale
print('ψ >>> ', ψ_name)
if ψ_name == ψ_list[0]: Ψ = DFT.wave_pack(x, x0, p0, σ0, N, L, h)
elif ψ_name == ψ_list[1]: Ψ = DFT.arm_ES(x, x0, n, m, ω, h)
elif ψ_name == ψ_list[2]: Ψ, norm_factor = DFT.RL_wp(x, x0, x_V_centered, p0, σ0, h, m, α, N, norm_factor = 0)
elif ψ_name == ψ_list[3]: Ψ, coefficients = DFT.coherent(5, 0, x, x0, m, ω, h, np.zeros(N, dtype = complex))
elif ψ_name == ψ_list[4]:
o = np.load(PATH + '/custom.npz')
Ψ = o['Ψ']
if len(Ψ) != len(x):
print('Error len(Ψ) != len(x)')
f = open('abort.log', 'w')
f.write('Simulation aborted')
f.close()
exit()
if debug_norma: cont, norm = DFT.check_norma(DFT.norma(Ψ, np.zeros(ll, dtype = complex), ll , dx), cont, norm, STD_NORMA)
V = np.zeros(len(x), dtype = complex)
for i in range(len(V)):
if Potential == Potential_list[1]: V[i] = __.step(x[i], step_x, V0)
elif Potential == Potential_list[2]: V[i] = __.barrier(x[i], barrier_width, V0, x_V_centered)
elif Potential == Potential_list[3]: V[i] = __.buca(x[i], barrier_width, V0, x_V_centered)
elif Potential == Potential_list[4]: V[i] = __.tunnel(x[i], x_V_centered, V0)
elif Potential == Potential_list[5]: V[i] = __.arm_osc(x[i], x_V_centered, a)
elif Potential == Potential_list[6]: V[i] = __.RL(x[i], RF_l, x_V_centered, h, m, α)
dic = {}
if Potential == Potential_list[7]:
print("import " + lib + "\ndef F(x, t): return " + V_function)
exec("import " + lib + "\ndef F(x, t): return " + V_function, dic)
for i in range(len(V)): V[i] = dic['F'](x[i] , 0)
E, T, U = __.H_mean(x, p, Ψ, dx, dp, m, V, h, P_MAX, N, L, ll, np.ndarray((ll, ll), dtype=complex), np.zeros(ll, dtype = complex), np.zeros(ll, dtype = complex))
print('E =', E)
if STOP_BOUNDARIES:
V[x < 0.1*L] = -1j * ST_BD_COEFF
V[x > 0.9*L] = -1j * ST_BD_COEFF
#print(V)
OUT, V_Max = __.V_out_of_range(V, V_MAX)
print('V_Max = ', V_Max)
np.savez(PATH +'/0', x = x, V = V, Ψ = Ψ )
t = 1
i = 1
start_time = time.time()
while i < FRAME:
try:
for k in range(len(V)): V[k] = dic['F'](x[k], (i*dt))
if STOP_BOUNDARIES:
V[x < 0.1*L] = -1j * ST_BD_COEFF
V[x > 0.9*L] = -1j * ST_BD_COEFF
except:
if i == 1: print('V in not time dependent')
Ψ_n = __.evolution_t_dependent(Level, Ψ, x, p, dt, V, m, ff, iff, N, L, h, P_MAX, ll, np.zeros(ll, dtype = complex))
np.savez( str(PATH) + '/' + str(i), Ψ = Ψ, V = V )
Ψ = Ψ_n
if debug_norma: cont, norm = DFT.check_norma(DFT.norma(Ψ, np.zeros(ll, dtype = complex), ll , dx), cont, norm, STD_NORMA)
print(i, '/'+str(FRAME) , end = '\r')
t+=dt
i+=1
print('TIME = ' , time.time() - start_time)