-
Notifications
You must be signed in to change notification settings - Fork 0
/
effective_potential.py
113 lines (47 loc) · 2.18 KB
/
effective_potential.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
import Numerov as nu
import numpy as np
from tqdm import tqdm
f=open("results/effective.txt","a")
value =-1.2
radius=2
#value of c and d to be found
a = [0.1]
#function to compute the sum of relative errors
def error_sum(data,energy):
error=0
for datas, energies in zip(data, energy):
error+=(datas-energies)**2
return error
#initialize data array
data = [-1.568949087013607, -0.19602247419243213, -0.07505287685489748, -0.039067748657544143, -0.023876894192653708,
-0.016084664603113197, -0.011565622189664282, -0.008714093928574584, -0.006800400515203364, -0.0054541801364393905]
effective_data = []
for a in a:
f.write(f"For a={a}\n\n")
effective_data=[]
errors=[]
difference_low_energy = []
values=[]
for c in tqdm(range(-11050,-11008)):
c=c/100.
for d in range(-2400,-2300):
d=d/100
values.append([c,d])
for n in range(1,11):
grid, step = nu.spatial_objects.uniform_grid(0,n*50,10**4,retstep=True)
potential=nu.potentials.effective_potential(grid,a,c,d)#writing down the full effective potential at order a**4
energy_effective = nu.Numerov_algorithm.fast_radial_numerov(grid,step,1,n,-100,0,potential,accuracy=10**-10,dy=10**-150)[0]
effective_data.append(energy_effective)
errors.append(error_sum(data,effective_data)) #compute error for fit
effective_data=[]
pos=np.argmin(errors)
c, d= values[pos]
for n in range(1,11):
grid, step = nu.spatial_objects.uniform_grid(0,n*50,10**5,retstep=True)
potential=nu.potentials.effective_potential(grid,a,c,d)
energy_effective = nu.Numerov_algorithm.fast_radial_numerov(grid,step,1,n,-100,0,potential,accuracy=10**-10,dy=10**-150)[0]
effective_data.append(energy_effective)
f.write(f"Minimixe square error gives c= {c} and d={d}\n")
f.write(f"Our approximation gives energies {effective_data}\n\n")
f.write(f"Error sum {error_sum(data,effective_data)}\n\n")
f.close()