Replies: 11 comments 39 replies
-
one reason might be: I am using "best-practice" imports, e.g. I am not using this is using https://pypi.org/project/black/ and some more stuff. I am also running on a CPython compiled and built from upstream sources. None of above should be a bummer, and it is arguably best practice in Python in general. Anyways, if you have issues with Python related things, I can certainly help! Need some logs, errors dump, whatever, plus system (OS) and Python details. I should also note, above script shared via GitHub Gists is deliberately written to be complete and self-contained. This is just to make cross-testing and discussions easier. At least that's what I hope;) Personally, I am running code actually from a proper command line tool, classes etc containing very similar code, but structured differently, and I can run this stuff from the command line like:
and so on .. but this code has already grown quite a bit bigger, and it includes automated tests:
those warnings come from MyPy, a static type checker for Python, and they are due to the fact that openEMS (the Python bits) is sadly not type annotated. anyways, Python details;) |
Beta Was this translation helpful? Give feedback.
-
awesome! still in the middle of sth, but I will study your comments and code in detail today!
sure, that's what you said, and I thought Dirac would therefor be the right excitation, since a Dirac pulse (isn't that basically one rect wave with raise time zero? and hence have waves of all frequencies?) would create a broad spectrum? anyways, I'll revisit this aspect .. |
Beta Was this translation helpful? Give feedback.
-
Hi Volker, alright, please find the adjusted https://gist.github.com/oberstet/2fa832d542e5bf2590d9cab344f827d4 I've copied all your changes, left NOTES and QUESTIONS in the source, and tried to keep the length etc to the bare minimum and fully self-contained. you corrected some issues that apparently were in and it does "work". though I don't trust the tool I guess at this point. the results are not repeatable. pls see my NOTES so in a way, I am more puzzled than before:( the touchstone file for 1 run is here: https://gist.github.com/oberstet/594f684eb362b5e7b13fbb9668ce2bcb - I haven't checked that file as I do not have any tool that is able to read it. is there an OSS tool that can digest this format? the matplot plot for that same run is here: the results printed for the that run:
|
Beta Was this translation helpful? Give feedback.
-
Hi Volker, fantastic!! thank you very much. fwiw, it'll take a bit to digest and work in all your comments, and also to come up with results using scikit-rf (which looks pretty good so far), so the following are just a couple of replies to aspects where I do know about (mostly, SW arch/eng)
yes, that's what I assumed .. also the "+1" thing ... and now I'm wondering: should we use
yes, unavoidably (the temporal length of a single gaussian pulse is already defined by the minimum/maximum frequency it is limited to, as that determines the rise time etc), and I was also worried about that, which is why the single gaussian pulse always seemed a bit questionable to me and a gaussian shaped (over a multi-second time scale) continuous white noise excitation seemed preferrable .. but that's not in openEMS .. and it is not what RF engineers are commonly doing you say (and I believe that of course). catch 22 :(
yes, I like having stuff written in the proper system location (the tempfile area), and I like them to be overwritten so no crap is accumulating, and if I want to keep stuff, I just copy it from the tmp folder to wherever, but I can easily add some "run serial" or "run date" to the folders, but I really dislike storing crap in my Git working directory;) I am working with working directory == git repo working directory.
This is the most important hint and advice for me. Thank you! I am coming from a world where "identical" means: identical, to arbitrary precision, not limited even by finite bits in IEEE floats or what.
I will use
as a definition and work from there, but I can outline how a "proper/exact" solution would look like:
then a simulation using multiple threads would need to properly partition the workload .. e.g. have all threads run from different seeds but the same geometry and meshes wouldn't really accelerate things I guess .. so the workload partitioning is actually the harder problem, but rgd "repeatable random numbers", above approach is scalable and allows you to recompute simulation results exactly ... today, tomorrow and next week
aaahhh, I got it! thank you=) I wasn't aware at all.
oh yes, a lot!! thanks again=) Cheers, |
Beta Was this translation helpful? Give feedback.
-
Reality is continuous, but for FDTD we discretize the model (and resulting fields) into small boxes. This means an approximated model geometry, and limited degrees of freedom for the solver to put the correct field values. So for accuracy, dense mesh is better. But dense mesh means a larger model, which takes longer to solve. So the answer what is "best" really depends on the goal: ultimate accuracy, or fastest simulation, or some reasonable compromise. If we don't know what the is best compromise for our needs, we usually try different mesh density and compare results, and then decide what difference in results is "good enough". By doing this on a many geometries, we then learn to estimate a suitable mesh upfront. Side note: there is another solver method (FEM, finite elements in frequency domain) where local mesh refinement in areas of high energy/fields is part of the solution process. But openEMS uses FDTD, so we neet to set the mesh upfront.
Yes, correct. The aspect ratio should not be too extreme, but cell size is allowed to be quite different in x,y,z, if that is appropriate for the model geometry. One more detail that will be relevant to your work: For PCB stuff where we have lines that are very thin compared to the xy dimensions, it is also possible (and common!) to simulate the metal as zero thickness sheet, and not resolve the 17µm metal thickness at all. The losses are then handled by openEMS with a surface impedance mapped onto the thin sheet, you will find this in the openEMS transmission line examples. So for your meander antenna work, your mesh-from-edges code can be limited to xy plane, and use a single mesh line for teh conductor in z direction. (If you look up the transmission lines examples, you will also note that they do not put the mesh lines exactly on the edge, and instead use the "thirds rule" to offset the mesh line from the conductor edge. This helps to model the correct transmission line impedance with only a few mesh cells across the line. Google search should give some more info on that. For your PCB antenna, I think it's totally ok to put the mesh lines on the conductor edges, the resulting error is not critical for that case.) |
Beta Was this translation helpful? Give feedback.
-
alright, got it! so it's really about trying to tinker around, and lots of experience which knobs to turn. there are indeed quite a lot of variables, like geometry, mesh, excitation, .. and all seem to impact results.
it's pretty quick even with some 100,000's cells. my patience for poking around is like 5min, otherwise an hour is ok. anyways, I don't have time for it, but of course this could be massively parallelized if needed, and firing up 100 VMs with 800 cores on cloud for 1 hour would go a long way. I don't need it now, I have more fundamental problems, eg the bandwidth thing .. and antenna size ..
awesome!! thanks for making this explicit!
alright, I wasn't aware at all, but it sounds pretty much what I want/should do! so again: thank you so much for making me aware! in the meantime, I've optimized the parametrized meshing, fixed a number of small things, including the "differentiable" function of axis position for mesh resolution. turns out, the resulting model (which I also optimized) is working pretty stable I could now analyze higher order harmonics. DC-7GHz. without changing anything else it converges "good enough" on a fixed point "close enough" to my main frequency of interest it is borderline working at 10GHz, which makes sense, as the wire perimeter (~10mm) is on the order of lambda/4 of 10GHz. so I guess other effects kick in I should probably say: I wasn't aware at all of the apparent (and it seems universal, at least I checked couple of dipoles) fact that every dipole exhibits higher order k-harmonics only where k is odd. There will be a deep reason for this I guess. understanding why this happens, and how, would obviously be quite useful. do you happen to have a reference that might go into this aspect? And it is "odd", not "prime". I checked that;) and of course I am wondering: can I have an antenna type with even harmonics? with power2 harmonics? with prime harmonics? obviously, this k-odd harmonics thing (if it would apply to all antenna types, which I don't know) will make it impossible to cover 446MHz at fundamental resonance, and 869MHz at a harmonic .. not even with "some bandwidth". just from the numbers, I would need to go much lower with fundamental resonance, and then have both 446 and 869 being k-order harmonics for some odd k's. like 29MHz. of course it doesn't help that 869 ~ 2* 446. unless I had an antenna type with even or power2 harmonics. I begin to get a feeling for the problems in antenna design .. maybe .. I think;) sub-ghzfundamental resonance only: up to 7Ghz3th, 5th, .. 15th harmonic: up to 10GHzartifacts (I think) become stronger .. actually, I would only trust it up to and including 7th harmonic (~3GHz) |
Beta Was this translation helpful? Give feedback.
-
Hi Tobias, it's not really tinker around, there are mostly expected effects and dependencies, but it depends on the user's simulation experience and understanding of the device under test. When I give FDTD hands-on classes for the commercial solver, these are 2 days seminars because the users already have an RF design background and understanding of their devices that they want to simulate. Regarding simulation speed: what I mentioned becomes important when you go to more complex models. Just now I am simulating an antenna model with 3D stuff around it, which is 11M mesh cells, and other models are much larger. And to be prepared for such large models, you need to understand that simulation time depends not only on the number of cells, but also on the smallest mesh cell dimension. If the smallest mesh cell in your model is shrinked by factor 10, the simulation will take 10x longer, because the FDTD timestep is reduced to resolve field propagation across that small dimension. That's why we don't want mesh into 17µm metal thickniss if all other dimensions are much larger. Antenna harmonics: That's really the wavelength-dependecy which you can't change. We have zero current at the open end of the radiator, and that occurs when the dipole arm is lambda/4, or lambda/4 plus multiples of lambda/2. To learn some basics, try to get an introductory university textbook on RF. "Hochfrequenztechnik" by Frank Gustrau is one example, it covers the basics and many practical applications. There are scripts from RF classes online as well. Regarding artifacts: if you mean the low frequency ripple for your more wideband simulations, this looks like artefacts from stopping the FDTD simulation too early, before it is converged at low frequencies. This might be from running into the number-of-steps limit (not sure what the openEMS default value is, have a look at the comments in the sources) or from residual enery limit (EndCriteria=1e-4). You can check if EndCriteria=1e-5 reduces the ripple, otherwise it is the number-of-steps limit that stops simulation to early. |
Beta Was this translation helpful? Give feedback.
-
I am really glad for your support, and I am fully aware that your tips and hints are "expert level", and that it is in a way quite unusual to receive such support in a forum of a OSS package. I highly appreciate your help! But if you don't have the time or for any other reason, I can fully understand, if you want to limit your time or would rather redirect me or similar. No problem, I get it.
ahh, ok! I wasn't aware of these connections. this is quite important to know, so thank you one more time for your spot on, perfect hint!
Yeah, that could be helpful;) Thanks for the concrete book recommendation as well!
Yeah, your picture, and in the meantime, I've figured out my mistake with the odd-order harmonics thing: my mistake was thinking of EM only in terms of magnitude, but of course currents are vectors, have a direction, and as such, can cancel out - which explains why there are only odd, not even harmonics. I haven't looked into how this cancellations looks in EM vector space or electromagnetic waves at the Physics level or what, I guess I would really need "more basics" and dig into EM theory etc;) But I can grok the cancellation at a general level as a consequence of math in vector spaces in general. And I am soon going back to "Far-field vs Near-field" and "Paraview" and all that. rendering the current distribution within the dipole in time should make such effects visible. E.g. the other "effect" I'd love to look at visually is what happens at >7GHz .. around 10GHz ... when dipole perimeter approaches quarter wavelength, I would expect this to be visible in a current/time view on the dipole surface. Maybe I need a super fine mesh, will see.
Yes, the ripples around DC in wideband analysis is 1/3 of the artifacts/questions I meant. I am using an upper bound of 4.1GHz to catch 7th harmonics, and those ripples disappear when using 1GHz, it is perfectly flat around DC then. I tested your hint decreasing EndCriteria to 1e-5: it works!! the ripples are (almost completely) gone, here: so your EndCriteria tip clearly answers "Q2: yes, artifact" in the following summary of my remaining puzzlement the other questions Q1 and Q3 are also unclear to me at this point. I would more lean towards or expect: "Q1: yes, always (for any dipole)." and "Q3: yes, always (for any dipole)" .. but I'm not sure .. don't know .. |
Beta Was this translation helpful? Give feedback.
-
here is when using end criteria of -60dB: ripples are completely gone. after running for an 1 hour:
|
Beta Was this translation helpful? Give feedback.
-
alright, making some progress, I now have both standard dipole and monopole models with meshing and lumped port working, and reproducing theoretical values pretty closely (close enough), and with parametrized meshing granularity which allows to trade off cpu time vs precision. I'm gonna close this issue, thank you both again a lot for all your help and tips! I am obviously still digesting;) if you think a PR with a dipole example would be welcome, pls let me know, I can create a simple script similar to existing examples |
Beta Was this translation helpful? Give feedback.
-
this discussion has become quite extensive/unwieldly, and the original issue (like in the title) has been resolved (thanks again for helping!), hence I closed the discussion, but now that I am slowly digesting all the tips, I would like to come back to 2 specific comments by @biergaizi :
I think I'm on a good track rgd simulation, and I plan to have a prototype PCB manufactured soon, because I want to verify the simulation results in the real world. now here is my next newbie problem;) the simulation gives my S11 and S21 depending on frequency for my antenna. I've done some research, and it seems I would need a VNA to analyze the prototype PCB in the real world and verify results are close to simulation. is that correct? I have also looked at some VNAs, and obviously, I cannot afford industry leading state-of-the-art kit. simple as that. then I've looked at USB3 based VNAs, which tbh, seems attractive both price-wise, and because I can do all the work on my notebook, which has better display / UI controls than a bench top kit anyways;) do you know / what do you think of : https://www.zeenko.tech/librevna ? it's ~500 bucks, OSS/OHW, fits in a notebook bag, tech specs seem good and sufficient for my sub-Ghz antenna thing anyways. makes sense?
in the meantime, it became obvious to me that I won't be able to avoid it:( in addition to antenna, I need RF switches, impedance matching and external connectors before even reaching a LNA/PA. I might also want to try PIN diodes to adjust the electrical length of my antenna .. the bandwidth I want is a challenge .. I can do 80MHz (simulated), but not the ~600MHz. maybe one unswitched fractal antenna would work .. will see .. but maybe not .. and if so, maybe PIN diodes can do the trick anyways, I had a look a Qucs. it is pretty much unmaintained for years, and is built on Qt4 .. which is EOL for some time already and not in distros by standard anymore Qucs-S is somewhat maintained ... at least more than Qucs. Do I really need "Qucs's unique RF simulation features" for my simple stuff (sub-ghz)? Would Qucs-S be my best bet (I can't afford pro, non OSS tools)? I could wrap for current distros or even update Qucs for newer Qt ... but that would be significant work I'd rather not do;) |
Beta Was this translation helpful? Give feedback.
-
the discussion split out is about how to create a most simple, center-fed half-wave dipole model using openEMS in Python.
I'm gonna repost link to the latest code
https://gist.github.com/oberstet/8877417387c622f59700612818a1484d
which includes all improvements and corrections suggested in #151 by @VolkerMuehlhaus
results from running above self-contained complete script using
is:
Beta Was this translation helpful? Give feedback.
All reactions