Skip to content

Commit

Permalink
Add some user-defined parameters (#27)
Browse files Browse the repository at this point in the history
* Added the USE_LLG in the Make.WarpX

* Added the macro USE_LLG and modified the related files

* Modified the git style for pulling request

* Modified the git style for pulling request

* indentation

* indentation fixes

* Modified the git style for pulling request

* Added the USE_LLG in the building.rst and changed one indentation in WarpX.cpp

* HtoE and normalization of M field

* ws

* eolw

* indentation

* 2nd order of M field

* tabs

* eolw

* Update the codes and the document

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: jackiezy <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: jackiezy <[email protected]>

* Update Source/FieldSolver/WarpXPushFieldsEM.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/Evolve/WarpXEvolve.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.H

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.H

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/WarpX.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: jackiezy <[email protected]>

* Update Source/Evolve/WarpXEvolve.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* some indentations

* updateM_field

* some comments

* resolve some comments

* tab

* eolw

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Revathi  Jambunathan <[email protected]>

* documents

* use-defined inputs

* tabs

* eols

* indentation

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM_2nd.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveM.cpp

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H

Co-authored-by: Andy Nonaka <[email protected]>

* Update Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H

Co-authored-by: Andy Nonaka <[email protected]>

* parameters.rst

* get to query

Co-authored-by: Andy Nonaka <[email protected]>
Co-authored-by: jackiezy <[email protected]>
Co-authored-by: Revathi  Jambunathan <[email protected]>
  • Loading branch information
4 people authored Aug 4, 2020
1 parent 45addc3 commit 653889b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Docs/source/running_cpp/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,15 @@ Numerics and algorithms
The conductivity, permittivity, and permeability of the computational medium, respectively.
If ``algo.em_solver_medium`` is set to macroscopic, then these properties must be provided.

* ``macroscopic.mag_normalized_error`` (`double`; default: `0.1`)
The maximum relative amount we let M deviate from Ms before aborting for the LLG equation. This requires `USE_LLG=TRUE` in the GNUMakefile.

* ``macroscopic.mag_max_iter`` (`int`; default: `100`)
The maximum number of iterations allowed of the 2nd-order trapezoidal scheme for the LLG equation. This requires `USE_LLG=TRUE` in the GNUMakefile.

* ``macroscopic.mag_tol`` (`double`; default: `0.0001`)
The relative tolerance stopping criteria for 2nd-order iterative algorithm of the 2nd-order trapezoidal scheme for the LLG equation. This requires `USE_LLG=TRUE` in the GNUMakefile.

* ``warpx.mag_time_scheme_order`` (`1` or `2`; default: `1`)
The value of the time advancement scheme of M field. `mag_time_scheme_order==1` is the 1st-order Eulerian scheme and `mag_time_scheme_order==2` is the 2nd-order trapezoidal scheme for the LLG equation. This requires `USE_LLG=TRUE` in the GNUMakefile.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveM (
amrex::Real const dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties )
{
// Temporary value hard-coded for normalized error used for LLG.
amrex::Real mag_normalized_error = 0.1_rt; // normalization error of M field for checking

// obtain the maximum relative amount we let M deviate from Ms before aborting
amrex::Real mag_normalized_error = macroscopic_properties->getmag_normalized_error();

for (MFIter mfi(*Mfield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi) /* remember to FIX */
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ void FiniteDifferenceSolver::MacroscopicEvolveM_2nd (
}

// initialize M_max_iter, M_iter, M_tol, M_iter_error
// change these to user-defined input in the next PR
int M_max_iter = 100;
// maximum number of iterations allowed
int M_max_iter = macroscopic_properties->getmag_max_iter();
int M_iter = 0;
amrex::Real M_tol = 0.0001;
// relative tolerance stopping criteria for 2nd-order iterative algorithm
amrex::Real M_tol = macroscopic_properties->getmag_tol();
amrex::Real M_iter_maxerror = -1.0;
int stop_iter = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public:
amrex::MultiFab& getmag_alpha_mf () {return (*m_mag_alpha_mf);}
amrex::MultiFab& getmag_gamma_mf () {return (*m_mag_gamma_mf);}

amrex::Real getmag_normalized_error () {return m_mag_normalized_error;}
int getmag_max_iter () {return m_mag_max_iter;}
amrex::Real getmag_tol () {return m_mag_tol;}

// interpolate the magnetic properties to B locations
// magnetic properties are cell nodal
// B locations are face centered
Expand Down Expand Up @@ -174,6 +178,17 @@ private:
amrex::Real m_mag_alpha;
/** gyromagnetic ratio, should be a negative value, only applies for magnetic materials */
amrex::Real m_mag_gamma;

// If the magnitude of the magnetization deviates by more than this amount relative
// to the user-defined Ms, abort. Default 0.1.
amrex::Real m_mag_normalized_error;

// maximum iteration count for the second-order time advancement scheme of M field, default 100
int m_mag_max_iter;

// the relative tolerance for the second-order time advancement scheme of M field, default 0.0001
amrex::Real m_mag_tol;

#endif

/** Multifab for m_sigma */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ MacroscopicProperties::ReadParameters ()
m_mag_gamma_parser.reset(new ParserWrapper<3>(
makeParser(m_str_mag_gamma_function,{"x","y","z"})));
}

m_mag_normalized_error = 0.1;
pp.query("mag_normalized_error",m_mag_normalized_error);

m_mag_max_iter = 100;
pp.query("mag_max_iter",m_mag_max_iter);

m_mag_tol = 0.0001;
pp.query("mag_tol",m_mag_tol);

#endif
}

Expand Down

0 comments on commit 653889b

Please sign in to comment.