mbsolver 0.5.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {mbsolver-0.5.0/src/mbsolver.egg-info → mbsolver-0.6.0}/PKG-INFO +4 -4
  2. {mbsolver-0.5.0 → mbsolver-0.6.0}/README.md +3 -3
  3. {mbsolver-0.5.0 → mbsolver-0.6.0}/pyproject.toml +1 -1
  4. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/two_level/__init__.py +7 -7
  5. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/two_level/_kernel_1d.py +6 -2
  6. {mbsolver-0.5.0 → mbsolver-0.6.0/src/mbsolver.egg-info}/PKG-INFO +4 -4
  7. {mbsolver-0.5.0 → mbsolver-0.6.0}/tests/test_two_level.py +1 -0
  8. {mbsolver-0.5.0 → mbsolver-0.6.0}/tests/test_two_level_adiabatic.py +3 -2
  9. {mbsolver-0.5.0 → mbsolver-0.6.0}/LICENSE +0 -0
  10. {mbsolver-0.5.0 → mbsolver-0.6.0}/setup.cfg +0 -0
  11. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/__init__.py +0 -0
  12. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/constants.py +0 -0
  13. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/grids.py +0 -0
  14. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/profiles.py +0 -0
  15. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/sample.py +0 -0
  16. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/three_level/__init__.py +0 -0
  17. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/three_level/_kernel_1d.py +0 -0
  18. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/three_level/sample.py +0 -0
  19. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver/two_level/_kernel_adiabatic_1d.py +0 -0
  20. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver.egg-info/SOURCES.txt +0 -0
  21. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver.egg-info/dependency_links.txt +0 -0
  22. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver.egg-info/requires.txt +0 -0
  23. {mbsolver-0.5.0 → mbsolver-0.6.0}/src/mbsolver.egg-info/top_level.txt +0 -0
  24. {mbsolver-0.5.0 → mbsolver-0.6.0}/tests/test_profiles.py +0 -0
  25. {mbsolver-0.5.0 → mbsolver-0.6.0}/tests/test_sample.py +0 -0
  26. {mbsolver-0.5.0 → mbsolver-0.6.0}/tests/test_three_level.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbsolver
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Fast Maxwell-Bloch solvers for masers, superradiance and coherent pulse propagation
5
5
  Author: Toktam Rashidi
6
6
  Author-email: Vahid Anari <vahid.anari8@gmail.com>
@@ -102,8 +102,8 @@ plt.show()
102
102
 
103
103
  ### Result
104
104
 
105
- `res.time`, `res.z` (positions of the stored planes), `res.intensity` and
106
- `res.w` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
105
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
106
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
107
107
 
108
108
  ### Adiabatic (rate-equation) limit
109
109
 
@@ -116,7 +116,7 @@ dA/dz = −η R0 + η T2 A w
116
116
  ```
117
117
 
118
118
  `solve_1d_adiabatic` takes the same arguments as `solve_1d` (with a finite
119
- `t2`) and returns the same result plus `res.R`, so the two can be compared
119
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
120
120
  directly. The limit differs from the full system during the first few `T2`
121
121
  and in bursts faster than `T2`; see the section on it in
122
122
  [`docs/two_level.pdf`](docs/two_level.pdf).
@@ -70,8 +70,8 @@ plt.show()
70
70
 
71
71
  ### Result
72
72
 
73
- `res.time`, `res.z` (positions of the stored planes), `res.intensity` and
74
- `res.w` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
73
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
74
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
75
75
 
76
76
  ### Adiabatic (rate-equation) limit
77
77
 
@@ -84,7 +84,7 @@ dA/dz = −η R0 + η T2 A w
84
84
  ```
85
85
 
86
86
  `solve_1d_adiabatic` takes the same arguments as `solve_1d` (with a finite
87
- `t2`) and returns the same result plus `res.R`, so the two can be compared
87
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
88
88
  directly. The limit differs from the full system during the first few `T2`
89
89
  and in bursts faster than `T2`; see the section on it in
90
90
  [`docs/two_level.pdf`](docs/two_level.pdf).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mbsolver"
