-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsemiclassical_collapse_Alcubierre.c
2977 lines (2434 loc) · 169 KB
/
semiclassical_collapse_Alcubierre.c
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
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
This code was written by Benjamin Berczi as part of the PhD project titled "Simulating Semiclassical Black Holes" from the University of Nottingham.
It is a self-contained C file that simulates a massless quantum scalar field coupled to Einstein gravity in the ADM formulation.
Details may be found in Benjamin Berczi's publications and PhD thesis.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Initialising the libraries for the code */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <omp.h>
#include <gsl/gsl_sf.h>
#include <gsl/gsl_sf_exp.h>
#include <gsl/gsl_sf_bessel.h>
#include <gsl/gsl_sf_gamma.h>
#include <complex.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Initialising the constants and parameters */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* CONSANTS */
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define M_P 1.0 //sqrt(8*PI)
#define c 1.0 // speed of light
/* GRID PARAMETERS */
#define lattice_size 700
#define buff_size 10
#define lattice_size_buff 710
#define dr 0.025 // size of the spatial grid spacing
#define dt dr*0.25 // size of the temporal grid spacing
/* SCALAR FIELD PARAMETERS */
#define amplitude 5.0 // amplitude of the gaussian scalar field
#define mass 0.0
#define initial_radius 0.0 // initial radius of the gaussian scalar field
#define initial_width 2.0 // initial width of the gaussian scalar field
/* QUANTUM OR CLASSICAL SIMULATION */
#define hbar 0 // set to 1 for quantum, 0 for classical. This just sets the backreaction, and is in set_bi_linears.c, the quantum modes are still evolved
#define coherent_state_switch 1 // set to 0 to just have the mode functions
#define damping_order 4 // order of damping
#define epsilonc 0.001 // epsilon is the constant in the damping term, it's max value is 0.5
#define epsilonq 0.5 // epsilon is the constant in the damping term, it's max value is 0.5
/* QUANTUM GHOST FIELD PARAMETERS */
#define number_of_q_fields 6 // number of quantum fields, 1 real, 5 ghosts for regularisation
#define muSq 0.0 // mass of scalar field
#define mSqGhost 2.0 // base mass of the Pauli-Villars regulator fields
double massSq[number_of_q_fields] = { muSq, mSqGhost, 3.0 * mSqGhost, mSqGhost, 3.0 * mSqGhost, 4.0 * mSqGhost}; // masses of the ghost fields
double ghost_or_physical[number_of_q_fields] = { 1, -1, 1, -1, 1, -1}; // distinguishing between the real and ghost fields
/* QUANTUM MODE PARAMETERS */
#define dk 1.0*PI/15.0
#define k_min 1.0*PI/15.0 // minimum value of k, also =dk
#define number_of_k_modes 100 // number of k modes
#define number_of_l_modes 100 // number of l modes
#define k_start 0
#define l_start 0 //the range of l is l_start, l_start+l_step, l_start+2l_step...
#define l_step 1
/* SIMULATION PARAMETERS */
#define evolve_time 1.0
#define evolve_time_int (int)(1000)
#define per_five (int)(1)
#define evolve_time_int_per_five (int)(1000)
/* NUMERICAL TIME ITERATION PARAMETERS */
#define nu_legendre 5 // order of the Legendre gaussian quadrature
#define number_of_RK_implicit_iterations 10 // number of iterations for the time evolution
#define ADM_loc 960
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Defining structures */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// classical field or coherent state expectation value
struct classical_fields{
double *pi;
double *phi;
double *chi;
};
typedef struct classical_fields Classical_fields;
// quantum mode functions
struct quantum_fields{
__complex__ double ***pi;
__complex__ double ***phi;
__complex__ double ***chi;
};
typedef struct quantum_fields Quantum_fields;
// metric variables
struct metric_fields{
double *A;
double *B;
double *D_B;
double *U_tilda;
double *K;
double *K_B;
double *lambda;
double *alpha;
double *D_alpha;
};
typedef struct metric_fields Metric_Fields;
// stress-energy tensor components
struct stress_tensor{
double rho;
double j_A;
double S_A;
double S_B;
};
typedef struct stress_tensor Stress_Tensor;
// bilinears of the full quantum field
struct bi_linears{
double phi_phi;
double chi_chi;
double pi_pi;
double chi_pi;
double del_theta_phi_del_theta_phi_over_r_sq;
};
typedef struct bi_linears Bi_Linears;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Making the points for the spatial grid */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void make_points(double r[lattice_size_buff]){
for (int i=buff_size;i<lattice_size_buff;++i){
r[i]=(i-buff_size)*dr; // uniform grid
}
for (int i=1;i<buff_size+1;++i){
r[buff_size-i]=-i*dr; // uniform grid
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function to set the buff zone of the spatial grid for all fields */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_buff_zone(Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric_fields){
#pragma omp parallel for
for (int i=1; i<buff_size+1; i++){
c_fields->phi[buff_size-i] = c_fields->phi[buff_size+i];
c_fields->chi[buff_size-i] =-c_fields->chi[buff_size+i];
c_fields->pi[buff_size-i] = c_fields->pi[buff_size+i];
metric_fields->A[buff_size-i] = metric_fields->A[buff_size+i];
metric_fields->B[buff_size-i] = metric_fields->B[buff_size+i];
metric_fields->D_B[buff_size-i] = -metric_fields->D_B[buff_size+i];
metric_fields->U_tilda[buff_size-i]= -metric_fields->U_tilda[buff_size+i];
metric_fields->K[buff_size-i] = metric_fields->K[buff_size+i];
metric_fields->K_B[buff_size-i] = metric_fields->K_B[buff_size+i];
metric_fields->lambda[buff_size-i] = -metric_fields->lambda[buff_size+i];
metric_fields->alpha[buff_size-i] = metric_fields->alpha[buff_size+i];
metric_fields->D_alpha[buff_size-i]= -metric_fields->D_alpha[buff_size+i];
//for k and l values
for(int k=0; k<number_of_k_modes; ++k){
for(int l=0; l<number_of_l_modes; ++l){
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){
q_fields[which_q_field]->phi[k][l][buff_size-i] = q_fields[which_q_field]->phi[k][l][buff_size+i];
q_fields[which_q_field]->chi[k][l][buff_size-i] =-q_fields[which_q_field]->chi[k][l][buff_size+i];
q_fields[which_q_field]->pi[k][l][buff_size-i] = q_fields[which_q_field]->pi[k][l][buff_size+i];
}
}
}
}
c_fields->chi[buff_size] = 0.0;
metric_fields->D_alpha[buff_size] = 0.0;
metric_fields->D_B[buff_size] = 0.0;
metric_fields->U_tilda[buff_size] = 0.0;
metric_fields->lambda[buff_size] = 0.0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Calculating constants for the gaussian quadrature time iteration */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void find_c_i(double c_i[nu_legendre]){//these were calculated in Mathematics using, for example, N[Roots[LegendreP[6, x] == 0, x], 20]
double zeros_of_P[nu_legendre];//={0.0};
if(nu_legendre==2){
zeros_of_P[0] = -sqrt(3.0)/3.0;
zeros_of_P[1] = sqrt(3.0)/3.0;
}
if(nu_legendre==3){
zeros_of_P[0] = -sqrt(15.0)/5.0;
zeros_of_P[1] = 0.0;
zeros_of_P[2] = sqrt(15.0)/5.0;
}
if(nu_legendre==4){
zeros_of_P[0] = -sqrt(525.0+70.0*sqrt(30.0))/35.0;
zeros_of_P[1] = -sqrt(525.0-70.0*sqrt(30.0))/35.0;
zeros_of_P[2] = sqrt(525.0-70.0*sqrt(30.0))/35.0;
zeros_of_P[3] = sqrt(525.0+70.0*sqrt(30.0))/35.0;
}
if(nu_legendre==5){
zeros_of_P[0] = -sqrt(245.0+14.0*sqrt(70.0))/21.0;
zeros_of_P[1] = -sqrt(245.0-14.0*sqrt(70.0))/21.0;
zeros_of_P[2] = 0.0;
zeros_of_P[3] = sqrt(245.0-14.0*sqrt(70.0))/21.0;
zeros_of_P[4] = sqrt(245.0+14.0*sqrt(70.0))/21.0;
}
if(nu_legendre==6){
zeros_of_P[0] = -0.93246951420315202781;
zeros_of_P[1] = -0.66120938646626451366;
zeros_of_P[2] = -0.23861918608319690863;
zeros_of_P[3] = 0.23861918608319690863;
zeros_of_P[4] = 0.66120938646626451366;
zeros_of_P[5] = 0.93246951420315202781;
}
if(nu_legendre==7){
zeros_of_P[0] = -0.94910791234275852453;
zeros_of_P[1] = -0.74153118559939443986;
zeros_of_P[2] = -0.40584515137739716691;
zeros_of_P[3] = 0.0;
zeros_of_P[4] = 0.40584515137739716691;
zeros_of_P[5] = 0.74153118559939443986;
zeros_of_P[6] = 0.94910791234275852453;
}
for(int i=0;i<nu_legendre;++i){
c_i[i] = (zeros_of_P[i]+1.0)/2.0 ;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void find_a_ij__b_i(double c_i[nu_legendre], double b_i[nu_legendre], double a_ij[nu_legendre][nu_legendre], double GL_matrix_inverse[nu_legendre][nu_legendre]){
double RHS_vector1[nu_legendre], RHS_vector2[nu_legendre];
for(int row=0;row<nu_legendre;++row){
for(int j=0;j<nu_legendre;++j){
RHS_vector1[j] = pow(c_i[row],j+1)/(j+1);
RHS_vector2[j] = 1.0/(j+1);
}
for(int i=0;i<nu_legendre;++i){
a_ij[row][i]=0.0;
for(int j=0;j<nu_legendre;++j){
a_ij[row][i] = a_ij[row][i] + GL_matrix_inverse[i][j]*RHS_vector1[j];
}
}
}
for(int i=0;i<nu_legendre;++i){
b_i[i] = 0.0;
for(int j=0;j<nu_legendre;++j){
b_i[i] = b_i[i] + GL_matrix_inverse[i][j]*RHS_vector2[j];
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-Gauss-Legendre matrix inverse---------------------
void find_GL_matrix_inverse(double c_i[nu_legendre], double GL_matrix_inverse[nu_legendre][nu_legendre]){
double determinant, row_factor[nu_legendre], linear_sum[nu_legendre], quadratic_sum[nu_legendre], cubic_sum[nu_legendre], quartic_sum[nu_legendre];
//first get the determinant
determinant = 1.0;
for(int i=0;i<nu_legendre;++i){
for(int j=i+1;j<nu_legendre;++j){
determinant = determinant*(c_i[j] - c_i[i]);
}
}
//this gives determinants of {(c1-c0); (c1-c0)(c2-c0)(c2-c1); (c1-c0)(c2-c0)(c3-c0)(c2-c1)(c3-c1)(c3-c2)}
for(int row=0;row<nu_legendre;++row){
row_factor[row]=1.0;
for(int i=0;i<nu_legendre;++i){
for(int j=i+1;j<nu_legendre;++j){
if(i!=row && j!=row) row_factor[row] = row_factor[row]*(c_i[j]-c_i[i]);
}
}
linear_sum[row] = 0.0;
for(int i=0;i<nu_legendre;++i){
if(i!=row)linear_sum[row] = linear_sum[row] + c_i[i];
}
quadratic_sum[row] = 0.0;
for(int i=0;i<nu_legendre;++i){
for(int j=i+1;j<nu_legendre;++j){
if(i!=row && j!=row)quadratic_sum[row] = quadratic_sum[row] + c_i[i]*c_i[j];
}
}
cubic_sum[row] = 0.0;
for(int i=0;i<nu_legendre;++i){
for(int j=i+1;j<nu_legendre;++j){
for(int k=j+1;k<nu_legendre;++k){
if(i!=row && j!=row && k!=row)cubic_sum[row] = cubic_sum[row] + c_i[i]*c_i[j]*c_i[k];
}
}
}
quartic_sum[row] = 0.0;
for(int i=0;i<nu_legendre;++i){
for(int j=i+1;j<nu_legendre;++j){
for(int k=j+1;k<nu_legendre;++k){
for(int l=k+1;l<nu_legendre;++l){
if(i!=row && j!=row && k!=row && l!=row)quartic_sum[row] = quartic_sum[row] + c_i[i]*c_i[j]*c_i[k]*c_i[l];
}
}
}
}
}
for(int col=0;col<nu_legendre;++col){
for(int row=0;row<nu_legendre;++row){
if(col==0)GL_matrix_inverse[row][col] = row_factor[row]*quartic_sum[row]/determinant;
if(col==1)GL_matrix_inverse[row][col] = row_factor[row]*cubic_sum[row]/determinant;
if(col==2)GL_matrix_inverse[row][col] = row_factor[row]*quadratic_sum[row]/determinant;
if(col==3)GL_matrix_inverse[row][col] = row_factor[row]*linear_sum[row]/determinant;
if(col==4)GL_matrix_inverse[row][col] = row_factor[row]/determinant;
GL_matrix_inverse[row][col] = pow(-1,(row+col))*GL_matrix_inverse[row][col];
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* First derivative function for real fields, uses 20 neighbouring points at the moment*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double first_deriv(int m, double *field){
double deriv=0.0;
if (m<lattice_size_buff-buff_size){
//deriv=-(field[m+4]-32.0/3.0*field[m+3]+56.0*field[m+2]-224.0*field[m+1]+224.0*field[m-1]-56.0*field[m-2]+32.0/3.0*field[m-3]-field[m-4])/(280.0*dr);
deriv = (6.097575365271568 * pow(10.0, 40) * field[m - 10] - 1.3550167478381302 * pow(10.0, 42) * field[m - 9] + 1.448174149252008 * pow(10.0, 43) * field[m - 8] - 9.930337023442402 * pow(10.0, 43) * field[m - 7]
+ 4.92379210745689 * pow(10.0, 44) * field[m - 6] - 1.8907361692634594 * pow(10.0, 45) * field[m - 5] + 5.90855052894837 * pow(10.0, 45) * field[m - 4] - 1.5756134743862517 * pow(10.0, 46) * field[m - 3]
+ 3.840557843816541 * pow(10.0, 46) * field[m - 2] - 1.024148758351083 * pow(10.0, 47) * field[m - 1] - 1.2569905698058102 * pow(10.0, 33) * field[m] + 1.024148758351106 * pow(10.0, 47) * field[m + 1]
- 3.8405578438166756 * pow(10.0, 46) * field[m + 2] + 1.5756134743863493 * pow(10.0, 46) * field[m + 3] - 5.908550528948874 * pow(10.0, 45) * field[m + 4] + 1.8907361692636562 * pow(10.0, 45) * field[m + 5]
- 4.923792107457477 * pow(10.0, 44) * field[m + 6] + 9.930337023443726 * pow(10.0, 43) * field[m + 7] - 1.448174149252219 * pow(10.0, 43) * field[m + 8] + 1.3550167478383397 * pow(10.0, 42) * field[m + 9]
- 6.097575365272549 * pow(10.0, 40) * field[m + 10]) / (1.1265636341862039 * pow(10.0, 47) * dr);
}
else if (m != lattice_size_buff-1){
deriv=(field[m+1]-field[m-1])/(2.0*dr);
//deriv = (23100.0 * field[m - 12] - 302400.0 * field[m - 11] + 1829520.0 * field[m - 10] - 6776000.0 * field[m - 9] + 17151750.0 * field[m - 8] - 31363200.0 * field[m - 7] + 42688800.0 * field[m - 6] - 43908480.0 * field[m - 5] + 34303500.0 * field[m - 4] - 20328000.0 * field[m - 3] + 9147600.0 * field[m - 2] - 3326400.0 * field[m - 1] + 860210.0 * field[m]) / (27720.0 * dr);
}
else{
deriv=(field[m]-field[m-1])/(dr);
}
return deriv;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* First derivative function for complex fields, uses 20 neighbouring points at the moment*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
__complex__ double first_deriv_comp(int m, __complex__ double *field){
__complex__ double deriv=0.0;
if (m<lattice_size_buff-buff_size){
//deriv=-(field[m+4]-32.0/3.0*field[m+3]+56.0*field[m+2]-224.0*field[m+1]+224.0*field[m-1]-56.0*field[m-2]+32.0/3.0*field[m-3]-field[m-4])/(280.0*dr);
deriv=(6.097575365271568*pow(10.0,40)*field[m-10]-1.3550167478381302*pow(10.0,42)*field[m-9]+1.448174149252008*pow(10.0,43)*field[m-8]-9.930337023442402*pow(10.0,43)*field[m-7]
+4.92379210745689*pow(10.0,44)*field[m-6]-1.8907361692634594*pow(10.0,45)*field[m-5]+5.90855052894837*pow(10.0,45)*field[m-4]-1.5756134743862517*pow(10.0,46)*field[m-3]
+3.840557843816541*pow(10.0,46)*field[m-2]-1.024148758351083*pow(10.0,47)*field[m-1]-1.2569905698058102*pow(10.0,33)*field[m]+1.024148758351106*pow(10.0,47)*field[m+1]
-3.8405578438166756*pow(10.0,46)*field[m+2]+1.5756134743863493*pow(10.0,46)*field[m+3]-5.908550528948874*pow(10.0,45)*field[m+4]+1.8907361692636562*pow(10.0,45)*field[m+5]
-4.923792107457477*pow(10.0,44)*field[m+6]+9.930337023443726*pow(10.0,43)*field[m+7]-1.448174149252219*pow(10.0,43)*field[m+8]+1.3550167478383397*pow(10.0,42)*field[m+9]
-6.097575365272549*pow(10.0,40)*field[m+10])/(1.1265636341862039*pow(10.0,47)*dr);
}
else if (m != lattice_size_buff){
deriv=(field[m+1]-field[m-1])/(2.0*dr);
//deriv=(23100.0*field[m-12]-302400.0*field[m-11]+1829520.0*field[m-10]-6776000.0*field[m-9]+17151750.0*field[m-8]-31363200.0*field[m-7]+42688800.0*field[m-6]-43908480.0*field[m-5]+34303500.0*field[m-4]-20328000.0*field[m-3]+9147600.0*field[m-2]-3326400.0*field[m-1]+860210.0*field[m])/(27720.0*dr);
}
else{
deriv=(field[m]-field[m-1])/(dr);
}
return deriv;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function for the artificial dissipation, aka fourth derivative function for real fields, uses 4 neighbouring points at the moment*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double fourth_deriv(int m, double *field){
double der=0.0;
if (m<lattice_size_buff-buff_size){
//der=(field[m+2]-4.0*field[m+1]+6.0*field[m]-4.0*field[m-1]+field[m-2])/pow(dr, 4.0);
der = (2.152198547886781*pow(10.0,133) * field[m - 10] - 5.30597476094236*pow(10.0,134) * field[m - 9] + 6.365997549976923*pow(10.0,135) * field[m - 8] - 4.973308793355959*pow(10.0,136) * field[m - 7] + 2.863057643183926*pow(10.0,137) * field[m - 6]
- 1.3087023772291203*pow(10.0,138) * field[m - 5] + 5.035932719448925*pow(10.0,138) * field[m - 4] - 1.7320298147875656*pow(10.0,139) * field[m - 3] + 5.721367554653479*pow(10.0,139) * field[m - 2] - 1.2906606322972197*pow(10.0,140) * field[m - 1]
+ 1.7040604531116496*pow(10.0,140) * field[m + 0] - 1.290660405149481*pow(10.0,140) * field[m + 1] + 5.721366313699189*pow(10.0,139) * field[m + 2] - 1.732029331201294*pow(10.0,139) * field[m + 3] + 5.035930883803483*pow(10.0,138) * field[m + 4]
- 1.30870177022071*pow(10.0,138) * field[m + 5] + 2.8630560175418586*pow(10.0,137) * field[m + 6] - 4.973305446769496*pow(10.0,136) * field[m + 7] + 6.365992596959947*pow(10.0,135) * field[m + 8] - 5.305970076416748*pow(10.0,134) * field[m + 9]
+ 2.1521964229110124*pow(10.0,133) * field[m + 10]) / (1.0760047710287274*pow(10.0,139) * pow(dr, 4));
}
else{
der=0.0;
//der=(field[m]-4.0*field[m-1]+6.0*field[m-2]-4.0*field[m-3]+field[m-4])/pow(dr, 4.0);
}
return der;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function for the artificial dissipation, twelfth derivative function for real fields*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double twelfth_deriv(int m, double* field) {
double der = 0.0;
if (m < lattice_size_buff - buff_size) {
der = (field[m-6]-12.0*field[m-5]+66.0*field[m-4]-220.0*field[m-3]+495.0*field[m-2]-792.0*field[m-1]+924.0*field[m]-792.0*field[m+1]+495.0*field[m+2]-220.0*field[m+3]+66.0*field[m+4]-12.0*field[m+5]+field[m+6])/pow(dr, 12);
}
else {
der = 0.0;
}
return der;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function for the artificial dissipation, aka fourth derivative function for complex fields, uses 4 neighbouring points at the moment*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
__complex__ double fourth_deriv_comp(int m, __complex__ double *field){
__complex__ double der=0.0;
if (m<lattice_size_buff-2){
der=(field[m+2]-4.0*field[m+1]+6.0*field[m]-4.0*field[m-1]+field[m-2])/pow(dr, 4.0);
// der = (2.152198547886781 * pow(10.0, 133) * field[m - 10] - 5.30597476094236 * pow(10.0, 134) * field[m - 9] + 6.365997549976923 * pow(10.0, 135) * field[m - 8] - 4.973308793355959 * pow(10.0, 136) * field[m - 7] + 2.863057643183926 * pow(10.0, 137) * field[m - 6]
// - 1.3087023772291203 * pow(10.0, 138) * field[m - 5] + 5.035932719448925 * pow(10.0, 138) * field[m - 4] - 1.7320298147875656 * pow(10.0, 139) * field[m - 3] + 5.721367554653479 * pow(10.0, 139) * field[m - 2] - 1.2906606322972197 * pow(10.0, 140) * field[m - 1]
// + 1.7040604531116496 * pow(10.0, 140) * field[m + 0] - 1.290660405149481 * pow(10.0, 140) * field[m + 1] + 5.721366313699189 * pow(10.0, 139) * field[m + 2] - 1.732029331201294 * pow(10.0, 139) * field[m + 3] + 5.035930883803483 * pow(10.0, 138) * field[m + 4]
// - 1.30870177022071 * pow(10.0, 138) * field[m + 5] + 2.8630560175418586 * pow(10.0, 137) * field[m + 6] - 4.973305446769496 * pow(10.0, 136) * field[m + 7] + 6.365992596959947 * pow(10.0, 135) * field[m + 8] - 5.305970076416748 * pow(10.0, 134) * field[m + 9]
// + 2.1521964229110124 * pow(10.0, 133) * field[m + 10]) / (1.0760047710287274 * pow(10.0, 139) * pow(dr, 4));
}
else{
der=0.0;
//der=(field[m]-4.0*field[m-1]+6.0*field[m-2]-4.0*field[m-3]+field[m-4])/pow(dr, 4.0);
}
return der;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function for the artificial dissipation, twelfth derivative function for complex fields*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
__complex__ double twelfth_deriv_comp(int m, __complex__ double* field) {
__complex__ double der = 0.0;
if (m < lattice_size_buff - buff_size) {
der = (field[m-6]-12.0*field[m-5]+66.0*field[m-4]-220.0*field[m-3]+495.0*field[m-2]-792.0*field[m-1]+924.0*field[m]-792.0*field[m+1]+495.0*field[m+2]-220.0*field[m+3]+66.0*field[m+4]-12.0*field[m+5]+field[m+6])/pow(dr, 12);
}
else {
der = 0.0;
}
return der;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* This function provides a version of gsl's Bessel function that ignores any underflow error */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double gsl_sf_bessel_jl_safe(int l, double x){
gsl_sf_result answer;
gsl_error_handler_t *old_error_handler=gsl_set_error_handler_off (); // turn off the error handler
int error_code=gsl_sf_bessel_jl_e(l, x, &answer); //compute the answer, and construct an error code
gsl_set_error_handler(old_error_handler); //reset the error handler
if(error_code==GSL_SUCCESS){ //if there's no error then return the correct answer
return answer.val;
}
else{
//printf ("error in gsl_sf_bessel_jl_safe: %s\n", gsl_strerror (error_code));
//exit(1);
if(error_code==GSL_EUNDRFLW){
return 0.0;
}
else{
printf ("error in gsl_sf_bessel_jl_safe: %s\n", gsl_strerror (error_code));
exit(1);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* These functions provides the initial profile functions */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double phi_mode_profile_0(double k, int l, double r){
return ( sqrt(k/PI)*gsl_sf_bessel_jl_safe(l, k*r)/pow(r,l) );
}
//---
double phi_mode_profile_0_prime(double k, int l, double r){
return ( -k*sqrt(k/PI)*gsl_sf_bessel_jl_safe(l+1, k*r)/pow(r,l) );
}
//---
double phi_mode_profile_massive(double msq, double k, int l, double r){
return ( k/sqrt(PI*sqrt(k*k+msq))*gsl_sf_bessel_jl_safe (l, k*r)/pow(r,l) );
}
//---
double phi_mode_profile_massive_prime(double msq, double k, int l, double r){
return ( -k*k/sqrt(PI*sqrt(k*k+msq))*gsl_sf_bessel_jl_safe (l+1, k*r)/pow(r,l) );
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function that initialises the classical variables */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void initial_conditions_classical(Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric){
double rpoints[lattice_size_buff], r;
make_points(rpoints);
/* METRIC FIELDS */
//#pragma omp parallel for
for (int i=0;i<lattice_size_buff;++i){
metric->A[i] = 1.0;
metric->B[i] = 1.0;
metric->D_B[i] = 0.0;
metric->K[i] = 0.0;
metric->K_B[i] = 0.0;
metric->alpha[i] = 1.0;
metric->D_alpha[i] = 0.0;
metric->lambda[i] = 0.0;
metric->U_tilda[i] = 0.0;
}
/* CLASSICAL MATTER FIELDS */
/* PHI */
for (int i=buff_size;i<lattice_size_buff;++i){
r=rpoints[i];
//c_fields->phi[i] = amplitude * exp(- r * r / (2.0*initial_width * initial_width));
c_fields->phi[i]=(amplitude*(r/initial_width)*(r/initial_width)*exp(-(r-initial_radius)*(r-initial_radius)/(initial_width*initial_width)))+
(amplitude*(r/initial_width)*(r/initial_width)*exp(-(-r-initial_radius)*(-r-initial_radius)/(initial_width*initial_width)));
}
/* CHI */
for (int i=buff_size; i<lattice_size_buff; ++i){
r=rpoints[i];
if (i>buff_size){
//c_fields->chi[i] = - amplitude *r/ (initial_width * initial_width) * exp(-r * r / (2.0*initial_width * initial_width));
c_fields->chi[i]=(1/initial_width*(2.0*amplitude*(r/initial_width)*(1.0 - (r)*(r-initial_radius)/(initial_width*initial_width))
*exp(-(r-initial_radius)*(r-initial_radius)/(initial_width*initial_width))))+
(1/initial_width*(2.0*amplitude*(r/initial_width)*(1.0 + (r)*(-r-initial_radius)/(initial_width*initial_width))
*exp(-(-r-initial_radius)*(-r-initial_radius)/(initial_width*initial_width))));
}
else{
c_fields->chi[i]=0.0;
}
}
/* PI */
for (int i=buff_size;i<lattice_size_buff;++i){
c_fields->pi[i]=0;
}
set_buff_zone(c_fields, q_fields, metric);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function that initialises the quantum variables */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void initial_conditions_quantum(Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric){
/* QUANTUM MATTER FIELDS */
//the initial data for the quantum vacuum modes phi
for(int i=buff_size; i<lattice_size_buff; ++i){
double k_wavenumber, omega_phi;
int l_value;
double r;
r =(i-buff_size)*dr;
for(int k=0; k<number_of_k_modes; ++k){
k_wavenumber = (k_start+(k+1))*k_min;
for(int l=0; l<number_of_l_modes; ++l){
l_value = l_start + l*l_step;
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){//cycle through the quantum fields and initialize them
omega_phi = sqrt(k_wavenumber*k_wavenumber + massSq[which_q_field]);
if(massSq[which_q_field]==0){
if(i>buff_size){
q_fields[which_q_field]->phi[k][l][i] = phi_mode_profile_0(k_wavenumber,l_value,r); //set the r!=0 zero values
}
else{
if(2*l_value+1<GSL_SF_DOUBLEFACT_NMAX){ //check that 1/gsl_sf_doublefact isn't too small
q_fields[which_q_field]->phi[k][l][i] = sqrt(k_wavenumber/PI)*pow(k_wavenumber,l_value)/gsl_sf_doublefact(2*l_value+1);
}
else{
q_fields[which_q_field]->phi[k][l][i] = 0.0;
}
}
}
else{
if(i>buff_size){
q_fields[which_q_field]->phi[k][l][i] = phi_mode_profile_massive(massSq[which_q_field],k_wavenumber,l_value,r);
}
else{ //this is the value at the origin
if(2*l_value+1<GSL_SF_DOUBLEFACT_NMAX){//check that 1/gsl_sf_doublefact isn't too small
q_fields[which_q_field]->phi[k][l][i] = k_wavenumber/sqrt(PI*omega_phi)*pow(k_wavenumber,l_value)/gsl_sf_doublefact(2*l_value+1);
}
else{
q_fields[which_q_field]->phi[k][l][i] = 0.0;
}
}
}
//then sort out the momenta
q_fields[which_q_field]->pi[k][l][i] = -I*omega_phi*q_fields[which_q_field]->phi[k][l][i]; //note that this is a specification of pi, and not phi_dot
}
}
}
}
//the initial data for the quantum vacuum modes chi
for(int i=buff_size; i<lattice_size_buff; ++i){
double r;
r = (i - buff_size) * dr;
double k_wavenumber, omega_phi;
int l_value;
for(int k=0; k<number_of_k_modes; ++k){
k_wavenumber = (k_start + (k + 1))*k_min;
for(int l=0; l<number_of_l_modes; ++l){
l_value = l_start + l*l_step;
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){//cycle through the quantum fields and initialize their gradients
omega_phi = sqrt(k_wavenumber*k_wavenumber + massSq[which_q_field]);
if(massSq[which_q_field]==0){//the massless case
if(i>buff_size){
q_fields[which_q_field]->chi[k][l][i] = phi_mode_profile_0_prime(k_wavenumber,l_value,r); //this is a place-holder for phi_prime, it will get replaced with psi
}
else{//this is the value at the origin
if(2*l_value+3<GSL_SF_DOUBLEFACT_NMAX){//check that 1/gsl_sf_doublefact isn't too small
q_fields[which_q_field]->chi[k][l][i] = -sqrt(k_wavenumber/PI)*pow(k_wavenumber,l_value+2)*r/gsl_sf_doublefact(2*l_value+3);
}
else{
q_fields[which_q_field]->chi[k][l][i] = 0.0;
}
}
}
else{//the massive case
if(i>buff_size){
q_fields[which_q_field]->chi[k][l][i] = phi_mode_profile_massive_prime(massSq[which_q_field],k_wavenumber,l_value,r); //this is a place-holder for phi_prime, it will get replaced with psi
// in set_A_and_K_and_lapse_initial(...)
}
else{//this is the value at the origin
if(2*l_value+3<GSL_SF_DOUBLEFACT_NMAX){//check that 1/gsl_sf_doublefact isn't too small
q_fields[which_q_field]->chi[k][l][i] = -k_wavenumber*k_wavenumber/sqrt(PI*omega_phi)*pow(k_wavenumber,l_value+1)*r/gsl_sf_doublefact(2*l_value+3);
}
else{
q_fields[which_q_field]->chi[k][l][i] = 0.0;
}
}
}
}
}
}
}
set_buff_zone(c_fields, q_fields, metric);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function that calculates the norm */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double norm(__complex__ double number){
double nor=0.0;
nor=(pow((__real__ number),2.0)+pow((__imag__ number),2.0));
return nor;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function that calculates the bilinears */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_bi_linears(int i, Bi_Linears *bi_linears, Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric){
double r, r_l;
double phi_phi, chi_chi, pi_pi, chi_pi, del_theta_phi_del_theta_phi_over_r_sq;
__complex__ double Phi_mode, Phi_mode_plus, Chi_mode, Pi_mode;
int l_value;
r = dr*(i-buff_size);
phi_phi = 0.0;
chi_chi = 0.0;
pi_pi = 0.0;
chi_pi = 0.0;
del_theta_phi_del_theta_phi_over_r_sq = 0.0;
if(coherent_state_switch!=0){
phi_phi = c_fields->phi[i]*c_fields->phi[i];
chi_chi = c_fields->chi[i]*c_fields->chi[i];
pi_pi = c_fields->pi[i] *c_fields->pi[i];
chi_pi = c_fields->chi[i]*c_fields->pi[i];
del_theta_phi_del_theta_phi_over_r_sq = 0.0;
}
//note that these modes are actually modes of phi, where Phi = r^l phi
//Phi = r^l phi
//Pi = r^l pi
//Psi = lr^{l-1} u + r^l psi
if(hbar!= 0){
//#pragma omp parallel for
for(int k=0; k<number_of_k_modes; ++k){
for(int l=0; l<number_of_l_modes; ++l){
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){
l_value = l_start + l*l_step;
r_l = pow(r,l_value);
/* PHI MODE */
Phi_mode = r_l*(q_fields[which_q_field]->phi[k][l][i]);
if(i==buff_size){
Phi_mode_plus = pow(r+dr,l_value)*(q_fields[which_q_field]->phi[k][l][i+1]);
}
/* CHI MODE */
if(l_value==0){
Chi_mode = q_fields[which_q_field]->chi[k][l][i];
}
else if (l_value==1){
Chi_mode = q_fields[which_q_field]->phi[k][l][i]+r*q_fields[which_q_field]->chi[k][l][i];
}
else{
Chi_mode = l_value*pow(r,l_value-1)*q_fields[which_q_field]->phi[k][l][i]+r_l*(q_fields[which_q_field]->chi[k][l][i]);
}
/* PI MODE */
Pi_mode = r_l*q_fields[which_q_field]->pi[k][l][i];
/* ACTUAL BILINEARS */
phi_phi = phi_phi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Phi_mode); // instead of norm
chi_chi = chi_chi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Chi_mode);
pi_pi = pi_pi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Pi_mode);
chi_pi = chi_pi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)* (__real__ (Pi_mode * conj(Chi_mode)));
if(i!=buff_size){
del_theta_phi_del_theta_phi_over_r_sq = del_theta_phi_del_theta_phi_over_r_sq + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*0.5*l_value*(l_value+1.0)*(2.0*l_value+1.0)*norm(Phi_mode)/(r*r);
}
else{//use the data at r=dr to estimate the r=0 case. This is only relevant for l=1
del_theta_phi_del_theta_phi_over_r_sq = del_theta_phi_del_theta_phi_over_r_sq + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*0.5*l_value*(l_value+1.0)*(2.0*l_value+1.0)*norm(Phi_mode_plus)/(dr*dr);
}
}
}
}
}
//printf("\n %.100f, ", norm(chi_mode));
bi_linears->phi_phi = phi_phi;
bi_linears->chi_chi = chi_chi;
bi_linears->pi_pi = pi_pi;
bi_linears->chi_pi = chi_pi;
bi_linears->del_theta_phi_del_theta_phi_over_r_sq = del_theta_phi_del_theta_phi_over_r_sq;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Function that calculates the biliears in the midpoints of the iteration */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_bi_linears_midpoint(int i , Bi_Linears *bi_binears_midpoint, Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric)
{
double r, r_l;
double phi_phi=0.0, psi_psi=0.0, pi_pi=0.0, psi_pi=0.0, del_theta_phi_del_theta_phi_over_r_sq=0.0;
__complex__ double Phi_mode, Psi_mode, Pi_mode;
int l_value;
r = dr*(i-buff_size) + 0.5*dr;
phi_phi = 0.0;
psi_psi = 0.0;
pi_pi = 0.0;
psi_pi = 0.0;
del_theta_phi_del_theta_phi_over_r_sq = 0.0;
if(coherent_state_switch!=0){
phi_phi = 0.25*(c_fields->phi[i] + c_fields->phi[i+1])*(c_fields->phi[i] + c_fields->phi[i+1]);
psi_psi = 0.25*(c_fields->chi[i] + c_fields->chi[i+1])*(c_fields->chi[i] + c_fields->chi[i+1]);
pi_pi = 0.25*(c_fields->pi[i] + c_fields->pi[i+1] )*(c_fields->pi[i] + c_fields->pi[i+1] );
psi_pi = 0.25*(c_fields->chi[i] + c_fields->chi[i+1])*(c_fields->pi[i] + c_fields->pi[i+1] );
del_theta_phi_del_theta_phi_over_r_sq = 0.0;
}
//note that these modes are actually modes of phi, where Phi = r^l phi
//Phi = r^l phi
//Pi = r^l pi
//Psi = lr^{l-1} u + r^l psi
if(hbar!= 0){
for(int k=0; k<number_of_k_modes; ++k){
for(int l=0; l<number_of_l_modes; ++l){
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){
l_value = l_start + l*l_step;
r_l = pow(r,l_value);
Phi_mode = 0.5*r_l*(q_fields[which_q_field]->phi[k][l][i] + q_fields[which_q_field]->phi[k][l][i+1]);
if(l_value==0){
Psi_mode = 0.5*(q_fields[which_q_field]->chi[k][l][i] + q_fields[which_q_field]->chi[k][l][i+1]);
}
else if (l_value==1){
Psi_mode = 0.5*(q_fields[which_q_field]->phi[k][l][i] + q_fields[which_q_field]->phi[k][l][i+1])
+0.5*r*(q_fields[which_q_field]->chi[k][l][i] + q_fields[which_q_field]->chi[k][l][i+1]);
}
else{
Psi_mode = 0.5*l_value*pow(r, l_value-1)*((q_fields[which_q_field]->phi[k][l][i]) + (q_fields[which_q_field]->phi[k][l][i+1]))
+0.5*r_l*(q_fields[which_q_field]->chi[k][l][i] + q_fields[which_q_field]->chi[k][l][i+1]);
}
Pi_mode = 0.5*r_l*(q_fields[which_q_field]->pi[k][l][i]+ q_fields[which_q_field]->pi[k][l][i+1]);
phi_phi = phi_phi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Phi_mode);
psi_psi = psi_psi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Psi_mode);
pi_pi = pi_pi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*norm(Pi_mode);
psi_pi = psi_pi + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*(2.0*l_value+1.0)*(__real__ (Pi_mode * conj(Psi_mode)));
del_theta_phi_del_theta_phi_over_r_sq = del_theta_phi_del_theta_phi_over_r_sq + hbar*ghost_or_physical[which_q_field]*dk/(4.0*PI)*0.5*l_value*(l_value+1.0)*(2.0*l_value+1.0)*norm(Phi_mode)/(r*r);
}
}
}
}
bi_binears_midpoint->phi_phi = phi_phi;
bi_binears_midpoint->chi_chi = psi_psi;
bi_binears_midpoint->pi_pi = pi_pi;
bi_binears_midpoint->chi_pi = psi_pi;
bi_binears_midpoint->del_theta_phi_del_theta_phi_over_r_sq = del_theta_phi_del_theta_phi_over_r_sq;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Setting the cosmological constant */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double set_cosm_constant(Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric){
double rho, S_A, A, B;
int i;
double phi_phi, chi_chi, pi_pi, chi_pi, del_theta_phi_del_theta_phi_over_r_sq;
Bi_Linears bi_linears;
A = 1.0;
B = 1.0;
i = buff_size;
set_bi_linears(i, &bi_linears, c_fields, q_fields, metric);
phi_phi = bi_linears.phi_phi;
chi_chi = bi_linears.chi_chi;
pi_pi = bi_linears.pi_pi;
chi_pi = bi_linears.chi_pi;
del_theta_phi_del_theta_phi_over_r_sq = bi_linears.del_theta_phi_del_theta_phi_over_r_sq;
rho = 1.0/(2.0*A)*(pi_pi/(B*B)+chi_chi)+1.0/B*del_theta_phi_del_theta_phi_over_r_sq;
S_A = 1.0 / (2.0 * A) * (pi_pi / (B * B) + chi_chi) - 1.0 / (B)*del_theta_phi_del_theta_phi_over_r_sq;
return rho;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Setting the stress tensor components for given variable fields */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_stress_tensor(int i, Stress_Tensor *stress_tnsr, Bi_Linears bi_linears, Metric_Fields *metric, Classical_fields *c_fields, Quantum_fields **q_fields){
double rho=0.0, j_A=0.0, S_A=0.0, S_B=0.0;
double A, B;
double phi_phi, chi_chi, pi_pi, chi_pi, del_theta_phi_del_theta_phi_over_r_sq;
rho = stress_tnsr->rho;
j_A = stress_tnsr->j_A;
S_A = stress_tnsr->S_A;
S_B = stress_tnsr->S_B;
A = metric->A[i];
B = metric->B[i];
phi_phi = bi_linears.phi_phi;
chi_chi = bi_linears.chi_chi;
pi_pi = bi_linears.pi_pi;
chi_pi = bi_linears.chi_pi;
del_theta_phi_del_theta_phi_over_r_sq = bi_linears.del_theta_phi_del_theta_phi_over_r_sq;
rho = 1.0 / (2.0 * A) * (pi_pi / (B * B) + chi_chi) + 1.0 / (B)*del_theta_phi_del_theta_phi_over_r_sq;
j_A = -chi_pi / (sqrt(A) * B);
S_A = 1.0 / (2.0 * A) * (pi_pi / (B * B) + chi_chi) - 1.0 / (B)*del_theta_phi_del_theta_phi_over_r_sq;
S_B = 1.0 / (2.0 * A) * (pi_pi / (B * B) - chi_chi);
stress_tnsr->rho = rho;
stress_tnsr->j_A = j_A;
stress_tnsr->S_A = S_A;
stress_tnsr->S_B = S_B;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Finding the initial dA_dr - note that only "classical" contribution present, since the quantum ones are cancelled out exactly by the cosmological constant */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double set_dA_dr_initial(double r, double A, double cos_const, Bi_Linears bi_linears)
{
double d_A_dr;
double phi_phi, chi_chi, pi_pi, chi_pi, del_theta_phi_del_theta_phi_over_r_sq;
double rho=0.0;
double chi=0.0;
double B=1.0;
phi_phi = bi_linears.phi_phi;
chi_chi = bi_linears.chi_chi; //this really IS phi_prime^2, and not psi^2, as psi was used as a placeholder for phi_prime in initialize_matter(...)
pi_pi = bi_linears.pi_pi;
chi_pi = bi_linears.chi_pi; //this really IS phi_prime_pi, and not psi^2, as psi was used as a placeholder for phi_prime in initialize_matter(...)
del_theta_phi_del_theta_phi_over_r_sq = bi_linears.del_theta_phi_del_theta_phi_over_r_sq;
/*this calculation takes into account the quantum mode contribution*/
//rho = 1.0/(2.0*A)*(pi_pi/(B*B)+chi_chi)+1.0/(B)*del_theta_phi_del_theta_phi_over_r_sq;
//d_A_dr = A*(( r!=0.0 ? 1.0/r*(1.0-A) : 0.0)+A*r*M_P*M_P*(rho-cos_const));
/*this calculation does not take into account the quantum mode contribution, works because initially the quantum mode contribution to \rho is of order 10^-16*/
//chi= - amplitude * r / (initial_width * initial_width) * exp(-r * r / (2.0*initial_width * initial_width));
double phi, phi_prime;
phi = amplitude * exp(-1.0 / 2.0 * pow((r - initial_radius) / initial_width, 2.0));
phi_prime = -(r - initial_radius) / pow(initial_width, 2.0) * phi;
//chi = (r != 0.0 ? phi_prime : 0.0);
chi=(1/initial_width*(2.0*amplitude*(r/initial_width)*(1.0 - (r)*(r-initial_radius)/(initial_width*initial_width))
*exp(-(r-initial_radius)*(r-initial_radius)/(initial_width*initial_width))))+
(1/initial_width*(2.0*amplitude*(r/initial_width)*(1.0 + (r)*(-r-initial_radius)/(initial_width*initial_width))
*exp(-(-r-initial_radius)*(-r-initial_radius)/(initial_width*initial_width))));
d_A_dr = A*(( r!=0.0 ? 1.0/r*(1.0-A) : 0.0)+r/2.0*(M_P*M_P)*chi*chi);
return d_A_dr;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Setting the initial A, U_tilde, and lambda */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_A_U_lambda_initial(double cos_const, Classical_fields *c_fields, Quantum_fields **q_fields, Metric_Fields *metric)
{
metric->A[buff_size] = 1.0;
//solve with 4th-order Runge Kutta
for(int i=buff_size; i<lattice_size_buff-1; ++i){
double r, A, rho;
Bi_Linears bi_linears, bi_linears_midpoint, bi_linears_plus;
double k1_A = 0.0, k2_A = 0.0, k3_A = 0.0, k4_A = 0.0;
r = (i-buff_size)*dr;
A = metric->A[i];
set_bi_linears(i, &bi_linears, c_fields, q_fields, metric);
set_bi_linears_midpoint(i, &bi_linears_midpoint, c_fields, q_fields, metric);
set_bi_linears(i+1, &bi_linears_plus, c_fields, q_fields, metric);
k1_A = dr*set_dA_dr_initial(r, A, cos_const, bi_linears);
k2_A = dr*set_dA_dr_initial(r+0.5*dr, A+0.5*k1_A, cos_const, bi_linears_midpoint);
k3_A = dr*set_dA_dr_initial(r+0.5*dr, A+0.5*k2_A, cos_const, bi_linears_midpoint);
k4_A = dr*set_dA_dr_initial(r+dr, A+k3_A, cos_const, bi_linears_plus);
metric->A[i+1] = metric->A[i] + ( k1_A + 2.0*k2_A + 2.0*k3_A + k4_A ) / 6.0;
}
//Now we rescale pi and find the initial U_tilda and lambda
//#pragma omp parallel for
for(int i=buff_size; i<lattice_size_buff; ++i){
double r;
r = (i-buff_size)*dr;
metric->lambda[i] = (i!=buff_size ? 1.0/r*(1.0-metric->A[i]/metric->B[i]) : 0.0);
//metric->U_tilda[i]=1.0/r*(1.0-metric->A[i])*(1.0-4.0/metric->A[i])+r/2.0*M_P*M_P*rho;
metric->U_tilda[i] = (first_deriv(i, metric->A)-4.0*metric->lambda[i])/metric->A[i];
c_fields->pi[i] = sqrt(metric->A[i])*c_fields->pi[i]; //here we rescale the placeholder pi
//#pragma omp parallel for
for(int k=0; k<number_of_k_modes; ++k){
for(int l=0; l<number_of_l_modes; ++l){
for(int which_q_field=0;which_q_field<number_of_q_fields;++which_q_field){