48 RP::add(
"Distributions.rho1",
"Number density, first peak (m^-3)", 0.0);
49 RP::add(
"Distributions.rho2",
"Number density, second peak (m^-3)", 0.0);
50 RP::add(
"Distributions.Tx1",
"Temperature, first peak (K)", 0.0);
51 RP::add(
"Distributions.Tx2",
"Temperature, second peak (K)", 0.0);
52 RP::add(
"Distributions.Ty1",
"Temperature, first peak (K)", 0.0);
53 RP::add(
"Distributions.Ty2",
"Temperature, second peak (K)", 0.0);
54 RP::add(
"Distributions.Tz1",
"Temperature, first peak (K)", 0.0);
55 RP::add(
"Distributions.Tz2",
"Temperature, second peak (K)", 0.0);
56 RP::add(
"Distributions.Vx1",
"Bulk velocity x component, first peak (m/s)", 0.0);
57 RP::add(
"Distributions.Vx2",
"Bulk velocity x component, second peak (m/s)", 0.0);
58 RP::add(
"Distributions.Vy1",
"Bulk velocity y component, first peak (m/s)", 0.0);
59 RP::add(
"Distributions.Vy2",
"Bulk velocity y component, second peak (m/s)", 0.0);
60 RP::add(
"Distributions.Vz1",
"Bulk velocity z component, first peak (m/s)", 0.0);
61 RP::add(
"Distributions.Vz2",
"Bulk velocity z component, second peak (m/s)", 0.0);
62 RP::add(
"Distributions.Bx",
"Magnetic field x component (T)", 0.0);
63 RP::add(
"Distributions.By",
"Magnetic field y component (T)", 0.0);
64 RP::add(
"Distributions.Bz",
"Magnetic field z component (T)", 0.0);
65 RP::add(
"Distributions.dBx",
"Magnetic field x component cosine perturbation amplitude (T)", 0.0);
66 RP::add(
"Distributions.dBy",
"Magnetic field y component cosine perturbation amplitude (T)", 0.0);
67 RP::add(
"Distributions.dBz",
"Magnetic field z component cosine perturbation amplitude (T)", 0.0);
68 RP::add(
"Distributions.magXPertAbsAmp",
"Absolute amplitude of the random magnetic perturbation along x (T)", 1.0e-9);
69 RP::add(
"Distributions.magYPertAbsAmp",
"Absolute amplitude of the random magnetic perturbation along y (T)", 1.0e-9);
70 RP::add(
"Distributions.magZPertAbsAmp",
"Absolute amplitude of the random magnetic perturbation along z (T)", 1.0e-9);
71 RP::add(
"Distributions.rho1PertAbsAmp",
"Absolute amplitude of the density perturbation, first peak", 0.1);
72 RP::add(
"Distributions.rho2PertAbsAmp",
"Absolute amplitude of the density perturbation, second peak", 0.1);
79 RP::add(
"Distributions.lambda",
"B cosine perturbation wavelength (m)", 0.0);
88 std::cerr <<
"The selected project does not support multiple particle populations! Aborting in " << __FILE__ <<
" line " << __LINE__ << std::endl;
92 RP::get(
"Distributions.rho1", this->
rho[0]);
93 RP::get(
"Distributions.rho2", this->
rho[1]);
94 RP::get(
"Distributions.Tx1", this->
Tx[0]);
95 RP::get(
"Distributions.Tx2", this->
Tx[1]);
96 RP::get(
"Distributions.Ty1", this->
Ty[0]);
97 RP::get(
"Distributions.Ty2", this->
Ty[1]);
98 RP::get(
"Distributions.Tz1", this->
Tz[0]);
99 RP::get(
"Distributions.Tz2", this->
Tz[1]);
100 RP::get(
"Distributions.Vx1", this->
Vx[0]);
101 RP::get(
"Distributions.Vx2", this->
Vx[1]);
102 RP::get(
"Distributions.Vy1", this->
Vy[0]);
103 RP::get(
"Distributions.Vy2", this->
Vy[1]);
104 RP::get(
"Distributions.Vz1", this->
Vz[0]);
105 RP::get(
"Distributions.Vz2", this->
Vz[1]);
106 RP::get(
"Distributions.Bx", this->
Bx);
107 RP::get(
"Distributions.By", this->
By);
108 RP::get(
"Distributions.Bz", this->
Bz);
112 RP::get(
"Distributions.rho1PertAbsAmp", this->
rhoPertAbsAmp[0]);
113 RP::get(
"Distributions.rho2PertAbsAmp", this->
rhoPertAbsAmp[1]);
120 RP::get(
"Distributions.dBx", this->
dBx);
121 RP::get(
"Distributions.dBy", this->
dBy);
122 RP::get(
"Distributions.dBz", this->
dBz);
123 RP::get(
"Distributions.lambda", this->
lambda);
128 const uint nRequested
137 creal scaledVx1 = this->
Vx[1] * relx;
138 creal scaledVy1 = this->
Vy[1] * rely;
139 creal scaledVz1 = this->
Vz[1] * relz;
144 const Real initT0x = this->
Tx[0];
145 const Real initT0y = this->
Ty[0];
146 const Real initT0z = this->
Tz[0];
147 const Real initT1x = this->
Tx[1];
148 const Real initT1y = this->
Ty[1];
149 const Real initT1z = this->
Tz[1];
150 const Real initV0X = this->
Vx[0];
151 const Real initV0Y = this->
Vy[0];
152 const Real initV0Z = this->
Vz[0];
153 const Real initV1X = this->
Vx[1];
154 const Real initV1Y = this->
Vy[1];
155 const Real initV1Z = this->
Vz[1];
174 vmesh->getBlockInfo(blockGID,&blockCoords[0]);
175 creal vxBlock = blockCoords[0];
176 creal vyBlock = blockCoords[1];
177 creal vzBlock = blockCoords[2];
178 creal dvxCell = blockCoords[3];
179 creal dvyCell = blockCoords[4];
180 creal dvzCell = blockCoords[5];
182 Real vx = vxBlock + (
i+0.5)*dvxCell - initV0X;
183 Real vy = vyBlock + (
j+0.5)*dvyCell - initV0Y;
184 Real vz = vzBlock + (
k+0.5)*dvzCell - initV0Z;
186 vx = vxBlock + (
i+0.5)*dvxCell - initV1X;
187 vy = vyBlock + (
j+0.5)*dvyCell - initV1Y;
188 vz = vzBlock + (
k+0.5)*dvzCell - initV1Z;
212 creal scaledVx1 = this->
Vx[1] * relx;
213 creal scaledVy1 = this->
Vy[1] * rely;
214 creal scaledVz1 = this->
Vz[1] * relz;
219 const Real initT0x = this->
Tx[0];
220 const Real initT0y = this->
Ty[0];
221 const Real initT0z = this->
Tz[0];
222 const Real initT1x = this->
Tx[1];
223 const Real initT1y = this->
Ty[1];
224 const Real initT1z = this->
Tz[1];
225 const Real initV0X = this->
Vx[0];
226 const Real initV0Y = this->
Vy[0];
227 const Real initV0Z = this->
Vz[0];
228 const Real initV1X = this->
Vx[1];
229 const Real initV1Y = this->
Vy[1];
230 const Real initV1Z = this->
Vz[1];
233 Real vx = vx_in - initV0X;
234 Real vy = vy_in - initV0Y;
235 Real vz = vz_in - initV0Z;
237 vx = vx_in - initV1X;
238 vy = vy_in - initV1Y;
239 vz = vz_in - initV1Z;
245 std::default_random_engine rndState;
247 for (uint
i=0;
i<2;
i++) {
267 const auto dBx_l = this->
dBx;
268 const auto dBy_l = this->
dBy;
269 const auto dBz_l = this->
dBz;
270 const auto lambda_l = this->
lambda;
276 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
277 phiprof::initializeTimer(
"setProjectBField-loop"), technical,
278 [=](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
279 const std::array<Real, 3> xyz = coordinates.getPhysicalCoords(stencil.i, stencil.j, stencil.k);
280 auto& cell = perb[stencil.ooo()];
282 const auto seedmodifier = coordinates.globalIDFromLocalCoordinates(stencil.i, stencil.j, stencil.k);
283 std::default_random_engine rndState_l;
284 rndState_l.seed(
seed+seedmodifier);
286 rndBuffer[0] = std::uniform_real_distribution<>(-0.5,0.5)(rndState_l);
287 rndBuffer[1] = std::uniform_real_distribution<>(-0.5,0.5)(rndState_l);
288 rndBuffer[2] = std::uniform_real_distribution<>(-0.5,0.5)(rndState_l);
290 cell[
fsgrids::bfield::PERBX] = dBx_l * cos(2.0 * M_PI * xyz[0] / lambda_l) + magXPertAbsAmp_l * rndBuffer[0];
291 cell[
fsgrids::bfield::PERBY] = dBy_l * sin(2.0 * M_PI * xyz[0] / lambda_l) + magYPertAbsAmp_l * rndBuffer[1];
292 cell[
fsgrids::bfield::PERBZ] = dBz_l * cos(2.0 * M_PI * xyz[0] / lambda_l) + magZPertAbsAmp_l * rndBuffer[2];
303 vector<std::array<Real, 3>> centerPoints;
307 creal scaledVx1 = this->
Vx[1] * relx;
308 creal scaledVy1 = this->
Vy[1] * rely;
309 creal scaledVz1 = this->
Vz[1] * relz;
310 std::array<Real, 3> point0 {{this->
Vx[0], this->
Vy[0], this->
Vz[0]}};
311 std::array<Real, 3> point1 {{scaledVx1, scaledVy1, scaledVz1}};
312 centerPoints.push_back(point0);
313 centerPoints.push_back(point1);
#define ARCH_INNER_BODY(...)
void setBackgroundField(const FieldFunction &bgFunction, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, bool append)
void initialize(const double Bx, const double By, const double Bz)
virtual Realf probePhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, Real vx_in, Real vy_in, Real vz_in) const 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
virtual void getParameters(void) override
virtual Realf fillPhaseSpace(spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const override
virtual bool initialize(void) override
static void addParameters(void)
virtual void setProjectBField(fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid) override
Real getRandomNumber(std::default_random_engine &randGen) const
virtual bool initialize()
virtual void getParameters()
void setRandomCellSeed(spatial_cell::SpatialCell *cell, 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 TriMaxwellianPhaseSpaceDensity(creal &vx, creal &vy, creal &vz, creal &Tx, creal &Ty, creal &Tz, creal &rho, creal &mass)
std::vector< species::Species > particleSpecies