// Scaling and constants
// we are working in nm units since we are in optics
Include "shape_data.geo";

nm	     = 1;
epsilon0 = 8.854187817e-3*nm;
mu0      = 400.*Pi*nm;

// Problem Setup
DefineConstant[ Flag_PW        = {0   , Name StrCat["1Problem Set up/", "0plane wave or source point "], Choices {0="source point",1="plane wave"},Highlight "Pink", ServerAction "ResetDatabase" }];
If (Flag_PW==0)
    DefineConstant[ FLAG_TOT = {0   , Name StrCat["1Problem Set up/", "1formulation "], Choices {0="scattered field",1="total field"} ,Highlight "Pink", ServerAction "ResetDatabase" }];
EndIf
DefineConstant[ flag_Hparallel = {0   , Name StrCat["1Problem Set up/", "2polarization case"], Choices {0="E //",1="H //"}, Highlight "Pink" }];
DefineConstant[ lambda0        = {400 , Name StrCat["1Problem Set up/", "3freespace wavelength [nm]"], Highlight "Snow" }];
DefineConstant[ theta_PW_deg   = {0   , Name StrCat["1Problem Set up/", "4incident plane wave angle [deg]"], Highlight "Snow" }];
lambda0 = lambda0*nm;

r_src = lambda0/50; // delta approx for point source
safe_dist = 5*r_src; // avoid placing sources or scatters too close to PMLs

// Geom : computational domain
DefineConstant[ shape_size = {1000 , Name StrCat["2Geometry/", "2shape size [nm]"], Min 500 , Max 2000, Step 10, Highlight "Ivory" }];
shape_size = shape_size*nm;
shape_max_extent = shape_max_norm_extent*shape_size;
DefineConstant[ dom_x = {shape_max_extent+500*nm , Name StrCat["2Geometry/", "0domain x size [nm]"], Min shape_max_extent+safe_dist , Max 3000, Step 10, Highlight "Ivory" }];
DefineConstant[ dom_y = {shape_max_extent+500*nm , Name StrCat["2Geometry/", "1domain y size [nm]"], Min shape_max_extent+safe_dist , Max 3000, Step 10, Highlight "Ivory" }];
DefineConstant[ shape_rotation = {10 , Name StrCat["2Geometry/", "3rotate shape [deg]"], Min 0 , Max 90, Step 5, Highlight "Ivory" }];
dom_x    = dom_x*nm;
dom_y    = dom_y*nm;


// let the GUI user choose the x source location
DefineConstant[ x_src = {0 , Name StrCat["1Problem Set up/", "5source point x [nm]"], Min -dom_x/2+safe_dist  , Max dom_x/2-safe_dist, Step 10, Highlight "Snow" }];
DefineConstant[ y_src = {shape_max_extent/2+safe_dist , Name StrCat["1Problem Set up/", "6source point y [nm]"], Min shape_max_extent/2+safe_dist , Max dom_y/2-safe_dist, Step 10, Highlight "Snow" }];
x_src = x_src*nm;
y_src = y_src*nm;


DefineConstant[ epsr_shape_re = {9 , Name StrCat["3Shape properties/", "0 (real part) shape permittivity [-]"], Min 1 , Max 32, Step 2, Highlight "MintCream" }];
DefineConstant[ epsr_shape_im = {1 , Name StrCat["3Shape properties/", "1 (imag part) shape permittivity [-]"], Min 0 , Max 100, Step 2, Highlight "MintCream" }];
DefineConstant[ mur_shape_re  = {1 , Name StrCat["3Shape properties/", "2 (real part) shape permeability [-]"], Min 1 , Max 32, Step 2, Highlight "MintCream" }];
DefineConstant[ mur_shape_im  = {0 , Name StrCat["3Shape properties/", "3 (imag part) shape permeability [-]"], Min 0 , Max 100, Step 2, Highlight "MintCream" }];

epsr_bg_re    = 1.;
epsr_bg_im    = 0.;

// Discretization & PMLs
DefineConstant[ paramaille = {10 , Name StrCat["4Discretization/", "0mesh size [fraction of wavelength]]"], Highlight "PaleTurquoise" }];
DefineConstant[ FE_lagrange_order = {2 , Name StrCat["4Discretization/", "1FE order (Lagrange P1, P2 or P3)"], Choices {1="P1",2="P2",3="P3"}, Highlight "PaleTurquoise" }];

deg2rad = Pi/180.0;

flag_order2 = 1;
PML_size  = lambda0;

// FT Time Sign
siwt   = -1;
