// // 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 using namespace amrex; void PhysicalParticleContainer::InitData() { BL_PROFILE("SPC::InitData()"); // species_id 0 : the electrons of the plasma // 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 { amrex::Abort("PhysicalParticleContainer::InitData(): species_id must be 0 or 1"); } const int lev = 0; const Geometry& geom = Geom(lev); const Real* dx = geom.CellSize(); Real weight, gamma, uz; Real particle_xmin, particle_xmax, particle_ymin, particle_ymax, particle_zmin, particle_zmax; int n_part_per_cell; { ParmParse pp("lwfa"); // Calculate the particle weight n_part_per_cell = 1; pp.query("num_particles_per_cell", n_part_per_cell); weight = 1.e22; if (species_id == 0) { pp.query("plasma_density", 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 // Calculate the limits between which the particles will be initialized particle_xmin = particle_ymin = particle_zmin = -2.e-5; particle_xmax = particle_ymax = particle_zmax = 2.e-5; if (species_id == 0) { pp.query("plasma_xmin", particle_xmin); pp.query("plasma_xmax", particle_xmax); pp.query("plasma_ymin", particle_ymin); pp.query("plasma_ymax", particle_ymax); pp.query("plasma_zmin", particle_zmin); pp.query("plasma_zmax", particle_zmax); } uz = 0.; uz *= PhysConst::c; } std::array attribs; attribs.fill(0.0); attribs[PIdx::w ] = weight; attribs[PIdx::uz] = uz; 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= particle_xmax || x < particle_xmin || y >= particle_ymax || y < particle_ymin || z >= particle_zmax || z < particle_zmin ) { continue; } else { AddOneParticle(lev, grid_id, tile_id, x, y, z, attribs); } } } } }