// // Each problem must have its own version of PhysicalParticleContainer::InitData() // to initialize the particle data. It must also initialize charge and mass. // #include #include #include #include #include using namespace amrex; void PhysicalParticleContainer::InitData() { BL_PROFILE("PPC::InitData()"); // species_id 0 : electrons // species_id 1 : Hydrogen ions // Note: the ions of the plasma are implicitly motionless, and so are not part of the simulation if (species_id == 0) { charge = -PhysConst::q_e; mass = PhysConst::m_e; } else { charge = PhysConst::q_e; mass = PhysConst::m_p; } const int lev = 0; const Geometry& geom = Geom(lev); const Real* dx = geom.CellSize(); Real weight, u_th, ux_m, uy_m, uz_m; Real particle_shift_x, particle_shift_y, particle_shift_z; int n_part_per_cell; { ParmParse pp("uniform_plasma"); n_part_per_cell = 1; pp.query("num_particles_per_cell", n_part_per_cell); weight = 1.e25; pp.query("n_e", weight); #if BL_SPACEDIM==3 weight *= dx[0]*dx[1]*dx[2]/n_part_per_cell; #elif BL_SPACEDIM==2 weight *= dx[0]*dx[1]/n_part_per_cell; #endif u_th = 0.; ux_m = 0.; uy_m = 0.; uz_m = 0.; pp.query("u_th", u_th); pp.query("ux_m", ux_m); pp.query("uy_m", uy_m); pp.query("uz_m", uz_m); u_th *= PhysConst::c; ux_m *= PhysConst::c; uy_m *= PhysConst::c; uz_m *= PhysConst::c; } std::array attribs; attribs.fill(0.0); attribs[PIdx::w ] = weight; // Initialize random generator for normal distribution std::default_random_engine generator; std::normal_distribution velocity_distribution(0.0, u_th); for (MFIter mfi = MakeMFIter(lev); mfi.isValid(); ++mfi) { const Box& tile_box = mfi.tilebox(); RealBox tile_real_box { tile_box, dx, geom.ProbLo() }; const int grid_id = mfi.index(); const int tile_id = mfi.LocalTileIndex(); const auto& boxlo = tile_box.smallEnd(); for (IntVect iv = tile_box.smallEnd(); iv <= tile_box.bigEnd(); tile_box.next(iv)) { for (int i_part=0; i_part