Closed demisjohn closed 6 years ago
The mode solver uses finite-differences on a staggered grid, so E and H fields are located on different points on the grid: nodes, vertical/horizontal edges, center. That is the reason why they don't have the same dimensions. You can of course interpolate the values on any (x,y) point you need using one of the scipy's interp functions.
I see, that makes sense about the extra data point. Since there's no way for a user to know which coordinates to discard to match the grid to their desired coordinate space, we could have the solver interpolate to return field values at the same X/Y coordinates the user provided.
Also, what's going on with the 90° rotation?
Can you post the code you used to make the spatial field plots shown on the web page, here? I believe the code there also only plots versus grid number, not spatial dimension like the plots shown. That would probably clarify things.
Thanks!
You can use FDMode.get_field
to interpolate a mode where needed. I had to fix a bug in that function, though. Also, I've updated the example in http://lbolla.github.io/EMpy/#example_modesolver
I'm trying to use your modesolver example #2 with the "CrossSection" & "Slices" method that I like very much (
ex_modesolver_2.py
). Your example only plots the mode versus grid/mesh points - the spatial dimension is missing.If I insert the variables
X
&Y
into thecontourf
function, thesolver.modes[0].Ex
array then doesn't match theX
&Y
arrays, I have to usenumpy.rot90()
to get it to plot, indicating that the X & Y axes are flipped for some reason (and the mode shows up sideways). (Also I have to strip one point off from each X/Y array, asCrossSection.grid()
is one value larger in each direction than thesolver.modes[0].Ex
array.)I am thus unable to figure out which way is the expected "up/down/left/right" in this example, it doesn't seem to match the passed X & Y arrays.
Is
VFDModeSolver.solve()
returning the modes sideways, and missing one point in each dimension? Is it also solving them sideways?