7
- version = "0.5.0"
7
+ version = "0.6.0"
8
8
  description = "Fast Maxwell-Bloch solvers for masers, superradiance and coherent pulse propagation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -39,8 +39,8 @@ class Result:
39
39
  pump: Total pump ``Λ(t)``.
40
40
  field_in: Boundary field ``A(t, z=0)``.
41
41
  t1, t2: Relaxation times on the time grid.
42
- R: Coherence on the stored planes, shape ``(n_planes, nt)``; only from
43
- :func:`solve_1d_adiabatic` (``None`` from :func:`solve_1d`).
42
+ R: Coherence on the stored planes, shape ``(n_planes, nt)`` (from both solvers;
43
+ ``None`` only for a hand-built result).
44
44
  """
45
45
 
46
46
  time: np.ndarray
@@ -94,14 +94,14 @@ def solve_1d(
94
94
  Example:
95
95
  >>> res = solve_1d(t_max=200, nt=4000, nz=200, eta=5.0, theta0=0.01,
96
96
  ... t1=1.0, t2=0.5, pump=Pulse(a=0.1, x0=50, w=10))
97
- >>> exit_intensity = res.intensity[-1]
97
+ >>> exit_intensity, exit_coherence = res.intensity[-1], res.R[-1]
98
98
  """
99
99
  g = _prepare(t_max=t_max, nt=nt, nz=nz, t1=t1, t2=t2, theta0=theta0, w0=w0, R0=R0,
100
100
  pump=pump, field_in=field_in, n_planes=n_planes)
101
- w, intensity = solve_kernel(g["t"], g["dt"], g["z"], g["dz"], g["n_planes"], g["w_z"], g["R_z"],
102
- g["field_t"], g["pump_t"], g["t1_t"], g["t2_t"], float(eta))
101
+ w, intensity, R = solve_kernel(g["t"], g["dt"], g["z"], g["dz"], g["n_planes"], g["w_z"], g["R_z"],
102
+ g["field_t"], g["pump_t"], g["t1_t"], g["t2_t"], float(eta))
103
103
  return Result(time=g["t"], z=g["planes"], intensity=intensity, w=w, pump=g["pump_t"],
104
- field_in=g["field_t"], t1=g["t1_t"], t2=g["t2_t"])
104
+ field_in=g["field_t"], t1=g["t1_t"], t2=g["t2_t"], R=R)
105
105
 
106
106
 
