@@ -19,23 +19,29 @@ namespace user {
1919
2020 template <Dimension D>
2121 struct InitFields {
22- InitFields (real_t b0_, real_t rho_GJ_ , real_t l_atm_ , real_t ds_)
22+ InitFields (real_t b0_, real_t coeff_ , real_t xsurf_ , real_t ds_)
2323 : b0 { b0_ }
24- , rho_GJ { rho_GJ_ }
25- , l_atm { l_atm_ }
24+ , coeff { coeff_ }
25+ , xsurf { xsurf_ }
2626 , ds { ds_ }{}
2727
2828 Inline auto bx1 (const coord_t <D>& x_Ph) const -> real_t {
2929 return b0;
3030 }
3131
3232 Inline auto ex1 (const coord_t <D>& x_Ph) const -> real_t {
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);
33+ if (x_Ph[0 ] < xsurf ){
34+ return ZERO;
35+ }else {
36+ // return -coeff * (x_Ph[0] - xsurf
37+ // + 0.03 * ds * math::log(0.01 + math::exp((xsurf + 1.0 * ds - x_Ph[0]) / 0.03 / ds))
38+ // - 0.03 * ds * math::log(0.01 + math::exp(1.0 / 0.03)));
39+ return -coeff * (x_Ph[0 ] - xsurf - ds);
40+ }
3541 }
3642
3743 private:
38- const real_t b0, rho_GJ, l_atm , ds;
44+ const real_t b0, coeff, xsurf , ds;
3945 };
4046
4147 template <Dimension D>
@@ -57,8 +63,8 @@ namespace user {
5763
5864 template <Dimension D>
5965 struct DriveFields : public InitFields <D> {
60- DriveFields (real_t time, real_t b0_, real_t l_atm_ , real_t ds_)
61- : InitFields<D> { b0_, ZERO, l_atm_ , ds_ } {}
66+ DriveFields (real_t time, real_t b0_, real_t xsurf_ , real_t ds_)
67+ : InitFields<D> { b0_, ZERO, xsurf_ , ds_ } {}
6268
6369 using InitFields<D>::bx1;
6470
@@ -71,17 +77,22 @@ namespace user {
7177
7278 template <SimEngine::type S, class M >
7379 struct TargetDensityProfile : public arch ::SpatialDistribution<S, M> {
74- const real_t nmax, height, xsurf;
80+ const real_t nmax, height, xsurf, ds ;
7581
76- TargetDensityProfile (const M& metric, real_t nmax, real_t height, real_t xsurf)
82+ TargetDensityProfile (const M& metric, real_t nmax, real_t height, real_t xsurf, real_t ds )
7783 : arch::SpatialDistribution<S, M>(metric)
7884 , nmax { nmax }
7985 , height { height }
80- , xsurf { xsurf } {}
86+ , xsurf { xsurf }
87+ , ds { ds } {}
8188
8289 Inline auto operator ()(const coord_t <M::Dim>& x_Ph) const -> real_t {
83- return nmax * math::exp (-(x_Ph[0 ] - xsurf) / height);
84- }
90+ if (x_Ph[0 ] < xsurf){
91+ return ZERO;
92+ }else {
93+ return nmax * math::exp (-(x_Ph[0 ] - xsurf) / height);
94+ }
95+ }
8596 }; // TargetDensityProfile
8697
8798 template <SimEngine::type S, class M >
@@ -94,7 +105,11 @@ namespace user {
94105 , ds { ds_ } {}
95106
96107 Inline auto operator ()(const coord_t <M::Dim>& x_Ph) const -> real_t {
97- return ONE - 0.01 / (0.01 + math::exp (-(x_Ph[0 ] - xsurf - 0.8 * ds) / 0.03 / ds));
108+ if ( x_Ph[0 ] < xsurf ){
109+ return ZERO;
110+ }else {
111+ return ONE - 0.01 / (0.01 + math::exp (-(x_Ph[0 ] - xsurf - 1.0 * ds) / 0.03 / ds));
112+ }
98113 }
99114 }; // ExtraCharge
100115
@@ -137,7 +152,7 @@ namespace user {
137152 const real_t b0, Omega, skindepth0, larmor0;
138153 const real_t temp;
139154 const real_t j0;
140- const real_t l_atm , ds;
155+ const real_t xsurf , ds;
141156 InitFields<D> init_flds;
142157 MagnetosphericCurrent<D> ext_current;
143158
@@ -150,23 +165,24 @@ namespace user {
150165 , skindepth0 { p.template get <real_t >(" scales.skindepth0" ) }
151166 , larmor0 { p.template get <real_t >(" scales.larmor0" ) }
152167 , temp { p.template get <real_t >(" setup.temp" ) }
153- , j0 { p.template get <real_t >(" setup.j0" ) }
168+ , j0 { p.template get <real_t >(" setup.j0" ) / p. template get < real_t >( " scales.V0 " ) }
154169 , ds { p.template get <real_t >(" grid.boundaries.atmosphere.ds" ) }
155- , l_atm ([&m, this ]() {
170+ , xsurf ([&m, this ]() {
156171 const auto min_buff = params.template get <unsigned short >(" algorithms.current_filters" ) + 2 ;
157172 const auto buffer_ncells = min_buff > 5 ? min_buff : 5 ;
158173 return m.mesh ().metric .template convert <1 , Crd::Cd, Crd::Ph>(static_cast <real_t >(buffer_ncells));
159174 }())
175+ // , l_atm { ZERO }
160176 // , init_flds(b0, TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0, l_atm, ds)
161- , init_flds(b0, ONE, l_atm , ds)
177+ , init_flds(b0, larmor0 / SQR(skindepth0), xsurf , ds)
162178 , ext_current(j0)
163179 {}
164180
165181 inline PGen () {}
166182
167183
168184 auto AtmFields (real_t time) const -> DriveFields<D> {
169- return DriveFields<D> { time, b0, l_atm , ds};
185+ return DriveFields<D> { time, b0, xsurf , ds};
170186 }
171187
172188 auto MatchFields (real_t ) const -> MFields<D> {
@@ -193,7 +209,8 @@ namespace user {
193209 local_domain.mesh .metric ,
194210 params.template get <real_t >(" grid.boundaries.atmosphere.density" ),
195211 params.template get <real_t >(" grid.boundaries.atmosphere.height" ),
196- l_atm);
212+ xsurf,
213+ ds);
197214 const auto injector = arch::NonUniformInjector<S, M, arch::Maxwellian, TargetDensityProfile>(
198215 energy_dist,
199216 spatial_dist,
@@ -207,19 +224,19 @@ namespace user {
207224
208225 const auto extra_charge = ExtraCharge<S, M>(
209226 local_domain.mesh .metric ,
210- l_atm ,
227+ xsurf ,
211228 ds
212229 );
213230 const auto injector_extra_charge = arch::NonUniformInjector<S, M, arch::Maxwellian, ExtraCharge>(
214231 energy_dist,
215232 extra_charge,
216233 { 2 , 2 }
217234 );
218- arch::InjectNonUniform<S, M, decltype (injector_extra_charge)>(
219- params,
220- local_domain,
221- injector_extra_charge,
222- TWO);
235+ // arch::InjectNonUniform<S, M, decltype(injector_extra_charge)>(
236+ // params,
237+ // local_domain,
238+ // injector_extra_charge,
239+ // TWO);
223240 }
224241 }; // PGen
225242
0 commit comments