27#define cross_product(av,bv) (av).cross(bv)
28#define dot_product(av,bv) (av).dot(bv)
29#define vector_length(v) (v).norm()
30#define normalize_vector(v) (v).normalized()
48 Vec3d& x = particles[0].x;
49 Vec3d& v = particles[0].v;
51 std::cout << 0 <<
" " << time <<
"\t" << x[0] <<
" " << x[1] <<
" " << x[2] <<
"\t"
52 << v[0] <<
" " << v[1] <<
" " << v[2] << std::endl;
76 particles.push_back(p);
79 delete velocity_distribution;
87 char filename_buffer[256];
100 for(
unsigned int i=0;
i<particles.size();
i++) {
116 double latitude = atan2(particles[
i].x[2],particles[
i].x[0]);
117 printf(
"%u %i %lf %lf %lf\n",
i, start_timestep, start_pos, latitude, .5*particles[
i].m *
121 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
122 particles[
i].v =
Vec3d(0,0,0);
126 printf(
"%u %i %lf -5. -1.\n",
i, start_timestep, start_pos);
128 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
129 particles[
i].v =
Vec3d(0,0,0);
145 Vec3d pos(start_x,0,0);
148 double min_B = 99999999999.;
149 for(
double z=-1e7; z<1e7; z+=1e5) {
150 Vec3d candidate_pos(start_x,0,z);
163 char filename_buffer[256];
174 std::cerr <<
"Reading initial particle data from stdin" << std::endl
175 <<
"(format: x y z vx vy vz)" << std::endl;
178 double x0,x1,x2,v0,v1,v2;
179 std::cin >> x0 >> x1 >> x2 >> v0 >> v1 >> v2;
192 for(
unsigned int i=0;
i< particles.size();
i++) {
193 Vec3d& x = particles[
i].x;
194 Vec3d& v = particles[
i].v;
195 std::cout <<
i <<
" " << time <<
"\t" << x[0] <<
" " << x[1] <<
" " << x[2] <<
"\t"
196 << v[0] <<
" " << v[1] <<
" " << v[2] << std::endl;
203 const int num_points = 200;
209 for(
unsigned int i=0;
i< num_points;
i++) {
213 ((double)
i)/num_points *
222 Vec3d pos(x,start_y,0);
237 particles.push_back(p);
242 delete velocity_distribution;
245 char filename_buffer[256];
254 for(
unsigned int i=0;
i<particles.size();
i++) {
262 double y = particles[
i].x[1];
278 if(particles[
i].x[0] < boundary_left) {
283 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
284 particles[
i].v =
Vec3d(0,0,0);
285 }
else if (particles[
i].x[0] > boundary_right) {
291 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
292 particles[
i].v =
Vec3d(0.,0.,0.);
299 transmitted.writeBovAscii(
"transmitted.dat.bov",0,
"transmitted.dat");
301 reflected.writeBovAscii(
"reflected.dat.bov",0,
"reflected.dat");
310 traFile = fopen(
"transmitted.dat",
"w");
311 refFile = fopen(
"reflected.dat",
"w");
319 std::random_device rd;
320 std::mt19937 gen(rd());
328 Real posx = disx(gen);
329 Real posy = disy(gen);
330 Real posz = disz(gen);
331 Vec3d vpos(posx, posy, posz);
342 particles.push_back(p);
345 delete velocity_distribution;
352 char filename_buffer[256];
362 for(
unsigned int i=0;
i<particles.size();
i++) {
370 double x = particles[
i].x[0];
379 fprintf(
traFile,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf\n", time,
380 particles[
i].x[0], particles[
i].x[1], particles[
i].x[2],
381 particles[
i].v[0], particles[
i].v[1], particles[
i].v[2],
386 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
387 particles[
i].v =
Vec3d(0,0,0);
394 fprintf(
refFile,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf\n", time,
395 particles[
i].x[0], particles[
i].x[1], particles[
i].x[2],
396 particles[
i].v[0], particles[
i].v[1], particles[
i].v[2],
401 particles[
i].x =
Vec3d(std::numeric_limits<double>::quiet_NaN(),0.,0.);
402 particles[
i].v =
Vec3d(0.,0.,0.);
424 std::map<std::string,
Scenario*(*)()> scenario_lookup;
432 if(scenario_lookup.find(name) == scenario_lookup.end()) {
433 std::cerr <<
"Error: can't find particle pusher mode \"" << name <<
"\". Aborting." << std::endl;
437 return scenario_lookup[name]();
virtual Particle next_particle()=0
#define normalize_vector(v)
#define dot_product(av, bv)
void writeParticles(const ParticleContainer &p, const char *filename)
std::vector< Particle, aligned_allocator< Particle, 32 > > ParticleContainer
Scenario * createScenario(std::string name)
Scenario * createScenario()
static Distribution *(* distribution)(std::default_random_engine &)
static Real ipshock_transmit
static std::default_random_engine::result_type random_seed
static Real ipshock_reflect
static Real reflect_downstream_boundary
static Real precip_stop_x
static Real reflect_y_scale
static Real precip_inner_boundary
static Real ipshock_inject_y1
static Real precip_start_x
static Real reflect_start_y
static Real ipshock_inject_z1
static std::string output_filename_pattern
static Real reflect_x_offset
static uint64_t num_particles
static Real ipshock_inject_z0
static Real ipshock_inject_x1
static Real ipshock_inject_x0
static Real reflect_upstream_boundary
static Real ipshock_inject_y0
static Real reflect_stop_y
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
LinearHistogram2D reflected
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
LinearHistogram2D transmitted
virtual void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
ParticleContainer initialParticles(Field &E, Field &B, Field &V)