cfsem 3.0.0__tar.gz → 3.0.2__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.
- {cfsem-3.0.0 → cfsem-3.0.2}/.github/workflows/release_python.yml +4 -4
- {cfsem-3.0.0 → cfsem-3.0.2}/.github/workflows/test_python.yml +3 -4
- {cfsem-3.0.0 → cfsem-3.0.2}/CHANGELOG.md +22 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/Cargo.lock +9 -29
- {cfsem-3.0.0 → cfsem-3.0.2}/Cargo.toml +2 -2
- {cfsem-3.0.0 → cfsem-3.0.2}/PKG-INFO +3 -13
- {cfsem-3.0.0 → cfsem-3.0.2}/README.md +2 -3
- {cfsem-3.0.0 → cfsem-3.0.2}/benches/circular_filament.rs +2 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/benches/linear_filament.rs +2 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/benches/point_source.rs +8 -6
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/__init__.py +2 -2
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/bindings.py +2 -4
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/solenoid_stress/solenoid_1d.py +2 -1
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/types.py +1 -3
- {cfsem-3.0.0 → cfsem-3.0.2}/pyproject.toml +4 -5
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/point_source.rs +43 -29
- {cfsem-3.0.0 → cfsem-3.0.2}/src/python.rs +164 -194
- {cfsem-3.0.0 → cfsem-3.0.2}/uv.lock +60 -808
- {cfsem-3.0.0 → cfsem-3.0.2}/.cargo/config.toml +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/.github/workflows/release_rust.yml +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/.github/workflows/test_rust.yml +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/.gitignore +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/.readthedocs.yml +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/CHANGELOG_PYTHON_ARCHIVE.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/CHANGELOG_RUST_ARCHIVE.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/CONTRIBUTING.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/LICENSE +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/build_docs.sh +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/py.typed +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/solenoid_stress/__init__.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/solenoid_stress/solenoid_handcalc.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/cfsem/solenoid_stress/thick_wall_cylinder_handcalc.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/assets/logo.svg +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/index.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/javascripts/mathjax.js +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/example_outputs/.placeholder +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/examples.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/filament.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/flux_density.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/force.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/grad_shafranov.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/inductance.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/math.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/solenoid_stress.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/types.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/python/vector_potential.md +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/requirements.txt +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/docs/stylesheets/extra.css +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/examples/helmholtz.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/examples/inductance.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/katex-header.html +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/mkdocs.yml +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/lib.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/math.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/mesh.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/biotsavart.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/circular_filament.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/gradshafranov.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/linear_filament.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/mesh_filament.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/mod.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/physics/volumetric.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/src/testing.rs +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/__init__.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_electromagnetics.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_examples.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_filaments.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_funcs.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_gradshafranov.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_math.py +0 -0
- {cfsem-3.0.0 → cfsem-3.0.2}/test/test_solenoid_stress.py +0 -0
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
runs-on: ${{ matrix.platform.runner }}
|
|
21
21
|
strategy:
|
|
22
22
|
matrix:
|
|
23
|
-
python-version: ['3.
|
|
23
|
+
python-version: ['3.13']
|
|
24
24
|
platform:
|
|
25
25
|
- runner: ubuntu-22.04
|
|
26
26
|
target: x86_64
|
|
@@ -56,7 +56,7 @@ jobs:
|
|
|
56
56
|
runs-on: ${{ matrix.platform.runner }}
|
|
57
57
|
strategy:
|
|
58
58
|
matrix:
|
|
59
|
-
python-version: ['3.
|
|
59
|
+
python-version: ['3.13']
|
|
60
60
|
platform:
|
|
61
61
|
- runner: ubuntu-22.04
|
|
62
62
|
target: x86_64
|
|
@@ -88,7 +88,7 @@ jobs:
|
|
|
88
88
|
runs-on: ${{ matrix.platform.runner }}
|
|
89
89
|
strategy:
|
|
90
90
|
matrix:
|
|
91
|
-
python-version: ['3.
|
|
91
|
+
python-version: ['3.13']
|
|
92
92
|
platform:
|
|
93
93
|
- runner: windows-latest
|
|
94
94
|
target: x64
|
|
@@ -116,7 +116,7 @@ jobs:
|
|
|
116
116
|
runs-on: ${{ matrix.platform.runner }}
|
|
117
117
|
strategy:
|
|
118
118
|
matrix:
|
|
119
|
-
python-version: ['3.
|
|
119
|
+
python-version: ['3.13']
|
|
120
120
|
platform:
|
|
121
121
|
- runner: macos-13
|
|
122
122
|
target: x86_64
|
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
timeout-minutes: 15
|
|
20
20
|
strategy:
|
|
21
21
|
matrix:
|
|
22
|
-
python-version: ['3.
|
|
22
|
+
python-version: ['3.10', '3.11', '3.12', '3.13']
|
|
23
23
|
|
|
24
24
|
steps:
|
|
25
25
|
|
|
@@ -40,13 +40,12 @@ jobs:
|
|
|
40
40
|
source .venv/bin/activate
|
|
41
41
|
|
|
42
42
|
uv pip install maturin
|
|
43
|
-
|
|
44
|
-
uv pip install .[dev]
|
|
43
|
+
uv pip install . --group dev
|
|
45
44
|
|
|
46
45
|
# Python lint, test, and coverage
|
|
47
46
|
uv run --locked ruff check ./cfsem
|
|
48
47
|
uv run --locked ruff format ./cfsem --check
|
|
49
|
-
uv run --locked pyright ./cfsem --pythonversion 3.
|
|
48
|
+
uv run --locked pyright ./cfsem --pythonversion 3.10
|
|
50
49
|
uv run --locked coverage run --source=./cfsem -m pytest ./test/
|
|
51
50
|
uv run --locked coverage report
|
|
52
51
|
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.2 2025-11-05
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
* Use numpy borrow interface instead of manually borrowchecking numpy arrays
|
|
8
|
+
|
|
9
|
+
## 3.0.1 2025-11-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
* Rust
|
|
14
|
+
* Improve performance of dipole calcs
|
|
15
|
+
* Now >1Gelem/s throughput including magnetized sphere fallback and nan clipping
|
|
16
|
+
* Update benchmarks to use latest version of criterion
|
|
17
|
+
* Python
|
|
18
|
+
* Use latest rust backend with improved dipole calc perf
|
|
19
|
+
* Eliminate duplicate wheel builds during deployment
|
|
20
|
+
* Maturin now builds for all supported python versions automatically in the same job;
|
|
21
|
+
matrix on python versions is no longer necessary
|
|
22
|
+
* Later, this can be further reduced to single wheels by building for a stable abi3 target
|
|
23
|
+
* Remove support for python 3.9 (leaving long term support)
|
|
24
|
+
|
|
3
25
|
## 3.0.0 2025-10-29
|
|
4
26
|
|
|
5
27
|
### Added
|
|
@@ -64,7 +64,7 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
|
|
64
64
|
|
|
65
65
|
[[package]]
|
|
66
66
|
name = "cfsem"
|
|
67
|
-
version = "3.0.
|
|
67
|
+
version = "3.0.2"
|
|
68
68
|
dependencies = [
|
|
69
69
|
"criterion",
|
|
70
70
|
"itertools 0.14.0",
|
|
@@ -130,25 +130,22 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
|
|
130
130
|
|
|
131
131
|
[[package]]
|
|
132
132
|
name = "criterion"
|
|
133
|
-
version = "0.
|
|
133
|
+
version = "0.7.0"
|
|
134
134
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
135
|
-
checksum = "
|
|
135
|
+
checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928"
|
|
136
136
|
dependencies = [
|
|
137
137
|
"anes",
|
|
138
138
|
"cast",
|
|
139
139
|
"ciborium",
|
|
140
140
|
"clap",
|
|
141
141
|
"criterion-plot",
|
|
142
|
-
"
|
|
143
|
-
"itertools 0.10.5",
|
|
142
|
+
"itertools 0.13.0",
|
|
144
143
|
"num-traits",
|
|
145
|
-
"once_cell",
|
|
146
144
|
"oorandom",
|
|
147
145
|
"plotters",
|
|
148
146
|
"rayon",
|
|
149
147
|
"regex",
|
|
150
148
|
"serde",
|
|
151
|
-
"serde_derive",
|
|
152
149
|
"serde_json",
|
|
153
150
|
"tinytemplate",
|
|
154
151
|
"walkdir",
|
|
@@ -156,12 +153,12 @@ dependencies = [
|
|
|
156
153
|
|
|
157
154
|
[[package]]
|
|
158
155
|
name = "criterion-plot"
|
|
159
|
-
version = "0.
|
|
156
|
+
version = "0.6.0"
|
|
160
157
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
-
checksum = "
|
|
158
|
+
checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338"
|
|
162
159
|
dependencies = [
|
|
163
160
|
"cast",
|
|
164
|
-
"itertools 0.
|
|
161
|
+
"itertools 0.13.0",
|
|
165
162
|
]
|
|
166
163
|
|
|
167
164
|
[[package]]
|
|
@@ -313,34 +310,17 @@ version = "0.5.0"
|
|
|
313
310
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
314
311
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
315
312
|
|
|
316
|
-
[[package]]
|
|
317
|
-
name = "hermit-abi"
|
|
318
|
-
version = "0.5.2"
|
|
319
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
320
|
-
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
|
|
321
|
-
|
|
322
313
|
[[package]]
|
|
323
314
|
name = "indoc"
|
|
324
315
|
version = "2.0.6"
|
|
325
316
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
326
317
|
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
327
318
|
|
|
328
|
-
[[package]]
|
|
329
|
-
name = "is-terminal"
|
|
330
|
-
version = "0.4.16"
|
|
331
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
332
|
-
checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
|
333
|
-
dependencies = [
|
|
334
|
-
"hermit-abi",
|
|
335
|
-
"libc",
|
|
336
|
-
"windows-sys",
|
|
337
|
-
]
|
|
338
|
-
|
|
339
319
|
[[package]]
|
|
340
320
|
name = "itertools"
|
|
341
|
-
version = "0.
|
|
321
|
+
version = "0.13.0"
|
|
342
322
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
343
|
-
checksum = "
|
|
323
|
+
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
|
344
324
|
dependencies = [
|
|
345
325
|
"either",
|
|
346
326
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "cfsem"
|
|
3
|
-
version = "3.0.
|
|
3
|
+
version = "3.0.2"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
authors = ["Commonwealth Fusion Systems <jlogan@cfs.energy>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -24,7 +24,7 @@ libm = "^0.2"
|
|
|
24
24
|
num-traits = { version = "0.2.19", features = ["libm"] }
|
|
25
25
|
|
|
26
26
|
[dev-dependencies]
|
|
27
|
-
criterion = "0.
|
|
27
|
+
criterion = "0.7.0"
|
|
28
28
|
itertools = "0.14.0"
|
|
29
29
|
|
|
30
30
|
[profile.release]
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cfsem
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.2
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
7
|
Requires-Dist: numpy>=2
|
|
8
|
-
Requires-Dist: interpn>=0.
|
|
8
|
+
Requires-Dist: interpn[pydantic]>=0.7
|
|
9
9
|
Requires-Dist: findiff>=0.12.1
|
|
10
10
|
Requires-Dist: pydantic>=2
|
|
11
11
|
Requires-Dist: pydantic-numpy>=6
|
|
12
|
-
Requires-Dist: pytest>=7.1.3 ; extra == 'dev'
|
|
13
|
-
Requires-Dist: coverage>=6.5.0 ; extra == 'dev'
|
|
14
|
-
Requires-Dist: ruff>=0.6.2 ; extra == 'dev'
|
|
15
|
-
Requires-Dist: pyright==1.1.402 ; extra == 'dev'
|
|
16
|
-
Requires-Dist: scipy>=1.8 ; extra == 'dev'
|
|
17
|
-
Requires-Dist: mkdocs>=1.6.0 ; extra == 'dev'
|
|
18
|
-
Requires-Dist: mkdocs-material>=9.5.25 ; extra == 'dev'
|
|
19
|
-
Requires-Dist: mkdocstrings[python]>=0.25.1 ; extra == 'dev'
|
|
20
|
-
Requires-Dist: matplotlib>=3.9 ; extra == 'dev'
|
|
21
|
-
Provides-Extra: dev
|
|
22
12
|
License-File: LICENSE
|
|
23
13
|
Summary: Quasi-steady electromagnetics including filamentized approximations, Biot-Savart, and Grad-Shafranov.
|
|
24
14
|
Home-Page: https://github.com/cfs-energy/cfsem-py
|
|
25
15
|
Author-email: Commonwealth Fusion Systems <jlogan@cfs.energy>
|
|
26
16
|
License-Expression: MIT
|
|
27
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.10, <3.14
|
|
@@ -45,7 +45,7 @@ Requirements
|
|
|
45
45
|
To install in the active python environment, do
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
uv pip install -e .
|
|
48
|
+
uv pip install -e . --group dev
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
To build the Rust bindings only, do
|
|
@@ -61,8 +61,7 @@ Some computationally-expensive calculations are written in Rust. These calculati
|
|
|
61
61
|
To build with all of the optimizations available on your local machine, you can do:
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
RUSTCFLAGS="-Ctarget-cpu=native"
|
|
65
|
-
pip install -e .[dev]
|
|
64
|
+
RUSTCFLAGS="-Ctarget-cpu=native" pip install -e . --group dev --reinstall
|
|
66
65
|
```
|
|
67
66
|
|
|
68
67
|
## Contributing
|
|
@@ -10,6 +10,8 @@ use cfsem::physics::{
|
|
|
10
10
|
use criterion::*;
|
|
11
11
|
use std::time::Duration;
|
|
12
12
|
|
|
13
|
+
use std::hint::black_box;
|
|
14
|
+
|
|
13
15
|
fn bench_flux_circular_filament(c: &mut Criterion) {
|
|
14
16
|
let mut group = c.benchmark_group("Poloidal Flux of a Circular Filament");
|
|
15
17
|
group.sample_size(10);
|
|
@@ -7,6 +7,8 @@ use cfsem::physics::linear_filament::{
|
|
|
7
7
|
use criterion::*;
|
|
8
8
|
use std::time::Duration;
|
|
9
9
|
|
|
10
|
+
use std::hint::black_box;
|
|
11
|
+
|
|
10
12
|
fn bench_flux_density_linear_filament(c: &mut Criterion) {
|
|
11
13
|
let mut group = c.benchmark_group("Flux Density of Linear Filaments");
|
|
12
14
|
group.sample_size(10);
|
|
@@ -7,6 +7,8 @@ use cfsem::physics::point_source::{
|
|
|
7
7
|
use criterion::*;
|
|
8
8
|
use std::time::Duration;
|
|
9
9
|
|
|
10
|
+
use std::hint::black_box;
|
|
11
|
+
|
|
10
12
|
fn bench_flux_density_dipole(c: &mut Criterion) {
|
|
11
13
|
let mut group = c.benchmark_group("Flux Density of a Magnetic Dipole");
|
|
12
14
|
group.sample_size(10);
|
|
@@ -18,11 +20,11 @@ fn bench_flux_density_dipole(c: &mut Criterion) {
|
|
|
18
20
|
let locy = vec![0.02_f64; ndipoles];
|
|
19
21
|
let locz = vec![0.03_f64; ndipoles];
|
|
20
22
|
|
|
21
|
-
let momx = vec![0.
|
|
22
|
-
let momy = vec![0.
|
|
23
|
+
let momx = vec![0.17_f64; ndipoles];
|
|
24
|
+
let momy = vec![0.077_f64; ndipoles];
|
|
23
25
|
let momz = vec![1.0_f64; ndipoles];
|
|
24
26
|
|
|
25
|
-
let outer_radius = vec![0.
|
|
27
|
+
let outer_radius = vec![0.001_f64; ndipoles];
|
|
26
28
|
|
|
27
29
|
let obsx = vec![0.7_f64; nobs];
|
|
28
30
|
let obsy = vec![-0.4_f64; nobs];
|
|
@@ -101,11 +103,11 @@ fn bench_vector_potential_dipole(c: &mut Criterion) {
|
|
|
101
103
|
let locy = vec![0.02_f64; ndipoles];
|
|
102
104
|
let locz = vec![0.03_f64; ndipoles];
|
|
103
105
|
|
|
104
|
-
let momx = vec![0.
|
|
105
|
-
let momy = vec![0.
|
|
106
|
+
let momx = vec![0.17_f64; ndipoles];
|
|
107
|
+
let momy = vec![0.077_f64; ndipoles];
|
|
106
108
|
let momz = vec![1.0_f64; ndipoles];
|
|
107
109
|
|
|
108
|
-
let outer_radius = vec![0.
|
|
110
|
+
let outer_radius = vec![0.001_f64; ndipoles];
|
|
109
111
|
|
|
110
112
|
let obsx = vec![0.7_f64; nobs];
|
|
111
113
|
let obsy = vec![-0.4_f64; nobs];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Quasi-steady electromagnetics calcs"""
|
|
2
2
|
|
|
3
|
-
from typing import Literal
|
|
3
|
+
from typing import Literal
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from interpn import MulticubicRectilinear
|
|
@@ -295,7 +295,7 @@ def mutual_inductance_of_circular_filaments(rzn1: NDArray, rzn2: NDArray, par: b
|
|
|
295
295
|
def self_inductance_axisymmetric_coil(
|
|
296
296
|
f: NDArray,
|
|
297
297
|
section_kind: Literal["rectangular", "circular", "annular"],
|
|
298
|
-
section_size:
|
|
298
|
+
section_size: tuple[float, float] | float,
|
|
299
299
|
par: bool = True,
|
|
300
300
|
) -> float:
|
|
301
301
|
"""
|
|
@@ -5,8 +5,6 @@ This fulfills the function of typing stubs, while also guaranteeing arrays are
|
|
|
5
5
|
passed as contiguous and reallocating into contiguous inputs if necessary.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import Optional
|
|
9
|
-
|
|
10
8
|
from numpy import ascontiguousarray, float64, zeros_like
|
|
11
9
|
from numpy.typing import NDArray
|
|
12
10
|
|
|
@@ -475,7 +473,7 @@ def flux_density_dipole(
|
|
|
475
473
|
moment: Array3xN,
|
|
476
474
|
xyzp: Array3xN,
|
|
477
475
|
par: bool = True, # Ordered for backwards compatibility
|
|
478
|
-
outer_radius:
|
|
476
|
+
outer_radius: NDArray[float64] | None = None,
|
|
479
477
|
) -> Array3xN:
|
|
480
478
|
"""
|
|
481
479
|
Magnetic flux density of a dipole in cartesian coordiantes.
|
|
@@ -507,7 +505,7 @@ def vector_potential_dipole(
|
|
|
507
505
|
moment: Array3xN,
|
|
508
506
|
xyzp: Array3xN,
|
|
509
507
|
par: bool = True, # Ordered for backwards compatibility
|
|
510
|
-
outer_radius:
|
|
508
|
+
outer_radius: NDArray[float64] | None = None,
|
|
511
509
|
) -> Array3xN:
|
|
512
510
|
"""
|
|
513
511
|
Magnetic vector potential of a dipole in cartesian coordiantes.
|
|
@@ -24,7 +24,8 @@ from dataclasses import dataclass
|
|
|
24
24
|
from functools import cached_property
|
|
25
25
|
from logging import getLogger
|
|
26
26
|
from pathlib import Path
|
|
27
|
-
from typing import
|
|
27
|
+
from typing import Literal
|
|
28
|
+
from collections.abc import Callable
|
|
28
29
|
|
|
29
30
|
import findiff
|
|
30
31
|
import numpy as np
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
|
|
3
1
|
from numpy import float64
|
|
4
2
|
from numpy.typing import NDArray
|
|
5
3
|
|
|
6
|
-
Array3xN =
|
|
4
|
+
Array3xN = NDArray[float64] | tuple[NDArray[float64], NDArray[float64], NDArray[float64]]
|
|
7
5
|
"""A 3xN array expressed as either a 2D numpy array or a tuple of 1D numpy arrays"""
|
|
@@ -4,10 +4,10 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cfsem"
|
|
7
|
-
version = "3.0.
|
|
7
|
+
version = "3.0.2"
|
|
8
8
|
description = "Quasi-steady electromagnetics including filamentized approximations, Biot-Savart, and Grad-Shafranov."
|
|
9
9
|
authors = [{name = "Commonwealth Fusion Systems", email = "jlogan@cfs.energy"}]
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10, <3.14"
|
|
11
11
|
classifiers = [
|
|
12
12
|
"Programming Language :: Rust",
|
|
13
13
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
@@ -15,14 +15,14 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
17
|
"numpy >= 2",
|
|
18
|
-
"interpn >= 0.
|
|
18
|
+
"interpn[pydantic] >= 0.7",
|
|
19
19
|
"findiff >= 0.12.1",
|
|
20
20
|
"pydantic >= 2",
|
|
21
21
|
"pydantic-numpy >= 6"
|
|
22
22
|
]
|
|
23
23
|
license = "MIT"
|
|
24
24
|
|
|
25
|
-
[
|
|
25
|
+
[dependency-groups]
|
|
26
26
|
dev = [
|
|
27
27
|
# Tests
|
|
28
28
|
"pytest >= 7.1.3",
|
|
@@ -43,7 +43,6 @@ features = ["pyo3/extension-module", "python"]
|
|
|
43
43
|
module-name = "cfsem.cfsem"
|
|
44
44
|
|
|
45
45
|
[tool.ruff]
|
|
46
|
-
target-version = "py39"
|
|
47
46
|
line-length = 110
|
|
48
47
|
|
|
49
48
|
[tool.ruff.lint]
|
|
@@ -8,7 +8,7 @@ use rayon::{
|
|
|
8
8
|
use crate::{
|
|
9
9
|
MU0_OVER_4PI, chunksize,
|
|
10
10
|
macros::{check_length_3tup, mut_par_chunks_3tup, par_chunks_3tup},
|
|
11
|
-
math::{cross3, dot3, rss3
|
|
11
|
+
math::{clip_nan, cross3, dot3, rss3},
|
|
12
12
|
physics::volumetric::{
|
|
13
13
|
flux_density_inside_magnetized_sphere, vector_potential_inside_magnetized_sphere,
|
|
14
14
|
},
|
|
@@ -51,18 +51,23 @@ pub fn flux_density_dipole_scalar(
|
|
|
51
51
|
rhat.1.mul_add(c1, -moment.1),
|
|
52
52
|
rhat.2.mul_add(c1, -moment.2),
|
|
53
53
|
);
|
|
54
|
-
let (bx, by, bz) = (c * tsum.0, c * tsum.1, c * tsum.2);
|
|
55
54
|
|
|
56
55
|
// Defer to magnetized sphere if necessary
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// the
|
|
56
|
+
// This branch does not cause a cache miss because the conditional
|
|
57
|
+
// does not require fetching any additional resources from RAM into cache.
|
|
58
|
+
// In fact, this has essentially no effect on performance because the
|
|
59
|
+
// branch is extremely predictable, and can be resolved consistently
|
|
60
|
+
// between when rmag is calculated and when the other dependencies are done.
|
|
60
61
|
let inside = rmag < outer_radius;
|
|
61
|
-
let (
|
|
62
|
-
flux_density_inside_magnetized_sphere(moment, outer_radius)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
let (mut bx, mut by, mut bz) = match inside {
|
|
63
|
+
true => flux_density_inside_magnetized_sphere(moment, outer_radius),
|
|
64
|
+
false => (c * tsum.0, c * tsum.1, c * tsum.2),
|
|
65
|
+
}; // [T]
|
|
66
|
+
|
|
67
|
+
// This does not produce a jmp
|
|
68
|
+
bx = clip_nan(bx, 0.0);
|
|
69
|
+
by = clip_nan(by, 0.0);
|
|
70
|
+
bz = clip_nan(bz, 0.0);
|
|
66
71
|
|
|
67
72
|
(bx, by, bz) // [T]
|
|
68
73
|
}
|
|
@@ -146,7 +151,7 @@ pub fn flux_density_dipole_par(
|
|
|
146
151
|
///
|
|
147
152
|
/// Returns
|
|
148
153
|
///
|
|
149
|
-
/// * (ax, ay, az) [V
|
|
154
|
+
/// * (ax, ay, az) [V-s/m] vector potential components at observation point
|
|
150
155
|
#[inline]
|
|
151
156
|
pub fn vector_potential_dipole_scalar(
|
|
152
157
|
loc: (f64, f64, f64),
|
|
@@ -167,26 +172,35 @@ pub fn vector_potential_dipole_scalar(
|
|
|
167
172
|
// Use normalized vectors for cross product to improve float roundoff
|
|
168
173
|
let mhat_cross_rhat = cross3(mhat.0, mhat.1, mhat.2, rhat.0, rhat.1, rhat.2);
|
|
169
174
|
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
// Defer to magnetized sphere if necessary
|
|
179
|
-
// Because this is done without producing a true branch,
|
|
180
|
-
// it is only a 20-40% reduction in throughput, and does not disrupt
|
|
181
|
-
// the autovectorizer.
|
|
175
|
+
// Defer to magnetized sphere if necessary.
|
|
176
|
+
// This branch does not cause a cache miss because the conditional
|
|
177
|
+
// does not require fetching any additional resources from RAM into cache.
|
|
178
|
+
// In fact, this has essentially no effect on performance because the
|
|
179
|
+
// branch is extremely predictable, and can be resolved consistently
|
|
180
|
+
// between when rmag is calculated and when the other dependencies are done.
|
|
182
181
|
let inside = rmag < outer_radius;
|
|
183
|
-
let (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
let (mut ax, mut ay, mut az) = match inside {
|
|
183
|
+
// Magnetized sphere internal field
|
|
184
|
+
true => {
|
|
185
|
+
vector_potential_inside_magnetized_sphere(mhat_cross_rhat, mmag, rmag, outer_radius)
|
|
186
|
+
}
|
|
187
|
+
// Dipole field
|
|
188
|
+
false => {
|
|
189
|
+
let c = MU0_OVER_4PI * mmag / r2; // [V-s/m] Shared factor
|
|
190
|
+
(
|
|
191
|
+
mhat_cross_rhat.0 * c,
|
|
192
|
+
mhat_cross_rhat.1 * c,
|
|
193
|
+
mhat_cross_rhat.2 * c,
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// This does not produce a jmp
|
|
199
|
+
ax = clip_nan(ax, 0.0);
|
|
200
|
+
ay = clip_nan(ay, 0.0);
|
|
201
|
+
az = clip_nan(az, 0.0);
|
|
188
202
|
|
|
189
|
-
(ax, ay, az) // [V
|
|
203
|
+
(ax, ay, az) // [V-s/m]
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
/// Magnetic vector potential of a dipole in cartesian coordinates.
|