29 using namespace swarm;
33 int count_running = 0;
34 for(
int i = 0; i < ens.
nsys() ; i++)
35 if( ens[i].is_disabled() ) count_running++;
64 int nsys = cfg.
require(
"nsys",0);
65 int nbod = cfg.
require(
"nbod",0);
66 double spacing_factor = cfg.
optional(
"spacing_factor", 1.4 );
67 double planet_mass = cfg.
optional(
"planet_mass" , .001 );
68 double ejection_factor = cfg.
optional(
"ejection_factor", 1.0/sqrt(2) );
74 for(
unsigned int sys=0;sys<ens.
nsys();++sys)
78 double x=0, y=0, z=0, vx=0, vy=0, vz=0;
79 ens.set_body(sys, 0, mass_sun, x, y, z, vx, vy, vz);
82 for(
unsigned int bod=1;bod<ens.
nbod();++bod)
84 double rmag = pow( spacing_factor ,
int(bod-1));
85 double vmag = sqrt(2*mass_sun/rmag) * ejection_factor ;
86 double theta = (2.*M_PI*rand())/static_cast<double>(RAND_MAX);
87 x = rmag*cos(theta); y = rmag*sin(theta); z = 0;
88 vx = -vmag*sin(theta); vy = vmag*cos(theta); vz = 0.;
91 ens.set_body(sys, bod, planet_mass , x, y, z, vx, vy, vz);
93 ens[sys].set_active();
101 return energy_conservation_error_range(ens,reference_ensemble).max;
105 energy_init(reference_ensemble.
nsys())
106 ,energy_final(ens.
nsys())
115 return ensemble::range_t::calculate( deltaE.begin(), deltaE.end() );
121 int nsystems = cfg.
optional(
"nsys",1000);
122 int nbodypersystem = cfg.
optional(
"nbod",3);
129 if(!(nsystems>=1)||!(nsystems<=256000)) valid =
false;
130 if(!(nbodypersystem>=3)||!(nbodypersystem<=MAX_NBODIES)) valid =
false;
136 o <<
"# Integrator:\t" << cfg[
"integrator"] <<
"\n"
137 <<
"# Time step\t" << cfg[
"time_step"] <<
"\n"
138 <<
"# Destination time\t" << cfg[
"destination_time"] <<
"\n"
139 <<
"# Min time step\t" << cfg[
"min_time_step"] <<
"\n"
140 <<
"# Max time step\t" << cfg[
"max_time_step"] <<
"\n"
141 <<
"# No. Systems\t" << cfg[
"nsys"] <<
"\n"
142 <<
"# No. Bodies\t" << cfg[
"nbod"] <<
"\n"
151 cfg[
"integrator"] =
"hermite_cpu";
152 cfg[
"time_step"] =
"0.001";
153 cfg[
"log_writer"] =
"null";
159 if(r.min-r.max < 1e-11)
160 return o << r.median;
162 return o << r.median <<
"[" << (r.min-r.median) <<
"," << (r.max-r.median) <<
"] ";
168 pos_diff = vel_diff = time_diff = 0;
170 for(
int i = 0; i < e1.
nsys(); i++) {
171 for(
int j = 0; j < e1.
nbod() ; j++){
175 square ( e1[i][j][0].pos() - e2[i][j][0].pos() )
176 +
square ( e1[i][j][1].pos() - e2[i][j][1].pos() )
177 +
square ( e1[i][j][2].pos() - e2[i][j][2].pos() ) ) ;
181 square ( e1[i][j][0].pos() + e2[i][j][0].pos() )
182 +
square ( e1[i][j][1].pos() + e2[i][j][1].pos() )
183 +
square ( e1[i][j][2].pos() + e2[i][j][2].pos() ) ) / 2.0 ;
187 square ( e1[i][j][0].vel() - e2[i][j][0].vel() )
188 +
square ( e1[i][j][1].vel() - e2[i][j][1].vel() )
189 +
square ( e1[i][j][2].vel() - e2[i][j][2].vel() ) ) ;
193 square ( e1[i][j][0].vel() + e2[i][j][0].vel() )
194 +
square ( e1[i][j][1].vel() + e2[i][j][1].vel() )
195 +
square ( e1[i][j][2].vel() + e2[i][j][2].vel() ) ) / 2.0 ;
197 if ( dp > pos_diff ) pos_diff = dp;
198 if ( dv > vel_diff ) vel_diff = dv;
203 double dt = fabs(e1[i].time() - e2[i].time())
204 /(e1[i].time() + e2[i].time())*2;
205 if ( dt > time_diff ) time_diff = dt;