fixed HUGE bug with shot noise
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "scgenerator"
|
||||
version = "0.3.26"
|
||||
version = "0.4.0"
|
||||
description = "Simulate nonlinear pulse propagation in optical fibers"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "Benoit Sierro", email = "benoit.sierro@iap.unibe.ch" }]
|
||||
|
||||
@@ -559,10 +559,11 @@ def finalize_pulse(
|
||||
dt: float,
|
||||
input_transmission: float,
|
||||
) -> np.ndarray:
|
||||
pre_field_0 *= np.sqrt(input_transmission)
|
||||
if quantum_noise:
|
||||
pre_field_0 = pre_field_0 + shot_noise(w, dt)
|
||||
|
||||
return np.sqrt(input_transmission) * pre_field_0
|
||||
return pre_field_0
|
||||
|
||||
|
||||
def A_to_C(A: np.ndarray, effective_area_arr: np.ndarray) -> np.ndarray:
|
||||
@@ -614,29 +615,7 @@ def compress_pulse(spectra: np.ndarray):
|
||||
else:
|
||||
return fftshift(ifft(flatten_phase(spectra)), axes=1)
|
||||
|
||||
def shot_noise(w: np.ndarray, dt: float):
|
||||
"""
|
||||
|
||||
Parameters
|
||||
----------
|
||||
w : array, shape (n,)
|
||||
angular frequencies
|
||||
dt : float
|
||||
resolution of time grid
|
||||
|
||||
Returns
|
||||
-------
|
||||
np.ndarray, shape (n,)
|
||||
noise field to be added on top of initial field in time domain
|
||||
"""
|
||||
dw = w[1] - w[0]
|
||||
|
||||
rand_phase = np.random.rand(len(w)) * 2 * pi
|
||||
shot_noise_phase = np.exp(-1j * rand_phase)
|
||||
|
||||
shot_noise_amplitude = np.sqrt(0.5 * units.hbar * np.abs(w) / dw)
|
||||
|
||||
return ifft(shot_noise_amplitude * shot_noise_phase / dt * np.sqrt(2 * pi))
|
||||
def ideal_compressed_pulse(spectra: np.ndarray):
|
||||
"""
|
||||
returns the ideal compressed pulse assuming flat phase
|
||||
|
||||
@@ -389,7 +389,7 @@ def propagation_series(
|
||||
convenient object to work with multiple propagations **built on the same grid**
|
||||
"""
|
||||
if isinstance(files, str) or not isinstance(files, Sequence):
|
||||
files = sorted(Path(files).glob("*.zip"), key=logical_sort_key)
|
||||
files = sorted(Path(files).expanduser().glob("*.zip"), key=logical_sort_key)
|
||||
if len(files) == 0:
|
||||
raise ValueError("You must provide at least one file to build a propagation series")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user