Bugfix for TDEM magnetic dipole sources #1572
Conversation
…he b-field (or h-field) is what we are solving for
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1572 +/- ##
==========================================
- Coverage 86.44% 86.44% -0.01%
==========================================
Files 407 407
Lines 52475 52469 -6
Branches 4997 4993 -4
==========================================
- Hits 45363 45357 -6
- Misses 5686 5687 +1
+ Partials 1426 1425 -1 ☔ View full report in Codecov by Sentry. |
|
Right at that moment when the transmitter shuts off, you are right that db/dt, isn't defined, but a couple of things... for the definition of initial fields, the limit is always from the left (while the transmitter is still on), so zero is a valid limit. Second, the current solution isn't physical (so isn't the limit from either side!) So having the solution be zero is both physical and consistent with our definition of initial fields |
|
Thanks for the explanation there. So then is your change assuming that if the waveform has initial fields, the amplitude is 1? |
|
If the waveform has initial fields, those will be either |
|
is there any chance of getting this into a patch release relatively soon? I will be using this code in a demo this week. If we don't get it in before then, that is fine, but it would be good to have it out shortly after to avoid potential confusion |
|
Ah, I see what was happening then! The source was zero before because in the formulation it makes use of the time derivative of Your fix at least fixes that portion, but also would have issues again if the source waveform is not 1 at the start. From what I could tell, all of the waveforms that have initial fields support evaluating themselves with a time before its start time. |
|
The source was zero before, but it wasn't used in the b, h simulations (exactly as you say -- because we were using the derivative of the source term for computing in the b, h formulations). So we never caught the issue. However, when computing the fields it matters. This should be fine for any waveform (we test the e formulation and it makes use of the Previously, we had an if-else statement that treated b,h formulations differently for this source than for e,j, but there is no reason for that. So this pr simply gets rid of the if-else statements that were treating them differently |
|
One other related note, for the figure that I showed, that is bd/dt computed at t=0 (so the moment before the transmitter shuts off) -- it wasn't an effect due to transmitter turn off, it is because we needed to have the source term included when we solve for the initial simpeg/simpeg/electromagnetics/time_domain/fields.py Lines 246 to 251 in 8c04621 simpeg/simpeg/electromagnetics/time_domain/fields.py Lines 226 to 232 in 8c04621 |
| if simulation._fieldType == "b": | ||
| return Zero() | ||
| elif simulation._fieldType == "e": |
There was a problem hiding this comment.
this if-else statement wasn't necessary
|
This notebook is one you can test out before / after the pr if you like: https://github.com/ubcgif/2024-aqgeo-meeting-em-tutorial/blob/notebooks/1-forward-simulation.ipynb The widget at the bottom is the one I grabbed the screenshots from. |
|
Ok, thanks for sharing the notebook, was helpful! looks good to me now then. |
|
Thanks for taking the time to go through this one Joe! It was a bit of a subtle bug. I appreciate your help 😄 |

Summary
Bugfix so that the initial fields produced for
db/dt,dh/dt, from the B field or H field simulations are zero. There was previously a bug where we set the electric source term toZero()when infact it should have been evaluated. This would only effectdb/dt(ordh/dt) that were measured before the first time-step, but it also impacted visualizations of the fields.To catch this issue, I have extended our cross-check tests for tdem simulation to also include an evaluation of the data at t=0. Running this test on the current main version of SimPEG will fail.
As an example, using the
tdem.simulation.Simulation3DMagneticFluxDensityfor a loop source and plotting db/dt gives:Before the bugfix

Crazy db/dt!
After

Zero -- as it should be
PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.