pp1 = "1Geometry/";
pp2 = "2Plane Wave/";
pp3 = "3Relative Permittivity/";
pp4 = "4Numerical Parameters/";

// units & scaling (we choose nanometer=1)
nm = 1.;

// geometry of the problem
DefineConstant[
  h_super = { 300*nm, Name StrCat[pp1, "0superstrate thickness"]},
  h_subs  = { 300*nm, Name StrCat[pp1, "1substrate thickness"]},
  d       = { 75*nm, Name StrCat[pp1, "2period"]}
];

// Plane wave main parameters
DefineConstant[
  lambda0      = { 633*nm, Name StrCat[pp2, "0wavelentgh"]},
  theta0_deg   = { 30    , Name StrCat[pp2, "1polar angle"]},
  phi0_deg     = { 45    , Name StrCat[pp2, "2azimut angle"]},
  psi0_deg     = { 90    , Name StrCat[pp2, "3polarization angle"]},
  FLAG_CIRCPOL = { 1     , Name StrCat[pp2, "4circular polarization?"] , Choices {0,1}},
  FLAG_LEFTPOL = { 0     , Name StrCat[pp2, "5if circular polarization, left-handed?"] , Choices {0,1}}
];

// Permittivities
DefineConstant[
  epsr_super_re = { 1, Name StrCat[pp3, "0superstrate (real part) relative permittivity"]},
  epsr_subs_re  = { 5, Name StrCat[pp3, "1substrate (real part) relative permittivity"]},
  epsr_subs_im  = { 0, Name StrCat[pp3, "2substrate (imag part) relative permittivity"]}
];

// PML and mesh parameters
DefineConstant[
  h_pml_super_wl = {1.5  , Name StrCat[pp4, "0PML superstrate thickness [wavelength units]"]},
  h_pml_subs_wl  = {1.5  , Name StrCat[pp4, "1PML substrate thickness [wavelength units]"]},
  mesh_param     = {7    , Name StrCat[pp4, "2mesh size = lambda0/mesh_param [-]"]},
  flag_interp    = {4    , Name StrCat[pp4, "3FEM interpolation scheme (1,2,3,4)"]},
  FLAG_EXCLUDE_FACETS_FROM_LINK = { 1 , Name StrCat[pp4, "4do we link facets?"] , Choices {0,1}}
];

// scale wavelength units to nm
lc = lambda0/mesh_param;
h_pml_super = h_pml_super_wl * lambda0;
h_pml_subs  = h_pml_subs_wl  * lambda0;

// scale meter units to nm
norm2nm = 1e-9/nm;
ep0     = 8.854187818814e-12/norm2nm;
mu0     = 4*Pi*1e-7/norm2nm;
cel     = 1/Sqrt[ep0*mu0];

// deg2rad
theta0 = theta0_deg * Pi/180.;
phi0 = phi0_deg * Pi/180.;
psi0 = psi0_deg * Pi/180.;

// Energy balance based on a Rayleigh expansion
// we need only order 0
Nmax = 0;

If (FLAG_LEFTPOL==0)
  FLAG_LRCIRC = 1;
Else
  FLAG_LRCIRC = -1;
EndIf
