43 RP::add(
"KHB.P",
"Constant total pressure (thermal+magnetic), used to determine the temperature profile (Pa)", 0.0);
44 RP::add(
"KHB.rho1",
"Number density, this->TOP state (m^-3)", 0.0);
45 RP::add(
"KHB.rho2",
"Number density, this->BOTTOM state (m^-3)", 0.0);
46 RP::add(
"KHB.Vx1",
"Bulk velocity x component, this->TOP state (m/s)", 0.0);
47 RP::add(
"KHB.Vx2",
"Bulk velocity x component, this->BOTTOM state (m/s)", 0.0);
48 RP::add(
"KHB.Vy1",
"Bulk velocity y component, this->TOP state (m/s)", 0.0);
49 RP::add(
"KHB.Vy2",
"Bulk velocity y component, this->BOTTOM state (m/s)", 0.0);
50 RP::add(
"KHB.Vz1",
"Bulk velocity z component, this->TOP state (m/s)", 0.0);
51 RP::add(
"KHB.Vz2",
"Bulk velocity z component, this->BOTTOM state (m/s)", 0.0);
52 RP::add(
"KHB.Bx1",
"Magnetic field x component, this->TOP state (T)", 0.0);
53 RP::add(
"KHB.Bx2",
"Magnetic field x component, this->BOTTOM state (T)", 0.0);
54 RP::add(
"KHB.By1",
"Magnetic field y component, this->TOP state (T)", 0.0);
55 RP::add(
"KHB.By2",
"Magnetic field y component, this->BOTTOM state (T)", 0.0);
56 RP::add(
"KHB.Bz1",
"Magnetic field z component, this->TOP state (T)", 0.0);
57 RP::add(
"KHB.Bz2",
"Magnetic field z component, this->BOTTOM state (T)", 0.0);
58 RP::add(
"KHB.lambda",
"Initial perturbation wavelength (m)", 0.0);
59 RP::add(
"KHB.amp",
"Initial velocity perturbation amplitude (m s^-1)", 0.0);
60 RP::add(
"KHB.offset",
"Boundaries offset from 0 (m)", 0.0);
61 RP::add(
"KHB.transitionWidth",
"Width of tanh transition for all changing values", 0.0);
62 RP::add(
"KHB.harmonics",
"Number of harmonics of lambda included in the initial perturbation", 0);
63 RP::add(
"KHB.randomPhase",
"If true, set a random phase for each mode of the initial perturbation. Seed set via project_common.seed", 0);
71 std::cerr <<
"The selected project does not support multiple particle populations! Aborting in " << __FILE__ <<
" line " << __LINE__ << std::endl;
75 RP::get(
"KHB.P", this->
P);
76 RP::get(
"KHB.rho1", this->
rho[this->
TOP]);
77 RP::get(
"KHB.rho2", this->
rho[this->
BOTTOM]);
78 RP::get(
"KHB.Vx1", this->
Vx[this->TOP]);
79 RP::get(
"KHB.Vx2", this->
Vx[this->BOTTOM]);
80 RP::get(
"KHB.Vy1", this->
Vy[this->TOP]);
81 RP::get(
"KHB.Vy2", this->
Vy[this->BOTTOM]);
82 RP::get(
"KHB.Vz1", this->
Vz[this->TOP]);
83 RP::get(
"KHB.Vz2", this->
Vz[this->BOTTOM]);
84 RP::get(
"KHB.Bx1", this->
Bx[this->TOP]);
85 RP::get(
"KHB.Bx2", this->
Bx[this->BOTTOM]);
86 RP::get(
"KHB.By1", this->
By[this->TOP]);
87 RP::get(
"KHB.By2", this->
By[this->BOTTOM]);
88 RP::get(
"KHB.Bz1", this->
Bz[this->TOP]);
89 RP::get(
"KHB.Bz2", this->
Bz[this->BOTTOM]);
90 RP::get(
"KHB.lambda", this->
lambda);
91 RP::get(
"KHB.amp", this->
amp);
92 RP::get(
"KHB.offset", this->
offset);
94 RP::get(
"KHB.harmonics", this->
harmonics);
104 return 0.5 * ((top-bottom) * (
108 return 0.5 * ((top-bottom) * tanh(x/this->
transitionWidth) + top+bottom);
119 Real Vy =
profile(this->Vy[this->BOTTOM], this->Vy[this->TOP], x);
120 Real Vz =
profile(this->Vz[this->BOTTOM], this->Vz[this->TOP], x);
124 std::default_random_engine rndState;
134 if (this->
offset != 0.0) {
141 vector<std::array<Real, 3> > centerPoints;
142 std::array<Real, 3> V0 {{
Vx,
Vy,
Vz}};
143 centerPoints.push_back(V0);
149 const uint nRequested
159 std::array<Real, 3> initV0 = this->
getV0(x, y, z, popID)[0];
160 const Real initV0X = initV0[0];
161 const Real initV0Y = initV0[1];
162 const Real initV0Z = initV0[2];
166 creal Bx =
profile(this->Bx[this->BOTTOM], this->Bx[this->TOP], x);
167 creal By =
profile(this->By[this->BOTTOM], this->By[this->TOP], x);
168 creal Bz =
profile(this->Bz[this->BOTTOM], this->Bz[this->TOP], x);
188 vmesh->getBlockInfo(blockGID,&blockCoords[0]);
189 creal vxBlock = blockCoords[0];
190 creal vyBlock = blockCoords[1];
191 creal vzBlock = blockCoords[2];
192 creal dvxCell = blockCoords[3];
193 creal dvyCell = blockCoords[4];
194 creal dvzCell = blockCoords[5];
196 creal vx = vxBlock + (
i+0.5)*dvxCell - initV0X;
197 creal vy = vyBlock + (
j+0.5)*dvyCell - initV0Y;
198 creal vz = vzBlock + (
k+0.5)*dvzCell - initV0Z;
222 std::array<Real, 3> initV0 = this->
getV0(x, y, z, popID)[0];
223 const Real initV0X = initV0[0];
224 const Real initV0Y = initV0[1];
225 const Real initV0Z = initV0[2];
229 creal Bx =
profile(this->Bx[this->BOTTOM], this->Bx[this->TOP], x);
230 creal By =
profile(this->By[this->BOTTOM], this->By[this->TOP], x);
231 creal Bz =
profile(this->Bz[this->BOTTOM], this->Bz[this->TOP], x);
234 creal vx = vx_in - initV0X;
235 creal vy = vy_in - initV0Y;
236 creal vz = vz_in - initV0Z;
250 const auto Bx_l = this->
Bx;
251 const auto By_l = this->
By;
252 const auto Bz_l = this->
Bz;
253 const auto BOTTOM_l = this->
BOTTOM;
254 const auto TOP_l = this->
TOP;
256 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
257 phiprof::initializeTimer(
"setProjectBField-loop"), technical,
258 [=, *
this](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
259 const std::array<Real, 3> xyz = coordinates.getPhysicalCoords(stencil.i, stencil.j, stencil.k);
260 const std::array<Real, 3> gridSpacing = coordinates.physicalGridSpacing;
261 auto& cell = perb[stencil.ooo()];
264 profile(Bx_l[BOTTOM_l], Bx_l[TOP_l], xyz[0] + 0.5 * gridSpacing[0]);
266 profile(By_l[BOTTOM_l], By_l[TOP_l], xyz[0] + 0.5 * gridSpacing[0]);
268 profile(Bz_l[BOTTOM_l], Bz_l[TOP_l], xyz[0] + 0.5 * gridSpacing[0]);
#define ARCH_INNER_BODY(...)
void setBackgroundFieldToZero(FieldSolverGrid &fsgrid, fsgrids::technicalspan technical, fsgrids::bgbspan bgb)
virtual Realf probePhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, Real vx_in, Real vy_in, Real vz_in) const override
virtual void setProjectBField(fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid) override
virtual std::vector< std::array< Real, 3 > > getV0(creal x, creal y, creal z, const uint popID) const override
Return a vector containing the velocity coordinate of the centre of each ion population in the distri...
virtual void calcCellParameters(spatial_cell::SpatialCell *cell, creal &t) override
Real profile(creal top, creal bottom, creal x) const
static void addParameters(void)
virtual bool initialize(void) override
virtual Realf fillPhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const override
virtual void getParameters(void) override
Real getRandomNumber(std::default_random_engine &randGen) const
virtual bool initialize()
virtual void getParameters()
void setRandomSeed(uint64_t seedModifier, std::default_random_engine &randGen) const
vmesh::VelocityMesh * get_velocity_mesh(const size_t &popID)
vmesh::VelocityBlockContainer * get_velocity_blocks(const size_t &popID)
std::array< Real, CellParams::N_SPATIAL_CELL_PARAMS > parameters
vmesh::VelocityBlockContainer * dev_get_velocity_blocks(const size_t &popID)
vmesh::VelocityMesh * dev_get_velocity_mesh(const size_t &popID)
ARCH_HOSTDEV Realf * getData()
fsgrid::FsGrid< FS_STENCIL_WIDTH > FieldSolverGrid
ObjectWrapper & getObjectWrapper()
static void parallel_reduce(const uint(&limits)[NDim], Lambda loop_body, T &sum)
std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > perbspan
std::span< technical > technicalspan
std::span< std::array< Real, bgbfield::N_BGB > > bgbspan
ARCH_HOSTDEV Realf MaxwellianPhaseSpaceDensity(creal &vx, creal &vy, creal &vz, creal &T, creal &rho, creal &mass)
std::vector< species::Species > particleSpecies