Skip to content

Commit 63017f2

Browse files
update pgen
1 parent 38b5e4f commit 63017f2

1 file changed

Lines changed: 45 additions & 42 deletions

File tree

setups/srpic/1d_polar_cap/pgen.hpp

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ namespace user {
1818

1919
template <Dimension D>
2020
struct InitFields {
21-
InitFields(real_t b0_, real_t rho_GJ_, real_t xsurf_, real_t ds_)
21+
InitFields(real_t b0_, real_t rho_GJ_, real_t l_atm_, real_t ds_)
2222
: b0 { b0_ }
2323
, rho_GJ { rho_GJ_ }
24-
, xsurf { xsurf_ }
24+
, l_atm { l_atm_ }
2525
, ds { ds_ }{}
2626

2727
Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t {
2828
return b0;
2929
}
3030

3131
Inline auto ex1(const coord_t<D>& x_Ph) const -> real_t {
32-
return -rho_GJ * (x_Ph[0] +
33-
0.03 * ds * math::log(0.01 + math::exp((xsurf + 0.8 * ds - x_Ph[0]) / 0.03 / ds)) -
34-
0.03 * ds * math::log(0.01 + math::exp((0.8 * ds) / 0.03 / ds)) - xsurf);
32+
//return -rho_GJ * (x_Ph[0] + 0.03 * ds * math::log(0.01 + math::exp(l_atm + 0.8 * ds - x_Ph[0]) / 0.03 / ds));
33+
return -rho_GJ * (x_Ph[0] - l_atm);
3534
}
3635

3736
private:
38-
const real_t b0, rho_GJ, xsurf, ds;
37+
const real_t b0, rho_GJ, l_atm, ds;
3938
};
4039

4140
template <Dimension D>
@@ -80,11 +79,7 @@ namespace user {
8079
, xsurf { xsurf } {}
8180

8281
Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t {
83-
if (x_Ph[0] < xsurf) {
84-
return ZERO;
85-
}else{
86-
return nmax * math::exp(-(x_Ph[0] - xsurf) / height);
87-
}
82+
return nmax * math::exp(-(x_Ph[0] - xsurf) / height);
8883
}
8984
}; // TargetDensityProfile
9085

@@ -98,12 +93,8 @@ namespace user {
9893
, ds { ds_ } {}
9994

10095
Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t {
101-
if (x_Ph[0] < xsurf) {
102-
return ZERO;
103-
}else{
104-
return ONE - 0.01 / (0.01 + math::exp(-(x_Ph[0] - xsurf - 0.8 * ds) / 0.03 / ds));
105-
}
106-
}
96+
return ONE - 0.01 / (0.01 + math::exp(-(x_Ph[0] - xsurf - 0.8 * ds) / 0.03 / ds));
97+
}
10798
}; // ExtraCharge
10899

109100

@@ -143,7 +134,8 @@ namespace user {
143134
const auto buffer_ncells = min_buff > 5 ? min_buff : 5;
144135
return m.mesh().metric.template convert<1, Crd::Cd, Crd::Ph>(static_cast<real_t>(buffer_ncells));
145136
}())
146-
, init_flds(b0, -TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0, l_atm, ds)
137+
// , init_flds(b0, TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0, l_atm, ds)
138+
, init_flds(b0, ONE, l_atm, ds)
147139
{}
148140

149141
inline PGen() {}
@@ -162,37 +154,48 @@ namespace user {
162154
const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh.metric,
163155
local_domain.random_pool,
164156
temp);
165-
const auto spatial_dist = TargetDensityProfile<S, M>(
166-
local_domain.mesh.metric,
167-
params.template get<real_t>("grid.boundaries.atmosphere.density"),
168-
params.template get<real_t>("grid.boundaries.atmosphere.height"),
169-
l_atm);
170-
const auto injector = arch::NonUniformInjector<S, M, arch::Maxwellian, TargetDensityProfile>(
157+
const auto injector = arch::UniformInjector<S, M, arch::Maxwellian>(
171158
energy_dist,
172-
spatial_dist,
173159
{ 1, 2 }
174160
);
175-
arch::InjectNonUniform<S, M, decltype(injector)>(
161+
162+
arch::InjectUniform<S, M, decltype(injector)>(
176163
params,
177164
local_domain,
178165
injector,
179-
ONE);
180-
181-
const auto extra_charge = ExtraCharge<S, M>(
182-
local_domain.mesh.metric,
183-
l_atm,
184-
ds
166+
ONE
185167
);
186-
const auto injector_extra_charge = arch::NonUniformInjector<S, M, arch::Maxwellian, ExtraCharge>(
187-
energy_dist,
188-
extra_charge,
189-
{ 2, 2 }
190-
);
191-
arch::InjectNonUniform<S, M, decltype(injector_extra_charge)>(
192-
params,
193-
local_domain,
194-
injector_extra_charge,
195-
TWO);
168+
// const auto spatial_dist = TargetDensityProfile<S, M>(
169+
// local_domain.mesh.metric,
170+
// params.template get<real_t>("grid.boundaries.atmosphere.density"),
171+
// params.template get<real_t>("grid.boundaries.atmosphere.height"),
172+
// l_atm);
173+
// const auto injector = arch::NonUniformInjector<S, M, arch::Maxwellian, TargetDensityProfile>(
174+
// energy_dist,
175+
// spatial_dist,
176+
// { 1, 2 }
177+
// );
178+
// arch::InjectNonUniform<S, M, decltype(injector)>(
179+
// params,
180+
// local_domain,
181+
// injector,
182+
// ONE);
183+
184+
// const auto extra_charge = ExtraCharge<S, M>(
185+
// local_domain.mesh.metric,
186+
// l_atm,
187+
// ds
188+
// );
189+
// const auto injector_extra_charge = arch::NonUniformInjector<S, M, arch::Maxwellian, ExtraCharge>(
190+
// energy_dist,
191+
// extra_charge,
192+
// { 2, 2 }
193+
// );
194+
// arch::InjectNonUniform<S, M, decltype(injector_extra_charge)>(
195+
// params,
196+
// local_domain,
197+
// injector_extra_charge,
198+
// HALF);
196199
}
197200
}; // PGen
198201

0 commit comments

Comments
 (0)