-
Notifications
You must be signed in to change notification settings - Fork 47
Custom\manual waveguide modes definition for Excitations #56
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
base: master
Are you sure you want to change the base?
Conversation
|
Hey @thliebig Took me long enough, but I have a parser for CSV files with E and H data. double CSPropExcitation::GetWeightedExcitation(int ny, const double* coords)is used by openEMS. |
|
Hey @thliebig In order to overcome that, I have two possible courses of action:
I'll go with #1 right now, but if you have a different idea I'd love to hear. Cheers |
e992297 to
68e0075
Compare
|
Hey @thliebig Finally got a hold of this, or at least I think. Rebased, tested, the works. Cheers |
|
Hey @thliebig. This was done in parallel to the openEMS PR, as usual. Let me know if this is more in the direction you wanted |
|
@thliebig found an opportunity to take a look by any chance? |
|
Yes I had a first look. I have not yet tried to build and test this. Looks good so far I think. Next I will have a closer look at the openEMS counterpart first. |
18e1059 to
f0868ed
Compare
|
During adding another example, I found a bug in the transpose of the file parser. Fixed in the last push. Forced push for rebase purposes, as usual... |
thliebig
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally there are many random blank lines in odd places?
|
I pushed the changes @thliebig. I'm assuming it's just an initial review... |
|
Yes, but I think it is looking okay. I need some closer look at the You may add some unit tests in the |
|
I'm having serious trouble with the python bindings. There was a change to update_openEMS.sh, and now the python binding are compiled using /scripts/build_python.sh. I can't find the logs anywhere to find the errors.
|
|
Very testing and development you should really not use the update_openEMS.sh. That is meant to build and install everything. What you want is only build what you are actively working on! If it is only the python bindings, cd into the the specific python path, here You have to adept the path obviously and @biergaizi is most likely yelling at me for not using a venv and pip 😏 |
|
I did that. It compiled and everything, but when I run the unit test it doesn't see my additions. Let me know what to do. I'm really on the verge of ditching this. |
What do you mean? You are in the "tests" folder when you run |
|
I wrote everything and tested as best as I could. I can't install with the new workflow, and I'm not going to try anymore. The new installation script after @biergaizi 's latest "re-write" doesn't work with my additions. Tried rebasing and everything. Got no idea why. The C++ part works. The python, doesn't. There is no feedback, logs or anything that I can find. When I tried this:
The python bindings compiled fine. They were installed somewhere. When I tried to run the unit tests, it referred to the previous version. Why? I don't know. ~ Throwing the white flag ~ My collegue said he wanted to try from his side. @tmpusr123, it's up to you now. |
|
Well I was able to checkout, rebase and build it just fine. Not sure whats up with your setup (or mine). The tests obviously can not work like this yet and they are already a bit deeper than I intended. |
|
I can port This is the line it uses: m_ModeFile.linInterp2(loc_coords[nPyp],loc_coords[nPypp],Wny)With this test, you can use both interpolants. I'm guessing this entire effort was to better use VScode. I use Eclipse for all of my work. As far as the rest of the setup, it's the same Linux VM I've been working with since the first lumped element PR. |
That does make little sense, just "unpush"? The last commit and we go from there... |
I edited a second later. This is the line it uses: m_ModeFile.linInterp2(loc_coords[nPyp],loc_coords[nPypp],Wny)With this test, you can use both interpolants. |
|
I'll refine. In the // Get weights in both directions
double Wny[2] = {0.0,0.0};
m_ModeFile.linInterp2(loc_coords[nPyp],loc_coords[nPypp],Wny);While the "shift" to the local coordinate system is done in openEMS, as it relates to the primitive that defines the excitation. if (!shiftCoordsForModeFile(volt_coord, highestPriorityPrim))This may not be the optimal solution. However, considering that in the rectangular waveguide port, this is done in the openEMS python interface, I figured that doing it in the C++ code would even be a bit friendlier. This is how it's done in the original master branch, BTW:: name_P = '({}-{})'.format(xyz[self.ny_P], self.start[self.ny_P])
name_PP = '({}-{})'.format(xyz[self.ny_PP], self.start[self.ny_PP])So testing |
|
Hi @thliebig, happy new year — did you have a chance to build/test this locally, or are there any more blockers to merging? |
|
Sorry but the test are still failing and I tried to fix some obvious issues, but the tests still fail... |
|
Oh well |
1. Bilinear interpolation errors 2. Parsing error - line too short.
No longer necessary as there are no more c-style memory allocations in the python interface.
ffe7a18 to
0536c5b
Compare
1) Fixed the unit test. Added relevant assertions 2) Found bug in ModeFileParser.cpp - Nearest neighbor case
|
It wasn't a simple rebase, but with the help of friendly robots, I managed. The results for this I verified that it works with openEMS, as well, although that's irrelevant here. Cheers |
|
I noticed that the linux tests fail because of lack of scipy. What should I do? |
|
We should avoid the scipy dependency (only for this). You can just check against fixed numbers instead of using the interpolator? Usually putting fixed numbers in code is a no-no. But in this tests it is okay as we expect the result to always be the exact same number no matter what. |
|
I checked. Numpy has linear interp built in. I'll write NN manually. Will finish this by tomorrow. |
test_CSProperties.py was embedded with linear and nearest-neighbor interpolation schemes. The test is now with more points.
|
Green lights all around, @thliebig |
|
To try and not mix further the already mixed salad here. @biergaizi, @thliebig, if the only issue to make this work with openEMS better is to rename the mode parser as CSModeFileParser and add the Let me know |
|
@biergaizi, I reviewed the code. Everything that is exposed is necessary. @thliebig, let me know what is the best course of action here. Simply add |
|
Why would you need to rename something? It just sounds like you need to add some "CSXCAD_EXPORT" at some places? |
|
As far as I see it the class "ModeFileParser" is not exposed. Just add a "CSXCAD_EXPORT" in front of it and all should be good.... maybe 😏 |
To resolve the openEMS MSVC compilation issues, CSXCAD_EXPORT was added to ModeFileParser.h
|
Can do! |
|
Seems good now |
Please reconsider, and address my comment in thliebig/openEMS#175 (comment). Everything in ModeFileParser will permanently become CSXCAD's public API, and in theory anyone who uses CSXCAD will be able to link against it and use it. But this class does not follow CSXCAD's naming conventions, and it will be too late to change it if it's accepted as a stable API. |
|
@biergaizi, sorry I somehow missed that comment completely. I agree with your summary there but it exposes more like a different issue. We need the "CSXCAD_EXPORT" to make (the current implementation) equal to whats available for Linux and fix the current issue. So it needs to be there. But we should address the points you made too. But another point I would like to look at is, why does openEMS need to know all this at all? Ideally openEMS just wants the mode profile and does not want to know how and where that came from (function vs file)? Not sure if that is feasible or not. But if we could make that unnecessary, we could make the ModeFileParser truly "internal" maybe.... But it does not hurt anything if @gadiLhv could look at and fix this to the CSXCAD naming convention (fully internal or not), thanks. |
|
I'll address what's relevant to me, if you may.
I'll start with the complicated part. The mode port factually has 2 parts.
Except for renaming it to something like CSModeParser, anything else? |
|
Well name of the files, name of the class and name of the methods. As well as maybe checking which methods need to be public and which one could be made private. |
According to latest PR request: 1) Changed the ModeFileParser.cpp and ModeFileParser.h naming convention 2) Exposed as little as possible from the CSModeFileParser class methods as public. No python interface added to CSModeFileParser
Applied this, to the best of my understanding. |
As I am getting the hang of the Git protocol, I can start this, seperately. This was (re)based around the original repository master, rather than my one, which has the absorbers. In the future I'll make a habit of opening branches for new features.
I'll go over the remarks from the previous PR
The line that guided me here was "make as little damage as possible". This was for two main reasons:
Hence, the fields for the mode consist of three columns of coordinates, and three columns of field values: [X,Y,Z,Ex,Ey,Ez]. Replace with H at your own convenience.
Three reasons, this time
To avoid all this mess, I simply extract all three coordinates. I'll give this some more re-thinking.
I know. I didn't find any built-in XML functions for handling arrays, except for the mesh processing. Care to give me a hint?
I'll think how to implement these functions just one time. Missed this remark while re-basing the code.
This will take some figuring out. CSV is my weapon of choice, I guess. Easy to manipulate both in M-script and python. If I make this a 2D file, how do I handle the coordinate shift? Rotation is the easy bit, but where is (0,0)?