mbsolver 0.5.0__tar.gz → 0.6.1__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 (27) hide show
  1. {mbsolver-0.5.0/src/mbsolver.egg-info → mbsolver-0.6.1}/PKG-INFO +8 -6
  2. {mbsolver-0.5.0 → mbsolver-0.6.1}/README.md +5 -4
  3. {mbsolver-0.5.0 → mbsolver-0.6.1}/pyproject.toml +4 -2
  4. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/two_level/__init__.py +7 -7
  5. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/two_level/_kernel_1d.py +6 -2
  6. {mbsolver-0.5.0 → mbsolver-0.6.1/src/mbsolver.egg-info}/PKG-INFO +8 -6
  7. mbsolver-0.6.1/src/mbsolver.egg-info/requires.txt +12 -0
  8. {mbsolver-0.5.0 → mbsolver-0.6.1}/tests/test_two_level.py +1 -0
  9. {mbsolver-0.5.0 → mbsolver-0.6.1}/tests/test_two_level_adiabatic.py +3 -2
  10. mbsolver-0.5.0/src/mbsolver.egg-info/requires.txt +0 -7
  11. {mbsolver-0.5.0 → mbsolver-0.6.1}/LICENSE +0 -0
  12. {mbsolver-0.5.0 → mbsolver-0.6.1}/setup.cfg +0 -0
  13. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/__init__.py +0 -0
  14. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/constants.py +0 -0
  15. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/grids.py +0 -0
  16. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/profiles.py +0 -0
  17. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/sample.py +0 -0
  18. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/three_level/__init__.py +0 -0
  19. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/three_level/_kernel_1d.py +0 -0
  20. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/three_level/sample.py +0 -0
  21. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver/two_level/_kernel_adiabatic_1d.py +0 -0
  22. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver.egg-info/SOURCES.txt +0 -0
  23. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver.egg-info/dependency_links.txt +0 -0
  24. {mbsolver-0.5.0 → mbsolver-0.6.1}/src/mbsolver.egg-info/top_level.txt +0 -0
  25. {mbsolver-0.5.0 → mbsolver-0.6.1}/tests/test_profiles.py +0 -0
  26. {mbsolver-0.5.0 → mbsolver-0.6.1}/tests/test_sample.py +0 -0
  27. {mbsolver-0.5.0 → mbsolver-0.6.1}/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.1
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>
@@ -23,7 +23,8 @@ Requires-Python: >=3.10
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: numpy>=1.24
26
- Requires-Dist: numba>=0.58
26
+ Requires-Dist: numba<0.63,>=0.58; sys_platform == "darwin" and platform_machine == "x86_64"
27
+ Requires-Dist: numba>=0.58; sys_platform != "darwin" or platform_machine != "x86_64"
27
28
  Provides-Extra: dev
28
29
  Requires-Dist: build; extra == "dev"
29
30
  Requires-Dist: twine; extra == "dev"
@@ -50,7 +51,8 @@ desktop app runs on the same code.
50
51
  pip install mbsolver
51
52
  ```
52
53
 
53
- Requires Python 3.10+ (numpy and numba are installed with it).
54
+ Requires Python 3.10+ (numpy and numba are installed with it). On Intel Macs numba
55
+ stays at 0.62, the last version built for them; with it, Python 3.10–3.13 are supported there.
54
56
 
55
57
  ## Two-level model in one dimension
56
58
 
@@ -102,8 +104,8 @@ plt.show()
102
104
 
103
105
  ### Result
104
106
 
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`.
107
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
108
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
107
109
 
108
110
  ### Adiabatic (rate-equation) limit
109
111
 
@@ -116,7 +118,7 @@ dA/dz = −η R0 + η T2 A w
116
118
  ```
117
119
 
118
120
  `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
121
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
120
122
  directly. The limit differs from the full system during the first few `T2`
121
123
  and in bursts faster than `T2`; see the section on it in
122
124
  [`docs/two_level.pdf`](docs/two_level.pdf).
@@ -18,7 +18,8 @@ desktop app runs on the same code.
18
18
  pip install mbsolver
