-
Notifications
You must be signed in to change notification settings - Fork 0
/
g2header.h
211 lines (129 loc) · 7.59 KB
/
g2header.h
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
/**********************************
Header File (declarations)
**********************************/
/*
This header file contains all the declarations for program functions.
Copyright (2013):
Kenyon College
John T. Giblin, Jr
Tate Deskins and Hillary Child
Last Updated: 06.27.2013
*/
#include <stdio.h>//needed for printf fprintf
#include <stdlib.h>//needed for malloc
#include <math.h>//needed for fabs, tanh
#include <time.h>//needed for time and ctime
#include <fftw3.h>//needed for the rand initial conditions
#include <unistd.h>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Eigenvalues>
#include<iostream>
typedef Eigen::Matrix<long double, 3,3> Matrix3L;
typedef Eigen::Matrix<long double, 3,1> Vector3L;
typedef Eigen::Matrix<long double, 5,5> Matrix5L;
typedef Eigen::Matrix<long double, 5,1> Vector5L;
#include <omp.h>// needed for ompeff
#define omp_set_nested(x)
#define omp_get_num_threads() 1
#define float double
//this is a directive to declare all the common indecies for the fields
#define DECLARE_INDEX int fld,i,j,k;
/****************
LOOP DEFINITIONS
****************/
//the following are definitions for looping over different field indicies
#define fldLOOP for(fld=0;fld<nflds;fld++) for(i=0;i<N;i++) for(j=0;j<N;j++) for(k=0;k<N;k++)
//this loops over the fld and all three indicies
#define LOOP for(i=0;i<N;i++) for(j=0;j<N;j++) for(k=0;k<N;k++)
//this loops over just the indicies (3D)
#define LOOP2 for(j=0;j<N;j++) for(k=0;k<N;k++)
//this loops over just the j and k indicies (2d)
#include "g2parameters.h"
//this is the include statement for the parameters file
/******************************
global parameters DO NOT CHANGE
******************************/
extern long double t;//this is the variable that stores the evolution time
extern long double (* field)[nflds][N][N][N];//this stores the field values for each step along the grid
extern long double (* dfield)[nflds][N][N][N];//this stores the derivative of the field for each step along the grid
extern long double (* Rfield)[nflds][N][N][N];//another array for random ICs
extern long double (* Rdfield)[nflds][N][N][N];
extern long double (* Sfield)[nflds][N][N][N];//array to receive fourier transforms without modifying original
extern long double (* Sdfield)[nflds][N][N][N];
//The following are all arrays of length two, one for each step of the RK2 integration
extern long double a[2];//this stores the scale facator for each step
extern long double adot[2];// this stores the time derivative of the scale factor
extern long double edpot[2]; //this stores the average potential energy
extern long double edkin[2]; //this stores the average kinetic energy
//extern long double edkinH[2];
//extern long double edkinRho[2];
extern long double edgrad[2]; //this stores the average gradient energy
extern long double edrho[2]; // this stores the avg. energy density over the box
/***********************
Initialization Header
***********************/
//These are the declerations of the initialization functions whose definitions are found in g2init.cpp
void initexpansion();// initializes all of the energy densities and scale factor as appropriet for the begining of the run
void dftMemAlloc();// Allocates the memory for the dft for moving the random intialization in momentum space to configuration space
void randInit( long double f[][N][N],long double df[][N][N],long double d2vdf2);//function which initializes the random conditions for fields f and df
void initDestroy();//destroys the fftw extra stuffs needed only durring intialization
/************
Model Header
************/
//These are the declerations of the functions defined in g2model.cpp
void modelinfo(FILE *info);//function which prints model dependent information to info.txt
long double potential(int s, int i, int j, int k);// function to evaluate the potential of the field(s)
long double dVdf(int s, int fld, int i, int j, int k);//function to store derivative wrt field of the potential
/*inline*/ long double effMass(int s, int fld);// function holds the effective mass of the fields, returns 1. if none is stored.
void initfields();//function to initialize the fields (and anything else)
/************
Functions Header
************/
// There are the declerations of the functions defined in g2functions.cpp
long double pw2(long double x);//This function squares doubles
/*long double mod2(long double f1, long double f2);
long double mod(long double f1, long double f2);*/
int incr(int i);///for incremiting with periodic boundary conditions
int decr(int i);//for decremiting with periodic boundary conditions
long double laplacian(long double f[][N][N], int i, int j, int k);//this is the function to call for the 7pt laplacian
long double dfdi(long double f[][N][N], int i, int j, int k);//spatial derivative of a field in the i (x) direction
long double dfdj(long double f[][N][N], int i, int j, int k);//spatial derivative of a field in the j (y) direction
long double dfdk(long double f[][N][N], int i, int j, int k);//spatial derivative of a field in the j (y) direction
long double dfdx(long double f[][N][N], int x, int i, int j, int k);//spatial derivative of the field f in the "x" direction (stores the three functions above).
long double gradF2(long double f[][N][N],int i,int j,int k);//takes the gradient of the field at a point and squares it
long double avgGrad(int s);//calculates the average gradient energy over the box
long double avgPot(int s);//calculates the average potential energy over the box
long double avgKin(int s);// calculates the avereage kinetic energy over the box
//long double avgKinH(int s);// calculates the avereage kinetic energy over the box, just in h1,h2
//long double avgKinRho(int s);
void calcEnergy(int s);// calculates the total average energy over the box
long double adf(int s);// calculates adot from the average energy density
long double ddfield(int s, int fld, int i, int j, int k);//equation of motion for the fields (klein gordon)
void step();//performs the full RK2 integration
//CHRIS my functions
long double calcdda(int s);
void mass_matrix_calc(int s, long double(* evec)[nflds][nflds], long double (*mdiag)[nflds], bool ifdiag);
void fromDiag ( long double (*Sfield)[nflds][N][N][N],long double (*Sdfield)[nflds][N][N][N] , long double(*evec)[nflds][nflds] );
void toDiag ( long double (*Sfield)[nflds][N][N][N],long double (*Sdfield)[nflds][N][N][N] , long double(*evec)[nflds][nflds] , bool ifdiag );
void diag_test(long double(* evec)[nflds][nflds], long double* lambda);
void eigen_test();
void calcE0 ( long double *kin, long double* pot);
void Viicalc (int s,long double *V11, long double *V22, long double *V12, long double *Vrr);
long double Vrrcalc (int s);
/**************
Output Header
*************/
//Decleartion for all output functions found in g2output.cpp
void outputfield(int first);//outputs the field values over box (dimension and sampling determined in g2parameters.h
int slicewaitf();//evaluates the slicewait value (how long to wait between output slices) for the outputslice function
void outputslice();//this function determines what is output how and when
void output_parameters();//this creates the info.txt and populates it
void readable_time(int tt, FILE *info);//prints meanigful time to the info.txt
void screenout();//determines when there should be screen output
void meansvars(); //outputs means and variances of all fields
/**************
Spectra Header
**************/
//Decleration for all functions found in g2spectra.cpp
void specOut(int first);//the calculates and prints to file the spectra of the fields
void specClear();//clears memory from the dft's used in specOut