kill(all);

/* Enable this for TeXmacs output:
%epsilon:epsilon;
%mu:mu;
*/

load("maxwellbase.mac");

/* ------------------------------------------------------------------------- */

max_radbdryspinw:makelist(
  if max_D[i,i] >= 0 then max_sminw[i,1] else 0,
i, 1, 6)$

print("Radiation boundary condition for Maxwell's:");
print(fullhypsimp(max_V.max_radbdryspinw));

/* ------------------------------------------------------------------------- */
max_pecbdrywpins:ev(max_pecbdrywp,[Em=max_Emins, Hm=max_Hmins]);

print("PEC bdry condition for Maxwell's in terms of characteristic variables (s)");
max_pecbdryspinw:fullhypsimp(max_invV.max_pecbdrywpins);
print(max_pecbdryspinw);

/* ------------------------------------------------------------------------- */
/* Simple upwinded flux */
/* ------------------------------------------------------------------------- */

max_sfluxstoopid:max_D . makelist(
  if max_D[i,i] >= 0 then 
    sm[i,1]
  else
    sp[i,1], 
  i, 1, length(max_D));

max_wfluxstoopid:fullhypsimp(max_V . ev(max_sfluxstoopid, [sm=max_sminw,sp=max_spinw]));

print("Stoopid upwind flux for Maxwell's in terms of characteristic variables:");
print(max_sfluxstoopid);
print("Stoopid upwind flux for Maxwell's in terms of physical variables:");
print(max_wfluxstoopid);

/* ------------------------------------------------------------------------- */
/* Rankine-Hugoniot flux */
/* ------------------------------------------------------------------------- */

print("Maxwell's flux in terms of characteristic variables:");
print(max_sflux);

print("Maxwell's flux in terms of physical variables:");
print(max_wflux);

/* ------------------------------------------------------------------------- */
/* known flux value*/
/* ------------------------------------------------------------------------- */
max_Z:sqrt(%mu/%epsilon)$
max_Y:sqrt(%epsilon/%mu)$

max_knownstrongwflux:ratsimp(vstack(
  -1/(2*%epsilon)
  *(crossprod(n,(max_Hm-max_Hp)-1/max_Z*crossprod(n,max_Em-max_Ep))),
  1/(2*%mu)
  *(crossprod(n,(max_Em-max_Ep)+1/max_Y*crossprod(n,max_Hm-max_Hp)))
  ))$

assert(norm_2_squared(hypsimp(
  (max_strongwflux)
  -max_knownstrongwflux))=0);