19
19
  ```
20
20
 
21
- Requires Python 3.10+ (numpy and numba are installed with it).
21
+ Requires Python 3.10+ (numpy and numba are installed with it). On Intel Macs numba
22
+ stays at 0.62, the last version built for them; with it, Python 3.10–3.13 are supported there.
22
23
 
23
24
  ## Two-level model in one dimension
24
25
 
@@ -70,8 +71,8 @@ plt.show()
70
71
 
71
72
  ### Result
72
73
 
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`.
74
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
75
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
75
76
 
76
77
  ### Adiabatic (rate-equation) limit
77
78
 
@@ -84,7 +85,7 @@ dA/dz = −η R0 + η T2 A w
84
85
  ```
85
86
 
86
87
  `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
88
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
88
89
  directly. The limit differs from the full system during the first few `T2`
89
90
  and in bursts faster than `T2`; see the section on it in
90
91
  [`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.1"
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"
@@ -32,7 +32,9 @@ classifiers = [
32
32
  ]
33
33
  dependencies = [
34
34
  "numpy>=1.24",
35
- "numba>=0.58",
35
+ # numba (and llvmlite) have no Intel-Mac wheels after 0.62 (0.45): newer ones would be compiled from source
36
+ "numba>=0.58,<0.63; sys_platform == 'darwin' and platform_machine == 'x86_64'",
37
+ "numba>=0.58; sys_platform != 'darwin' or platform_machine != 'x86_64'",
36
38
  ]
37
39
 
38
40
  [project.optional-dependencies]
@@ -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.1
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>
@@ -23,7 +23,8 @@ Requires-Python: >=3.10
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: numpy>=1.24
26
- Requires-Dist: numba>=0.58
26
+ Requires-Dist: numba<0.63,>=0.58; sys_platform == "darwin" and platform_machine == "x86_64"
27
+ Requires-Dist: numba>=0.58; sys_platform != "darwin" or platform_machine != "x86_64"
27
28
  Provides-Extra: dev
28
29
  Requires-Dist: build; extra == "dev"
29
30
  Requires-Dist: twine; extra == "dev"
@@ -50,7 +51,8 @@ desktop app runs on the same code.
50
51
  pip install mbsolver
51
52
  ```
52
53
 
53
- Requires Python 3.10+ (numpy and numba are installed with it).
54
+ Requires Python 3.10+ (numpy and numba are installed with it). On Intel Macs numba
55
+ stays at 0.62, the last version built for them; with it, Python 3.10–3.13 are supported there.
54
56
 
55
57
  ## Two-level model in one dimension
56
58
 
@@ -102,8 +104,8 @@ plt.show()
102
104
 
103
105
  ### Result
104
106
 
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`.
107
+ `res.time`, `res.z` (positions of the stored planes), `res.intensity`,
108
+ `res.w` and `res.R` (shape `(n_planes, nt)`), `res.pump`, `res.field_in`, `res.t1`, `res.t2`.
107
109
 
108
110
  ### Adiabatic (rate-equation) limit
109
111
 
@@ -116,7 +118,7 @@ dA/dz = −η R0 + η T2 A w
116
118
  ```
117
119
 
118
120
  `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
121
+ `t2`) and returns the same result (`res.R` included, as from `solve_1d`), so the two can be compared
120
122
  directly. The limit differs from the full system during the first few `T2`
121
123
  and in bursts faster than `T2`; see the section on it in
122
124
  [`docs/two_level.pdf`](docs/two_level.pdf).
@@ -0,0 +1,12 @@
1
+ numpy>=1.24
2
+
3
+ [:sys_platform != "darwin" or platform_machine != "x86_64"]
4
+ numba>=0.58
5
+
6
+ [:sys_platform == "darwin" and platform_machine == "x86_64"]
7
+ numba<0.63,>=0.58
8
+
9
+ [dev]
10
+ build
11
+ twine
12
+ pytest
@@ -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():
@@ -1,7 +0,0 @@
1
- numpy>=1.24
2
- numba>=0.58
3
-
4
- [dev]
5
- build
6
- twine
7
- pytest
File without changes
File without changes
File without changes
File without changes