-
Notifications
You must be signed in to change notification settings - Fork 1
/
new_main.cpp
195 lines (153 loc) · 7.65 KB
/
new_main.cpp
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
#include <iostream>
#include "stars.h"
#include <time.h>
#include <cstdlib>
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;
int main (int argc, char * argv[]) {
ifstream input ("input.txt");
parametrs_B param_B (&input);
parametrs_lum param_lum (&input);
double T = -5.e8; //-350e6; // начало
int number_stars = 7; // темп звездообразования (звёзд в тысячалетие)
int number_millenium = -T/1e3; // количество тысячалетий
cout<<"//----------------------------------------------------------//"<<endl;
cout<<"// Пульсарная популяция. Версия 0.80см соглашение о версиях //"<<endl;
cout<<"// Автор: Игошев Андрей, научный руководитель: А.Ф. Холтыгин//"<<endl;
cout<<"// e-mail: [email protected] СПбГУ, 2010-2012 //"<<endl;
cout<<"//----------------------------------------------------------//"<<endl;
param_B.print_description (&cout);
param_B.print_parametrs (&cout);
param_lum.print_description(&cout);
param_lum.print_parametrs (&cout);
ifstream in_p, in_b;
PDistr p_distr;
BDistr b_distr;
if (argc>2) {
in_p.open (argv[1]);
in_b.open (argv[2]);
} else {
cout<<"You did not mention files for P and B distributions, so standards files are used"<<endl;
in_p.open ("P_init.txt");
in_b.open ("B_init.txt");
if ((!in_p) || (!in_b)) {
cout<<"Files with initial P&B are absent."<<endl;
} else {
p_distr.Set(&in_p);
b_distr.Set(&in_b);
}
}
p_distr.print_param (&cout);
b_distr.print_param (&cout);
cout<<"// Параметры популяциии: "<<endl;
cout<<"// T_start "<<T<<endl;
cout<<"// star formation rate "<<number_stars<<endl;
cout<<"//----------------------------------------------------------//"<<endl;
cout<<"// Инициализация расчётов. //"<<endl;
srand(time(0));
TMap T_copy;
cout<<"// Инициализация расчётов закончена. //"<<endl;
cout<<"//----------------------------------------------------------//"<<endl;
ofstream out_p ("result_p_p_dot.txt");
ofstream out_pos ("result_pos.txt");
ofstream out_lum ("result_radio_lum.txt");
ofstream out_ances ("result_ancest_pos.txt");
ofstream out_about ("output.txt");
ofstream out_short ("output_short.txt");
ofstream out_exper ("result_experiment.txt");
ofstream out_str ("otl_v_x.txt");
param_B.print_short (&out_short);
param_lum.print_short (&out_short);
SpecialStar sun;
SpecialStar sun_nowaday;
double now = 0, shift;
double P, dot_P, x, y, z, B;
double dist_to_sun, lumin;
double x_ances, y_ances, z_ances;
int counter = 0;
int rand_shift; // случайное время рождения внутри тысячелетия
int n_magnet = 0;
sun_nowaday.move_to(now);
out_about<<"//----------------------------------------------------------//"<<endl;
out_about<<"// Пульсарная популяция. Версия 0.80см соглашение о версиях //"<<endl;
out_about<<"// Автор: Игошев Андрей, научный руководитель: А.Ф. Холтыгин//"<<endl;
out_about<<"// e-mail: [email protected] СПбГУ, 2010-2012 //"<<endl;
out_about<<"//----------------------------------------------------------//"<<endl;
out_about<<"// Параметры модели: "<<endl;
out_about<<"// T_start "<<T<<endl;
out_about<<"// star formation rate "<<number_stars<<endl;
param_B.print_description (&out_about);
param_B.print_parametrs (&out_about);
param_lum.print_description(&out_about);
param_lum.print_parametrs (&out_about);
p_distr.print_param (&out_about);
b_distr.print_param (&out_about);
out_about<<"//----------------------------------------------------------//"<<endl;
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime(&rawtime);
out_about<<"// Запушено "<<asctime(timeinfo);
OBStar * ancester;
NeutronStar * descendant;
for (int i = 0; i < number_millenium; i++) {
sun.move_to(T);
for (int j = 0; j < number_stars; j++) {
rand_shift = rand()%500;
ancester = new OBStar (T + rand_shift, &sun);
if (!(i%10000) && j==0) {
cout<<T<<"\t"<<i<<endl;
}
shift = ancester->get_time_on_MS();
shift += ancester->get_t_He ();
if (shift + T + rand_shift < 0) {
ancester->move_to (shift); // На сколько нужно сдвинуть, действительно мы не знаем времени рождения звезды
descendant = new NeutronStar (T + shift + rand_shift, ancester, ¶m_B, &p_distr, &b_distr);
P = descendant->get_P(now/*,¶m_B*/);
out_str << descendant->get_velocity_x()<<endl;
// cout<<P<<endl;
if (descendant->is_pulsar_alive(now) && descendant->is_this_ns() && param_lum.is_beam_on(P)) {
//cout<<"TTT"<<endl;
//cout<<descendant->get_B(now)<<"\t"<<descendant->get_dot_P(now)<<endl;
descendant->move_to(now);
lumin = descendant->is_pulsar_visible(now, &sun_nowaday, &T_copy, ¶m_lum);
if (lumin) {
counter++;
// if (descendant->is_this_ns()) {
// x_ances = ancester->get_position_x();
// y_ances = ancester->get_position_y();
// out_ances<<sqrt(pow(x_ances, 2) + pow(y_ances, 2))<<endl; }
x = descendant->get_position_x();
y = descendant->get_position_y();
z = descendant->get_position_z();
P = descendant->get_P(now/*,¶m_B*/);
dot_P = descendant->get_dot_P(now/*,¶m_B*/);
B = descendant->get_B (now);
dist_to_sun = descendant->get_dist_to_sun(now, &sun_nowaday);
if (dist_to_sun < 10) {
out_p << P<<"\t"<< dot_P<<endl;
}
out_pos<< x<<"\t" << y <<"\t"<< z <<endl;
out_lum<<lumin*1000*pow(dist_to_sun, 2)<<endl;
// out_exper<<P<<"\t"<<P/2./dot_P/365.24/24/3600.<<"\t"<<-(T + shift + rand_shift)<<endl;
out_exper<<P*sqrt(1 + (T + shift + rand_shift)/(P/2./dot_P/365.24/24/3600.))<<endl;
if (B > 1e14) {
n_magnet++;
}
}
}
delete descendant;
}
delete ancester;
}
T += 1000;
}
time (&rawtime);
timeinfo = localtime(&rawtime);
out_about<<"// Закончено "<<asctime(timeinfo);
out_about<<"// За время работы пульсаров замечено "<<counter<<endl;
out_about<<"// За время работы магнетаров замечено "<<n_magnet<<endl;
return 0;
}