8 #ifndef WARPX_MACROSCOPICPROPERTIES_H_
9 #define WARPX_MACROSCOPICPROPERTIES_H_
36 void ReadParameters ();
60 const std::string& npy_filename,
62 const int npy_k_index,
63 const amrex::Real npy_value);
68 const int npy_k_index);
90 std::string m_sigma_s =
"constant";
92 std::string m_epsilon_s =
"constant";
94 std::string m_mu_s =
"constant";
96 amrex::Real m_sigma = 0.0;
102 int m_npy_k_index = 0;
108 amrex::Real m_sigma_npy_value = 0.;
109 amrex::Real m_epsilon_npy_value = 0.;
110 amrex::Real m_mu_npy_value = 0.;
134 amrex::MultiFab& getmag_alpha_mf (
int dir) {
return (*m_mag_alpha_mf[dir]);}
136 amrex::MultiFab& getmag_gamma_mf (
int dir) {
return (*m_mag_gamma_mf[dir]);}
138 amrex::MultiFab& getmag_exchange_mf (
int dir) {
return (*m_mag_exchange_mf[dir]);}
139 amrex::MultiFab * getmag_pointer_exchange (
int dir) {
return m_mag_exchange_mf[dir].
get();}
140 amrex::MultiFab& getmag_anisotropy_mf(
int dir) {
return (*m_mag_anisotropy_mf[dir]);}
141 amrex::MultiFab * getmag_pointer_anisotropy (
int dir) {
return m_mag_anisotropy_mf[dir].
get();}
143 amrex::Real getmag_normalized_error () {
return m_mag_normalized_error;}
144 int getmag_max_iter () {
return m_mag_max_iter;}
145 amrex::Real getmag_tol () {
return m_mag_tol;}
153 using namespace amrex;
154 return ( 0.125_rt * ( macro_mag_prop(
i ,j ,k )
155 + macro_mag_prop(
i-iv[0]+1,j ,k )
156 + macro_mag_prop(
i ,j-iv[1]+1,k )
157 + macro_mag_prop(
i ,j ,k-iv[2]+1)
158 + macro_mag_prop(
i ,j-iv[1]+1,k-iv[2]+1)
159 + macro_mag_prop(
i-iv[0]+1,j ,k-iv[2]+1)
160 + macro_mag_prop(
i-iv[0]+1,j-iv[1]+1,k )
161 + macro_mag_prop(
i-iv[0]+1,j-iv[1]+1,k-iv[2]+1)
183 static amrex::Real face_avg_to_face (
int i,
int j,
int k,
int n,
186 using namespace amrex;
187 return ( 0.125_rt * ( Fieldcomp(
i , j , k ,
n)
188 + Fieldcomp(
i+iv_in[0]-iv_out[0], j , k ,
n)
189 + Fieldcomp(
i , j+iv_in[1]-iv_out[1], k ,
n)
190 + Fieldcomp(
i , j , k+iv_in[2]-iv_out[2],
n)
191 + Fieldcomp(
i+iv_in[0]-iv_out[0], j+iv_in[1]-iv_out[1], k ,
n)
192 + Fieldcomp(
i+iv_in[0]-iv_out[0], j , k+iv_in[2]-iv_out[2],
n)
193 + Fieldcomp(
i , j+iv_in[1]-iv_out[1], k+iv_in[2]-iv_out[2],
n)
194 + Fieldcomp(
i+iv_in[0]-iv_out[0], j+iv_in[1]-iv_out[1], k+iv_in[2]-iv_out[2],
n)
213 static amrex::Real getH_Maxwell (
int i,
int j,
int k,
int n,
216 using namespace amrex;
217 amrex::Real H_Maxwell = face_avg_to_face(
i, j, k, 0, iv_in, iv_out, Bcomp)/
PhysConst::mu0
228 static amrex::Real updateM_field (
int i,
int j,
int k,
int n,
230 using namespace amrex;
231 amrex::Real a_square =
pow(a(
i, j, k, 0), 2.0) +
pow(a(
i, j, k, 1), 2.0) +
pow(a(
i, j, k, 2), 2.0);
232 amrex::Real a_dot_b = a(
i, j, k, 0) *
b(
i, j, k, 0) +
233 a(
i, j, k, 1) *
b(
i, j, k, 1) +
234 a(
i, j, k, 2) *
b(
i, j, k, 2);
236 amrex::Real M_field = 0._rt;
239 amrex::Real a_cross_b_x = a(
i, j, k, 1) *
b(
i, j, k, 2) -
240 a(
i, j, k, 2) *
b(
i, j, k, 1);
241 M_field = (
b(
i, j, k, 0) + a_dot_b * a(
i, j, k, 0) - a_cross_b_x ) / ( 1.0 + a_square);
244 amrex::Real a_cross_b_y = a(
i, j, k, 2) *
b(
i, j, k, 0) -
245 a(
i, j, k, 0) *
b(
i, j, k, 2);
246 M_field = (
b(
i, j, k, 1) + a_dot_b * a(
i, j, k, 1) - a_cross_b_y ) / ( 1.0 + a_square);
249 amrex::Real a_cross_b_z = a(
i, j, k, 0) *
b(
i, j, k, 1) -
250 a(
i, j, k, 1) *
b(
i, j, k, 0);
251 M_field = (
b(
i, j, k, 2) + a_dot_b * a(
i, j, k, 2) - a_cross_b_z ) / ( 1.0 + a_square);
262 amrex::Real m_mag_Ms;
264 amrex::Real m_mag_alpha;
266 amrex::Real m_mag_gamma;
268 amrex::Real m_mag_exchange;
270 amrex::Real m_mag_anisotropy;
274 amrex::Real m_mag_normalized_error;
280 amrex::Real m_mag_tol;
283 std::array<std::unique_ptr<amrex::MultiFab>, 3> m_mag_Ms_mf;
285 std::array<std::unique_ptr<amrex::MultiFab>, 3> m_mag_alpha_mf;
287 std::array<std::unique_ptr<amrex::MultiFab>, 3> m_mag_gamma_mf;
289 std::array<std::unique_ptr<amrex::MultiFab>, 3> m_mag_exchange_mf;
291 std::array<std::unique_ptr<amrex::MultiFab>, 3> m_mag_anisotropy_mf;
294 std::string m_mag_Ms_s;
295 std::string m_mag_alpha_s;
296 std::string m_mag_gamma_s;
297 std::string m_mag_exchange_s;
298 std::string m_mag_anisotropy_s;
301 std::string m_str_mag_Ms_function;
302 std::string m_str_mag_alpha_function;
303 std::string m_str_mag_gamma_function;
304 std::string m_str_mag_exchange_function;
305 std::string m_str_mag_anisotropy_function;
307 std::unique_ptr<amrex::Parser> m_mag_Ms_parser;
308 std::unique_ptr<amrex::Parser> m_mag_alpha_parser;
309 std::unique_ptr<amrex::Parser> m_mag_gamma_parser;
310 std::unique_ptr<amrex::Parser> m_mag_exchange_parser;
311 std::unique_ptr<amrex::Parser> m_mag_anisotropy_parser;
342 static amrex::Real
alpha (amrex::Real
const sigma,
343 amrex::Real
const epsilon,
345 using namespace amrex;
346 amrex::Real fac1 = 0.5_rt * sigma *
dt / epsilon;
347 amrex::Real
alpha = (1._rt - fac1)/(1._rt + fac1);
352 static amrex::Real
beta (amrex::Real
const sigma,
353 amrex::Real
const epsilon,
355 using namespace amrex;
356 amrex::Real fac1 = 0.5_rt * sigma *
dt / epsilon;
357 amrex::Real
beta =
dt / ( epsilon * (1._rt + fac1) );
374 static amrex::Real
alpha (amrex::Real
const sigma,
375 amrex::Real
const epsilon,
377 using namespace amrex;
378 amrex::Real fac1 = sigma *
dt / epsilon;
379 amrex::Real
alpha = (1._rt)/(1._rt + fac1);
384 static amrex::Real
beta (amrex::Real
const sigma,
385 amrex::Real
const epsilon,
387 using namespace amrex;
388 amrex::Real fac1 = sigma *
dt / epsilon;
389 amrex::Real
beta =
dt / ( epsilon * (1._rt + fac1) );
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
This class contains the macroscopic properties of the medium needed to evaluate macroscopic Maxwell e...
Definition: MacroscopicProperties.H:32
amrex::GpuArray< int, 3 > epsilon_IndexType
Definition: MacroscopicProperties.H:73
amrex::GpuArray< int, 3 > mu_IndexType
Definition: MacroscopicProperties.H:75
amrex::GpuArray< int, 3 > Bx_IndexType
Definition: MacroscopicProperties.H:83
amrex::GpuArray< int, 3 > sigma_IndexType
Definition: MacroscopicProperties.H:71
amrex::GpuArray< int, 3 > By_IndexType
Definition: MacroscopicProperties.H:85
std::string m_str_epsilon_function
Definition: MacroscopicProperties.H:326
std::string m_str_mu_function
Definition: MacroscopicProperties.H:327
amrex::MultiFab * get_pointer_eps()
Definition: MacroscopicProperties.H:45
amrex::MultiFab & getepsilon_mf()
Definition: MacroscopicProperties.H:44
std::unique_ptr< amrex::Parser > m_mu_parser
Definition: MacroscopicProperties.H:114
amrex::MultiFab & getsigma_mf()
Definition: MacroscopicProperties.H:41
std::unique_ptr< amrex::MultiFab > m_mu_mf
Definition: MacroscopicProperties.H:321
std::string m_str_sigma_function
Definition: MacroscopicProperties.H:325
std::unique_ptr< amrex::Parser > m_epsilon_parser
Definition: MacroscopicProperties.H:113
std::string m_epsilon_npy_filename
Definition: MacroscopicProperties.H:105
amrex::GpuArray< int, 3 > Ex_IndexType
Definition: MacroscopicProperties.H:77
amrex::GpuArray< int, 3 > Ey_IndexType
Definition: MacroscopicProperties.H:79
amrex::GpuArray< int, 3 > Bz_IndexType
Definition: MacroscopicProperties.H:87
amrex::MultiFab * get_pointer_sigma()
Definition: MacroscopicProperties.H:42
amrex::MultiFab & getmu_mf()
Definition: MacroscopicProperties.H:47
amrex::GpuArray< int, 3 > Ez_IndexType
Definition: MacroscopicProperties.H:81
std::string m_sigma_npy_filename
Definition: MacroscopicProperties.H:104
std::string m_mu_npy_filename
Definition: MacroscopicProperties.H:106
amrex::GpuArray< int, 3 > macro_cr_ratio
Definition: MacroscopicProperties.H:51
std::unique_ptr< amrex::Parser > m_sigma_parser
Definition: MacroscopicProperties.H:112
std::unique_ptr< amrex::MultiFab > m_sigma_mf
Definition: MacroscopicProperties.H:317
amrex::MultiFab * get_pointer_mu()
Definition: MacroscopicProperties.H:48
std::unique_ptr< amrex::MultiFab > m_eps_mf
Definition: MacroscopicProperties.H:319
const FAB & get(const MFIter &mfi) const noexcept
static constexpr auto ep0
vacuum permittivity: dielectric permittivity of vacuum [F/m]
Definition: constant.H:46
static constexpr auto mu0
vacuum permeability: magnetic permeability of vacuum = 4.0e-7 * pi [H/m]
Definition: constant.H:48
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
void Abort(const std::string &msg)
i
Definition: check_interp_points_and_weights.py:174
int n
Definition: run_libensemble_on_warpx.py:67
int dt
Definition: stencil.py:440
This struct contains only static functions to compute the co-efficients for the BackwardEuler scheme ...
Definition: MacroscopicProperties.H:371
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real beta(amrex::Real const sigma, amrex::Real const epsilon, amrex::Real dt)
Definition: MacroscopicProperties.H:384
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real alpha(amrex::Real const sigma, amrex::Real const epsilon, amrex::Real dt)
Definition: MacroscopicProperties.H:374
This struct contains only static functions to compute the co-efficients for the Lax-Wendroff scheme o...
Definition: MacroscopicProperties.H:339
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real beta(amrex::Real const sigma, amrex::Real const epsilon, amrex::Real dt)
Definition: MacroscopicProperties.H:352
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real alpha(amrex::Real const sigma, amrex::Real const epsilon, amrex::Real dt)
Definition: MacroscopicProperties.H:342