pymaga 0.0.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.
- pymaga-0.0.0/LICENSE.md +24 -0
- pymaga-0.0.0/PKG-INFO +69 -0
- pymaga-0.0.0/README.md +33 -0
- pymaga-0.0.0/pyproject.toml +123 -0
- pymaga-0.0.0/setup.cfg +4 -0
- pymaga-0.0.0/src/maga/__init__.py +175 -0
- pymaga-0.0.0/src/maga/core/__init__.py +30 -0
- pymaga-0.0.0/src/maga/core/device_manager.py +357 -0
- pymaga-0.0.0/src/maga/core/field_calculator.py +570 -0
- pymaga-0.0.0/src/maga/core/grid.py +419 -0
- pymaga-0.0.0/src/maga/core/kernels.py +499 -0
- pymaga-0.0.0/src/maga/geometry/__init__.py +36 -0
- pymaga-0.0.0/src/maga/geometry/base.py +378 -0
- pymaga-0.0.0/src/maga/geometry/chopped_beam.py +264 -0
- pymaga-0.0.0/src/maga/geometry/circular_coil.py +286 -0
- pymaga-0.0.0/src/maga/geometry/coil_pairs.py +431 -0
- pymaga-0.0.0/src/maga/geometry/oscillating_beam.py +362 -0
- pymaga-0.0.0/src/maga/geometry/oscillating_beam_2d.py +171 -0
- pymaga-0.0.0/src/maga/geometry/rectangular_coil.py +386 -0
- pymaga-0.0.0/src/pymaga.egg-info/PKG-INFO +69 -0
- pymaga-0.0.0/src/pymaga.egg-info/SOURCES.txt +32 -0
- pymaga-0.0.0/src/pymaga.egg-info/dependency_links.txt +1 -0
- pymaga-0.0.0/src/pymaga.egg-info/requires.txt +12 -0
- pymaga-0.0.0/src/pymaga.egg-info/top_level.txt +1 -0
- pymaga-0.0.0/tests/test_basic_functionality.py +378 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_harmonics.py +222 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_harmonics_2d.py +261 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_harmonics_chopped.py +239 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_harmonics_chopped_2d.py +292 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_visualization.py +389 -0
- pymaga-0.0.0/tests/test_time_dependent_beam_visualization_chopped.py +391 -0
- pymaga-0.0.0/tests/test_time_dependent_circbeam_harmonics.py +210 -0
- pymaga-0.0.0/tests/test_time_dependent_circbeam_harmonics_2d.py +246 -0
- pymaga-0.0.0/tests/test_time_dependent_circbeam_visualization.py +291 -0
pymaga-0.0.0/LICENSE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright 2026, Thomas Spielauer
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain this list of conditions and the
|
|
7
|
+
following disclaimer.
|
|
8
|
+
* Redistributions in binary form must reproduce this list of conditions and the
|
|
9
|
+
following disclaimer in the documentation and/or other materials provided with
|
|
10
|
+
the distribution.
|
|
11
|
+
* Neither the name of the copyright holder nor the names of its contributors may
|
|
12
|
+
be used to endorse or promote products derived from this software without
|
|
13
|
+
specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
19
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pymaga-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pymaga
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Magnetic Analysis with GPU Acceleration - A Python library for GPU-accelerated magnetic field calculations using the Biot-Savart law
|
|
5
|
+
Author-email: Thomas Spielauer <pypipackages01@tspi.at>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/tspspi/maga
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/tspspi/maga/issues
|
|
9
|
+
Keywords: magnetic-field,biot-savart,gpu-acceleration,opencl,physics,electromagnetic,simulation,coils,scientific-computing
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE.md
|
|
26
|
+
Requires-Dist: numpy>=1.26.4
|
|
27
|
+
Requires-Dist: pyopencl>=2018.2
|
|
28
|
+
Provides-Extra: visualization
|
|
29
|
+
Requires-Dist: matplotlib>=3.8.0; extra == "visualization"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.1.1; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
|
33
|
+
Provides-Extra: all
|
|
34
|
+
Requires-Dist: pymaga[dev,visualization]; extra == "all"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Magnetic Analysis with GPU Acceleration (MAGA)
|
|
38
|
+
|
|
39
|
+
MAGA (Magnetic Analysis with GPU Acceleration) is a Python library for GPU-accelerated
|
|
40
|
+
magnetic field calculations using the Biot-Savart law. It supports arbitrary coil
|
|
41
|
+
geometries via Python or OpenCL geometry generators. GPU acceleration is realized
|
|
42
|
+
with OpenCL.
|
|
43
|
+
|
|
44
|
+
> __magus, maga, magum__ <br>
|
|
45
|
+
> _adjective_ <br>
|
|
46
|
+
> magic, magical
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
See [LICENSE.md](./LICENSE.md)
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pip install pymaga
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
Detailed usage examples can be seen in the ```examples``` directory.
|
|
64
|
+
|
|
65
|
+
## Validation
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
Validation scenarios can be found in the ```verification``` directory.
|
pymaga-0.0.0/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Magnetic Analysis with GPU Acceleration (MAGA)
|
|
2
|
+
|
|
3
|
+
MAGA (Magnetic Analysis with GPU Acceleration) is a Python library for GPU-accelerated
|
|
4
|
+
magnetic field calculations using the Biot-Savart law. It supports arbitrary coil
|
|
5
|
+
geometries via Python or OpenCL geometry generators. GPU acceleration is realized
|
|
6
|
+
with OpenCL.
|
|
7
|
+
|
|
8
|
+
> __magus, maga, magum__ <br>
|
|
9
|
+
> _adjective_ <br>
|
|
10
|
+
> magic, magical
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
See [LICENSE.md](./LICENSE.md)
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pip install pymaga
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Detailed usage examples can be seen in the ```examples``` directory.
|
|
28
|
+
|
|
29
|
+
## Validation
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
Validation scenarios can be found in the ```verification``` directory.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=63.1.0",
|
|
4
|
+
"wheel>=0.45.1",
|
|
5
|
+
"setuptools-git-versioning"
|
|
6
|
+
]
|
|
7
|
+
build-backend = "setuptools.build_meta"
|
|
8
|
+
|
|
9
|
+
[project]
|
|
10
|
+
name = "pymaga"
|
|
11
|
+
dynamic = [ "version" ]
|
|
12
|
+
description = "Magnetic Analysis with GPU Acceleration - A Python library for GPU-accelerated magnetic field calculations using the Biot-Savart law"
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Thomas Spielauer", email = "pypipackages01@tspi.at" }
|
|
15
|
+
]
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
license = "BSD-3-Clause"
|
|
18
|
+
license-files = [ "LICENSE.md" ]
|
|
19
|
+
requires-python = ">=3.10"
|
|
20
|
+
keywords = [
|
|
21
|
+
"magnetic-field",
|
|
22
|
+
"biot-savart",
|
|
23
|
+
"gpu-acceleration",
|
|
24
|
+
"opencl",
|
|
25
|
+
"physics",
|
|
26
|
+
"electromagnetic",
|
|
27
|
+
"simulation",
|
|
28
|
+
"coils",
|
|
29
|
+
"scientific-computing"
|
|
30
|
+
]
|
|
31
|
+
classifiers = [
|
|
32
|
+
"Development Status :: 4 - Beta",
|
|
33
|
+
"Intended Audience :: Science/Research",
|
|
34
|
+
"Intended Audience :: Education",
|
|
35
|
+
"Operating System :: OS Independent",
|
|
36
|
+
"Programming Language :: Python :: 3",
|
|
37
|
+
"Programming Language :: Python :: 3.8",
|
|
38
|
+
"Programming Language :: Python :: 3.9",
|
|
39
|
+
"Programming Language :: Python :: 3.10",
|
|
40
|
+
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Programming Language :: Python :: 3.12",
|
|
42
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
43
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
44
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
45
|
+
]
|
|
46
|
+
dependencies = [
|
|
47
|
+
"numpy>=1.26.4",
|
|
48
|
+
"pyopencl>=2018.2",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.optional-dependencies]
|
|
52
|
+
visualization = [
|
|
53
|
+
"matplotlib>=3.8.0",
|
|
54
|
+
]
|
|
55
|
+
dev = [
|
|
56
|
+
"pytest>=8.1.1",
|
|
57
|
+
"pytest-cov>=2.0"
|
|
58
|
+
]
|
|
59
|
+
all = [
|
|
60
|
+
"pymaga[visualization,dev]"
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
"Homepage" = "https://github.com/tspspi/maga"
|
|
65
|
+
"Bug Reports" = "https://github.com/tspspi/maga/issues"
|
|
66
|
+
|
|
67
|
+
[tool.setuptools]
|
|
68
|
+
package-dir = {"" = "src"}
|
|
69
|
+
|
|
70
|
+
[tool.setuptools.packages.find]
|
|
71
|
+
where = ["src"]
|
|
72
|
+
include = ["maga*"]
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.package-data]
|
|
75
|
+
maga = ["*.cl", "kernels/*.cl"]
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
minversion = "8.1.1"
|
|
79
|
+
addopts = "-ra -q --strict-markers --strict-config"
|
|
80
|
+
testpaths = ["tests"]
|
|
81
|
+
python_files = ["test_*.py"]
|
|
82
|
+
python_classes = ["Test*"]
|
|
83
|
+
python_functions = ["test_*"]
|
|
84
|
+
markers = [
|
|
85
|
+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
86
|
+
"gpu: marks tests that require GPU/OpenCL support",
|
|
87
|
+
"integration: marks tests as integration tests",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[tool.pytest.coverage.run]
|
|
91
|
+
source = ["src/maga"]
|
|
92
|
+
omit = [
|
|
93
|
+
"*/tests/*",
|
|
94
|
+
"*/examples/*",
|
|
95
|
+
"*/__pycache__/*",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[tool.pytest.coverage.report]
|
|
99
|
+
exclude_lines = [
|
|
100
|
+
"pragma: no cover",
|
|
101
|
+
"def __repr__",
|
|
102
|
+
"if self.debug:",
|
|
103
|
+
"if settings.DEBUG",
|
|
104
|
+
"raise AssertionError",
|
|
105
|
+
"raise NotImplementedError",
|
|
106
|
+
"if 0:",
|
|
107
|
+
"if __name__ == .__main__.:",
|
|
108
|
+
"class .*\\bProtocol\\):",
|
|
109
|
+
"@(abc\\.)?abstractmethod",
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
[tool.coverage.run]
|
|
113
|
+
source = ["src"]
|
|
114
|
+
omit = [
|
|
115
|
+
"*/tests/*",
|
|
116
|
+
"*/examples/*",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[tool.coverage.report]
|
|
120
|
+
precision = 2
|
|
121
|
+
skip_covered = false
|
|
122
|
+
skip_empty = false
|
|
123
|
+
sort = "cover"
|
pymaga-0.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MAGA: Magnetic Analysis with GPU Acceleration
|
|
3
|
+
|
|
4
|
+
A Python library for GPU-accelerated magnetic field calculations using the Biot-Savart law.
|
|
5
|
+
Provides high-performance computation of magnetic fields from arbitrary current geometries
|
|
6
|
+
with support for various coil configurations and time-dependent simulations.
|
|
7
|
+
|
|
8
|
+
Key Features:
|
|
9
|
+
- GPU-accelerated Biot-Savart calculations using OpenCL
|
|
10
|
+
- Multiple geometry types: circular coils, rectangular coils, coil pairs, electron beams
|
|
11
|
+
- Flexible grid configurations for field mapping
|
|
12
|
+
- Time-dependent simulations for dynamic systems
|
|
13
|
+
- Automatic device selection with CPU fallback
|
|
14
|
+
- Memory-efficient batching for large calculations
|
|
15
|
+
|
|
16
|
+
Basic Usage:
|
|
17
|
+
>>> from maga import CircularCoil, RectangularGrid, MagneticFieldCalculator
|
|
18
|
+
>>>
|
|
19
|
+
>>> # Create a circular coil
|
|
20
|
+
>>> coil = CircularCoil(center=(0,0,0), radius=1.0, current=10.0)
|
|
21
|
+
>>>
|
|
22
|
+
>>> # Define calculation grid
|
|
23
|
+
>>> grid = RectangularGrid(x_range=(-2,2), y_range=(-2,2), z_range=(-1,1),
|
|
24
|
+
... nx=21, ny=21, nz=11)
|
|
25
|
+
>>>
|
|
26
|
+
>>> # Calculate magnetic field
|
|
27
|
+
>>> calculator = MagneticFieldCalculator()
|
|
28
|
+
>>> A, B, I = coil.get_geometry()
|
|
29
|
+
>>> result = calculator.calculate_magnetic_field(A, B, I, grid)
|
|
30
|
+
>>>
|
|
31
|
+
>>> print(f"Max field: {result.max_field:.2e} T")
|
|
32
|
+
|
|
33
|
+
Dependencies:
|
|
34
|
+
- numpy: Numerical computing
|
|
35
|
+
- pyopencl: OpenCL Python bindings for GPU acceleration
|
|
36
|
+
- Optional: matplotlib for visualization
|
|
37
|
+
|
|
38
|
+
Author: MAGA Development Team
|
|
39
|
+
License: Open Source
|
|
40
|
+
Version: 1.0.0
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
__version__ = "1.0.0"
|
|
44
|
+
__author__ = "MAGA Development Team"
|
|
45
|
+
__license__ = "Open Source"
|
|
46
|
+
|
|
47
|
+
# Import core computational components
|
|
48
|
+
from .core import (
|
|
49
|
+
KernelRegistry,
|
|
50
|
+
DeviceManager,
|
|
51
|
+
DeviceInfo,
|
|
52
|
+
GridConfiguration,
|
|
53
|
+
RectangularGrid,
|
|
54
|
+
CylindricalGrid,
|
|
55
|
+
PlaneGrid,
|
|
56
|
+
CustomGrid,
|
|
57
|
+
MagneticFieldCalculator,
|
|
58
|
+
CalculationResult
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Import geometry components
|
|
62
|
+
from .geometry import (
|
|
63
|
+
BaseGeometry,
|
|
64
|
+
GeometryParameters,
|
|
65
|
+
CircularCoil,
|
|
66
|
+
RectangularCoil,
|
|
67
|
+
OscillatingBeam,
|
|
68
|
+
OscillatingBeam2D,
|
|
69
|
+
ChoppedBeam,
|
|
70
|
+
HelmholtzCoils,
|
|
71
|
+
AntiHelmholtzCoils
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Main public API - commonly used classes
|
|
75
|
+
__all__ = [
|
|
76
|
+
# Core calculation components
|
|
77
|
+
'MagneticFieldCalculator',
|
|
78
|
+
'CalculationResult',
|
|
79
|
+
|
|
80
|
+
# Device and kernel management
|
|
81
|
+
'DeviceManager',
|
|
82
|
+
'DeviceInfo',
|
|
83
|
+
'KernelRegistry',
|
|
84
|
+
|
|
85
|
+
# Grid configurations
|
|
86
|
+
'GridConfiguration',
|
|
87
|
+
'RectangularGrid',
|
|
88
|
+
'CylindricalGrid',
|
|
89
|
+
'PlaneGrid',
|
|
90
|
+
'CustomGrid',
|
|
91
|
+
|
|
92
|
+
# Geometry base classes
|
|
93
|
+
'BaseGeometry',
|
|
94
|
+
'GeometryParameters',
|
|
95
|
+
|
|
96
|
+
# Basic geometry types
|
|
97
|
+
'CircularCoil',
|
|
98
|
+
'RectangularCoil',
|
|
99
|
+
'OscillatingBeam',
|
|
100
|
+
'OscillatingBeam2D',
|
|
101
|
+
'ChoppedBeam',
|
|
102
|
+
|
|
103
|
+
# Coil pair configurations
|
|
104
|
+
'HelmholtzCoils',
|
|
105
|
+
'AntiHelmholtzCoils',
|
|
106
|
+
|
|
107
|
+
# Version information
|
|
108
|
+
'__version__',
|
|
109
|
+
'__author__',
|
|
110
|
+
'__license__'
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
# Convenience functions for common use cases
|
|
114
|
+
def quick_coil_calculation(radius=1.0, current=1.0, grid_size=21, grid_range=2.0):
|
|
115
|
+
"""
|
|
116
|
+
Quick magnetic field calculation for a circular coil.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
radius: Coil radius in meters
|
|
120
|
+
current: Current in Amperes
|
|
121
|
+
grid_size: Number of grid points per dimension
|
|
122
|
+
grid_range: Grid extends from -grid_range to +grid_range
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
CalculationResult object with magnetic field data
|
|
126
|
+
"""
|
|
127
|
+
coil = CircularCoil(radius=radius, current=current)
|
|
128
|
+
grid = RectangularGrid(
|
|
129
|
+
x_range=(-grid_range, grid_range),
|
|
130
|
+
y_range=(-grid_range, grid_range),
|
|
131
|
+
z_range=(-grid_range/2, grid_range/2),
|
|
132
|
+
nx=grid_size, ny=grid_size, nz=grid_size//2
|
|
133
|
+
)
|
|
134
|
+
calculator = MagneticFieldCalculator()
|
|
135
|
+
A, B, I = coil.get_geometry()
|
|
136
|
+
return calculator.calculate_magnetic_field(A, B, I, grid)
|
|
137
|
+
|
|
138
|
+
def list_opencl_devices():
|
|
139
|
+
"""
|
|
140
|
+
List all available OpenCL devices.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
List of device information strings
|
|
144
|
+
"""
|
|
145
|
+
try:
|
|
146
|
+
manager = DeviceManager()
|
|
147
|
+
devices = manager.list_available_devices()
|
|
148
|
+
return [str(device) for device in devices]
|
|
149
|
+
except Exception as e:
|
|
150
|
+
return [f"Error listing devices: {e}"]
|
|
151
|
+
|
|
152
|
+
# Package metadata
|
|
153
|
+
def get_version_info():
|
|
154
|
+
"""Get detailed version information."""
|
|
155
|
+
try:
|
|
156
|
+
import pyopencl as cl
|
|
157
|
+
opencl_version = cl.get_platforms()[0].version if cl.get_platforms() else "Not available"
|
|
158
|
+
except:
|
|
159
|
+
opencl_version = "Not available"
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
import numpy as np
|
|
163
|
+
numpy_version = np.__version__
|
|
164
|
+
except:
|
|
165
|
+
numpy_version = "Not available"
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
'maga_version': __version__,
|
|
169
|
+
'numpy_version': numpy_version,
|
|
170
|
+
'opencl_version': opencl_version,
|
|
171
|
+
'available_devices': len(list_opencl_devices())
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
# Add convenience imports to global namespace
|
|
175
|
+
__all__.extend(['quick_coil_calculation', 'list_opencl_devices', 'get_version_info'])
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Core computation modules for MAGA library.
|
|
3
|
+
|
|
4
|
+
This package contains the fundamental computational components:
|
|
5
|
+
- Kernel management and OpenCL kernel registry
|
|
6
|
+
- Device management and OpenCL context handling
|
|
7
|
+
- Grid configuration for calculation domains
|
|
8
|
+
- Magnetic field calculator (main computation engine)
|
|
9
|
+
|
|
10
|
+
The core modules provide the low-level functionality needed for
|
|
11
|
+
GPU-accelerated magnetic field calculations using the Biot-Savart law.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .kernels import KernelRegistry
|
|
15
|
+
from .device_manager import DeviceManager, DeviceInfo
|
|
16
|
+
from .grid import GridConfiguration, RectangularGrid, CylindricalGrid, PlaneGrid, CustomGrid
|
|
17
|
+
from .field_calculator import MagneticFieldCalculator, CalculationResult
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
'KernelRegistry',
|
|
21
|
+
'DeviceManager',
|
|
22
|
+
'DeviceInfo',
|
|
23
|
+
'GridConfiguration',
|
|
24
|
+
'RectangularGrid',
|
|
25
|
+
'CylindricalGrid',
|
|
26
|
+
'PlaneGrid',
|
|
27
|
+
'CustomGrid',
|
|
28
|
+
'MagneticFieldCalculator',
|
|
29
|
+
'CalculationResult'
|
|
30
|
+
]
|