Skip to content

Commit

Permalink
print to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Nov 14, 2023
1 parent 7de20d9 commit 13ed05a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Source/Particles/Pusher/PushSelector.H
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void doParticlePush(const GetParticlePosition& GetPosition,
#endif
const amrex::Real dt, amrex::Real * PulsarDiag = nullptr)
{
#ifdef PULSAR
amrex::Real ux_pre = ux;
amrex::Real uy_pre = uy;
amrex::Real uz_pre = uz;
#endif
amrex::ParticleReal qp = a_q;
if (ion_lev) { qp *= ion_lev; }

Expand Down Expand Up @@ -106,8 +111,19 @@ void doParticlePush(const GetParticlePosition& GetPosition,
}
amrex::ParticleReal x, y, z;
GetPosition(i, x, y, z);
#ifdef PULSAR
amrex::Real x_pre = x;
amrex::Real y_pre = y;
amrex::Real z_pre = z;
#endif
UpdatePosition(x, y, z, ux, uy, uz, dt );
SetPosition(i, x, y, z);
#ifdef PULSAR
if ( std::sqrt(x*x + y*y + z*z) > 125200 )
{
printf(" ux_pre = %e uy_pre = %e uz_pre = %e ux_post = %e uy_post = %e uz_post= %e x_pre = %f y_pre=%f z_pre=%f x=%f y=%f z=%f \n", ux_pre, uy_pre, uz_pre, ux, uy, uz, x_pre, y_pre, z_pre, x, y, z );
}
#endif
} else
#endif
{
Expand Down Expand Up @@ -136,8 +152,19 @@ void doParticlePush(const GetParticlePosition& GetPosition,
dt);
amrex::ParticleReal x, y, z;
GetPosition(i, x, y, z);
#ifdef PULSAR
amrex::Real x_pre = x;
amrex::Real y_pre = y;
amrex::Real z_pre = z;
#endif
UpdatePosition(x, y, z, ux, uy, uz, dt );
SetPosition(i, x, y, z);
#ifdef PULSAR
if ( std::sqrt(x*x + y*y + z*z) > 125200 )
{
printf(" ux_pre = %e uy_pre = %e uz_pre = %e ux_post = %e uy_post = %e uz_post= %e x_pre = %f y_pre=%f z_pre=%f x=%f y=%f z=%f \n", ux_pre, uy_pre, uz_pre, ux, uy, uz, x_pre, y_pre, z_pre, x, y, z );
}
#endif
} else if (pusher_algo == ParticlePusherAlgo::Vay) {
UpdateMomentumVay( ux, uy, uz,
Ex, Ey, Ez, Bx,
Expand Down
13 changes: 12 additions & 1 deletion Source/Particles/Pusher/UpdateMomentumBoris.H
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ void UpdateMomentumBoris(

const amrex::ParticleReal econst = 0.5_prt*q*dt/m;

#ifdef PULSAR
amrex::Real abs_u_pre = std::sqrt(ux*ux + uy*uy + uz*uz);
#endif

// First half-push for E
ux += econst*Ex;
uy += econst*Ey;
Expand Down Expand Up @@ -92,7 +96,7 @@ void UpdateMomentumBoris(

// 1(b) unit vector along drift velocity
amrex::Real drift_mag = std::sqrt(vx_drift*vx_drift + vy_drift*vy_drift + vz_drift*vz_drift);
if (drift_mag < (0.99 * PhysConst::c) ) {
if (drift_mag < (PhysConst::c) ) {
amrex::Real vxd_hat = vx_drift/drift_mag;
amrex::Real vyd_hat = vy_drift/drift_mag;
amrex::Real vzd_hat = vz_drift/drift_mag;
Expand Down Expand Up @@ -124,6 +128,13 @@ void UpdateMomentumBoris(
ux = gamma_drift * ( ux_new_prime + gamma_new_prime * vx_drift);
uy = gamma_drift * ( uy_new_prime + gamma_new_prime * vy_drift);
uz = gamma_drift * ( uz_new_prime + gamma_new_prime * vz_drift);

// debugging
amrex::Real abs_u_post = std::sqrt(ux*ux + uy*uy + uz*uz);
if ( abs_u_post > abs_u_pre || (drift_mag > 0.99999999*PhysConst::c))
{
printf(" premom = %e postmom = %e gammadrift = %e gammanewprime = %e B_sq = %e Eprime_sq = %e drift_mag = %e \n", abs_u_pre, abs_u_post, gamma_drift, gamma_new_prime, B_sq, Eprime_sq, drift_mag );
}
}
}
}
Expand Down

0 comments on commit 13ed05a

Please sign in to comment.