Skip to content

Commit 60dc1c0

Browse files
simplified pgen
1 parent cd91e9e commit 60dc1c0

1 file changed

Lines changed: 47 additions & 102 deletions

File tree

setups/srpic/1d_polar_cap/pgen.hpp

Lines changed: 47 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -17,99 +17,47 @@ namespace user {
1717

1818
template <Dimension D>
1919
struct InitFields {
20-
InitFields(real_t b0, real_t angle, real_t Omega, real_t d0, real_t rho0, real_t r, real_t bp)
21-
: b0 { b0 }
22-
, angle { angle }
23-
, Omega { Omega }
24-
, skindepth0 { d0 }
25-
, larmor0 { rho0 }
26-
, R { r }
27-
, bp { bp } {}
20+
InitFields(real_t b0_, real_t rho_GJ_)
21+
: b0 { b0_ }
22+
, rho_GJ { rho_GJ_ } {}
2823

2924
Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t {
30-
return b0 * math::cos(angle);
31-
}
32-
33-
Inline auto bx2(const coord_t<D>& x_Ph) const -> real_t {
34-
return bp;
35-
}
36-
37-
Inline auto bx3(const coord_t<D>& x_Ph) const -> real_t {
38-
return b0 * math::sin(angle);
25+
return b0;
3926
}
4027

4128
Inline auto ex1(const coord_t<D>& x_Ph) const -> real_t {
42-
// return Omega * b0 * (-math::sin(angle) * R + TWO * SQR(skindepth0) * x_Ph[0] / larmor0);
43-
return ZERO;
44-
}
45-
46-
Inline auto ex3(const coord_t<D>& x_Ph) const -> real_t {
47-
return -Omega * bx1(x_Ph) * R;
29+
return rho_GJ * x_Ph[0];
30+
//return ZERO;
4831
}
4932

5033
private:
51-
const real_t b0, angle, R, Omega, skindepth0, larmor0, bp;
34+
const real_t b0, rho_GJ;
5235
};
5336

5437
template <Dimension D>
5538
struct MFields {
56-
MFields(real_t b0, real_t angle, real_t omega, real_t r, real_t bp)
57-
: b0 { b0 }
58-
, angle { angle }
59-
, Omega { omega }
60-
, R { r }
61-
, bp { bp } {}
39+
MFields(real_t b0_)
40+
: b0 { b0_ } {}
6241

6342
Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t {
64-
return b0 * math::cos(angle);
65-
}
66-
67-
Inline auto bx2(const coord_t<D>& x_Ph) const -> real_t {
68-
return bp;
69-
}
70-
71-
Inline auto bx3(const coord_t<D>& x_Ph) const -> real_t {
72-
return b0 * math::sin(angle);
43+
return b0;
7344
}
7445

7546
Inline auto ex1(const coord_t<D>& x_Ph) const -> real_t {
7647
return ZERO;
7748
}
7849

79-
Inline auto ex3(const coord_t<D>& x_Ph) const -> real_t {
80-
return -Omega * bx1(x_Ph) * R;
81-
}
82-
83-
8450
private:
85-
const real_t b0, angle, Omega, R, bp;
51+
const real_t b0;
8652
};
8753

8854
template <Dimension D>
8955
struct DriveFields : public InitFields<D> {
90-
DriveFields(real_t time, real_t b0, real_t angle, real_t omega, real_t r, real_t d0, real_t rho0, real_t bp)
91-
: InitFields<D> { b0, angle, omega, d0, rho0, r, bp}
92-
, time { time }
93-
, Omega { omega }
94-
, R { r }{}
56+
DriveFields(real_t time, real_t b0_)
57+
: InitFields<D> { b0_, ZERO} {}
9558

9659
using InitFields<D>::bx1;
97-
using InitFields<D>::bx3;
98-
99-
Inline auto ex1(const coord_t<D>& x_Ph) const -> real_t {
100-
return -Omega * bx3(x_Ph) * R;
101-
}
102-
103-
Inline auto ex2(const coord_t<D>& x_Ph) const -> real_t {
104-
return Omega * bx1(x_Ph) * R;
105-
}
106-
107-
Inline auto ex3(const coord_t<D>&) const -> real_t {
108-
return ZERO;
109-
}
11060

111-
private:
112-
const real_t time, Omega, R;
11361
};
11462

11563
template <SimEngine::type S, class M>
@@ -126,67 +74,64 @@ namespace user {
12674
using arch::ProblemGenerator<S, M>::C;
12775
using arch::ProblemGenerator<S, M>::params;
12876

129-
const real_t B0, angle, R, Omega, skindepth0, larmor0, bp;
77+
const real_t b0, Omega, skindepth0, larmor0;
13078
const real_t temp;
13179
const real_t drift_u_1, drift_u_2;
13280
const real_t j0;
13381
InitFields<D> init_flds;
13482

13583
inline PGen(const SimulationParams& p, const Metadomain<S, M>& m)
13684
: arch::ProblemGenerator<S, M>(p)
137-
, B0 { p.template get<real_t>("setup.B0", ONE) }
138-
, R { p.template get<real_t>("setup.R") }
85+
, b0 { p.template get<real_t>("setup.B0", ONE) }
13986
, Omega { static_cast<real_t>(constant::TWO_PI) /
14087
p.template get<real_t>("setup.period", ONE) }
141-
, angle { p.template get<real_t>("setup.angle", ZERO) }
14288
, skindepth0 { p.template get<real_t>("scales.skindepth0") }
14389
, larmor0 { p.template get<real_t>("scales.larmor0") }
144-
, bp { p.template get<real_t>("setup.Bp") }
14590
, temp { p.template get<real_t>("setup.temp") }
14691
, drift_u_1 { p.template get<real_t>("setup.drift_u_1") }
14792
, drift_u_2 { p.template get<real_t>("setup.drift_u_2") }
14893
, j0 { p.template get<real_t>("setup.j0") }
149-
, init_flds { B0, angle, Omega, skindepth0, larmor0, R, bp } {}
94+
, init_flds { b0, TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0 } {}
15095

15196
inline PGen() {}
15297

15398
auto AtmFields(real_t time) const -> DriveFields<D> {
154-
return DriveFields<D> { time, B0, angle, Omega, R, skindepth0, larmor0, bp };
99+
return DriveFields<D> { time, b0 };
155100
}
156101

157102
auto MatchFields(real_t) const -> MFields<D> {
158-
return MFields<D> { B0, angle, Omega, R, bp };
103+
return MFields<D> { b0 };
159104
}
160105

161-
inline void InitPrtls(Domain<S, M>& local_domain) {
162-
const auto energy_dist_1 = arch::Maxwellian<S, M>(local_domain.mesh.metric,
163-
local_domain.random_pool,
164-
temp,
165-
-drift_u_1,
166-
in::x1);
167-
const auto energy_dist_2 = arch::Maxwellian<S, M>(local_domain.mesh.metric,
168-
local_domain.random_pool,
169-
temp,
170-
drift_u_2,
171-
in::x1);
172-
const auto injector_1 = arch::UniformInjector<S, M, arch::Maxwellian>(
173-
energy_dist_1,
174-
{ 1, 1 });
175-
const auto injector_2 = arch::UniformInjector<S, M, arch::Maxwellian>(
176-
energy_dist_2,
177-
{ 2, 2 });
178-
arch::InjectUniform<S, M, arch::UniformInjector<S, M, arch::Maxwellian>>(
179-
params,
180-
local_domain,
181-
injector_1,
182-
ONE);
183-
arch::InjectUniform<S, M, arch::UniformInjector<S, M, arch::Maxwellian>>(
184-
params,
185-
local_domain,
186-
injector_2,
187-
ONE + j0);
188-
}
189-
};
106+
// inline void InitPrtls(Domain<S, M>& local_domain) {
107+
// const auto energy_dist_1 = arch::Maxwellian<S, M>(local_domain.mesh.metric,
108+
// local_domain.random_pool,
109+
// temp,
110+
// -drift_u_1,
111+
// in::x1);
112+
// const auto energy_dist_2 = arch::Maxwellian<S, M>(local_domain.mesh.metric,
113+
// local_domain.random_pool,
114+
// temp,
115+
// drift_u_2,
116+
// in::x1);
117+
// const auto injector_1 = arch::UniformInjector<S, M, arch::Maxwellian>(
118+
// energy_dist_1,
119+
// { 1, 1 });
120+
// const auto injector_2 = arch::UniformInjector<S, M, arch::Maxwellian>(
121+
// energy_dist_2,
122+
// { 2, 2 });
123+
// arch::InjectUniform<S, M, arch::UniformInjector<S, M, arch::Maxwellian>>(
124+
// params,
125+
// local_domain,
126+
// injector_1,
127+
// ONE);
128+
// arch::InjectUniform<S, M, arch::UniformInjector<S, M, arch::Maxwellian>>(
129+
// params,
130+
// local_domain,
131+
// injector_2,
132+
// ONE + j0);
133+
// }
134+
// };
190135

191136
} // namespace user
192137

0 commit comments

Comments
 (0)