|
1 | 1 | import unittest |
| 2 | +import pytest |
2 | 3 | from simpeg import maps |
3 | 4 | import simpeg.electromagnetics.time_domain as tdem |
4 | 5 | from simpeg.electromagnetics.utils import convolve_with_waveform |
@@ -285,5 +286,68 @@ def test_backwards_compatible_filter_key(): |
285 | 286 | assert sim.time_filter == "key_81_2009" |
286 | 287 |
|
287 | 288 |
|
| 289 | +@pytest.mark.parametrize("prop", ["conductivity", "permeability"]) |
| 290 | +def test_real_vs_complex(prop): |
| 291 | + """just makes sure that it respect a complex conductivity, in that it is different |
| 292 | + from the real value. |
| 293 | + """ |
| 294 | + source_location = np.array([0.0, 0.0, 100.0 + 1e-5]) |
| 295 | + receiver_locations = np.array([[0.0, 0.0, 100.0 + 1e-5]]) |
| 296 | + receiver_orientation = "z" # "x", "y" or "z" |
| 297 | + times = np.logspace(-5, -2, 31) |
| 298 | + radius = 20.0 |
| 299 | + |
| 300 | + # Waveform |
| 301 | + waveform = tdem.sources.TriangularWaveform( |
| 302 | + start_time=-0.01, peak_time=-0.005, off_time=0.0 |
| 303 | + ) |
| 304 | + |
| 305 | + # Receiver list |
| 306 | + |
| 307 | + # Define receivers at each location. |
| 308 | + b_receiver = tdem.receivers.PointMagneticFluxDensity( |
| 309 | + receiver_locations, times, receiver_orientation |
| 310 | + ) |
| 311 | + dbzdt_receiver = tdem.receivers.PointMagneticFluxTimeDerivative( |
| 312 | + receiver_locations, times, receiver_orientation |
| 313 | + ) |
| 314 | + receivers_list = [ |
| 315 | + b_receiver, |
| 316 | + dbzdt_receiver, |
| 317 | + ] # Make a list containing all receivers even if just one |
| 318 | + |
| 319 | + # Must define the transmitter properties and associated receivers |
| 320 | + source_list = [ |
| 321 | + tdem.sources.CircularLoop( |
| 322 | + receivers_list, |
| 323 | + location=source_location, |
| 324 | + waveform=waveform, |
| 325 | + radius=radius, |
| 326 | + ) |
| 327 | + ] |
| 328 | + |
| 329 | + survey = tdem.Survey(source_list) |
| 330 | + |
| 331 | + sim = tdem.Simulation1DLayered(survey=survey, sigma=[1.0]) |
| 332 | + if prop == "conductivity": |
| 333 | + sim.eta = 0.5 |
| 334 | + else: |
| 335 | + sim.dchi = 1.0 |
| 336 | + |
| 337 | + d_c = sim.dpred(None) |
| 338 | + |
| 339 | + sim_real = tdem.Simulation1DLayered(survey=survey, sigma=[1.0]) |
| 340 | + |
| 341 | + # hijack these to just return the real values from the complex valued simulation |
| 342 | + # that way we are sure the two simulations have the same real parts of mu and sigma |
| 343 | + # but different imaginary portions |
| 344 | + sim_real.compute_complex_sigma = lambda f: sim.compute_complex_sigma(f).real |
| 345 | + sim_real.compute_complex_mu = lambda f: sim.compute_complex_mu(f).real |
| 346 | + |
| 347 | + d_r = sim_real.dpred(None) |
| 348 | + |
| 349 | + assert np.all(d_r != d_c) |
| 350 | + |
| 351 | + |
288 | 352 | if __name__ == "__main__": |
289 | 353 | unittest.main() |
0 commit comments