From 5e7137073c5c1b0f0fbb0e4299dbaddad36376ba Mon Sep 17 00:00:00 2001 From: rzamora2 Date: Thu, 10 Jun 2021 11:32:39 -0700 Subject: [PATCH 01/32] change plot.period to plot.intervals --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_PR10 | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_bulkmu | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_periodic_noMs | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_tfmu | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled | 2 +- .../Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled_unsat | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_PR10 | 2 +- Examples/Tests/Macroscopic_Maxwell/inputs_3d_periodic_noMs | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_PR10 b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_PR10 index 2a1dc45d4..c4eb2bdf0 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_PR10 +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_PR10 @@ -100,7 +100,7 @@ warpx.Mz_external_grid_function(x,y,z) = 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_bulkmu b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_bulkmu index 58429d053..d5e9e8ca3 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_bulkmu +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_bulkmu @@ -98,7 +98,7 @@ warpx.Mz_external_grid_function(x,y,z) = 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs index 58bb68348..be99b7c24 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs @@ -63,6 +63,6 @@ macroscopic.mag_gamma = 0. # Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz plt.diag_type = Full diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original index bf68e57a6..48a7c9f06 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original @@ -108,7 +108,7 @@ warpx.M_external_grid = 140000. 0. 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.interval = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_periodic_noMs b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_periodic_noMs index 66e6a671f..1e3b4d81e 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_periodic_noMs +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_periodic_noMs @@ -63,6 +63,6 @@ macroscopic.mag_gamma = 0. # Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface Mx_yface Mx_zface My_xface Mz_xface plt.diag_type = Full diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_tfmu b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_tfmu index 1e1b25261..340c7e895 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_tfmu +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_tfmu @@ -106,7 +106,7 @@ warpx.Mz_external_grid_function(x,y,z) = 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 1 +plt.intervals = 1 plt.diag_type = Full #plt.fields_to_plot = Ex Ey Ez Bx By Bz plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled index d956d3493..9111cd96c 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled @@ -78,7 +78,7 @@ warpx.M_external_grid = 140000. 0. 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals= 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled_unsat b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled_unsat index 0629d75d6..f1f82eb90 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled_unsat +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_uncoupled_unsat @@ -78,7 +78,7 @@ warpx.M_external_grid = 10000. 0. 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_PR10 b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_PR10 index 7165f0f7b..b70e87482 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_PR10 +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_PR10 @@ -72,7 +72,7 @@ warpx.Bz_external_grid_function(x,y,z) = 0. #Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Bx By Bz plt.plot_raw_fields = 0 diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_periodic_noMs b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_periodic_noMs index 1f6b6022a..b14213753 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_periodic_noMs +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_periodic_noMs @@ -54,6 +54,6 @@ warpx.Bz_external_grid_function(x,y,z) = 0. # Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.fields_to_plot = Ex Ey Ez Bx By Bz plt.diag_type = Full From b2d7bbdb1e8c6b518a4d8fa68c331456bfc2618f Mon Sep 17 00:00:00 2001 From: rzamora2 Date: Thu, 10 Jun 2021 11:37:50 -0700 Subject: [PATCH 02/32] changed plot.period to plot.intervals --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original index 48a7c9f06..cf35b8a2c 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_original @@ -108,7 +108,7 @@ warpx.M_external_grid = 140000. 0. 0. #Diagnostics diagnostics.diags_names = plt -plt.interval = 10 +plt.intervals = 10 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 From 3a82ef37851f314480064ae008dc1074941f3627 Mon Sep 17 00:00:00 2001 From: jackieyao0114 Date: Thu, 10 Jun 2021 14:12:54 -0700 Subject: [PATCH 03/32] updated Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs index 58bb68348..e6b243439 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs @@ -9,11 +9,13 @@ amr.n_cell = 16 16 128 amr.max_grid_size = 32 amr.blocking_factor = 16 geometry.coord_sys = 0 -geometry.is_periodic = 1 1 0 geometry.prob_lo = -16.e-6 -16.e-6 -128.e-6 geometry.prob_hi = 16.e-6 16.e-6 128.e-6 amr.max_level = 0 +boundary.field_lo = periodic periodic pec +boundary.field_lo = periodic periodic pec + ################################# ############ NUMERICS ########### ################################# @@ -63,6 +65,6 @@ macroscopic.mag_gamma = 0. # Diagnostics diagnostics.diags_names = plt -plt.period = 10 +plt.intervals = 10 plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz plt.diag_type = Full From 3200d03f39404e5ea86435924eeedd300cda8093 Mon Sep 17 00:00:00 2001 From: Jackie Yao Date: Tue, 29 Jun 2021 16:13:52 -0700 Subject: [PATCH 04/32] some tweaks Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs index e6b243439..be99b7c24 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_noMs @@ -9,13 +9,11 @@ amr.n_cell = 16 16 128 amr.max_grid_size = 32 amr.blocking_factor = 16 geometry.coord_sys = 0 +geometry.is_periodic = 1 1 0 geometry.prob_lo = -16.e-6 -16.e-6 -128.e-6 geometry.prob_hi = 16.e-6 16.e-6 128.e-6 amr.max_level = 0 -boundary.field_lo = periodic periodic pec -boundary.field_lo = periodic periodic pec - ################################# ############ NUMERICS ########### ################################# From 6dde33abdef513d5a5d07bad7520c8612b613f13 Mon Sep 17 00:00:00 2001 From: Jackie Yao Date: Tue, 29 Jun 2021 20:06:46 -0700 Subject: [PATCH 05/32] fixed bug in getting mag_exchange_init_style and mag_anisotropy_init_style --- .../MacroscopicProperties.cpp | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index 309ad8bec..4e8c97fe1 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -22,6 +22,8 @@ MacroscopicProperties::ReadParameters () // The vacuum values are used as default for the macroscopic parameters // with a warning message to the user to indicate that no value was specified. + auto &warpx = WarpX::GetInstance(); + // Query input for material conductivity, sigma. bool sigma_specified = false; if (queryWithParser(pp_macroscopic, "sigma", m_sigma)) { @@ -114,24 +116,28 @@ MacroscopicProperties::ReadParameters () makeParser(m_str_mag_gamma_function,{"x","y","z"}))); } - pp_macroscopic.get("mag_exchange_init_style", m_mag_exchange_s); - if (m_mag_exchange_s == "constant") pp_macroscopic.get("mag_exchange", m_mag_exchange); - // _mag_ such that it's clear the exch variable is only meaningful for magnetic materials - //initialization with parser - if (m_mag_exchange_s == "parse_mag_exchange_function") { - Store_parserString(pp_macroscopic, "mag_exchange_function(x,y,z)", m_str_mag_exchange_function); - m_mag_exchange_parser.reset(new ParserWrapper<3>( - makeParser(m_str_mag_exchange_function,{"x","y","z"}))); - } - - pp_macroscopic.get("mag_anisotropy_init_style", m_mag_anisotropy_s); - if (m_mag_anisotropy_s == "constant") pp_macroscopic.get("mag_anisotropy", m_mag_anisotropy); - // _mag_ such that it's clear the exch variable is only meaningful for magnetic materials - //initialization with parser - if (m_mag_anisotropy_s == "parse_mag_anisotropy_function") { - Store_parserString(pp_macroscopic, "mag_anisotropy_function(x,y,z)", m_str_mag_anisotropy_function); - m_mag_anisotropy_parser.reset(new ParserWrapper<3>( - makeParser(m_str_mag_anisotropy_function,{"x","y","z"}))); + if (warpx.mag_LLG_exchange_coupling == 1) { // spin exchange coupling turned off by default + pp_macroscopic.get("mag_exchange_init_style", m_mag_exchange_s); + if (m_mag_exchange_s == "constant") pp_macroscopic.get("mag_exchange", m_mag_exchange); + // _mag_ such that it's clear the exch variable is only meaningful for magnetic materials + //initialization with parser + if (m_mag_exchange_s == "parse_mag_exchange_function") { + Store_parserString(pp_macroscopic, "mag_exchange_function(x,y,z)", m_str_mag_exchange_function); + m_mag_exchange_parser.reset(new ParserWrapper<3>( + makeParser(m_str_mag_exchange_function,{"x","y","z"}))); + } + } + + if (warpx.mag_LLG_anisotropy_coupling == 1) { // magnetic crystal is considered as isotropic by default + pp_macroscopic.get("mag_anisotropy_init_style", m_mag_anisotropy_s); + if (m_mag_anisotropy_s == "constant") pp_macroscopic.get("mag_anisotropy", m_mag_anisotropy); + // _mag_ such that it's clear the exch variable is only meaningful for magnetic materials + //initialization with parser + if (m_mag_anisotropy_s == "parse_mag_anisotropy_function") { + Store_parserString(pp_macroscopic, "mag_anisotropy_function(x,y,z)", m_str_mag_anisotropy_function); + m_mag_anisotropy_parser.reset(new ParserWrapper<3>( + makeParser(m_str_mag_anisotropy_function,{"x","y","z"}))); + } } m_mag_normalized_error = 0.1; From f581c095a57a465509689a4eb7e80c4e20af684f Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Thu, 1 Jul 2021 16:46:27 -0700 Subject: [PATCH 06/32] EOL whitespace --- .../MacroscopicProperties/MacroscopicProperties.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index 4e8c97fe1..d0286e4f0 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -23,7 +23,7 @@ MacroscopicProperties::ReadParameters () // with a warning message to the user to indicate that no value was specified. auto &warpx = WarpX::GetInstance(); - + // Query input for material conductivity, sigma. bool sigma_specified = false; if (queryWithParser(pp_macroscopic, "sigma", m_sigma)) { @@ -126,9 +126,9 @@ MacroscopicProperties::ReadParameters () m_mag_exchange_parser.reset(new ParserWrapper<3>( makeParser(m_str_mag_exchange_function,{"x","y","z"}))); } - } - - if (warpx.mag_LLG_anisotropy_coupling == 1) { // magnetic crystal is considered as isotropic by default + } + + if (warpx.mag_LLG_anisotropy_coupling == 1) { // magnetic crystal is considered as isotropic by default pp_macroscopic.get("mag_anisotropy_init_style", m_mag_anisotropy_s); if (m_mag_anisotropy_s == "constant") pp_macroscopic.get("mag_anisotropy", m_mag_anisotropy); // _mag_ such that it's clear the exch variable is only meaningful for magnetic materials From eacbac7da885eddf6ced3ba5b17335fa5e0ed68c Mon Sep 17 00:00:00 2001 From: prkkumar Date: Tue, 21 Sep 2021 13:18:14 -0700 Subject: [PATCH 07/32] new Laplacian for exchange BC --- .../CartesianYeeAlgorithm.H | 72 +++++++++++++++++++ .../MacroscopicEvolveHM.cpp | 18 ++--- .../MacroscopicEvolveHM_2nd.cpp | 36 +++++----- 3 files changed, 99 insertions(+), 27 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index 354714611..f15c7652c 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -223,6 +223,78 @@ struct CartesianYeeAlgorithm { #endif +#ifdef WARPX_MAG_LLG + + /** + * Perform divergence of gradient along x on M field when exchange coupling is on */ + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real LaplacianDx_Mag ( + amrex::Array4 const& F, + amrex::Real const * const coefs_x, + int const i, int const j, int const k, int const ncomp=0 ) { + + amrex::Real const inv_dx = coefs_x[0]; + if ( F(i+1,j,k) == 0.) + { + return 0.; + } + else + { + return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); + } + } + + /** + * Perform divergence of gradient along y on M field when exchange coupling is on*/ + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real LaplacianDy_Mag ( + amrex::Array4 const& F, + amrex::Real const * const coefs_y, + int const i, int const j, int const k, int const ncomp=0 ) { + + amrex::Real const inv_dy = coefs_y[0]; + if ( F(i,j+1,k) == 0.) + { + return 0.; + } + else + { + return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); + } + } + + /** + * Perform divergence of gradient along z on M field when exchange coupling is on*/ + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real LaplacianDz_Mag ( + amrex::Array4 const& F, + amrex::Real const * const coefs_z, + int const i, int const j, int const k, int const ncomp=0 ) { + + amrex::Real const inv_dz = coefs_z[0]; + if ( F(i,j,k+1) == 0.) + { + return 0.; + } + else + { + return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); + } + } + + /** + * Compute the sum to get Laplacian of M field when exchange coupling is on*/ + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real Laplacian_Mag ( + amrex::Array4 const& F, + amrex::Real const * const coefs_x, amrex::Real const * const coefs_y, amrex::Real const * const coefs_z, + int const i, int const j, int const k, int const ncomp=0 ) { + + return LaplacianDx_Mag(F, coefs_x, i, j, k, ncomp) + LaplacianDy_Mag(F, coefs_y, i, j, k, ncomp) + LaplacianDz_Mag(F, coefs_z, i, j, k, ncomp); + } + +#endif + }; #endif // WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_YEE_H_ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index 16fba37e8..cd2519443 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -185,9 +185,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -298,9 +298,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -411,9 +411,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 2731689ce..9673ebc59 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -194,9 +194,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -275,9 +275,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -356,9 +356,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -510,9 +510,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -620,9 +620,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ @@ -731,9 +731,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); } if (mag_anisotropy_coupling == 1){ From 15aeca0fb1e10b691c04b90dfa0824a150a65f75 Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 22 Sep 2021 10:55:46 -0700 Subject: [PATCH 08/32] Neumann BC with one-sided derivative at corners --- .../CartesianYeeAlgorithm.H | 90 +++++++++++++++++-- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index f15c7652c..499d5c84b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -234,9 +234,35 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0 ) { amrex::Real const inv_dx = coefs_x[0]; - if ( F(i+1,j,k) == 0.) + if ( F(i+1,j,k) == 0.) //non-magnetic on right { - return 0.; + if (F(i,j+1,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i-1,j,k) + 4.*F(i-2,j,k) - F(i-3,j,k)); + } + else if (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i+1,j,k) + 4.*F(i+2,j,k) - F(i+3,j,k)); + } + else + { + return inv_dx*(0. - DownwardDx(F, coefs_x, i, j, k, ncomp)); + } + } + else if (F(i-1,j,k) == 0.) //non-magnetic on left + { + if (F(i,j+1,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i-1,j,k) + 4.*F(i-2,j,k) - F(i-3,j,k)); + } + else if (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i+1,j,k) + 4.*F(i+2,j,k) - F(i+3,j,k)); + } + else + { + return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - 0.); + } } else { @@ -253,9 +279,35 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0 ) { amrex::Real const inv_dy = coefs_y[0]; - if ( F(i,j+1,k) == 0.) + if ( F(i,j+1,k) == 0.) //non-magnetic on right + { + if (F(i+1,j,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j-1,k) + 4.*F(i,j-2,k) - F(i,j-3,k)); + } + else if (F(i-1,j,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j+1,k) + 4.*F(i,j+2,k) - F(i,j+3,k)); + } + else + { + return inv_dy*(0. - DownwardDy(F, coefs_y, i, j, k, ncomp)); + } + } + else if (F(i,j-1,k) == 0.) //non-magnetic on left { - return 0.; + if (F(i+1,j,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j-1,k) + 4.*F(i,j-2,k) - F(i,j-3,k)); + } + else if (F(i-1,j,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j+1,k) + 4.*F(i,j+2,k) - F(i,j+3,k)); + } + else + { + return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - 0.); + } } else { @@ -272,9 +324,35 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0 ) { amrex::Real const inv_dz = coefs_z[0]; - if ( F(i,j,k+1) == 0.) + if ( F(i,j,k+1) == 0.) //non-magnetic on right + { + if (F(i+1,j,k) == 0. || F(i,j+1,k) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k-1) + 4.*F(i,j,k-2) - F(i,j,k-3)); + } + else if (F(i-1,j,k) == 0. || F(i,j-1,k) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k+1) + 4.*F(i,j,k+2) - F(i,j,k+3)); + } + else + { + return inv_dz*(0. - DownwardDz(F, coefs_z, i, j, k, ncomp)); + } + } + else if (F(i,j,k-1) == 0.) //non-magnetic on left { - return 0.; + if (F(i+1,j,k) == 0. || F(i,j+1,k) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + { + return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k-1) + 4.*F(i,j,k-2) - F(i,j,k-3)); + } + else if (F(i-1,j,k) == 0. || F(i,j-1,k) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + { + return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k+1) + 4.*F(i,j,k+2) - F(i,j,k+3)); + } + else + { + return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - 0.); + } } else { From 490ba05f0d0ed7b106ab67002f798d5afe3cca05 Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 22 Sep 2021 15:19:31 -0700 Subject: [PATCH 09/32] fixes for components of M and nodality --- .../CartesianYeeAlgorithm.H | 70 +++++++++---------- .../MacroscopicEvolveHM.cpp | 18 ++--- .../MacroscopicEvolveHM_2nd.cpp | 36 +++++----- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index 499d5c84b..73ade6cce 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -231,33 +231,33 @@ struct CartesianYeeAlgorithm { static amrex::Real LaplacianDx_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_x, - int const i, int const j, int const k, int const ncomp=0 ) { + int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { amrex::Real const inv_dx = coefs_x[0]; - if ( F(i+1,j,k) == 0.) //non-magnetic on right + if ( F(i+1,j,k,ncomp) == 0.) //non-magnetic on right { - if (F(i,j+1,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i,j+1,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i-1,j,k) + 4.*F(i-2,j,k) - F(i-3,j,k)); + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); } - else if (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i+1,j,k) + 4.*F(i+2,j,k) - F(i+3,j,k)); + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); } else { return inv_dx*(0. - DownwardDx(F, coefs_x, i, j, k, ncomp)); } } - else if (F(i-1,j,k) == 0.) //non-magnetic on left + else if (F(i-1,j,k,ncomp) == 0.) //non-magnetic on left { - if (F(i,j+1,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i,j+1,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i-1,j,k) + 4.*F(i-2,j,k) - F(i-3,j,k)); + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); } - else if (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i,j-1,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dx*inv_dx*(2.*F(i,j,k) - 5.*F(i+1,j,k) + 4.*F(i+2,j,k) - F(i+3,j,k)); + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); } else { @@ -276,33 +276,33 @@ struct CartesianYeeAlgorithm { static amrex::Real LaplacianDy_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_y, - int const i, int const j, int const k, int const ncomp=0 ) { + int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { amrex::Real const inv_dy = coefs_y[0]; - if ( F(i,j+1,k) == 0.) //non-magnetic on right + if ( F(i,j+1,k,ncomp) == 0.) //non-magnetic on right { - if (F(i+1,j,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j-1,k) + 4.*F(i,j-2,k) - F(i,j-3,k)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); } - else if (F(i-1,j,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j+1,k) + 4.*F(i,j+2,k) - F(i,j+3,k)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); } else { return inv_dy*(0. - DownwardDy(F, coefs_y, i, j, k, ncomp)); } } - else if (F(i,j-1,k) == 0.) //non-magnetic on left + else if (F(i,j-1,k,ncomp) == 0.) //non-magnetic on left { - if (F(i+1,j,k) == 0. || F(i,j,k+1) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j-1,k) + 4.*F(i,j-2,k) - F(i,j-3,k)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); } - else if (F(i-1,j,k) == 0. || F(i,j,k-1) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dy*inv_dy*(2.*F(i,j,k) - 5.*F(i,j+1,k) + 4.*F(i,j+2,k) - F(i,j+3,k)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); } else { @@ -321,33 +321,33 @@ struct CartesianYeeAlgorithm { static amrex::Real LaplacianDz_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_z, - int const i, int const j, int const k, int const ncomp=0 ) { + int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { amrex::Real const inv_dz = coefs_z[0]; - if ( F(i,j,k+1) == 0.) //non-magnetic on right + if ( F(i,j,k+1,ncomp) == 0.) //non-magnetic on right { - if (F(i+1,j,k) == 0. || F(i,j+1,k) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j+1,k,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k-1) + 4.*F(i,j,k-2) - F(i,j,k-3)); + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); } - else if (F(i-1,j,k) == 0. || F(i,j-1,k) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j-1,k,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k+1) + 4.*F(i,j,k+2) - F(i,j,k+3)); + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); } else { return inv_dz*(0. - DownwardDz(F, coefs_z, i, j, k, ncomp)); } } - else if (F(i,j,k-1) == 0.) //non-magnetic on left + else if (F(i,j,k-1,ncomp) == 0.) //non-magnetic on left { - if (F(i+1,j,k) == 0. || F(i,j+1,k) == 0.) //Top corner is non-magnetic -- left sided 2nd order derivative + if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j+1,k,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative { - return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k-1) + 4.*F(i,j,k-2) - F(i,j,k-3)); + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); } - else if (F(i-1,j,k) == 0. || F(i,j-1,k) == 0.) //Bottom corner is non-magnetic -- right sided 2nd order derivative + else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j-1,k,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative { - return inv_dz*inv_dz*(2.*F(i,j,k) - 5.*F(i,j,k+1) + 4.*F(i,j,k+2) - F(i,j,k+3)); + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); } else { @@ -366,9 +366,9 @@ struct CartesianYeeAlgorithm { static amrex::Real Laplacian_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_x, amrex::Real const * const coefs_y, amrex::Real const * const coefs_z, - int const i, int const j, int const k, int const ncomp=0 ) { + int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { - return LaplacianDx_Mag(F, coefs_x, i, j, k, ncomp) + LaplacianDy_Mag(F, coefs_y, i, j, k, ncomp) + LaplacianDz_Mag(F, coefs_z, i, j, k, ncomp); + return LaplacianDx_Mag(F, coefs_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, i, j, k, ncomp, nodality); } #endif diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index cd2519443..b0e71849a 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -185,9 +185,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -298,9 +298,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -411,9 +411,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 9673ebc59..718e8bbc8 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -194,9 +194,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -275,9 +275,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -356,9 +356,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ @@ -510,9 +510,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -620,9 +620,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -731,9 +731,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0); - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1); - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2); + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ From d66c56fb98f1a80a71bbee5d26ffb6f7e8e567ad Mon Sep 17 00:00:00 2001 From: prkkumar Date: Mon, 25 Oct 2021 14:51:42 -0700 Subject: [PATCH 10/32] exchange BC test case --- .../inputs_3d_LLG_exchangeBC | 83 +++++++++++++++++++ GNUmakefile | 4 +- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC new file mode 100644 index 000000000..877eaf41c --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -0,0 +1,83 @@ +################################ +####### GENERAL PARAMETERS ###### +################################# +max_step = 1 +amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 +amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain +amr.blocking_factor = 16 +geometry.coord_sys = 0 + +geometry.prob_lo = -15e-3 -15e-3 -15.0e-3 +geometry.prob_hi = 15e-3 15e-3 15.0e-3 +boundary.field_lo = periodic periodic periodic +boundary.field_hi = periodic periodic periodic +amr.max_level = 0 + +################################# +############ NUMERICS ########### +################################# +warpx.verbose = 1 +warpx.use_filter = 0 +warpx.cfl = 0.9 +warpx.mag_time_scheme_order = 2 # default 1 +warpx.mag_M_normalization = 1 # 1 is saturated +warpx.mag_LLG_coupling = 0 +warpx.mag_LLG_exchange_coupling = 1 + +algo.em_solver_medium = macroscopic # vacuum/macroscopic +algo.macroscopic_sigma_method = laxwendroff # laxwendroff or backwardeuler + +macroscopic.sigma_function(x,y,z) = "0.0" +macroscopic.epsilon_function(x,y,z) = "8.8541878128e-12" +macroscopic.mu_function(x,y,z) = "1.25663706212e-06" + +#unit conversion: 1 Gauss = (1000/4pi) A/m +macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" +macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG +#macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 0.) * (z > -5e-3) * (z < 5e-3) + 0.7e5 * (x > -5e-3) * (x < 5e-3) * (y >= 0.) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" + +macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" +macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted + +macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # gyromagnetic ratio is constant for electrons in all materials + +macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON + +macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step +macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration +macroscopic.mag_normalized_error = 0.1 # if M magnitude relatively changes more than this value, raise a red flag + +################################# +############ FIELDS ############# +################################# +warpx.E_ext_grid_init_style = parse_E_ext_grid_function +warpx.Ex_external_grid_function(x,y,z) = 0. +warpx.Ey_external_grid_function(x,y,z) = 0. +warpx.Ez_external_grid_function(x,y,z) = 0. + +warpx.H_ext_grid_init_style = parse_H_ext_grid_function +warpx.Hx_external_grid_function(x,y,z)= 0. +warpx.Hy_external_grid_function(x,y,z) = 0. +warpx.Hz_external_grid_function(x,y,z) = 0. + +#unit conversion: 1 Gauss = 1 Oersted = (1000/4pi) A/m +#calculation of H_bias: H_bias (oe) = frequency / 2.8e6 +warpx.H_bias_ext_grid_init_style = parse_H_bias_ext_grid_function +warpx.Hx_bias_external_grid_function(x,y,z)= 0. +warpx.Hy_bias_external_grid_function(x,y,z)= "3.7e4" # * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # in A/m, equal to 464 Oersted +warpx.Hz_bias_external_grid_function(x,y,z)= 0. + +warpx.M_ext_grid_init_style = parse_M_ext_grid_function +warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" +warpx.My_external_grid_function(x,y,z) = 0. +#warpx.Mz_external_grid_function(x,y,z) = 0. +warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y >= 0.) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" + +#Diagnostics +diagnostics.diags_names = plt +plt.intervals = 10 +plt.diag_type = Full +plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface +plt.plot_raw_fields = 0 diff --git a/GNUmakefile b/GNUmakefile index bca1a2226..5c1eca282 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,8 +2,8 @@ AMREX_HOME ?= ../amrex PICSAR_HOME ?= ../picsar OPENBC_HOME ?= ../openbc_poisson -DEBUG = FALSE -#DEBUG = TRUE +#DEBUG = FALSE +DEBUG = TRUE WARN_ALL = TRUE #WARN_ERROR=TRUE From bfbf34c80197df6e5b71a77f2e005a779eb0e69a Mon Sep 17 00:00:00 2001 From: Prabhat Kumar Date: Tue, 26 Oct 2021 17:26:40 -0700 Subject: [PATCH 11/32] detect boundary based on Ms rather than M --- .../inputs_3d_LLG_exchangeBC | 15 +- .../CartesianYeeAlgorithm.H | 197 ++++++++---------- .../MacroscopicEvolveHM.cpp | 60 +++++- .../MacroscopicEvolveHM_2nd.cpp | 120 +++++++++-- 4 files changed, 247 insertions(+), 145 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 877eaf41c..692c817c0 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -7,8 +7,8 @@ amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the d amr.blocking_factor = 16 geometry.coord_sys = 0 -geometry.prob_lo = -15e-3 -15e-3 -15.0e-3 -geometry.prob_hi = 15e-3 15e-3 15.0e-3 +geometry.prob_lo = -10e-3 -10e-3 -10.0e-3 +geometry.prob_hi = 10e-3 10e-3 10.0e-3 boundary.field_lo = periodic periodic periodic boundary.field_hi = periodic periodic periodic amr.max_level = 0 @@ -37,13 +37,13 @@ macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= #macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 0.) * (z > -5e-3) * (z < 5e-3) + 0.7e5 * (x > -5e-3) * (x < 5e-3) * (y >= 0.) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted +macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # gyromagnetic ratio is constant for electrons in all materials +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # gyromagnetic ratio is constant for electrons in all materials macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -70,10 +70,9 @@ warpx.Hy_bias_external_grid_function(x,y,z)= "3.7e4" # * (x > -5e-3) * (x < 5e-3 warpx.Hz_bias_external_grid_function(x,y,z)= 0. warpx.M_ext_grid_init_style = parse_M_ext_grid_function -warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" +warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y < 0.) * (z >= -5e-3) * (z <= 5e-3)" warpx.My_external_grid_function(x,y,z) = 0. -#warpx.Mz_external_grid_function(x,y,z) = 0. -warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y >= 0.) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" +warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= 0.) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" #Diagnostics diagnostics.diags_names = plt diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index 73ade6cce..13a5c58a2 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -15,6 +15,9 @@ #include #include #include +#include "Utils/WarpXUtil.H" +#include "WarpX.H" +#include "FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H" #include #include @@ -230,44 +233,35 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDx_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_x, - int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { + amrex::Real const * const coefs_x, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, + int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dx = coefs_x[0]; - if ( F(i+1,j,k,ncomp) == 0.) //non-magnetic on right - { - if ((ncomp != nodality) && (F(i,j+1,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); - } - else if ((ncomp != nodality) && (F(i,j-1,k) == 0. || F(i,j,k-1) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); - } - else - { - return inv_dx*(0. - DownwardDx(F, coefs_x, i, j, k, ncomp)); - } - } - else if (F(i-1,j,k,ncomp) == 0.) //non-magnetic on left - { - if ((ncomp != nodality) && (F(i,j+1,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); - } - else if ((ncomp != nodality) && (F(i,j-1,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); - } - else - { - return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - 0.); - } - } - else - { - return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); - } + if(ncomp != nodality){ + if ( Ms_hi_x == 0.) //non-magnetic on right + { + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); + } + else if (Ms_lo_x == 0.) //non-magnetic on left + { + return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); + } else + { + return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); + } + } else { + if ( Ms_hi_x == 0.) //non-magnetic on right + { + return inv_dx*(0. - DownwardDx(F, coefs_x, i, j, k, ncomp)); + } + else if (Ms_lo_x == 0.) //non-magnetic on left + { + return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - 0.); + } else + { + return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); + } + } } /** @@ -275,44 +269,35 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDy_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_y, - int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { + amrex::Real const * const coefs_y, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, + int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dy = coefs_y[0]; - if ( F(i,j+1,k,ncomp) == 0.) //non-magnetic on right - { - if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); - } - else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); - } - else - { - return inv_dy*(0. - DownwardDy(F, coefs_y, i, j, k, ncomp)); - } - } - else if (F(i,j-1,k,ncomp) == 0.) //non-magnetic on left - { - if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j,k+1,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); - } - else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j,k-1,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); - } - else - { - return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - 0.); - } - } - else - { - return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); - } + if(ncomp != nodality){ + if ( Ms_hi_y == 0.) //non-magnetic on right + { + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); + } + else if (Ms_lo_y == 0.) //non-magnetic on left + { + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); + } else + { + return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); + } + } else { + if ( Ms_hi_y == 0.) //non-magnetic on right + { + return inv_dy*(0. - DownwardDy(F, coefs_y, i, j, k, ncomp)); + } + else if (Ms_lo_y == 0.) //non-magnetic on left + { + return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - 0.); + } else + { + return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); + } + } } /** @@ -320,44 +305,35 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDz_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_z, - int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { + amrex::Real const * const coefs_z, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, + int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dz = coefs_z[0]; - if ( F(i,j,k+1,ncomp) == 0.) //non-magnetic on right - { - if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j+1,k,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); - } - else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j-1,k,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); - } - else - { - return inv_dz*(0. - DownwardDz(F, coefs_z, i, j, k, ncomp)); - } - } - else if (F(i,j,k-1,ncomp) == 0.) //non-magnetic on left - { - if ((ncomp != nodality) && (F(i+1,j,k,ncomp) == 0. || F(i,j+1,k,ncomp) == 0.)) //Top corner is non-magnetic -- left sided 2nd order derivative - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); - } - else if ((ncomp != nodality) && (F(i-1,j,k,ncomp) == 0. || F(i,j-1,k,ncomp) == 0.)) //Bottom corner is non-magnetic -- right sided 2nd order derivative - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); - } - else - { - return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - 0.); - } - } - else - { - return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); - } + if(ncomp != nodality){ + if ( Ms_hi_z == 0.) //non-magnetic on right + { + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); + } + else if (Ms_lo_z == 0.) //non-magnetic on left + { + return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); + } else + { + return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); + } + } else { + if ( Ms_hi_z == 0.) //non-magnetic on right + { + return inv_dz*(0. - DownwardDz(F, coefs_z, i, j, k, ncomp)); + } + else if (Ms_lo_z == 0.) //non-magnetic on left + { + return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - 0.); + } else + { + return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); + } + } } /** @@ -366,9 +342,10 @@ struct CartesianYeeAlgorithm { static amrex::Real Laplacian_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_x, amrex::Real const * const coefs_y, amrex::Real const * const coefs_z, - int const i, int const j, int const k, int const ncomp=0, int const nodality=0 ) { + amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, + int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { - return LaplacianDx_Mag(F, coefs_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, i, j, k, ncomp, nodality); + return LaplacianDx_Mag(F, coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); } #endif diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index b0e71849a..e1e3cfc70 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -185,9 +185,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -298,9 +312,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -411,9 +439,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 718e8bbc8..f7ddca09f 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -194,9 +194,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -275,9 +289,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -356,9 +384,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ @@ -510,9 +552,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -620,9 +676,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -731,9 +801,23 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( // H_exchange if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_x = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_y = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_lo_z = mag_parser(x,y,z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + amrex::Real Ms_hi_z = mag_parser(x,y,z); + + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ From d917ea4194498cd76fc787a17138aa4273e7430d Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 27 Oct 2021 13:06:19 -0700 Subject: [PATCH 12/32] pass n_coefs_* in 1st order derivative calculations --- .../CartesianYeeAlgorithm.H | 33 ++++++------ .../MacroscopicEvolveHM.cpp | 27 +++++----- .../MacroscopicEvolveHM_2nd.cpp | 54 ++++++++++--------- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index 13a5c58a2..fa11a6a26 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -233,7 +233,7 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDx_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_x, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, + amrex::Real const * const coefs_x, int const n_coefs_x, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dx = coefs_x[0]; @@ -247,19 +247,19 @@ struct CartesianYeeAlgorithm { return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); } else { - return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); } } else { if ( Ms_hi_x == 0.) //non-magnetic on right { - return inv_dx*(0. - DownwardDx(F, coefs_x, i, j, k, ncomp)); + return inv_dx*(0. - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); } else if (Ms_lo_x == 0.) //non-magnetic on left { - return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - 0.); + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - 0.); } else { - return inv_dx*(UpwardDx(F, coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, i, j, k, ncomp)); + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); } } } @@ -269,7 +269,7 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDy_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_y, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, + amrex::Real const * const coefs_y, int const n_coefs_y, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dy = coefs_y[0]; @@ -283,19 +283,19 @@ struct CartesianYeeAlgorithm { return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); } else { - return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } else { if ( Ms_hi_y == 0.) //non-magnetic on right { - return inv_dy*(0. - DownwardDy(F, coefs_y, i, j, k, ncomp)); + return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } else if (Ms_lo_y == 0.) //non-magnetic on left { - return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - 0.); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); } else { - return inv_dy*(UpwardDy(F, coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, i, j, k, ncomp)); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } } @@ -305,7 +305,7 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDz_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_z, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, + amrex::Real const * const coefs_z, int const n_coefs_z, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dz = coefs_z[0]; @@ -319,19 +319,19 @@ struct CartesianYeeAlgorithm { return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); } else { - return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); } } else { if ( Ms_hi_z == 0.) //non-magnetic on right { - return inv_dz*(0. - DownwardDz(F, coefs_z, i, j, k, ncomp)); + return inv_dz*(0. - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); } else if (Ms_lo_z == 0.) //non-magnetic on left { - return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - 0.); + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - 0.); } else { - return inv_dz*(UpwardDz(F, coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, i, j, k, ncomp)); + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); } } } @@ -342,10 +342,11 @@ struct CartesianYeeAlgorithm { static amrex::Real Laplacian_Mag ( amrex::Array4 const& F, amrex::Real const * const coefs_x, amrex::Real const * const coefs_y, amrex::Real const * const coefs_z, + int const n_coefs_x, int const n_coefs_y, int const n_coefs_z, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { - return LaplacianDx_Mag(F, coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); + return LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); } #endif diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index e1e3cfc70..92973a82d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -141,9 +141,12 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( Box const &tbz = mfi.tilebox(Hfield[2]->ixType().toIntVect()); // Extract stencil coefficients for calculating the exchange field H_exchange and the anisotropy field H_anisotropy - amrex::Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + amrex::Real const *const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); + int const n_coefs_x = m_stencil_coefs_x.size(); + amrex::Real const *const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); + int const n_coefs_y = m_stencil_coefs_y.size(); + amrex::Real const *const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + int const n_coefs_z = m_stencil_coefs_z.size(); const auto dx = warpx.Geom(lev).CellSizeArray(); const auto problo = warpx.Geom(lev).ProbLoArray(); @@ -199,9 +202,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -326,9 +329,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -453,9 +456,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index f7ddca09f..238e6942b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -151,9 +151,12 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( Box const &tbz = mfi.tilebox(Mzface_stag); // Extract stencil coefficients for calculating the exchange field H_exchange and the anisotropy field H_anisotropy - amrex::Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + amrex::Real const *const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); + int const n_coefs_x = m_stencil_coefs_x.size(); + amrex::Real const *const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); + int const n_coefs_y = m_stencil_coefs_y.size(); + amrex::Real const *const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + int const n_coefs_z = m_stencil_coefs_z.size(); const auto dx = warpx.Geom(lev).CellSizeArray(); const auto problo = warpx.Geom(lev).ProbLoArray(); @@ -208,9 +211,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -303,9 +306,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -398,9 +401,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ @@ -513,9 +516,12 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( const auto mag_parser = macroscopic_properties->m_mag_Ms_parser->compile<3>(); // Extract stencil coefficients for calculating the exchange field H_exchange and the anisotropy field H_anisotropy - amrex::Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - amrex::Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + amrex::Real const *const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); + int const n_coefs_x = m_stencil_coefs_x.size(); + amrex::Real const *const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); + int const n_coefs_y = m_stencil_coefs_y.size(); + amrex::Real const *const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + int const n_coefs_z = m_stencil_coefs_z.size(); // loop over cells and update fields amrex::ParallelFor(tbx, @@ -566,9 +572,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 0); //Last argument is nodality -- xface = 0 } if (mag_anisotropy_coupling == 1){ @@ -690,9 +696,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 1); //Last argument is nodality -- yface = 1 } if (mag_anisotropy_coupling == 1){ @@ -815,9 +821,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); - Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 - Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 - Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 + Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 + Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 + Hz_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 2, 2); //Last argument is nodality -- zface = 2 } if (mag_anisotropy_coupling == 1){ From 6fdcb8049f627b502d454c65c14c368e315bef25 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Wed, 27 Oct 2021 15:47:54 -0700 Subject: [PATCH 13/32] properly initialize H_IndexType --- .../MacroscopicProperties.cpp | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index b7402d392..226d609ca 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -303,13 +303,16 @@ MacroscopicProperties::InitData () IntVect By_stag = warpx.getBfield_fp(0,1).ixType().toIntVect(); IntVect Bz_stag = warpx.getBfield_fp(0,2).ixType().toIntVect(); #ifdef WARPX_MAG_LLG + IntVect Hx_stag = warpx.getHfield_fp(0,0).ixType().toIntVect(); + IntVect Hy_stag = warpx.getHfield_fp(0,1).ixType().toIntVect(); + IntVect Hz_stag = warpx.getHfield_fp(0,2).ixType().toIntVect(); IntVect mag_alpha_stag = m_mag_alpha_mf->ixType().toIntVect(); IntVect mag_gamma_stag = m_mag_gamma_mf->ixType().toIntVect(); - IntVect mag_exchange_stag = m_mag_exchange_mf->ixType().toIntVect(); - IntVect mag_anisotropy_stag = m_mag_anisotropy_mf->ixType().toIntVect(); IntVect Mx_stag = warpx.getMfield_fp(0,0).ixType().toIntVect(); // face-centered IntVect My_stag = warpx.getMfield_fp(0,1).ixType().toIntVect(); IntVect Mz_stag = warpx.getMfield_fp(0,2).ixType().toIntVect(); + IntVect mag_exchange_stag = m_mag_exchange_mf->ixType().toIntVect(); + IntVect mag_anisotropy_stag = m_mag_anisotropy_mf->ixType().toIntVect(); #endif @@ -321,14 +324,17 @@ MacroscopicProperties::InitData () By_IndexType[idim] = By_stag[idim]; Bz_IndexType[idim] = Bz_stag[idim]; #ifdef WARPX_MAG_LLG - mag_alpha_IndexType[idim] = mag_alpha_stag[idim]; - mag_gamma_IndexType[idim] = mag_gamma_stag[idim]; - mag_exchange_IndexType[idim] = mag_exchange_stag[idim]; - mag_anisotropy_IndexType[idim] = mag_anisotropy_stag[idim]; - Mx_IndexType[idim] = Mx_stag[idim]; - My_IndexType[idim] = My_stag[idim]; - Mz_IndexType[idim] = Mz_stag[idim]; - macro_cr_ratio[idim] = 1; + Hx_IndexType[idim] = Hx_stag[idim]; + Hy_IndexType[idim] = Hy_stag[idim]; + Hz_IndexType[idim] = Hz_stag[idim]; + mag_alpha_IndexType[idim] = mag_alpha_stag[idim]; + mag_gamma_IndexType[idim] = mag_gamma_stag[idim]; + Mx_IndexType[idim] = Mx_stag[idim]; + My_IndexType[idim] = My_stag[idim]; + Mz_IndexType[idim] = Mz_stag[idim]; + mag_exchange_IndexType[idim] = mag_exchange_stag[idim]; + mag_anisotropy_IndexType[idim] = mag_anisotropy_stag[idim]; + macro_cr_ratio[idim] = 1; #endif } #if (AMREX_SPACEDIM==2) @@ -339,14 +345,17 @@ MacroscopicProperties::InitData () By_IndexType[2] = 0; Bz_IndexType[2] = 0; #ifdef WARPX_MAG_LLG - mag_alpha_IndexType[2] = 0; - mag_gamma_IndexType[2] = 0; - mag_exchange_IndexType[2] = 0; + Hx_IndexType[2] = 0; + Hy_IndexType[2] = 0; + Hz_IndexType[2] = 0; + mag_alpha_IndexType[2] = 0; + mag_gamma_IndexType[2] = 0; + Mx_IndexType[2] = 0; + My_IndexType[2] = 0; + Mz_IndexType[2] = 0; + mag_exchange_IndexType[2] = 0; mag_anisotropy_IndexType[2] = 0; - Mx_IndexType[2] = 0; - My_IndexType[2] = 0; - Mz_IndexType[2] = 0; - macro_cr_ratio[2] = 1; + macro_cr_ratio[2] = 1; #endif #endif From c404dfdac8210a955f8df9e5968f8694a3842811 Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 27 Oct 2021 16:01:10 -0700 Subject: [PATCH 14/32] proper stag bug fix --- .../inputs_3d_LLG_exchangeBC | 2 +- .../MacroscopicEvolveHM.cpp | 24 +++++----- .../MacroscopicEvolveHM_2nd.cpp | 48 +++++++++---------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 692c817c0..66bb76721 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -19,7 +19,7 @@ amr.max_level = 0 warpx.verbose = 1 warpx.use_filter = 0 warpx.cfl = 0.9 -warpx.mag_time_scheme_order = 2 # default 1 +warpx.mag_time_scheme_order = 1 # default 1 warpx.mag_M_normalization = 1 # 1 is saturated warpx.mag_LLG_coupling = 0 warpx.mag_LLG_exchange_coupling = 1 diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index 92973a82d..93bbe85fc 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -316,17 +316,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 @@ -443,17 +443,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 238e6942b..cae39341d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -293,17 +293,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 @@ -388,17 +388,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 @@ -683,17 +683,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 @@ -808,17 +808,17 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_z = mag_parser(x,y,z); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 From 71379de430f460deb0dcbd4ebc90515e3f35efdc Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 27 Oct 2021 17:39:43 -0700 Subject: [PATCH 15/32] exchange BC input file --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 66bb76721..d49280684 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -1,7 +1,7 @@ ################################ ####### GENERAL PARAMETERS ###### ################################# -max_step = 1 +max_step = 60000 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 @@ -19,7 +19,7 @@ amr.max_level = 0 warpx.verbose = 1 warpx.use_filter = 0 warpx.cfl = 0.9 -warpx.mag_time_scheme_order = 1 # default 1 +warpx.mag_time_scheme_order = 2 # default 1 warpx.mag_M_normalization = 1 # 1 is saturated warpx.mag_LLG_coupling = 0 warpx.mag_LLG_exchange_coupling = 1 From c9611de8c5c5bc37d2d519bba0f426065b76079c Mon Sep 17 00:00:00 2001 From: Prabhat Kumar Date: Tue, 2 Nov 2021 14:46:22 -0700 Subject: [PATCH 16/32] exchangeBC test input file --- .../inputs_3d_LLG_exchangeBC | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index d49280684..6b3e38a71 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -3,12 +3,12 @@ ################################# max_step = 60000 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 -amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain +amr.max_grid_size = 100 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 geometry.coord_sys = 0 -geometry.prob_lo = -10e-3 -10e-3 -10.0e-3 -geometry.prob_hi = 10e-3 10e-3 10.0e-3 +geometry.prob_lo = -10e-9 -10e-9 -10.0e-9 +geometry.prob_hi = 10e-9 10e-9 10.0e-9 boundary.field_lo = periodic periodic periodic boundary.field_hi = periodic periodic periodic amr.max_level = 0 @@ -18,7 +18,7 @@ amr.max_level = 0 ################################# warpx.verbose = 1 warpx.use_filter = 0 -warpx.cfl = 0.9 +warpx.cfl = 1000 warpx.mag_time_scheme_order = 2 # default 1 warpx.mag_M_normalization = 1 # 1 is saturated warpx.mag_LLG_coupling = 0 @@ -31,19 +31,25 @@ macroscopic.sigma_function(x,y,z) = "0.0" macroscopic.epsilon_function(x,y,z) = "8.8541878128e-12" macroscopic.mu_function(x,y,z) = "1.25663706212e-06" +my_constants.mag_lo_x = -5.e-9 +my_constants.mag_hi_x = 5.e-9 +my_constants.mag_lo_y = -5.e-9 +my_constants.mag_hi_y = 5.e-9 +my_constants.mag_lo_z = -5.e-9 +my_constants.mag_hi_z = 5.e-9 + #unit conversion: 1 Gauss = (1000/4pi) A/m macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" -macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG -#macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 0.) * (z > -5e-3) * (z < 5e-3) + 0.7e5 * (x > -5e-3) * (x < 5e-3) * (y >= 0.) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" +macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted +macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # gyromagnetic ratio is constant for electrons in all materials +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # gyromagnetic ratio is constant for electrons in all materials macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -66,13 +72,13 @@ warpx.Hz_external_grid_function(x,y,z) = 0. #calculation of H_bias: H_bias (oe) = frequency / 2.8e6 warpx.H_bias_ext_grid_init_style = parse_H_bias_ext_grid_function warpx.Hx_bias_external_grid_function(x,y,z)= 0. -warpx.Hy_bias_external_grid_function(x,y,z)= "3.7e4" # * (x > -5e-3) * (x < 5e-3) * (y > -5e-3) * (y < 5e-3) * (z > -5e-3) * (z < 5e-3)" # in A/m, equal to 464 Oersted +warpx.Hy_bias_external_grid_function(x,y,z)= "3.7e4" # in A/m, equal to 464 Oersted warpx.Hz_bias_external_grid_function(x,y,z)= 0. warpx.M_ext_grid_init_style = parse_M_ext_grid_function -warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= -5e-3) * (y < 0.) * (z >= -5e-3) * (z <= 5e-3)" +warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y < 0.) * (z >= mag_lo_z) * (z <= mag_hi_z)" warpx.My_external_grid_function(x,y,z) = 0. -warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= -5e-3) * (x <= 5e-3) * (y >= 0.) * (y <= 5e-3) * (z >= -5e-3) * (z <= 5e-3)" +warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= 0.) * (y <= mag_hi_x) * (z >= mag_lo_z) * (z <= mag_hi_z)" #Diagnostics diagnostics.diags_names = plt From 9474991f56270a1f471e4916af4dec143041df28 Mon Sep 17 00:00:00 2001 From: Prabhat Kumar <89051199+prkkumar@users.noreply.github.com> Date: Wed, 3 Nov 2021 10:26:34 -0700 Subject: [PATCH 17/32] Update GNUmakefile Co-authored-by: Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com> --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 5c1eca282..bca1a2226 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,8 +2,8 @@ AMREX_HOME ?= ../amrex PICSAR_HOME ?= ../picsar OPENBC_HOME ?= ../openbc_poisson -#DEBUG = FALSE -DEBUG = TRUE +DEBUG = FALSE +#DEBUG = TRUE WARN_ALL = TRUE #WARN_ERROR=TRUE From c1c7bdff46b53fe366c3f64da4503b41f9333aeb Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 3 Nov 2021 10:29:55 -0700 Subject: [PATCH 18/32] Fix typo in input file --- Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 6b3e38a71..618e189e9 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -3,7 +3,7 @@ ################################# max_step = 60000 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 -amr.max_grid_size = 100 # maximum size of each AMReX box, used to decompose the domain +amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 geometry.coord_sys = 0 From 8f34bd5414de66509aba4bedf9bf28bb1ba1ba9f Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 3 Nov 2021 10:31:59 -0700 Subject: [PATCH 19/32] Tabs --- .../CartesianYeeAlgorithm.H | 30 +++++++++---------- .../MacroscopicEvolveHM_2nd.cpp | 12 ++++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index fa11a6a26..ff2de3107 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -237,7 +237,7 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dx = coefs_x[0]; - if(ncomp != nodality){ + if(ncomp != nodality){ if ( Ms_hi_x == 0.) //non-magnetic on right { return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); @@ -245,11 +245,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_x == 0.) //non-magnetic on left { return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); - } else + } else { return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); } - } else { + } else { if ( Ms_hi_x == 0.) //non-magnetic on right { return inv_dx*(0. - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); @@ -257,11 +257,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_x == 0.) //non-magnetic on left { return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - 0.); - } else + } else { return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); } - } + } } /** @@ -273,7 +273,7 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dy = coefs_y[0]; - if(ncomp != nodality){ + if(ncomp != nodality){ if ( Ms_hi_y == 0.) //non-magnetic on right { return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); @@ -281,11 +281,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_y == 0.) //non-magnetic on left { return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); - } else + } else { return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } - } else { + } else { if ( Ms_hi_y == 0.) //non-magnetic on right { return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); @@ -293,11 +293,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_y == 0.) //non-magnetic on left { return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); - } else + } else { return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } - } + } } /** @@ -309,7 +309,7 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dz = coefs_z[0]; - if(ncomp != nodality){ + if(ncomp != nodality){ if ( Ms_hi_z == 0.) //non-magnetic on right { return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); @@ -317,11 +317,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_z == 0.) //non-magnetic on left { return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); - } else + } else { return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); } - } else { + } else { if ( Ms_hi_z == 0.) //non-magnetic on right { return inv_dz*(0. - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); @@ -329,11 +329,11 @@ struct CartesianYeeAlgorithm { else if (Ms_lo_z == 0.) //non-magnetic on left { return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - 0.); - } else + } else { return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); } - } + } } /** diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 732922534..df2cf21ab 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -199,7 +199,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); @@ -294,7 +294,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); @@ -389,7 +389,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); @@ -560,7 +560,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); @@ -684,7 +684,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); @@ -809,7 +809,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); + WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_lo_x = mag_parser(x,y,z); WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); amrex::Real Ms_hi_x = mag_parser(x,y,z); From 93dfcfda9874e1a10b71251a7cc02eb517522974 Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 3 Nov 2021 10:33:50 -0700 Subject: [PATCH 20/32] EOL --- .../FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index ff2de3107..a19c6716e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -233,7 +233,7 @@ struct CartesianYeeAlgorithm { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real LaplacianDx_Mag ( amrex::Array4 const& F, - amrex::Real const * const coefs_x, int const n_coefs_x, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, + amrex::Real const * const coefs_x, int const n_coefs_x, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dx = coefs_x[0]; @@ -344,7 +344,7 @@ struct CartesianYeeAlgorithm { amrex::Real const * const coefs_x, amrex::Real const * const coefs_y, amrex::Real const * const coefs_z, int const n_coefs_x, int const n_coefs_y, int const n_coefs_z, amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, - int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { + int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { return LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); } From be520a310f9b7ee2c5515fb4075a4047d66df636 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Mon, 22 Nov 2021 09:35:13 -0800 Subject: [PATCH 21/32] increase range of magnetic region so faces at interface are guaranteed to be magnetic --- .../Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 618e189e9..4e4936c94 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -40,16 +40,16 @@ my_constants.mag_hi_z = 5.e-9 #unit conversion: 1 Gauss = (1000/4pi) A/m macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" -macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG +macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted +macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # gyromagnetic ratio is constant for electrons in all materials +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # gyromagnetic ratio is constant for electrons in all materials macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y) * (y <= mag_hi_y) * (z >= mag_lo_z) * (z <= mag_hi_z)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -76,9 +76,9 @@ warpx.Hy_bias_external_grid_function(x,y,z)= "3.7e4" # in A/m, equal to 464 Oers warpx.Hz_bias_external_grid_function(x,y,z)= 0. warpx.M_ext_grid_init_style = parse_M_ext_grid_function -warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y) * (y < 0.) * (z >= mag_lo_z) * (z <= mag_hi_z)" +warpx.Mx_external_grid_function(x,y,z)= "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y < 0.) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" warpx.My_external_grid_function(x,y,z) = 0. -warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= 0.) * (y <= mag_hi_x) * (z >= mag_lo_z) * (z <= mag_hi_z)" +warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= 0.) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" #Diagnostics diagnostics.diags_names = plt From b1f2be1f9c9570f0a0b8b4c7a130832c4bec0cf9 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Mon, 22 Nov 2021 14:53:07 -0800 Subject: [PATCH 22/32] fill ghost cells for M_prev after each iteration --- .../FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index c14437888..5a9f1bb4f 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -1115,9 +1115,11 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( } } else{ - // Copy Mfield to Mfield_previous + const auto& period = warpx.Geom(lev).periodicity(); + // Copy Mfield to Mfield_previous and fill periodic/interior ghost cells for (int i = 0; i < 3; i++){ MultiFab::Copy(*Mfield_prev[i], *Mfield[i], 0, 0, 3, Mfield[i]->nGrow()); + (*Mfield_prev[i]).FillBoundary(Mfield[i]->nGrowVect(), period); } } From b35916a28feb869b40d2f6bd76b76e2caf6d9319 Mon Sep 17 00:00:00 2001 From: Prabhat Kumar Date: Mon, 22 Nov 2021 16:47:35 -0800 Subject: [PATCH 23/32] constant magnetic properties --- .../Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 4e4936c94..dc6244912 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -1,7 +1,7 @@ ################################ ####### GENERAL PARAMETERS ###### ################################# -max_step = 60000 +max_step = 6000 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 @@ -43,13 +43,13 @@ macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted +macroscopic.mag_alpha_function(x,y,z) = "0.058" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # gyromagnetic ratio is constant for electrons in all materials +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # gyromagnetic ratio is constant for electrons in all materials macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12 * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12" # * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -82,7 +82,7 @@ warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x < #Diagnostics diagnostics.diags_names = plt -plt.intervals = 10 +plt.intervals = 100 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 From fa1a655320138a638311beafe908d97effceef89 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Wed, 24 Nov 2021 12:59:25 -0800 Subject: [PATCH 24/32] bugfix; use zface only in z loop --- .../inputs_3d_LLG_exchangeBC | 12 ++++++------ .../CartesianYeeAlgorithm.H | 19 ++++++++++++------- .../MacroscopicEvolveHM.cpp | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index dc6244912..6884317ed 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -1,7 +1,7 @@ ################################ ####### GENERAL PARAMETERS ###### ################################# -max_step = 6000 +max_step = 1 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 @@ -19,7 +19,7 @@ amr.max_level = 0 warpx.verbose = 1 warpx.use_filter = 0 warpx.cfl = 1000 -warpx.mag_time_scheme_order = 2 # default 1 +warpx.mag_time_scheme_order = 1 # default 1 warpx.mag_M_normalization = 1 # 1 is saturated warpx.mag_LLG_coupling = 0 warpx.mag_LLG_exchange_coupling = 1 @@ -43,13 +43,13 @@ macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted +macroscopic.mag_alpha_function(x,y,z) = "0.058" macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # gyromagnetic ratio is constant for electrons in all materials +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11" macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12" # * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12" macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -82,7 +82,7 @@ warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x < #Diagnostics diagnostics.diags_names = plt -plt.intervals = 100 +plt.intervals = 1 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index a19c6716e..2c33609c2 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -276,28 +276,31 @@ struct CartesianYeeAlgorithm { if(ncomp != nodality){ if ( Ms_hi_y == 0.) //non-magnetic on right { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); +// return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); } else if (Ms_lo_y == 0.) //non-magnetic on left { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); +// return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); } else { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); +// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } else { if ( Ms_hi_y == 0.) //non-magnetic on right { - return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); +// return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } else if (Ms_lo_y == 0.) //non-magnetic on left { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); +// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); } else { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); +// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } + + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + } /** @@ -346,7 +349,9 @@ struct CartesianYeeAlgorithm { amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { - return LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); + return 0*LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + + 0*LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); } #endif diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index 6f606d628..a5ce0f42e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -498,7 +498,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // z component on z-faces of grid M_zface(i, j, k, 2) += dt * (PhysConst::mu0 * mag_gammaL) * (M_old_zface(i, j, k, 0) * Hy_eff - M_old_zface(i, j, k, 1) * Hx_eff) + dt * Gil_damp * (M_old_zface(i, j, k, 0) * (M_old_zface(i, j, k, 2) * Hx_eff - M_old_zface(i, j, k, 0) * Hz_eff) - - M_old_zface(i, j, k, 1) * (M_old_zface(i, j, k, 1) * Hz_eff - M_old_yface(i, j, k, 2) * Hy_eff)); + - M_old_zface(i, j, k, 1) * (M_old_zface(i, j, k, 1) * Hz_eff - M_old_zface(i, j, k, 2) * Hy_eff)); // temporary normalized magnitude of M_zface field at the fixed point // re-investigate the way we do Ms interp, in case we encounter the case where Ms changes across two adjacent cells that you are doing interp From d3637db4ff4e52b3dc880a8eee66ad1f11390a25 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Wed, 24 Nov 2021 13:06:39 -0800 Subject: [PATCH 25/32] revert these files --- .../inputs_3d_LLG_exchangeBC | 12 ++++++------ .../CartesianYeeAlgorithm.H | 19 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC index 6884317ed..dc6244912 100644 --- a/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC +++ b/Examples/Tests/Macroscopic_Maxwell/inputs_3d_LLG_exchangeBC @@ -1,7 +1,7 @@ ################################ ####### GENERAL PARAMETERS ###### ################################# -max_step = 1 +max_step = 6000 amr.n_cell = 64 64 64 # number of cells spanning the domain in each coordinate direction at level 0 amr.max_grid_size = 32 # maximum size of each AMReX box, used to decompose the domain amr.blocking_factor = 16 @@ -19,7 +19,7 @@ amr.max_level = 0 warpx.verbose = 1 warpx.use_filter = 0 warpx.cfl = 1000 -warpx.mag_time_scheme_order = 1 # default 1 +warpx.mag_time_scheme_order = 2 # default 1 warpx.mag_M_normalization = 1 # 1 is saturated warpx.mag_LLG_coupling = 0 warpx.mag_LLG_exchange_coupling = 1 @@ -43,13 +43,13 @@ macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" macroscopic.mag_Ms_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # in unit A/m, equal to 1750 Gauss; Ms must be nonzero for LLG macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "0.058" +macroscopic.mag_alpha_function(x,y,z) = "0.058" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # alpha is unitless, calculated from linewidth Delta_H = 40 Oersted macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = "-1.759e11" +macroscopic.mag_gamma_function(x,y,z) = "-1.759e11" # * (x >= mag_lo_x - 1e-12) * (x <= mag_hi_x + 1e-12) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # gyromagnetic ratio is constant for electrons in all materials macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "3.76e-12" +macroscopic.mag_exchange_function(x,y,z) = "3.76e-12" # * (x >= mag_lo_x) * (x <= mag_hi_x) * (y >= mag_lo_y - 1e-12) * (y <= mag_hi_y + 1e-12) * (z >= mag_lo_z - 1e-12) * (z <= mag_hi_z + 1e-12)" # exchange coupling constanit; Must be non-zero when exchange coupling is ON macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration @@ -82,7 +82,7 @@ warpx.Mz_external_grid_function(x,y,z) = "1.4e5 * (x >= mag_lo_x - 1e-12) * (x < #Diagnostics diagnostics.diags_names = plt -plt.intervals = 1 +plt.intervals = 100 plt.diag_type = Full plt.fields_to_plot = Ex Ey Ez Hx Hy Hz Bx By Bz Mx_xface My_xface Mz_xface Mx_yface My_yface Mz_yface Mx_zface My_zface Mz_zface plt.plot_raw_fields = 0 diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index 2c33609c2..a19c6716e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -276,31 +276,28 @@ struct CartesianYeeAlgorithm { if(ncomp != nodality){ if ( Ms_hi_y == 0.) //non-magnetic on right { -// return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); } else if (Ms_lo_y == 0.) //non-magnetic on left { -// return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); + return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); } else { -// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } else { if ( Ms_hi_y == 0.) //non-magnetic on right { -// return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } else if (Ms_lo_y == 0.) //non-magnetic on left { -// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); } else { -// return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); } } - - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); - } /** @@ -349,9 +346,7 @@ struct CartesianYeeAlgorithm { amrex::Real const Ms_lo_x, amrex::Real const Ms_hi_x, amrex::Real const Ms_lo_y, amrex::Real const Ms_hi_y, amrex::Real const Ms_lo_z, amrex::Real const Ms_hi_z, int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { - return 0*LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) - + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) - + 0*LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); + return LaplacianDx_Mag(F, coefs_x, n_coefs_x, Ms_lo_x, Ms_hi_x, i, j, k, ncomp, nodality) + LaplacianDy_Mag(F, coefs_y, n_coefs_y, Ms_lo_y, Ms_hi_y, i, j, k, ncomp, nodality) + LaplacianDz_Mag(F, coefs_z, n_coefs_z, Ms_lo_z, Ms_hi_z, i, j, k, ncomp, nodality); } #endif From 495ccfdb34b996d861ce51cd28306d08e95b612b Mon Sep 17 00:00:00 2001 From: prkkumar Date: Mon, 6 Dec 2021 17:17:36 -0800 Subject: [PATCH 26/32] Fixes for Neumann BC --- .../CartesianYeeAlgorithm.H | 128 ++++++++---------- 1 file changed, 53 insertions(+), 75 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H index a19c6716e..bacba1e84 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H @@ -237,31 +237,23 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dx = coefs_x[0]; - if(ncomp != nodality){ - if ( Ms_hi_x == 0.) //non-magnetic on right - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i-1,j,k,ncomp) + 4.*F(i-2,j,k,ncomp) - F(i-3,j,k,ncomp)); - } - else if (Ms_lo_x == 0.) //non-magnetic on left - { - return inv_dx*inv_dx*(2.*F(i,j,k,ncomp) - 5.*F(i+1,j,k,ncomp) + 4.*F(i+2,j,k,ncomp) - F(i+3,j,k,ncomp)); - } else - { - return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); - } - } else { - if ( Ms_hi_x == 0.) //non-magnetic on right - { - return inv_dx*(0. - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); - } - else if (Ms_lo_x == 0.) //non-magnetic on left - { - return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - 0.); - } else - { - return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); - } - } + if (nodality == 0){ // at x face (normal face). dM/dx = 0 + if (Ms_hi_x == 0.){ + return 0.5 * inv_dx * inv_dx * (8. * F(i-1, j, k, ncomp) - F(i-2, j, k, ncomp) - 7. * F(i, j, k, ncomp)); + } else if (Ms_lo_x == 0){ + return 0.5 * inv_dx * inv_dx * (8. * F(i+1, j, k, ncomp) - F(i+2, j, k, ncomp) - 7. * F(i, j, k, ncomp)); + } else { + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); + } + } else { // at y or z faces + if (Ms_hi_x == 0.){ + return inv_dx*(0. - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); + } else if (Ms_lo_x == 0.){ + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - 0.); + } else { + return inv_dx*(UpwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp) - DownwardDx(F, coefs_x, n_coefs_x, i, j, k, ncomp)); + } + } } /** @@ -273,31 +265,24 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dy = coefs_y[0]; - if(ncomp != nodality){ - if ( Ms_hi_y == 0.) //non-magnetic on right - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j-1,k,ncomp) + 4.*F(i,j-2,k,ncomp) - F(i,j-3,k,ncomp)); - } - else if (Ms_lo_y == 0.) //non-magnetic on left - { - return inv_dy*inv_dy*(2.*F(i,j,k,ncomp) - 5.*F(i,j+1,k,ncomp) + 4.*F(i,j+2,k,ncomp) - F(i,j+3,k,ncomp)); - } else - { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); - } - } else { - if ( Ms_hi_y == 0.) //non-magnetic on right - { - return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); - } - else if (Ms_lo_y == 0.) //non-magnetic on left - { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); - } else - { - return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); - } - } + if (nodality == 1){ // y face (normal face), dM/dy = 0 + if (Ms_hi_y == 0.){ + return 0.5 * inv_dy * inv_dy * (8. * F(i, j-1, k, ncomp) - F(i, j-2, k, ncomp) - 7. * F(i, j, k, ncomp)); + } else if (Ms_lo_y == 0.) { + return 0.5 * inv_dy * inv_dy * (8. * F(i, j+1, k, ncomp) - F(i, j+2, k, ncomp) - 7. * F(i, j, k, ncomp)); + } else { + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + } + + } else { // x or z faces + if (Ms_hi_y == 0.){ + return inv_dy*(0. - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + } else if (Ms_lo_y == 0.) { + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - 0.); + } else { + return inv_dy*(UpwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp) - DownwardDy(F, coefs_y, n_coefs_y, i, j, k, ncomp)); + } + } } /** @@ -309,31 +294,24 @@ struct CartesianYeeAlgorithm { int const i, int const j, int const k, int const ncomp=0, int const nodality=0) { amrex::Real const inv_dz = coefs_z[0]; - if(ncomp != nodality){ - if ( Ms_hi_z == 0.) //non-magnetic on right - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k-1,ncomp) + 4.*F(i,j,k-2,ncomp) - F(i,j,k-3,ncomp)); - } - else if (Ms_lo_z == 0.) //non-magnetic on left - { - return inv_dz*inv_dz*(2.*F(i,j,k,ncomp) - 5.*F(i,j,k+1,ncomp) + 4.*F(i,j,k+2,ncomp) - F(i,j,k+3,ncomp)); - } else - { - return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); - } - } else { - if ( Ms_hi_z == 0.) //non-magnetic on right - { - return inv_dz*(0. - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); - } - else if (Ms_lo_z == 0.) //non-magnetic on left - { - return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - 0.); - } else - { - return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); - } - } + if (nodality == 2){ // z face (normal face) dM/dz = 0 + if ( Ms_hi_z == 0.) { + return 0.5 * inv_dz * inv_dz * (8. * F(i, j, k-1, ncomp) - F(i, j, k-2, ncomp) - 7. * F(i, j, k, ncomp)); + } else if ( Ms_lo_z == 0.){ + return 0.5 * inv_dz * inv_dz * (8. * F(i, j, k+1, ncomp) - F(i, j, k+2, ncomp) - 7. * F(i, j, k, ncomp)); + } else { + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); + } + + } else { // x or y face + if ( Ms_hi_z == 0.) { + return inv_dz*(0. - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); + } else if ( Ms_lo_z == 0.){ + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - 0.); + } else { + return inv_dz*(UpwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp) - DownwardDz(F, coefs_z, n_coefs_z, i, j, k, ncomp)); + } + } } /** From ca8195ddb8186cd9a76e42025df4a13f1494855b Mon Sep 17 00:00:00 2001 From: prkkumar Date: Mon, 6 Dec 2021 17:19:41 -0800 Subject: [PATCH 27/32] bug fix yface --- .../FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index 6f606d628..a5ce0f42e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -498,7 +498,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( // z component on z-faces of grid M_zface(i, j, k, 2) += dt * (PhysConst::mu0 * mag_gammaL) * (M_old_zface(i, j, k, 0) * Hy_eff - M_old_zface(i, j, k, 1) * Hx_eff) + dt * Gil_damp * (M_old_zface(i, j, k, 0) * (M_old_zface(i, j, k, 2) * Hx_eff - M_old_zface(i, j, k, 0) * Hz_eff) - - M_old_zface(i, j, k, 1) * (M_old_zface(i, j, k, 1) * Hz_eff - M_old_yface(i, j, k, 2) * Hy_eff)); + - M_old_zface(i, j, k, 1) * (M_old_zface(i, j, k, 1) * Hz_eff - M_old_zface(i, j, k, 2) * Hy_eff)); // temporary normalized magnitude of M_zface field at the fixed point // re-investigate the way we do Ms interp, in case we encounter the case where Ms changes across two adjacent cells that you are doing interp From 3e17bcc4cef1a1b111c8e8cfd64fa8d97c3d9a74 Mon Sep 17 00:00:00 2001 From: jackieyao0114 Date: Sun, 13 Feb 2022 22:45:59 -0800 Subject: [PATCH 28/32] added test cases input and post processing bash --- .../PSSW_halfCos_exci/getLine.bash | 11 ++ .../input_LLG_PSSW_asymm_exci | 129 ++++++++++++++++++ .../PSSW_halfCos_exci/readfield.bash | 6 + .../PSSW_halfCos_exci/squashTime.bash | 6 + 4 files changed, 152 insertions(+) create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash new file mode 100644 index 000000000..7733d89f5 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash @@ -0,0 +1,11 @@ +#!/bin/bash +FILE="$1" +LINE_NO=$2 +i=0 +while read line; do + i=$(( i + 1 )) + case $i in $LINE_NO) echo "$line"; break;; esac +done <"$FILE" + +### how to run this script: +### $ bash squashTime.bash FILE LINE_NO \ No newline at end of file diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci new file mode 100644 index 000000000..f643c4577 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci @@ -0,0 +1,129 @@ +# set up to duplicate perpendicular standing spin wave for exchange boundary condition demo +# max step +max_step = 5000000 + +# number of grid points +amr.n_cell = n_cellx n_celly n_cellz + +# Maximum allowable size of each subdomain +amr.max_grid_size = grid_number +amr.blocking_factor = 8 + +amr.max_level = 0 + +# Geometry +geometry.coord_sys = 0 # 0: Cartesian +geometry.prob_lo = -width/2 -length/2 -thickness +geometry.prob_hi = width/2 length/2 thickness + +# Boundary condition +boundary.field_lo = periodic periodic pec +boundary.field_hi = periodic periodic pec +warpx.serialize_ics = 1 + +# Verbosity +warpx.verbose = 1 +warpx.use_filter = 0 +warpx.cfl = 1000.0 # We can use a large cfl number here because the Maxwell equations are not included. +warpx.mag_time_scheme_order = 2 # default 1 +warpx.mag_M_normalization = 1 +warpx.mag_LLG_coupling = 0 +warpx.mag_LLG_exchange_coupling = 1 +warpx.mag_LLG_anisotropy_coupling = 0 + +# Algorithms +algo.current_deposition = esirkepov +algo.em_solver_medium = macroscopic # vacuum/macroscopic + +my_constants.thickness = 345.0e-9 +my_constants.width = 6900.0e-9 +my_constants.length = 6900.0e-9 +my_constants.n_cellx = 8 +my_constants.n_celly = 8 +my_constants.n_cellz = 256 +my_constants.grid_number = 256 + +my_constants.epsilon_r = 13.0 +my_constants.pi = 3.14159265359 +my_constants.mu0 = 1.25663706212e-6 +my_constants.epsilon0 = 8.84e-12 +my_constants.Ms_ga = 1750. + +my_constants.flag_none = 0 +my_constants.flag_hs = 1 +my_constants.flag_ss = 2 + +algo.macroscopic_sigma_method = laxwendroff # laxwendroff or backwardeuler +macroscopic.sigma_function(x,y,z) = "0.0" +macroscopic.epsilon_function(x,y,z) = "epsilon0 * epsilon_r" +macroscopic.mu_function(x,y,z) = "mu0" + +#unit conversion: 1 Gauss = (1000/4pi) A/m +macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" +macroscopic.mag_Ms_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi" # in unit A/m + +macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" +macroscopic.mag_alpha_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 0.005" # alpha is unitless, typical values range from 1e-3 ~ 1e-5 + +macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" +macroscopic.mag_gamma_function(x,y,z) = " -1.759e11 " # gyromagnetic ratio is constant for electrons in all materials + +macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" +macroscopic.mag_exchange_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 3.1e-12" # YIG + +#macroscopic.mag_anisotropy_init_style = "parse_mag_anisotropy_function" # parse or "constant" +#macroscopic.mag_anisotropy_function(x,y,z) = "0.0" # Ku = mu0 * Ms * H_anis / 2.0, all fields in SI units, H_anis = 20 Oe + +macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step +macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration +macroscopic.mag_normalized_error = 0.1 # if M magnitude relatively changes more than this value, raise a red flag +#macroscopic.mag_LLG_anisotropy_axis = 0.0 1.0 0.0 + +################################# +############ FIELDS ############# +################################# +my_constants.Hy_bias_oe = 300 # in Oe +my_constants.Hx_rf_oe = 3 # in Oe +my_constants.c = 299792458. +my_constants.frequency = 2.5e9 # frequency of input microwave H +my_constants.TP = 1/frequency +my_constants.flag_none = 0 +my_constants.flag_hs = 1 +my_constants.flag_ss = 2 + +#warpx.E_excitation_on_grid_style = "parse_E_excitation_grid_function" +#warpx.Ex_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ey_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ez_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ex_excitation_flag_function(x,y,z) = "flag_none" +# warpx.Ey_excitation_flag_function(x,y,z) = "flag_ss * (z > -domain_size/2.0 + thickness - domain_size/grid_number/2.0) * (z <= -domain_size/2.0 + thickness + domain_size/grid_number/2.0)" +#warpx.Ey_excitation_flag_function(x,y,z) = "flag_none" +#warpx.Ez_excitation_flag_function(x,y,z) = "flag_none" + +#unit conversion: 1 Gauss = 1 Oersted = (1000/4pi) A/m +#calculation of H_bias: H_bias (oe) = frequency / 2.8e6 + +warpx.H_bias_excitation_on_grid_style = parse_h_bias_excitation_grid_function +#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t))" +warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t)) * cos(z/thickness * pi)" + +#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "0.0" +warpx.Hy_bias_excitation_grid_function(x,y,z,t) = "Hy_bias_oe * 1000/4/pi" +warpx.Hz_bias_excitation_grid_function(x,y,z,t) = "0.0" + +warpx.Hx_bias_excitation_flag_function(x,y,z) = "flag_hs" +warpx.Hy_bias_excitation_flag_function(x,y,z) = "flag_hs" +warpx.Hz_bias_excitation_flag_function(x,y,z) = "flag_none" + +warpx.M_ext_grid_init_style = parse_M_ext_grid_function +warpx.Mx_external_grid_function(x,y,z)= "0.0" +warpx.My_external_grid_function(x,y,z)= " (z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi " +warpx.Mz_external_grid_function(x,y,z)= "0.0" + + +# Diagnostics +diagnostics.diags_names = plt +plt.intervals = 500 +plt.diag_type = Full +plt.fields_to_plot = Mx_xface Mx_yface Mx_zface My_xface My_yface My_zface Mz_xface Mz_yface Mz_zface +plt.file_min_digits = 9 diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash new file mode 100644 index 000000000..a66156be4 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash @@ -0,0 +1,6 @@ +#!/bin/bash +for timestep in $(seq 0 500 5000000 ); do + newnumber='000000000'${timestep} # get number, pack with zeros + newnumber=${newnumber:(-9)} # the last seven characters + ./WritePlotfileToASCII3d.gnu.ex infile=diags/plt${newnumber} | tee raw_data/${newnumber}.txt +done diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash new file mode 100644 index 000000000..e57827115 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash @@ -0,0 +1,6 @@ +#!/bin/bash +for timestep in $(seq 0 500 5000000); do + newnumber='000000000'${timestep} # get number, pack with zeros + newnumber=${newnumber:(-9)} # the last seven characters + bash getLine.bash raw_data/${newnumber}.txt 128 | tee -a Mx_xface_center_128.txt +done From 3d5af9ada89098fa721739567dbdb25dc847e921 Mon Sep 17 00:00:00 2001 From: jackieyao0114 Date: Tue, 15 Feb 2022 14:08:53 -0800 Subject: [PATCH 29/32] clean up magnetic property arrays without parsing; added back lev in evolveHM_2nd --- .../FiniteDifferenceSolver.H | 2 + .../MacroscopicEvolveHM.cpp | 69 +++------ .../MacroscopicEvolveHM_2nd.cpp | 142 +++++++----------- Source/FieldSolver/WarpXPushFieldsEM.cpp | 2 +- 4 files changed, 78 insertions(+), 137 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H index e8f16ea4e..c29282ed8 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H @@ -136,6 +136,7 @@ class FiniteDifferenceSolver std::unique_ptr const ¯oscopic_properties); void MacroscopicEvolveHM_2nd ( + int lev, std::array, 3> &Mfield, std::array, 3> &Hfield, // H Maxwell std::array< std::unique_ptr, 3>& Bfield, @@ -323,6 +324,7 @@ class FiniteDifferenceSolver template< typename T_Algo > void MacroscopicEvolveHMCartesian_2nd( + int lev, std::array, 3> &Mfield, std::array, 3> &Hfield, // H Maxwell std::array< std::unique_ptr, 3 >& Bfield, diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp index 532fe79b9..ab3d2dc1c 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM.cpp @@ -190,21 +190,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( if (mag_exchange_xface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_xface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_xface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_xface_arr(i,j,k) / mag_Ms_xface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_xface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_xface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_xface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_xface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_xface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_xface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 @@ -314,21 +307,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( if (mag_exchange_yface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_yface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_yface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_yface_arr(i,j,k) / mag_Ms_yface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_yface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_yface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_yface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_yface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_yface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_yface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 @@ -439,21 +425,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian( if (mag_exchange_zface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_zface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_zface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_zface_arr(i,j,k) / mag_Ms_zface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_zface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_zface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_zface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_zface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_zface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_zface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_old_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp index 83758a67e..3bf2b121d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveHM_2nd.cpp @@ -29,6 +29,7 @@ using namespace amrex; void FiniteDifferenceSolver::MacroscopicEvolveHM_2nd( // The MField here is a vector of three multifabs, with M on each face, and each multifab is a three-component multifab. // Each M-multifab has three components, one for each component in x, y, z. (All multifabs are four dimensional, (i,j,k,n)), where, n=1 for E, B, but, n=3 for M_xface, M_yface, M_zface + int lev, std::array, 3> &Mfield, // Mfield contains three components MultiFab std::array, 3> &Hfield, std::array, 3> &Bfield, @@ -38,7 +39,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHM_2nd( std::unique_ptr const ¯oscopic_properties) { if (m_fdtd_algo == MaxwellSolverAlgo::Yee){ - MacroscopicEvolveHMCartesian_2nd(Mfield, Hfield, Bfield, H_biasfield, Efield, dt, macroscopic_properties); + MacroscopicEvolveHMCartesian_2nd(lev, Mfield, Hfield, Bfield, H_biasfield, Efield, dt, macroscopic_properties); } else { amrex::Abort("Only yee algorithm is compatible for M updates."); } @@ -47,6 +48,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveHM_2nd( #ifdef WARPX_MAG_LLG template void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( + int lev, std::array, 3> &Mfield, std::array, 3> &Hfield, std::array, 3> &Bfield, @@ -203,21 +205,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_xface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_xface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_xface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_xface_arr(i,j,k) / mag_Ms_xface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_xface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_xface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_xface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_xface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_xface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_xface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 @@ -295,21 +290,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_yface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_yface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_yface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_yface_arr(i,j,k) / mag_Ms_yface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_yface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_yface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_yface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_yface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_yface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_yface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 @@ -387,21 +375,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_zface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_zface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^(old_time) - if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_zface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_zface_arr(i,j,k) / mag_Ms_zface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_zface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_zface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_zface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_zface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_zface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_zface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 @@ -575,21 +556,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_xface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_xface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^[(new_time),r-1] - if (mag_exchange_arrx == 0._rt) amrex::Abort("The mag_exchange_arrx is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrx / PhysConst::mu0 / mag_Ms_arrx / mag_Ms_arrx; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mx_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_xface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_xface_arr(i,j,k) / mag_Ms_xface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_xface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_xface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_xface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_xface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_xface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_xface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 0); //Last argument is nodality -- xface = 0 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_xface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 0); //Last argument is nodality -- xface = 0 @@ -697,21 +671,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_yface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_yface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^[(new_time),r-1] - if (mag_exchange_arry == 0._rt) amrex::Abort("The mag_exchange_arry is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arry / PhysConst::mu0 / mag_Ms_arry / mag_Ms_arry; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, My_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_yface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_yface_arr(i,j,k) / mag_Ms_yface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_yface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_yface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_yface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_yface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_yface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_yface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 1); //Last argument is nodality -- yface = 1 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_yface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 1); //Last argument is nodality -- yface = 1 @@ -820,21 +787,14 @@ void FiniteDifferenceSolver::MacroscopicEvolveHMCartesian_2nd( if (mag_exchange_zface_arr(i,j,k) == 0._rt) amrex::Abort("The mag_exchange_zface_arr(i,j,k) is 0.0 while including the exchange coupling term H_exchange for H_eff"); // H_exchange - use M^[(new_time),r-1] - if (mag_exchange_arrz == 0._rt) amrex::Abort("The mag_exchange_arrz is 0.0 while including the exchange coupling term H_exchange for H_eff"); - amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_arrz / PhysConst::mu0 / mag_Ms_arrz / mag_Ms_arrz; - - WarpXUtilAlgo::getCellCoordinates(i-1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i+1, j, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_x = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j-1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j+1, k, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_y = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k-1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_lo_z = mag_parser(x,y,z); - WarpXUtilAlgo::getCellCoordinates(i, j, k+1, Mz_stag, problo, dx, x, y, z); - amrex::Real Ms_hi_z = mag_parser(x,y,z); + amrex::Real const H_exchange_coeff = 2.0 * mag_exchange_zface_arr(i,j,k) / PhysConst::mu0 / mag_Ms_zface_arr(i,j,k) / mag_Ms_zface_arr(i,j,k); + + amrex::Real Ms_lo_x = mag_Ms_zface_arr(i-1, j, k); + amrex::Real Ms_hi_x = mag_Ms_zface_arr(i+1, j, k); + amrex::Real Ms_lo_y = mag_Ms_zface_arr(i, j-1, k); + amrex::Real Ms_hi_y = mag_Ms_zface_arr(i, j+1, k); + amrex::Real Ms_lo_z = mag_Ms_zface_arr(i, j, k-1); + amrex::Real Ms_hi_z = mag_Ms_zface_arr(i, j, k+1); Hx_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 0, 2); //Last argument is nodality -- zface = 2 Hy_eff += H_exchange_coeff * T_Algo::Laplacian_Mag(M_prev_zface, coefs_x, coefs_y, coefs_z, n_coefs_x, n_coefs_y, n_coefs_z, Ms_lo_x, Ms_hi_x, Ms_lo_y, Ms_hi_y, Ms_lo_z, Ms_hi_z, i, j, k, 1, 2); //Last argument is nodality -- zface = 2 diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index cf03bd93c..00b4cf5d8 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -799,7 +799,7 @@ WarpX::MacroscopicEvolveHM_2nd (int lev, PatchType patch_type, amrex::Real a_dt) // Evolve H field in regular cells if (patch_type == PatchType::fine) { - m_fdtd_solver_fp[lev]->MacroscopicEvolveHM_2nd(Mfield_fp[lev], Hfield_fp[lev], Bfield_fp[lev], H_biasfield_fp[lev], Efield_fp[lev], + m_fdtd_solver_fp[lev]->MacroscopicEvolveHM_2nd(lev, Mfield_fp[lev], Hfield_fp[lev], Bfield_fp[lev], H_biasfield_fp[lev], Efield_fp[lev], a_dt, m_macroscopic_properties); } else { From 68237e3fb60dd86884f36f00223689546023e5cb Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 16 Feb 2022 10:35:22 -0800 Subject: [PATCH 30/32] style fix --- .../PSSW_halfCos_exci/analysis_getline.bash | 11 ++ .../PSSW_halfCos_exci/analysis_readfield.bash | 6 + .../analysis_squashTime.bash | 6 + .../inputs_LLG_PSSW_asymm_exci | 129 ++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_getline.bash create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_readfield.bash create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_squashTime.bash create mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_getline.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_getline.bash new file mode 100644 index 000000000..7733d89f5 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_getline.bash @@ -0,0 +1,11 @@ +#!/bin/bash +FILE="$1" +LINE_NO=$2 +i=0 +while read line; do + i=$(( i + 1 )) + case $i in $LINE_NO) echo "$line"; break;; esac +done <"$FILE" + +### how to run this script: +### $ bash squashTime.bash FILE LINE_NO \ No newline at end of file diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_readfield.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_readfield.bash new file mode 100644 index 000000000..a66156be4 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_readfield.bash @@ -0,0 +1,6 @@ +#!/bin/bash +for timestep in $(seq 0 500 5000000 ); do + newnumber='000000000'${timestep} # get number, pack with zeros + newnumber=${newnumber:(-9)} # the last seven characters + ./WritePlotfileToASCII3d.gnu.ex infile=diags/plt${newnumber} | tee raw_data/${newnumber}.txt +done diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_squashTime.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_squashTime.bash new file mode 100644 index 000000000..e57827115 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/analysis_squashTime.bash @@ -0,0 +1,6 @@ +#!/bin/bash +for timestep in $(seq 0 500 5000000); do + newnumber='000000000'${timestep} # get number, pack with zeros + newnumber=${newnumber:(-9)} # the last seven characters + bash getLine.bash raw_data/${newnumber}.txt 128 | tee -a Mx_xface_center_128.txt +done diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci new file mode 100644 index 000000000..f643c4577 --- /dev/null +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci @@ -0,0 +1,129 @@ +# set up to duplicate perpendicular standing spin wave for exchange boundary condition demo +# max step +max_step = 5000000 + +# number of grid points +amr.n_cell = n_cellx n_celly n_cellz + +# Maximum allowable size of each subdomain +amr.max_grid_size = grid_number +amr.blocking_factor = 8 + +amr.max_level = 0 + +# Geometry +geometry.coord_sys = 0 # 0: Cartesian +geometry.prob_lo = -width/2 -length/2 -thickness +geometry.prob_hi = width/2 length/2 thickness + +# Boundary condition +boundary.field_lo = periodic periodic pec +boundary.field_hi = periodic periodic pec +warpx.serialize_ics = 1 + +# Verbosity +warpx.verbose = 1 +warpx.use_filter = 0 +warpx.cfl = 1000.0 # We can use a large cfl number here because the Maxwell equations are not included. +warpx.mag_time_scheme_order = 2 # default 1 +warpx.mag_M_normalization = 1 +warpx.mag_LLG_coupling = 0 +warpx.mag_LLG_exchange_coupling = 1 +warpx.mag_LLG_anisotropy_coupling = 0 + +# Algorithms +algo.current_deposition = esirkepov +algo.em_solver_medium = macroscopic # vacuum/macroscopic + +my_constants.thickness = 345.0e-9 +my_constants.width = 6900.0e-9 +my_constants.length = 6900.0e-9 +my_constants.n_cellx = 8 +my_constants.n_celly = 8 +my_constants.n_cellz = 256 +my_constants.grid_number = 256 + +my_constants.epsilon_r = 13.0 +my_constants.pi = 3.14159265359 +my_constants.mu0 = 1.25663706212e-6 +my_constants.epsilon0 = 8.84e-12 +my_constants.Ms_ga = 1750. + +my_constants.flag_none = 0 +my_constants.flag_hs = 1 +my_constants.flag_ss = 2 + +algo.macroscopic_sigma_method = laxwendroff # laxwendroff or backwardeuler +macroscopic.sigma_function(x,y,z) = "0.0" +macroscopic.epsilon_function(x,y,z) = "epsilon0 * epsilon_r" +macroscopic.mu_function(x,y,z) = "mu0" + +#unit conversion: 1 Gauss = (1000/4pi) A/m +macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" +macroscopic.mag_Ms_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi" # in unit A/m + +macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" +macroscopic.mag_alpha_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 0.005" # alpha is unitless, typical values range from 1e-3 ~ 1e-5 + +macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" +macroscopic.mag_gamma_function(x,y,z) = " -1.759e11 " # gyromagnetic ratio is constant for electrons in all materials + +macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" +macroscopic.mag_exchange_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 3.1e-12" # YIG + +#macroscopic.mag_anisotropy_init_style = "parse_mag_anisotropy_function" # parse or "constant" +#macroscopic.mag_anisotropy_function(x,y,z) = "0.0" # Ku = mu0 * Ms * H_anis / 2.0, all fields in SI units, H_anis = 20 Oe + +macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step +macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration +macroscopic.mag_normalized_error = 0.1 # if M magnitude relatively changes more than this value, raise a red flag +#macroscopic.mag_LLG_anisotropy_axis = 0.0 1.0 0.0 + +################################# +############ FIELDS ############# +################################# +my_constants.Hy_bias_oe = 300 # in Oe +my_constants.Hx_rf_oe = 3 # in Oe +my_constants.c = 299792458. +my_constants.frequency = 2.5e9 # frequency of input microwave H +my_constants.TP = 1/frequency +my_constants.flag_none = 0 +my_constants.flag_hs = 1 +my_constants.flag_ss = 2 + +#warpx.E_excitation_on_grid_style = "parse_E_excitation_grid_function" +#warpx.Ex_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ey_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ez_excitation_grid_function(x,y,z,t) = "0.0" +#warpx.Ex_excitation_flag_function(x,y,z) = "flag_none" +# warpx.Ey_excitation_flag_function(x,y,z) = "flag_ss * (z > -domain_size/2.0 + thickness - domain_size/grid_number/2.0) * (z <= -domain_size/2.0 + thickness + domain_size/grid_number/2.0)" +#warpx.Ey_excitation_flag_function(x,y,z) = "flag_none" +#warpx.Ez_excitation_flag_function(x,y,z) = "flag_none" + +#unit conversion: 1 Gauss = 1 Oersted = (1000/4pi) A/m +#calculation of H_bias: H_bias (oe) = frequency / 2.8e6 + +warpx.H_bias_excitation_on_grid_style = parse_h_bias_excitation_grid_function +#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t))" +warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t)) * cos(z/thickness * pi)" + +#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "0.0" +warpx.Hy_bias_excitation_grid_function(x,y,z,t) = "Hy_bias_oe * 1000/4/pi" +warpx.Hz_bias_excitation_grid_function(x,y,z,t) = "0.0" + +warpx.Hx_bias_excitation_flag_function(x,y,z) = "flag_hs" +warpx.Hy_bias_excitation_flag_function(x,y,z) = "flag_hs" +warpx.Hz_bias_excitation_flag_function(x,y,z) = "flag_none" + +warpx.M_ext_grid_init_style = parse_M_ext_grid_function +warpx.Mx_external_grid_function(x,y,z)= "0.0" +warpx.My_external_grid_function(x,y,z)= " (z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi " +warpx.Mz_external_grid_function(x,y,z)= "0.0" + + +# Diagnostics +diagnostics.diags_names = plt +plt.intervals = 500 +plt.diag_type = Full +plt.fields_to_plot = Mx_xface Mx_yface Mx_zface My_xface My_yface My_zface Mz_xface Mz_yface Mz_zface +plt.file_min_digits = 9 From 6c876bb0586abdc2c902886bd007b7389ba48226 Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 16 Feb 2022 10:39:52 -0800 Subject: [PATCH 31/32] EOL --- .../PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci index f643c4577..d76f3cd3b 100644 --- a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci +++ b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/inputs_LLG_PSSW_asymm_exci @@ -104,8 +104,8 @@ my_constants.flag_ss = 2 #calculation of H_bias: H_bias (oe) = frequency / 2.8e6 warpx.H_bias_excitation_on_grid_style = parse_h_bias_excitation_grid_function -#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t))" -warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t)) * cos(z/thickness * pi)" +#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t))" +warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t)) * cos(z/thickness * pi)" #warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "0.0" warpx.Hy_bias_excitation_grid_function(x,y,z,t) = "Hy_bias_oe * 1000/4/pi" From 7b8630373195358163345156cf279e9ec5daa95f Mon Sep 17 00:00:00 2001 From: prkkumar Date: Wed, 16 Feb 2022 10:42:48 -0800 Subject: [PATCH 32/32] remove wrongly named files --- .../PSSW_halfCos_exci/getLine.bash | 11 -- .../input_LLG_PSSW_asymm_exci | 129 ------------------ .../PSSW_halfCos_exci/readfield.bash | 6 - .../PSSW_halfCos_exci/squashTime.bash | 6 - 4 files changed, 152 deletions(-) delete mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash delete mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci delete mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash delete mode 100644 Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash deleted file mode 100644 index 7733d89f5..000000000 --- a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/getLine.bash +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -FILE="$1" -LINE_NO=$2 -i=0 -while read line; do - i=$(( i + 1 )) - case $i in $LINE_NO) echo "$line"; break;; esac -done <"$FILE" - -### how to run this script: -### $ bash squashTime.bash FILE LINE_NO \ No newline at end of file diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci deleted file mode 100644 index f643c4577..000000000 --- a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/input_LLG_PSSW_asymm_exci +++ /dev/null @@ -1,129 +0,0 @@ -# set up to duplicate perpendicular standing spin wave for exchange boundary condition demo -# max step -max_step = 5000000 - -# number of grid points -amr.n_cell = n_cellx n_celly n_cellz - -# Maximum allowable size of each subdomain -amr.max_grid_size = grid_number -amr.blocking_factor = 8 - -amr.max_level = 0 - -# Geometry -geometry.coord_sys = 0 # 0: Cartesian -geometry.prob_lo = -width/2 -length/2 -thickness -geometry.prob_hi = width/2 length/2 thickness - -# Boundary condition -boundary.field_lo = periodic periodic pec -boundary.field_hi = periodic periodic pec -warpx.serialize_ics = 1 - -# Verbosity -warpx.verbose = 1 -warpx.use_filter = 0 -warpx.cfl = 1000.0 # We can use a large cfl number here because the Maxwell equations are not included. -warpx.mag_time_scheme_order = 2 # default 1 -warpx.mag_M_normalization = 1 -warpx.mag_LLG_coupling = 0 -warpx.mag_LLG_exchange_coupling = 1 -warpx.mag_LLG_anisotropy_coupling = 0 - -# Algorithms -algo.current_deposition = esirkepov -algo.em_solver_medium = macroscopic # vacuum/macroscopic - -my_constants.thickness = 345.0e-9 -my_constants.width = 6900.0e-9 -my_constants.length = 6900.0e-9 -my_constants.n_cellx = 8 -my_constants.n_celly = 8 -my_constants.n_cellz = 256 -my_constants.grid_number = 256 - -my_constants.epsilon_r = 13.0 -my_constants.pi = 3.14159265359 -my_constants.mu0 = 1.25663706212e-6 -my_constants.epsilon0 = 8.84e-12 -my_constants.Ms_ga = 1750. - -my_constants.flag_none = 0 -my_constants.flag_hs = 1 -my_constants.flag_ss = 2 - -algo.macroscopic_sigma_method = laxwendroff # laxwendroff or backwardeuler -macroscopic.sigma_function(x,y,z) = "0.0" -macroscopic.epsilon_function(x,y,z) = "epsilon0 * epsilon_r" -macroscopic.mu_function(x,y,z) = "mu0" - -#unit conversion: 1 Gauss = (1000/4pi) A/m -macroscopic.mag_Ms_init_style = "parse_mag_Ms_function" # parse or "constant" -macroscopic.mag_Ms_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi" # in unit A/m - -macroscopic.mag_alpha_init_style = "parse_mag_alpha_function" # parse or "constant" -macroscopic.mag_alpha_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 0.005" # alpha is unitless, typical values range from 1e-3 ~ 1e-5 - -macroscopic.mag_gamma_init_style = "parse_mag_gamma_function" # parse or "constant" -macroscopic.mag_gamma_function(x,y,z) = " -1.759e11 " # gyromagnetic ratio is constant for electrons in all materials - -macroscopic.mag_exchange_init_style = "parse_mag_exchange_function" # parse or "constant" -macroscopic.mag_exchange_function(x,y,z) = "(z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * 3.1e-12" # YIG - -#macroscopic.mag_anisotropy_init_style = "parse_mag_anisotropy_function" # parse or "constant" -#macroscopic.mag_anisotropy_function(x,y,z) = "0.0" # Ku = mu0 * Ms * H_anis / 2.0, all fields in SI units, H_anis = 20 Oe - -macroscopic.mag_max_iter = 100 # maximum number of M iteration in each time step -macroscopic.mag_tol = 1.e-6 # M magnitude relative error tolerance compared to previous iteration -macroscopic.mag_normalized_error = 0.1 # if M magnitude relatively changes more than this value, raise a red flag -#macroscopic.mag_LLG_anisotropy_axis = 0.0 1.0 0.0 - -################################# -############ FIELDS ############# -################################# -my_constants.Hy_bias_oe = 300 # in Oe -my_constants.Hx_rf_oe = 3 # in Oe -my_constants.c = 299792458. -my_constants.frequency = 2.5e9 # frequency of input microwave H -my_constants.TP = 1/frequency -my_constants.flag_none = 0 -my_constants.flag_hs = 1 -my_constants.flag_ss = 2 - -#warpx.E_excitation_on_grid_style = "parse_E_excitation_grid_function" -#warpx.Ex_excitation_grid_function(x,y,z,t) = "0.0" -#warpx.Ey_excitation_grid_function(x,y,z,t) = "0.0" -#warpx.Ez_excitation_grid_function(x,y,z,t) = "0.0" -#warpx.Ex_excitation_flag_function(x,y,z) = "flag_none" -# warpx.Ey_excitation_flag_function(x,y,z) = "flag_ss * (z > -domain_size/2.0 + thickness - domain_size/grid_number/2.0) * (z <= -domain_size/2.0 + thickness + domain_size/grid_number/2.0)" -#warpx.Ey_excitation_flag_function(x,y,z) = "flag_none" -#warpx.Ez_excitation_flag_function(x,y,z) = "flag_none" - -#unit conversion: 1 Gauss = 1 Oersted = (1000/4pi) A/m -#calculation of H_bias: H_bias (oe) = frequency / 2.8e6 - -warpx.H_bias_excitation_on_grid_style = parse_h_bias_excitation_grid_function -#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t))" -warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "Hx_rf_oe * 1000/4/pi * (exp(-(t-3*TP)**2/(2*TP**2))*cos(2*pi*frequency*t)) * cos(z/thickness * pi)" - -#warpx.Hx_bias_excitation_grid_function(x,y,z,t) = "0.0" -warpx.Hy_bias_excitation_grid_function(x,y,z,t) = "Hy_bias_oe * 1000/4/pi" -warpx.Hz_bias_excitation_grid_function(x,y,z,t) = "0.0" - -warpx.Hx_bias_excitation_flag_function(x,y,z) = "flag_hs" -warpx.Hy_bias_excitation_flag_function(x,y,z) = "flag_hs" -warpx.Hz_bias_excitation_flag_function(x,y,z) = "flag_none" - -warpx.M_ext_grid_init_style = parse_M_ext_grid_function -warpx.Mx_external_grid_function(x,y,z)= "0.0" -warpx.My_external_grid_function(x,y,z)= " (z < thickness/2 + 1e-12) * (z > -thickness/2 - 1e-12) * Ms_ga*1000/4/pi " -warpx.Mz_external_grid_function(x,y,z)= "0.0" - - -# Diagnostics -diagnostics.diags_names = plt -plt.intervals = 500 -plt.diag_type = Full -plt.fields_to_plot = Mx_xface Mx_yface Mx_zface My_xface My_yface My_zface Mz_xface Mz_yface Mz_zface -plt.file_min_digits = 9 diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash deleted file mode 100644 index a66156be4..000000000 --- a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/readfield.bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -for timestep in $(seq 0 500 5000000 ); do - newnumber='000000000'${timestep} # get number, pack with zeros - newnumber=${newnumber:(-9)} # the last seven characters - ./WritePlotfileToASCII3d.gnu.ex infile=diags/plt${newnumber} | tee raw_data/${newnumber}.txt -done diff --git a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash b/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash deleted file mode 100644 index e57827115..000000000 --- a/Examples/Tests/Macroscopic_Maxwell/PSSW_halfCos_exci/squashTime.bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -for timestep in $(seq 0 500 5000000); do - newnumber='000000000'${timestep} # get number, pack with zeros - newnumber=${newnumber:(-9)} # the last seven characters - bash getLine.bash raw_data/${newnumber}.txt 128 | tee -a Mx_xface_center_128.txt -done