-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior with 2D M4 solver #662
Comments
Hello, the |
Thanks, Is the reason for this limitation known? Is there anything specific to the laser module? |
The M4 solver was added in #486 |
Hello, I don't understand your point source was static? In that case the field was computed with the Poisson solver. |
Hi. This is what I tried. There seems to be no problem with light propagating in the y-direction, at least for the internal region.
|
Interesting, the isotropic propagation seems to work as expected. |
This is the time evolution I got (the color bar range is not the same as the figure above).
|
Thank you, my theory at the moment is that the boundary conditions are not adapted to the
|
Hi, I tried different interpolation orders (2 and 4), different boundary conditions (SM and PML), and different polarization (polarization_phi = 0 and pi/2) with 1 downward propagating laser (name list at the bottom). In MF_Solver2D_Yee.cpp, the y index runs from 1 to ny_d-2: for( unsigned int y = 1; y < ny_d - 1; ++y ) {
Bz2D[x * ny_d + y] += dt_ov_dy * ( Ex2D[x * ny_p + y] - Ex2D[x * ny_p + y - 1] ) -
dt_ov_dx * ( Ey2D[x * ny_d + y] - Ey2D[( x - 1 ) * ny_d + y] );
} This is the same for the Cowan solver, and the Bouchard solver updates y=1 and ny_d-2 as special cases. Whereas in MF_Solver2D_M4.cpp, the y index is from 2 to ny_d-3: for (unsigned int j=2 ; j<ny_d-2 ; j++) {
(*Bz2D)(i,j) += Ay * ((*Ex2D)(i,j)-(*Ex2D)(i,j-1))
+ By * ((*Ex2D)(i+1,j)-(*Ex2D)(i+1,j-1) + (*Ex2D)(i-1,j)-(*Ex2D)(i-1,j-1))
+ Dy * ((*Ex2D)(i,j+1)-(*Ex2D)(i,j-2))
+ Ax * ((*Ey2D)(i-1,j)-(*Ey2D)(i,j))
+ Bx * ((*Ey2D)(i-1,j+1)-(*Ey2D)(i,j+1) + (*Ey2D)(i-1,j-1)-(*Ey2D)(i,j-1))
+ Dx * ((*Ey2D)(i-2,j)-(*Ey2D)(i+1,j));
} j =1 and ny_d-2 are not updated in the MF solver for M4 (and Grassi solver as well?). This is the name list I used import math
micrometer = 7.75701890
femtosecond = 2.32549576
a0 = 9.79333075
pduration = 160.*femtosecond/math.sqrt(2.*math.log(2.))
pwidth = 40.*femtosecond
pcenter = 80.*femtosecond/math.sqrt(2.*math.log(2.))
nx = 1280
dx = 60.*micrometer/nx
nt = 10800
dt = 540.*femtosecond/nt
npatch = 128
output = nt/18
Main(
geometry = "2Dcartesian",
interpolation_order = 4,
#interpolation_order = 2,
number_of_timesteps = nt,
timestep = dt,
cell_length = [dx, dx],
number_of_cells = [nx, nx],
number_of_patches = [npatch, npatch],
patch_arrangement = "hilbertian",
EM_boundary_conditions = [["silver-muller"]],
#EM_boundary_conditions = [["PML"]],
maxwell_solver = "M4"
#maxwell_solver = "Yee"
)
LaserGaussian2D(
box_side = "ymax",
a0 = a0,
omega = 1.,
focus = [10.*micrometer, 10.*micrometer],
waist = 10.*micrometer,
incidence_angle = 0.,
polarization_phi = 0.,
#polarization_phi = math.pi/2.,
ellipticity = 0.,
time_envelope = tgaussian(duration=pduration, fwhm=pwidth, center=pcenter)
)
DiagScalar(
every = output
)
DiagFields(
every = output,
fields = ["Bx_m","By_m","Bz_m","Ex","Ey","Ez"]
) |
I don't know why those indices are like this in the |
The problems with a laser can be solved by adding these lines (which I copied from the Bouchard solver) to the // at Ymin+dy - treat using simple discretization of the curl (will be overwritten if not at the ymin-border)
for (unsigned int i=0 ; i<nx_p ; i++) {
(*Bx2D)(i,1) += dt_ov_dy * ( (*Ez2D)(i,0) - (*Ez2D)(i,1) );
}
// at Ymax-dy - treat using simple discretization of the curl (will be overwritten if not at the ymax-border)
for (unsigned int i=0 ; i<nx_p ; i++) {
(*Bx2D)(i,ny_d-2) += dt_ov_dy * ( (*Ez2D)(i,ny_d-3) - (*Ez2D)(i,ny_d-2) );
}
// at Ymin+dy - treat using simple discretization of the curl (will be overwritten if not at the ymin-border)
for (unsigned int i=2 ; i<nx_d-2 ; i++) {
(*Bz2D)(i,1) += dt_ov_dx * ( (*Ey2D)(i-1,1) - (*Ey2D)(i,1) )
+ dt_ov_dy * ( (*Ex2D)(i,1) - (*Ex2D)(i,0) );
}
// at Ymax-dy - treat using simple discretization of the curl (will be overwritten if not at the ymax-border)
for (unsigned int i=2 ; i<nx_d-2 ; i++) {
(*Bz2D)(i,ny_d-2) += dt_ov_dx * ( (*Ey2D)(i-1,ny_d-2) - (*Ey2D)(i,ny_d-2) )
+ dt_ov_dy * ( (*Ex2D)(i,ny_d-2) - (*Ex2D)(i,ny_d-3) );
}
|
Thank you! We'll test these changes and in case add them to the code. |
Hi, I found a possible bug in the 2D M4 solver.
The script I ran was
The Bz plot I got is
This is different than the expected behavior because there should be two identical laser pulses entering from Xmin and Ymax.
By changing the solver to Yee
maxwell_solver = "Yee"
, I got the following resultThis is the expected result.
I looked at the code src/ElectroMagnSolver/MF_Solver2D_M4.cpp and found that special treatment in Ymin and Ymax is absent.
In MF_Solver2D_Bouchard.cpp, there are lines after comment
//at Ymin+dy - treat using simple discretization of the curl
. (and for Ymax too).Also, both Y and Z boundaries seem to be treated specially in MF_Solver3D_M4.
It is just a simple guess, but could it be one of the reasons for the unexpected behavior?
The text was updated successfully, but these errors were encountered: