66
77#include " arch/kokkos_aliases.h"
88#include " arch/traits.h"
9+ #include " utils/numeric.h"
910
1011#include " archetypes/energy_dist.h"
1112#include " archetypes/spatial_dist.h"
@@ -29,8 +30,8 @@ namespace user {
2930 }
3031
3132 Inline auto ex1 (const coord_t <D>& x_Ph) const -> real_t {
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);
33+ 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));
34+ // return -rho_GJ * (x_Ph[0] - l_atm);
3435 }
3536
3637 private:
@@ -98,6 +99,27 @@ namespace user {
9899 }; // ExtraCharge
99100
100101
102+ template <Dimension D>
103+ struct MagnetosphericCurrent {
104+ MagnetosphericCurrent (const real_t J0_)
105+ : J0 { J0_ } {};
106+
107+ Inline auto jx1 (const coord_t <D>& x_Ph) const -> real_t {
108+ return J0;
109+ }
110+
111+ Inline auto jx2 (const coord_t <D>& x_Ph) const -> real_t {
112+ return ZERO;
113+ }
114+
115+ Inline auto jx3 (const coord_t <D>& x_Ph) const -> real_t {
116+ return ZERO;
117+ }
118+
119+ private:
120+ const real_t J0;
121+ };
122+
101123 template <SimEngine::type S, class M >
102124 struct PGen : public arch ::ProblemGenerator<S, M> {
103125 // compatibility traits for the problem generator
@@ -117,6 +139,7 @@ namespace user {
117139 const real_t j0;
118140 const real_t l_atm, ds;
119141 InitFields<D> init_flds;
142+ MagnetosphericCurrent<D> ext_current;
120143
121144
122145 inline PGen (const SimulationParams& p, const Metadomain<S, M>& m)
@@ -136,6 +159,7 @@ namespace user {
136159 }())
137160 // , init_flds(b0, TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0, l_atm, ds)
138161 , init_flds(b0, ONE, l_atm, ds)
162+ , ext_current(j0)
139163 {}
140164
141165 inline PGen () {}
@@ -154,48 +178,48 @@ namespace user {
154178 const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh .metric ,
155179 local_domain.random_pool ,
156180 temp);
157- const auto injector = arch::UniformInjector<S, M, arch::Maxwellian>(
158- energy_dist,
159- { 1 , 2 }
160- );
161-
162- arch::InjectUniform<S, M, decltype (injector)>(
163- params,
164- local_domain,
165- injector,
166- ONE
167- );
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>(
181+ // const auto injector = arch::UniformInjector<S, M, arch::Maxwellian>(
174182 // energy_dist,
175- // spatial_dist,
176183 // { 1, 2 }
177184 // );
178- // arch::InjectNonUniform<S, M, decltype(injector)>(
185+
186+ // arch::InjectUniform<S, M, decltype(injector)>(
179187 // params,
180188 // local_domain,
181189 // injector,
182- // ONE);
183-
184- // const auto extra_charge = ExtraCharge<S, M>(
185- // local_domain.mesh.metric,
186- // l_atm,
187- // ds
190+ // ONE
188191 // );
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);
192+ const auto spatial_dist = TargetDensityProfile<S, M>(
193+ local_domain.mesh .metric ,
194+ params.template get <real_t >(" grid.boundaries.atmosphere.density" ),
195+ params.template get <real_t >(" grid.boundaries.atmosphere.height" ),
196+ l_atm);
197+ const auto injector = arch::NonUniformInjector<S, M, arch::Maxwellian, TargetDensityProfile>(
198+ energy_dist,
199+ spatial_dist,
200+ { 1 , 2 }
201+ );
202+ arch::InjectNonUniform<S, M, decltype (injector)>(
203+ params,
204+ local_domain,
205+ injector,
206+ ONE);
207+
208+ const auto extra_charge = ExtraCharge<S, M>(
209+ local_domain.mesh .metric ,
210+ l_atm,
211+ ds
212+ );
213+ const auto injector_extra_charge = arch::NonUniformInjector<S, M, arch::Maxwellian, ExtraCharge>(
214+ energy_dist,
215+ extra_charge,
216+ { 2 , 2 }
217+ );
218+ arch::InjectNonUniform<S, M, decltype (injector_extra_charge)>(
219+ params,
220+ local_domain,
221+ injector_extra_charge,
222+ TWO);
199223 }
200224 }; // PGen
201225
0 commit comments