forked from MarcSerraPeralta/variational_QMonteCarlo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputs.py
833 lines (629 loc) · 28.1 KB
/
inputs.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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
import numpy as np
"""
LIST OF EXAMPLE OF INPUTS INCLUDED IN THIS FILE
===============================================
1) Test functions (EXAMPLE OF FUNCTIONS section)
- prob_density
- E_local_f
2) 1D Harmonic oscillator (HARMONIC OSCILLATOR section)
- E_local_Harmonic_Oscillator: H = -0.5*d^2/dx^2 + 0.5*x**2
- prob_density_Harmonic_Oscillator: psi = e**(-alpha*x**2)
3) Hydrogen atom (HYDROGEN ATOM section)
- E_local_Hydrogen_atom: H = -0.5*(d^2/dx^2 + d^2/dy^2 + d^2/dz^2) - 1/r, where r = sqrt(x**2 + y**2 + z**2)
- prob_density_Hydrogen_atom: e**(-alpha*r)
4) Helium atom (HELIUM ATOM)
- Trial wave functions: ground state, 1st excited, 2nd excited, 3rd excited and 4th excited from
"Doma, s. (2009). The Ground-State of the Helium Atom by Using Monte Carlo Variational Method."
- Hamiltonian: H = -0.5*(d^2/dx1^2 + d^2/dy1^2 + d^2/dz1^2 + d^2/dx2^2 + d^2/dy2^2 + d^2/dz2^2) - 2/r1 - 2/r2 + 1/r12
- For each of the trial wave functions: WF_Helium_atom (wavefunction), E_local_Helium_atom (local energy)
and prob_density_Helium_atom (probability density functon). The computation of the derivatives in the
local energy are done numerically except for the case of the ground state with 1 free parameter.
"""
################################
# EXAMPLE OF FUNCTIONS #
################################
def prob_density(r, alpha):
"""
Returns the value of the probability density function at the specified positions r and parameters alpha.
Parameters
----------
r : np.ndarray(N_walkers, dim)
Positions of N_walkers walkers
'dim' is the dimension of the integral space
alpha : np.ndarray(N_parameters)
Parameters of the trial wave function
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function of the different walkers at the specified r and alpha
"""
prob = np.zeros(r.shape[0])
return prob
def E_local_f(r, alpha):
"""
Returns the value of the local energy at the specified positions r and parameters alpha.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, dim)
Positions of N_walkers walkers for N_steps steps
'dim' is the dimension of the integral space
alpha : np.ndarray(N_parameters)
Parameters of the trial wave function
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy of the different walkers at the specified r and alpha
"""
E_local = np.zeros((r.shape[0],r.shape[1]))
return E_local
################################
# HARMONIC OSCILLATOR #
################################
# TRIAL WAVE FUNCTION = e**(-alpha*x**2)
def E_local_Harmonic_Oscillator(x, alpha):
"""
Returns the value of the local energy for the 1D Harmonic Oscillator
at the specified positions r and parameters alpha.
Parameters
----------
x : np.ndarray(N_steps, N_walkers, 1)
Position of N_walkers walkers for N_steps steps
alpha : np.ndarray(1) or float
Parameter of the trial wave function
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy of the different walkers at the specified x and alpha
"""
x = x.reshape(x.shape[:-1]) # x.shape = N_steps, N_walkers
E_local = alpha + (0.5 - 2*alpha**2)*x**2
return E_local
def prob_density_Harmonic_Oscillator(x, alpha):
"""
Returns the value of the probability density function for the 1D Harmonic Oscillator
at the specified positions x and parameters alpha.
Parameters
----------
x : np.ndarray(N_walkers, 1)
Position of N_walkers walkers
alpha : np.ndarray(1) or float
Parameter of the trial wave function
Returns
-------
prob : np.ndarray(N_walkers)
Probability density of the different walkers function at the specified x and alpha
"""
x = x.reshape(x.shape[:-1]) # x.shape = N_walkers
prob = np.exp(-2*alpha*x**2)
return prob
################################
# HYDROGEN ATOM #
################################
# TRIAL WAVE FUNCTION = e**(-alpha*r) where r = sqrt(x**2 + y**2 + z**2)
def E_local_Hydrogen_atom(r, alpha):
"""
Returns the value of the local energy for the Hydrogen atom
at the specified positions r and parameter alpha.
Parameters
----------
r : np.ndarray(Nsteps, N_walkers, 3)
Position in 3D of N_walkers walkers (r = (x,y,z)) for N_steps steps
alpha : np.ndarray(1) or float
Parameter of the trial wave function
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy of the different walkers at the specified r and alpha
"""
r = np.linalg.norm(r, axis=-1)
E_local = -0.5*(alpha**2 - 2*alpha/r) - 1/r
return E_local
def prob_density_Hydrogen_atom(r, alpha):
"""
Returns the value of the probability density function for the Hydrogen atom
at the specified positions r and parameter alpha.
Parameters
----------
r : np.ndarray(N_walkers, 3)
Position in 3D of N_walkers walkers (r = (x,y,z))
alpha : np.ndarray(1) or float
Parameter of the trial wave function
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function of the different walkers at the specified r and alpha
"""
r = np.linalg.norm(r, axis=-1)
prob = np.exp(-2*alpha*r)
return prob
################################
# HELIUM ATOM #
################################
# TRIAL WAVE FUNCTIONS FROM: Doma, s. (2009). The Ground-State of the Helium Atom by Using Monte Carlo Variational Method.
#------------------------------
#-- Ground State --#
#------------------------------
# 2 free parameters
def WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha):
"""
Returns the value of the wave function for the Helium atom
ground state at the specified positions r and parameters alpha.
Parameters
----------
x1, y1, z1, x2, y2, z2 : np.ndarray(N_walkers, N_steps)
Position in 6D of N_walkers walkers (r = (x1, y1, z1, x2, y2, z2)) for N_steps steps
alpha : np.ndarray(2)
Parameters of the trial wave function (from WF: alpha = (z, alpha))
Returns
-------
psi : np.ndarray(N_walkers, N_steps)
Wave function at the specified position and alpha
"""
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
psi = np.exp(-z*(r1+r2))*np.exp(r12/(2*(1+alpha*r12)))
return psi
def E_local_Helium_atom_GS(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
ground state at the specified positions r and parameters alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(2)
Parameters of the trial wave function (from WF: alpha = (z, alpha))
h : float
Step for the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
z, alpha = alpha
# kinetic energy / WF
d2x1 = (WF_Helium_atom_GS(x1+h, y1, z1, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1-h, y1, z1, x2, y2, z2, z, alpha))/h**2
d2y1 = (WF_Helium_atom_GS(x1, y1+h, z1, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1-h, z1, x2, y2, z2, z, alpha))/h**2
d2z1 = (WF_Helium_atom_GS(x1, y1, z1+h, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1-h, x2, y2, z2, z, alpha))/h**2
d2x2 = (WF_Helium_atom_GS(x1, y1, z1, x2+h, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2-h, y2, z2, z, alpha))/h**2
d2y2 = (WF_Helium_atom_GS(x1, y1, z1, x2, y2+h, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2, y2-h, z2, z, alpha))/h**2
d2z2 = (WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2+h, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2-h, z, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2) / WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)
# potential energy
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = (-2/r1 -2/r2 +1/r12)
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def prob_density_Helium_atom_GS(r, alpha):
"""
Returns the value of the probability density function for the Helium atom
ground state at the specified positions r and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(2)
Parameters of the trial wave function (from WF: alpha = (z, alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
z, alpha = alpha
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
prob = np.exp(-2*z*(r1+r2))*np.exp(r12/(1+alpha*r12))
return prob
# 1 free parameters (set z=2)
def E_local_Helium_atom_GS_1param_numeric(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
ground state at the specified position r and parameter alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(1)
Parameters of the trial wave function (from WF: alpha = (alpha))
h : float
Step of the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
z = 2 # one of the parameters is pre-set
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
alpha = alpha[0]
d2x1 = (WF_Helium_atom_GS(x1+h, y1, z1, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1-h, y1, z1, x2, y2, z2, z, alpha))/h**2
d2y1 = (WF_Helium_atom_GS(x1, y1+h, z1, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1-h, z1, x2, y2, z2, z, alpha))/h**2
d2z1 = (WF_Helium_atom_GS(x1, y1, z1+h, x2, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1-h, x2, y2, z2, z, alpha))/h**2
d2x2 = (WF_Helium_atom_GS(x1, y1, z1, x2+h, y2, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2-h, y2, z2, z, alpha))/h**2
d2y2 = (WF_Helium_atom_GS(x1, y1, z1, x2, y2+h, z2, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2, y2-h, z2, z, alpha))/h**2
d2z2 = (WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2+h, z, alpha)-2*WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)+WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2-h, z, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2)/WF_Helium_atom_GS(x1, y1, z1, x2, y2, z2, z, alpha)
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = -2/r1 - 2/r2 + 1/r12
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def E_local_Helium_atom_GS_1param_analytic(r, alpha):
"""
Returns the value of the local energy for the Helium atom
ground state at the specified position r and parameters alpha.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(1)
Parameters of the trial wave function (from WF: alpha = (alpha))
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
alpha = alpha[0]
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_loc = - 4 + ((x1/r1 - x2/r2)*(x1 - x2) + (y1/r1 - y2/r2)*(y1 - y2) + (z1/r1 - z2/r2)*(z1 - z2))*(1/(r12*(1 + alpha*r12)**2)) + \
- 1/(r12*(1 + alpha*r12)**3) - 1/(4*(1 + alpha*r12)**4) + 1/r12
E_loc = E_loc.T # to go back to desired shape
return E_loc
def prob_density_Helium_atom_GS_1param(r , alpha):
"""
Returns the value of the probability density function for the Helium atom
ground state at the specified positions x1, y1, z1, x2, y2, z2 and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(1)
Parameters of the trial wave function (from WF: alpha = (alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
z = 2 # one of the parameters is preset
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
alpha = alpha[0]
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
prob = np.exp(-2*z*(r1 + r2))*np.exp(r12/(1 + alpha*r12))
return prob
#------------------------------
#-- First excited --#
#------------------------------
def WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha):
"""
Returns the value of the wave function for the Helium atom
first excited state at the specified positions r and parameters alpha.
Parameters
----------
x1, y1, z1, x2, y2, z2 : np.ndarray(N_walkers, N_steps)
Position in 6D of N_walkers walkers (r = (x1, y1, z1, x2, y2, z2)) for N_steps steps
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
psi : np.ndarray(N_walkers, N_steps)
Wave function at the specified position and alpha
"""
q0, q1, alpha = alpha.T
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
psi1s1 = np.exp(-q0*r1)
psi1s2 = np.exp(-q0*r2)
psi2s1 = (1-q1*r1/2)*np.exp(-q1*r1/2)
psi2s2 = (1-q1*r2/2)*np.exp(-q1*r2/2)
f = np.exp(r12/(4*(1+alpha*r12)))
psi = (psi1s1*psi2s2 - psi2s1*psi1s2)*f
return psi
def E_local_Helium_atom_1E(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
first excited state at the specified positions r and parameters alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (z, alpha))
h : float
Step for the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
# kinetic energy / WF
d2x1 = (WF_Helium_atom_1E(x1+h, y1, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1-h, y1, z1, x2, y2, z2, alpha))/h**2
d2y1 = (WF_Helium_atom_1E(x1, y1+h, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1, y1-h, z1, x2, y2, z2, alpha))/h**2
d2z1 = (WF_Helium_atom_1E(x1, y1, z1+h, x2, y2, z2, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1, y1, z1-h, x2, y2, z2, alpha))/h**2
d2x2 = (WF_Helium_atom_1E(x1, y1, z1, x2+h, y2, z2, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1, y1, z1, x2-h, y2, z2, alpha))/h**2
d2y2 = (WF_Helium_atom_1E(x1, y1, z1, x2, y2+h, z2, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1, y1, z1, x2, y2-h, z2, alpha))/h**2
d2z2 = (WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2+h, alpha)-2*WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2-h, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2) / WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)
# potential energy
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = (-2/r1 -2/r2 +1/r12)
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def prob_density_Helium_atom_1E(r, alpha):
"""
Returns the value of the probability density function for the Helium atom
first excited state at the specified positions r and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(2)
Parameters of the trial wave function (from WF: alpha = (z, alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
psi = WF_Helium_atom_1E(x1, y1, z1, x2, y2, z2, alpha)
return psi**2
#-------------------------------
#-- Second excited --#
#-------------------------------
def WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha):
"""
Returns the value of the wave function for the Helium atom
second excited state at the specified positions r and parameters alpha.
Parameters
----------
x1, y1, z1, x2, y2, z2 : np.ndarray(N_walkers, N_steps)
Position in 6D of N_walkers walkers (r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
psi : np.ndarray(N_walkers, N_steps)
Wave function at the specified position and alpha
"""
q0, q1, alpha = alpha.T
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
psi1s1 = np.exp(-q0*r1)
psi1s2 = np.exp(-q0*r2)
psi2s1 = (1-q1*r1/2)*np.exp(-q1*r1/2)
psi2s2 = (1-q1*r2/2)*np.exp(-q1*r2/2)
f = np.exp(r12/(2*(1+alpha*r12)))
psi = (psi1s1*psi2s2 + psi2s1*psi1s2)*f
return psi
def E_local_Helium_atom_2E(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
first excited state at the specified positions r and parameters alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
h : float
Step for the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
# kinetic energy / WF
d2x1 = (WF_Helium_atom_2E(x1+h, y1, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1-h, y1, z1, x2, y2, z2, alpha))/h**2
d2y1 = (WF_Helium_atom_2E(x1, y1+h, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1, y1-h, z1, x2, y2, z2, alpha))/h**2
d2z1 = (WF_Helium_atom_2E(x1, y1, z1+h, x2, y2, z2, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1, y1, z1-h, x2, y2, z2, alpha))/h**2
d2x2 = (WF_Helium_atom_2E(x1, y1, z1, x2+h, y2, z2, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1, y1, z1, x2-h, y2, z2, alpha))/h**2
d2y2 = (WF_Helium_atom_2E(x1, y1, z1, x2, y2+h, z2, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1, y1, z1, x2, y2-h, z2, alpha))/h**2
d2z2 = (WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2+h, alpha)-2*WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2-h, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2) / WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)
# potential energy
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = -2/r1 - 2/r2 + 1/r12
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def prob_density_Helium_atom_2E(r, alpha):
"""
Returns the value of the probability density function for the Helium atom
second excited state at the specified positions r and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
psi = WF_Helium_atom_2E(x1, y1, z1, x2, y2, z2, alpha)
return psi**2
#------------------------------
#-- Third excited --#
#------------------------------
def WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha):
"""
Returns the value of the wave function for the Helium atom
third excited state at the specified positions r and parameters alpha.
Parameters
----------
x1, y1, z1, x2, y2, z2 : np.ndarray(N_walkers, N_steps)
Position in 6D of N_walkers walkers (r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
psi : np.ndarray(N_walkers, N_steps)
Wave function at the specified position and alpha
"""
q0, q1, alpha = alpha.T
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
psi1s1 = np.exp(-q0*r1)
psi1s2 = np.exp(-q0*r2)
psi2p1 = r1*np.exp(-q1*r1/2)*(z1/r1)
psi2p2 = r2*np.exp(-q1*r2/2)*(z2/r2)
f = np.exp(r12/(2*(1+alpha*r12)))
psi = (psi1s1*psi2p2 + psi2p1*psi1s2)*f
return psi
def E_local_Helium_atom_3E(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
third excited state at the specified positions r and parameters alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
h : float
Step for the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
# kinetic energy / WF
d2x1 = (WF_Helium_atom_3E(x1+h, y1, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1-h, y1, z1, x2, y2, z2, alpha))/h**2
d2y1 = (WF_Helium_atom_3E(x1, y1+h, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1, y1-h, z1, x2, y2, z2, alpha))/h**2
d2z1 = (WF_Helium_atom_3E(x1, y1, z1+h, x2, y2, z2, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1, y1, z1-h, x2, y2, z2, alpha))/h**2
d2x2 = (WF_Helium_atom_3E(x1, y1, z1, x2+h, y2, z2, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1, y1, z1, x2-h, y2, z2, alpha))/h**2
d2y2 = (WF_Helium_atom_3E(x1, y1, z1, x2, y2+h, z2, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1, y1, z1, x2, y2-h, z2, alpha))/h**2
d2z2 = (WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2+h, alpha)-2*WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2-h, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2) / WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)
# potential energy
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = -2/r1 - 2/r2 + 1/r12
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def prob_density_Helium_atom_3E(r, alpha):
"""
Returns the value of the probability density function for the Helium atom
third excited state at the specified positions r and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
psi = WF_Helium_atom_3E(x1, y1, z1, x2, y2, z2, alpha)
return psi**2
#-------------------------------
#-- Fourth excited --#
#-------------------------------
def WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha):
"""
Returns the value of the wave function for the Helium atom
fourth excited state at the specified positions r and parameters alpha.
Parameters
----------
x1, y1, z1, x2, y2, z2 : np.ndarray(N_walkers, N_steps)
Position in 6D of N_walkers walkers (r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
psi : np.ndarray(N_walkers, N_steps)
Wave function at the specified position and alpha
"""
q0, q1, alpha = alpha.T
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
psi1s1 = np.exp(-q0*r1)
psi1s2 = np.exp(-q0*r2)
psi2p1 = r1*np.exp(-q1*r1/2)*(z1/r1)
psi2p2 = r2*np.exp(-q1*r2/2)*(z2/r2)
f = np.exp(r12/(4*(1+alpha*r12)))
psi = (psi1s1*psi2p2 - psi2p1*psi1s2)*f
return psi
def E_local_Helium_atom_4E(r, alpha, h=5E-5):
"""
Returns the value of the local energy for the Helium atom
fourth excited state at the specified positions r and parameters alpha.
It uses numerical differentiation to compute the kinetic energy.
Parameters
----------
r : np.ndarray(N_steps, N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(3)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
h : float
Step for the numerical derivative
Returns
-------
E_local : np.ndarray(N_steps, N_walkers)
Local energy at the specified position and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers, N_steps)
# kinetic energy / WF
d2x1 = (WF_Helium_atom_4E(x1+h, y1, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1-h, y1, z1, x2, y2, z2, alpha))/h**2
d2y1 = (WF_Helium_atom_4E(x1, y1+h, z1, x2, y2, z2, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1, y1-h, z1, x2, y2, z2, alpha))/h**2
d2z1 = (WF_Helium_atom_4E(x1, y1, z1+h, x2, y2, z2, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1, y1, z1-h, x2, y2, z2, alpha))/h**2
d2x2 = (WF_Helium_atom_4E(x1, y1, z1, x2+h, y2, z2, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1, y1, z1, x2-h, y2, z2, alpha))/h**2
d2y2 = (WF_Helium_atom_4E(x1, y1, z1, x2, y2+h, z2, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1, y1, z1, x2, y2-h, z2, alpha))/h**2
d2z2 = (WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2+h, alpha)-2*WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)+WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2-h, alpha))/h**2
E_kin = -0.5*(d2x1 + d2y1 + d2z1 + d2x2 + d2y2 + d2z2) / WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)
# potential energy
r1 = np.sqrt(x1**2 + y1**2 + z1**2)
r2 = np.sqrt(x2**2 + y2**2 + z2**2)
r12 = np.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (z1 - z2)**2)
E_pot = -2/r1 - 2/r2 + 1/r12
E_local = (E_kin + E_pot).T # to go back to desired shape
return E_local
def prob_density_Helium_atom_4E(r, alpha):
"""
Returns the value of the probability density function for the Helium atom
fourth excited state at the specified positions r and parameters z and alpha.
Parameters
----------
r : np.ndarray(N_walkers, 6)
Position in 6D of N_walkers walkers (from WF: r = (x1, y1, z1, x2, y2, z2))
alpha : np.ndarray(2)
Parameters of the trial wave function (from WF: alpha = (q0, q1, alpha))
Returns
-------
prob : np.ndarray(N_walkers)
Probability density function at the specified position, z and alpha
"""
x1, y1, z1, x2, y2, z2 = r.T # x_i.shape = (N_walkers)
psi = WF_Helium_atom_4E(x1, y1, z1, x2, y2, z2, alpha)
return psi**2