107
107
  def solve_1d_adiabatic(
@@ -129,7 +129,7 @@ def solve_1d_adiabatic(
129
129
  The limit holds when ``T2`` is short compared with the times over which ``A`` and ``w``
130
130
  change; it differs from :func:`solve_1d` during the first few ``T2`` and in bursts faster
131
131
  than ``T2``. Same arguments and grids as :func:`solve_1d`, so the two can be compared
132
- directly; ``t2`` must be finite. The result also carries ``R``. Derivation and numerical
132
+ directly; ``t2`` must be finite. Derivation and numerical
133
133
  scheme: ``docs/two_level.pdf``, section "Adiabatic (Rate-Equation) Limit".
134
134
 
135
135
  Raises:
@@ -2,6 +2,7 @@
2
2
 
3
3
  Moved unchanged from MB Solver 8.13 (``solver/maxwell_bloch.py``):
4
4
  RK4 in time for the population and coherence, explicit step in z for the field.
5
+ From 0.6.0 the coherence R is also stored on the returned planes (numerics unchanged).
5
6
 
6
7
  dw/dt = A R - (w - w0) / T1 + Λ
7
8
  dR/dt = -A w - (R - R0) / T2
@@ -68,7 +69,7 @@ def solve_kernel(t, dt, z, dz, n_z_planes, w0, R0, A0, lambda_n, t1, t2, eta):
68
69
  eta: Coupling coefficient.
69
70
 
70
71
  Returns:
71
- ``(w, I)``, each of shape ``(n_z_planes, len(t))``.
72
+ ``(w, I, R)``, each of shape ``(n_z_planes, len(t))``.
72
73
  """
73
74
  nt = len(t)
74
75
  nz = len(z)
@@ -90,6 +91,7 @@ def solve_kernel(t, dt, z, dz, n_z_planes, w0, R0, A0, lambda_n, t1, t2, eta):
90
91
 
91
92
  w_result = np.empty((n_z_planes, nt), dtype=np.float64)
92
93
  I_result = np.empty((n_z_planes, nt), dtype=np.float64)
94
+ R_result = np.empty((n_z_planes, nt), dtype=np.float64)
93
95
 
94
96
  w_old[0], R_old[0] = w0[0], R0[0]
95
97
  A_old[0] = A0[0]
@@ -108,6 +110,7 @@ def solve_kernel(t, dt, z, dz, n_z_planes, w0, R0, A0, lambda_n, t1, t2, eta):
108
110
 
109
111
  w_result[0, :] = w_old
110
112
  I_result[0, :] = A_old * A_old
113
+ R_result[0, :] = R_old
111
114
  i = 1
112
115
 
113
116
  for z_idx in range(1, nz):
@@ -129,10 +132,11 @@ def solve_kernel(t, dt, z, dz, n_z_planes, w0, R0, A0, lambda_n, t1, t2, eta):
129
132
  if i < n_z_planes and z_plane_indices[i] == z_idx:
130
133
  w_result[i, :] = w_new
131
134
  I_result[i, :] = A_new * A_new
135
+ R_result[i, :] = R_new
132
136
  i += 1
133
137
 
134
138
  w_old, w_new = w_new, w_old
135
139
  R_old, R_new = R_new, R_old
136
140
  A_old, A_new = A_new, A_old
137
141
 
138
- return w_result, I_result
142
+ return w_result, I_result, R_result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbsolver
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Fast Maxwell-Bloch solvers for masers, superradiance and coherent pulse propagation
5
5
  Author: Toktam Rashidi
6
6
  Author-email: Vahid Anari <vahid.anari8@gmail.com>
@@ -102,8 +102,8 @@ plt.show()
102
102
 
103
103
  ### Result
104
104
 
105
- `res.time`, `res.z` (positions of the stored planes), `res.intensity` and
106
- `res.w` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
105
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
106
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
107
107
 
108
108
  ### Adiabatic (rate-equation) limit
109
109
 
@@ -116,7 +116,7 @@ dA/dz = −η R0 + η T2 A w
116
116
  ```
117
117
 
118
118
  `solve_1d_adiabatic` takes the same arguments as `solve_1d` (with a finite
119
- `t2`) and returns the same result plus `res.R`, so the two can be compared
119
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
120
120
  directly. The limit differs from the full system during the first few `T2`
121
121
  and in bursts faster than `T2`; see the section on it in
122
122
  [`docs/two_level.pdf`](docs/two_level.pdf).
@@ -54,6 +54,7 @@ def test_entrance_is_a_bloch_rotation():
54
54
  dt = res.time[1] - res.time[0]
55
55
  area = np.concatenate(([0.0], np.cumsum(res.field_in[:-1]) * dt))
56
56
  np.testing.assert_allclose(res.w[0], np.cos(theta0 - area), atol=1e-9)
57
+ np.testing.assert_allclose(res.R[0], np.sin(theta0 - area), atol=1e-9)
57
58
 
58
59
 
59
60
  def test_no_coupling_leaves_field_unchanged():
@@ -50,8 +50,9 @@ def test_stable_for_a_strong_field():
50
50
  assert np.all(np.isfinite(res.w)) and np.all(np.abs(res.w) <= 1.0 + 1e-12)
51
51
 
52
52
 
53
- def test_full_solver_returns_no_coherence():
54
- assert solve_1d(**CASE, t2=0.5).R is None
53
+ def test_full_solver_returns_coherence():
54
+ res = solve_1d(**CASE, t2=0.5)
55
+ assert res.R is not None and res.R.shape == res.w.shape
55
56
 
56
57
 
57
58
  def test_infinite_t2_is_refused():
File without changes
File without changes
File without changes
File without changes