Skip to content

Commit

Permalink
minor comment update implicit solver classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinRayAngus committed Aug 26, 2024
1 parent 815f99a commit 88ed376
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time,
{
amrex::ignore_unused(a_step);

// Fields have E^{n}, B^{n-1/2}
// Particles have p^{n} and x^{n}.
// Fields have Eg^{n}, Bg^{n-1/2}
// Particles have up^{n} and xp^{n}.

// Save the values at the start of the time step,
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// Save the fields at the start of the step
m_Eold.Copy( m_WarpX->getMultiLevelField(FieldType::Efield_fp) );
m_E.Copy(m_Eold); // initial guess for E

// Compute Bfield at time n+1/2
// Advance WarpX owned Bfield_fp to t_{n+1/2}
m_WarpX->EvolveB(a_dt, DtType::Full);
m_WarpX->ApplyMagneticFieldBCs();

const amrex::Real half_time = a_time + 0.5_rt*a_dt;

// Solve nonlinear system for E at t_{n+1/2}
// Solve nonlinear system for Eg at t_{n+1/2}
// Particles will be advanced to t_{n+1/2}
m_E.Copy(m_Eold); // initial guess for Eg^{n+1/2}
m_nlsolver->Solve( m_E, m_Eold, half_time, a_dt );

// Update WarpX owned Efield_fp to t_{n+1/2}
Expand All @@ -90,8 +90,8 @@ void SemiImplicitEM::OneStep ( amrex::Real a_time,
// Advance particles from time n+1/2 to time n+1
m_WarpX->FinishImplicitParticleUpdate();

// Advance E fields from time n+1/2 to time n+1
// Eg^{n+1} = 2.0*E_g^{n+1/2} - E_g^n
// Advance Eg from time n+1/2 to time n+1
// Eg^{n+1} = 2.0*Eg^{n+1/2} - Eg^n
m_E.linComb( 2._rt, m_E, -1._rt, m_Eold );
m_WarpX->SetElectricFieldAndApplyBCs( m_E );

Expand All @@ -112,6 +112,6 @@ void SemiImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS,
// current state of the fields E and B. Deposit current density at time n+1/2.
m_WarpX->ImplicitPreRHSOp( a_time, a_dt, a_nl_iter, a_from_jacobian );

// RHS = cvac^2*0.5*dt*( curl(B^{n+1/2}) - mu0*J^{n+1/2} )
// RHS = cvac^2*0.5*dt*( curl(Bg^{n+1/2}) - mu0*Jg^{n+1/2} )
m_WarpX->ImplicitComputeRHSE(0.5_rt*a_dt, a_RHS);
}
16 changes: 8 additions & 8 deletions Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,
{
amrex::ignore_unused(a_step);

// Fields have E^{n} and B^{n}
// Particles have p^{n} and x^{n}.
// Fields have Eg^{n} and Bg^{n}
// Particles have up^{n} and xp^{n}.

// Save the values at the start of the time step,
m_WarpX->SaveParticlesAtImplicitStepStart ( );

// Save the fields at the start of the step
m_Eold.Copy( m_WarpX->getMultiLevelField(FieldType::Efield_fp) );
m_E.Copy(m_Eold); // initial guess for E

const int num_levels = static_cast<int>(m_Bold.size());
for (int lev = 0; lev < num_levels; ++lev) {
Expand All @@ -106,8 +105,9 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,

const amrex::Real theta_time = a_time + m_theta*a_dt;

// Solve nonlinear system for E at t_{n+theta}
// Solve nonlinear system for Eg at t_{n+theta}
// Particles will be advanced to t_{n+1/2}
m_E.Copy(m_Eold); // initial guess for Eg^{n+theta}
m_nlsolver->Solve( m_E, m_Eold, theta_time, a_dt );

// Update WarpX owned Efield_fp and Bfield_fp to t_{n+theta}
Expand All @@ -116,7 +116,7 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time,
// Advance particles from time n+1/2 to time n+1
m_WarpX->FinishImplicitParticleUpdate();

// Advance E and B fields from time n+theta to time n+1
// Advance Eg and Bg from time n+theta to time n+1
const amrex::Real new_time = a_time + a_dt;
FinishFieldUpdate( new_time );

Expand All @@ -137,7 +137,7 @@ void ThetaImplicitEM::ComputeRHS ( WarpXSolverVec& a_RHS,
// current state of the fields E and B. Deposit current density at time n+1/2.
m_WarpX->ImplicitPreRHSOp( a_time, a_dt, a_nl_iter, a_from_jacobian );

// RHS = cvac^2*m_theta*dt*( curl(B^{n+theta}) - mu0*J^{n+1/2} )
// RHS = cvac^2*m_theta*dt*( curl(Bg^{n+theta}) - mu0*Jg^{n+1/2} )
m_WarpX->ImplicitComputeRHSE(m_theta*a_dt, a_RHS);
}

Expand All @@ -159,8 +159,8 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time )
{
amrex::ignore_unused(a_new_time);

// Eg^{n+1} = (1/theta)*E_g^{n+theta} + (1-1/theta)*E_g^n
// Bg^{n+1} = (1/theta)*B_g^{n+theta} + (1-1/theta)*B_g^n
// Eg^{n+1} = (1/theta)*Eg^{n+theta} + (1-1/theta)*Eg^n
// Bg^{n+1} = (1/theta)*Bg^{n+theta} + (1-1/theta)*Bg^n

const amrex::Real c0 = 1._rt/m_theta;
const amrex::Real c1 = 1._rt - c0;
Expand Down

0 comments on commit 88ed376

Please sign in to comment.