|
| 1 | +"""smokescreen checks of mixed domain default hamiltonian integration""" |
| 2 | +import WrightSim as ws |
| 3 | +import numpy as np |
| 4 | +import pytest |
| 5 | + |
| 6 | + |
| 7 | +dt = 20 |
| 8 | +nt = 21 |
| 9 | +wn_to_omega = 2 * np.pi * 3e-5 # cm / fs |
| 10 | +w_central = 3000 # wn |
| 11 | +coupling = 0 # wn |
| 12 | + |
| 13 | +ham = ws.hamiltonian.Hamiltonian( |
| 14 | + w_central=w_central, |
| 15 | + coupling=coupling, |
| 16 | + tau=100, |
| 17 | +) |
| 18 | +ham.recorded_elements = [7, 8] |
| 19 | + |
| 20 | + |
| 21 | +@pytest.mark.skip("this test currently fails; bugfix needed") |
| 22 | +def test_windowed(): |
| 23 | + exp = ws.experiment.builtin('trive') |
| 24 | + exp.w1.points = w_central # wn |
| 25 | + exp.w2.points = w_central # wn |
| 26 | + exp.d2.points = 50 # np.zeros((1,)) # fs |
| 27 | + exp.d1.points = 0 # fs |
| 28 | + exp.s1.points = exp.s2.points = dt # fs |
| 29 | + |
| 30 | + exp.d1.active = exp.d2.active = False |
| 31 | + |
| 32 | + # 400 time points |
| 33 | + exp.timestep = 1 |
| 34 | + exp.early_buffer = 100. |
| 35 | + exp.late_buffer = 300. |
| 36 | + |
| 37 | + scan = exp.run(ham, mp=False) |
| 38 | + data = scan.sig |
| 39 | + |
| 40 | + # shift delay so emission is timed differently |
| 41 | + exp2 = ws.experiment.builtin('trive') |
| 42 | + exp2.w1.points = w_central # wn |
| 43 | + exp2.w2.points = w_central # wn |
| 44 | + exp2.d2.points = 50 # np.zeros((1,)) # fs |
| 45 | + exp2.d1.points = 0 # fs |
| 46 | + exp2.s1.points = exp2.s2.points = dt # fs |
| 47 | + |
| 48 | + exp2.d1.active = exp2.d2.active = False |
| 49 | + |
| 50 | + exp2.timestep = 1 |
| 51 | + exp2.early_buffer = 100. |
| 52 | + exp2.late_buffer = 300. |
| 53 | + |
| 54 | + scan2 = exp2.run(ham, mp=False, windowed=True) |
| 55 | + data2 = scan2.sig |
| 56 | + |
| 57 | + assert data2.time.size == data.time.size |
| 58 | + assert data2.time.size == data2.channels[0].size |
| 59 | + assert np.all(np.isclose(data2.channels[0][:], data.channels[0][:])) |
| 60 | + |
| 61 | + |
| 62 | +def test_frequency(): |
| 63 | + |
| 64 | + exp = ws.experiment.builtin('trive') |
| 65 | + exp.w1.points = w_central # wn |
| 66 | + exp.w2.points = w_central # wn |
| 67 | + exp.d2.points = 0 # np.zeros((1,)) # fs |
| 68 | + exp.d1.points = 0 # fs |
| 69 | + exp.s1.points = exp.s2.points = dt # fs |
| 70 | + |
| 71 | + exp.d1.active = exp.d2.active = False |
| 72 | + |
| 73 | + # 400 time points |
| 74 | + exp.timestep = 1 |
| 75 | + exp.early_buffer = 100. |
| 76 | + exp.late_buffer = 300. |
| 77 | + |
| 78 | + scan = exp.run(ham, mp=False) |
| 79 | + data = scan.sig |
| 80 | + wn = np.fft.fftfreq(n=data.time.size, d=exp.timestep) / 3e-5 |
| 81 | + sig_fft = np.abs(np.fft.fft(data.channels[0][:])) |
| 82 | + |
| 83 | + assert np.abs(wn[np.argmax(sig_fft)] + w_central) < np.abs(wn[1] - wn[0]) |
| 84 | + |
| 85 | + |
| 86 | +if __name__ == "__main__": |
| 87 | + test_windowed() # fails atm |
| 88 | + test_frequency() |
0 commit comments