-
Notifications
You must be signed in to change notification settings - Fork 5
/
main_program.py
144 lines (103 loc) · 3.77 KB
/
main_program.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
import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
import numpy as np
import integrator.symp_integrator as si
import postprocess.procedures as pp
import solvers as solv
from lattice import *
"""
###############################################################################
# Import a scalar field model and create the objects needed for simulation
###############################################################################
"""
"Necessary constants defined in the model file:"
from models.chaotic import *
#from models.chaotic_massless import *
#from models.curvaton import *
#from models.curvaton_si import *
#from models.curvaton_single import *
#from models.oscillon import *
#from models.q_ball import *
#from models.AD import *
#from models.AD2 import *
#from models.infl2 import *
"Create a model:"
model = Model()
"Create a lattice:"
lat = Lattice(model, lin_order = 4, scale = model.scale,
init_m = 'defrost_cpu', precision='double')
" Create a potential function object:"
V = Potential(lat, model)
"Create simulation, evolution and postprocessing instances:"
sim = si.Simulation(model, lat, V, model.a_in, model.fields0, model.pis0,
steps = 10000)
evo = si.Evolution(lat, V, sim)
postp = pp.Postprocess(lat, V, sim)
if model.zetaQ == False:
"Create a new folder for the data:"
data_path = make_dir(model, lat, V, sim)
"""Set the average values of the fields equal to
their homogeneous values:"""
sim.adjust_fields(lat)
"""Canonical momentum p calculated with homogeneous fields.
Field fluctuations will lead to a small perturbation in p.
Adjust_p compensates this."""
evo.calc_rho_pres(lat, V, sim, print_Q = False, print_w=False, flush=False)
sim.adjust_p(lat)
"GPU memory status:"
show_GPU_mem()
"Time simulation:"
start = cuda.Event()
end = cuda.Event()
"""
################
Start Simulation
################
"""
"""
####################################################################
# Homogeneous evolution
####################################################################
"""
"Solve only background evolution:"
if model.homogenQ:
print '\nSolving homogeneous equations:\n'
solv.run_hom(lat, V, model, start, end, order = 4)
sim.time_sim += end.time_since(start)*1e-3
sim.per_stp += time_sim/sol.sim.i0_hom
"""
####################################################################
# Non-homogeneous evolution
####################################################################
"""
"""Run the simulations. Multiple runs can be used for
non-Gaussianity studies:"""
if model.evoQ:
print '\nRunning ' + str(model.sim_num) + ' simulation(s):'
solv.run_non_linear(lat, V, sim, evo, postp, model, start, end,
data_path, order = 4, endQ = 'time', print_Q = True,
print_w = False, adaptive = model.adaptQ)
if sim.i0 != 0:
"Print simulation time info:"
sim_time(sim.time_sim, sim.per_stp, sim.i0, data_path)
"Curvature perturbation (zeta) calculations:"
if model.zetaQ:
#r_decay = 0.0114181
#r_decay = 0.0550699
r_decay = 0.0369633
"List of different homogeneous initial values for fields:"
f0_list = [[model.f10 + i/20.*model.delta_f10/2.] for i in xrange(-20,21)]
for fields0 in f0_list:
solv.reinit(lat, V, sim, evo, model, model.a_in, fields0, model.pis0)
data_path = make_dir(model, lat, V, sim)
solv.run_non_linear(lat, V, sim, evo, postp, model, start, end,
data_path, order = 4, endQ = 'H', print_Q = True,
print_w = False, adaptive = model.adaptQ)
sim_time(sim.time_sim, sim.per_stp, sim.i0, data_path)
postp.calc_zeta(sim, model, f0_list, 1, r_decay, data_path)
"""
####################
Simulation finished
####################
"""
print 'Done.'