PyOpenMagnetics 1.1.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 (57) hide show
  1. pyopenmagnetics-1.1.0/.github/workflows/ci.yml +90 -0
  2. pyopenmagnetics-1.1.0/.github/workflows/publish.yml +158 -0
  3. pyopenmagnetics-1.1.0/.gitignore +6 -0
  4. pyopenmagnetics-1.1.0/CMakeLists.txt +240 -0
  5. pyopenmagnetics-1.1.0/LICENSE +21 -0
  6. pyopenmagnetics-1.1.0/PKG-INFO +373 -0
  7. pyopenmagnetics-1.1.0/PyOpenMagnetics.pyi +699 -0
  8. pyopenmagnetics-1.1.0/README.md +356 -0
  9. pyopenmagnetics-1.1.0/api/MAS.py +4878 -0
  10. pyopenmagnetics-1.1.0/api/mas_db_reader.py +126 -0
  11. pyopenmagnetics-1.1.0/api/validation.py +458 -0
  12. pyopenmagnetics-1.1.0/docs/compatibility.md +205 -0
  13. pyopenmagnetics-1.1.0/docs/errors.md +432 -0
  14. pyopenmagnetics-1.1.0/docs/performance.md +302 -0
  15. pyopenmagnetics-1.1.0/examples/README.md +80 -0
  16. pyopenmagnetics-1.1.0/examples/buck_inductor.py +229 -0
  17. pyopenmagnetics-1.1.0/examples/flyback_design.py +242 -0
  18. pyopenmagnetics-1.1.0/llms.txt +771 -0
  19. pyopenmagnetics-1.1.0/notebooks/01_getting_started.ipynb +283 -0
  20. pyopenmagnetics-1.1.0/notebooks/02_buck_inductor.ipynb +389 -0
  21. pyopenmagnetics-1.1.0/notebooks/03_core_losses.ipynb +466 -0
  22. pyopenmagnetics-1.1.0/notebooks/README.md +88 -0
  23. pyopenmagnetics-1.1.0/pyproject.toml +66 -0
  24. pyopenmagnetics-1.1.0/requirements.txt +5 -0
  25. pyopenmagnetics-1.1.0/src/advisers.cpp +258 -0
  26. pyopenmagnetics-1.1.0/src/advisers.h +17 -0
  27. pyopenmagnetics-1.1.0/src/bobbin.cpp +148 -0
  28. pyopenmagnetics-1.1.0/src/bobbin.h +18 -0
  29. pyopenmagnetics-1.1.0/src/common.h +50 -0
  30. pyopenmagnetics-1.1.0/src/core.cpp +1007 -0
  31. pyopenmagnetics-1.1.0/src/core.h +51 -0
  32. pyopenmagnetics-1.1.0/src/database.cpp +225 -0
  33. pyopenmagnetics-1.1.0/src/database.h +27 -0
  34. pyopenmagnetics-1.1.0/src/losses.cpp +626 -0
  35. pyopenmagnetics-1.1.0/src/losses.h +33 -0
  36. pyopenmagnetics-1.1.0/src/module.cpp +29 -0
  37. pyopenmagnetics-1.1.0/src/plotting.cpp +305 -0
  38. pyopenmagnetics-1.1.0/src/plotting.h +17 -0
  39. pyopenmagnetics-1.1.0/src/settings.cpp +251 -0
  40. pyopenmagnetics-1.1.0/src/settings.h +17 -0
  41. pyopenmagnetics-1.1.0/src/simulation.cpp +309 -0
  42. pyopenmagnetics-1.1.0/src/simulation.h +25 -0
  43. pyopenmagnetics-1.1.0/src/utils.cpp +324 -0
  44. pyopenmagnetics-1.1.0/src/utils.h +28 -0
  45. pyopenmagnetics-1.1.0/src/winding.cpp +907 -0
  46. pyopenmagnetics-1.1.0/src/winding.h +39 -0
  47. pyopenmagnetics-1.1.0/src/wire.cpp +855 -0
  48. pyopenmagnetics-1.1.0/src/wire.h +51 -0
  49. pyopenmagnetics-1.1.0/test.py +23 -0
  50. pyopenmagnetics-1.1.0/tests/__init__.py +1 -0
  51. pyopenmagnetics-1.1.0/tests/conftest.py +313 -0
  52. pyopenmagnetics-1.1.0/tests/test_core.py +220 -0
  53. pyopenmagnetics-1.1.0/tests/test_core_adviser.py +149 -0
  54. pyopenmagnetics-1.1.0/tests/test_examples_integration.py +409 -0
  55. pyopenmagnetics-1.1.0/tests/test_inputs.py +199 -0
  56. pyopenmagnetics-1.1.0/tests/test_magnetic_adviser.py +259 -0
  57. pyopenmagnetics-1.1.0/tests/test_winding.py +101 -0
@@ -0,0 +1,90 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master, develop]
6
+ pull_request:
7
+ branches: [main, master, develop]
8
+
9
+ env:
10
+ GIT_LFS_SKIP_SMUDGE: 1 # Skip LFS to avoid bandwidth quota issues
11
+
12
+ jobs:
13
+ test:
14
+ name: Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os: [ubuntu-22.04, windows-2022, macos-14]
20
+ python-version: ["3.10", "3.11", "3.12"]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ submodules: recursive
26
+
27
+ - name: Set up Python ${{ matrix.python-version }}
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: ${{ matrix.python-version }}
31
+
32
+ - name: Set up Node.js
33
+ uses: actions/setup-node@v4
34
+ with:
35
+ node-version: "18"
36
+
37
+ - name: Install quicktype
38
+ run: npm install -g quicktype
39
+
40
+ - name: Install build dependencies
41
+ run: |
42
+ python -m pip install --upgrade pip
43
+ pip install build pytest
44
+
45
+ - name: Build and install package
46
+ run: |
47
+ pip install .
48
+
49
+ - name: Verify installation
50
+ run: |
51
+ python -c "import PyOpenMagnetics; print('PyOpenMagnetics loaded with', len(dir(PyOpenMagnetics)), 'functions')"
52
+
53
+ - name: Run tests
54
+ run: |
55
+ pytest tests/ -v --tb=short
56
+ continue-on-error: true # Some tests may require specific data files
57
+
58
+ build_check:
59
+ name: Build check
60
+ runs-on: ubuntu-22.04
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ with:
64
+ submodules: recursive
65
+
66
+ - name: Set up Python
67
+ uses: actions/setup-python@v5
68
+ with:
69
+ python-version: "3.11"
70
+
71
+ - name: Set up Node.js
72
+ uses: actions/setup-node@v4
73
+ with:
74
+ node-version: "18"
75
+
76
+ - name: Install quicktype
77
+ run: npm install -g quicktype
78
+
79
+ - name: Install build
80
+ run: python -m pip install build
81
+
82
+ - name: Build package
83
+ run: python -m build
84
+
85
+ - name: Check built files
86
+ run: |
87
+ ls -la dist/
88
+ echo "--- Wheel contents ---"
89
+ python -m zipfile -l dist/*.whl | head -50
90
+
@@ -0,0 +1,158 @@
1
+ name: Build and Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch: # Allow manual trigger for testing
7
+
8
+ env:
9
+ GIT_LFS_SKIP_SMUDGE: 1 # Skip LFS to avoid bandwidth quota issues
10
+
11
+ jobs:
12
+ build_wheels:
13
+ name: Build wheels on ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os: [ubuntu-22.04, windows-2022, macos-15]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ with:
23
+ submodules: recursive
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.11"
29
+
30
+ - name: Set up Node.js
31
+ uses: actions/setup-node@v4
32
+ with:
33
+ node-version: "18"
34
+
35
+ - name: Install quicktype
36
+ run: npm install -g quicktype
37
+
38
+ - name: Install cibuildwheel
39
+ run: python -m pip install cibuildwheel==2.21.3
40
+
41
+ - name: Build wheels
42
+ run: python -m cibuildwheel --output-dir wheelhouse
43
+ env:
44
+ # Build for Python 3.10, 3.11, 3.12, 3.13
45
+ CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
46
+ # Skip 32-bit builds, musllinux, and PyPy
47
+ CIBW_SKIP: "*-win32 *-manylinux_i686 *musllinux* pp*"
48
+ # Use manylinux_2_28 (AlmaLinux 8) for C++23 support (GCC 12+ via gcc-toolset)
49
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
50
+ # Install Node.js 18 and quicktype in the build container (Linux)
51
+ # Also install gcc-toolset-13 for C++23 support
52
+ CIBW_BEFORE_ALL_LINUX: |
53
+ dnf install -y gcc-toolset-13 && \
54
+ source /opt/rh/gcc-toolset-13/enable && \
55
+ curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - && \
56
+ dnf install -y nodejs && \
57
+ npm install -g quicktype
58
+ CIBW_BEFORE_ALL_MACOS: npm install -g quicktype
59
+ CIBW_BEFORE_ALL_WINDOWS: npm install -g quicktype
60
+ # Set macOS deployment target to 15.0 for arm64 (Homebrew libraries require it)
61
+ CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=15.0
62
+ # Enable gcc-toolset-13 before build for C++23
63
+ CIBW_ENVIRONMENT_LINUX: PATH=/opt/rh/gcc-toolset-13/root/usr/bin:$PATH LD_LIBRARY_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64:$LD_LIBRARY_PATH
64
+ # Install build dependencies
65
+ CIBW_BEFORE_BUILD: pip install scikit-build-core cmake ninja pybind11
66
+ # Test the wheel
67
+ CIBW_TEST_COMMAND: python -c "import PyOpenMagnetics; print(f'PyOpenMagnetics loaded successfully with {len(dir(PyOpenMagnetics))} functions')"
68
+
69
+ - uses: actions/upload-artifact@v4
70
+ with:
71
+ name: wheels-${{ matrix.os }}
72
+ path: ./wheelhouse/*.whl
73
+
74
+ build_sdist:
75
+ name: Build source distribution
76
+ runs-on: ubuntu-22.04
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+ with:
80
+ submodules: recursive
81
+
82
+ - name: Set up Python
83
+ uses: actions/setup-python@v5
84
+ with:
85
+ python-version: "3.11"
86
+
87
+ - name: Set up Node.js
88
+ uses: actions/setup-node@v4
89
+ with:
90
+ node-version: "18"
91
+
92
+ - name: Install quicktype
93
+ run: npm install -g quicktype
94
+
95
+ - name: Install build
96
+ run: python -m pip install build
97
+
98
+ - name: Build sdist
99
+ run: python -m build --sdist
100
+
101
+ - uses: actions/upload-artifact@v4
102
+ with:
103
+ name: sdist
104
+ path: dist/*.tar.gz
105
+
106
+ publish:
107
+ name: Publish to PyPI
108
+ needs: [build_wheels, build_sdist]
109
+ runs-on: ubuntu-22.04
110
+ # Only publish on release
111
+ if: github.event_name == 'release'
112
+ environment:
113
+ name: pypi
114
+ url: https://pypi.org/p/pyopenmagnetics
115
+ permissions:
116
+ id-token: write # Required for trusted publishing
117
+
118
+ steps:
119
+ - name: Download all artifacts
120
+ uses: actions/download-artifact@v4
121
+ with:
122
+ path: dist
123
+ merge-multiple: true
124
+
125
+ - name: List distribution files
126
+ run: ls -la dist/
127
+
128
+ - name: Publish to PyPI
129
+ uses: pypa/gh-action-pypi-publish@release/v1
130
+ with:
131
+ # Option 1: Use API token (set PYPI_API_TOKEN in repository secrets)
132
+ password: ${{ secrets.PYPI_API_TOKEN }}
133
+ # Option 2: Use trusted publishing (no token needed, configure on PyPI)
134
+ # Uncomment the line below and remove password above to use trusted publishing
135
+ # trusted-publishing: true
136
+
137
+ # Optional: Publish to TestPyPI first for testing
138
+ publish_test:
139
+ name: Publish to TestPyPI
140
+ needs: [build_wheels, build_sdist]
141
+ runs-on: ubuntu-22.04
142
+ if: github.event_name == 'workflow_dispatch'
143
+ environment:
144
+ name: testpypi
145
+ url: https://test.pypi.org/p/pyopenmagnetics
146
+
147
+ steps:
148
+ - name: Download all artifacts
149
+ uses: actions/download-artifact@v4
150
+ with:
151
+ path: dist
152
+ merge-multiple: true
153
+
154
+ - name: Publish to TestPyPI
155
+ uses: pypa/gh-action-pypi-publish@release/v1
156
+ with:
157
+ repository-url: https://test.pypi.org/legacy/
158
+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}
@@ -0,0 +1,6 @@
1
+ build/
2
+ dist/
3
+ venv/
4
+
5
+ *.pyc
6
+ __pycache__/
@@ -0,0 +1,240 @@
1
+ cmake_minimum_required(VERSION 3.15...3.26)
2
+ project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)
3
+
4
+ set(PYBIND11_NEWPYTHON ON)
5
+
6
+ option(BUILD_TESTS "Build tests" OFF)
7
+ option(BUILD_EXAMPLES "Build examples" OFF)
8
+ option(UTPP_INCLUDE_TESTS_IN_BUILD "Build tests" OFF)
9
+ option(MKF_INCLUDE_TESTS "Build tests" OFF)
10
+ option(BUILD_TESTS "Build tests" OFF)
11
+ option(BUILD_EXAMPLES "Build examples" OFF)
12
+ option(BUILD_DEMO "Build examples" FALSE)
13
+ option(HAVE_LAPACK "HAVE_LAPACK" 0)
14
+
15
+ set(CMAKE_CXX_STANDARD 23)
16
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
17
+
18
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
19
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
20
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox")
21
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
22
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
23
+ else ()
24
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -Wno-switch")
25
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
26
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
27
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
28
+
29
+ # set(CMAKE_BUILD_TYPE RelWithDebInfo)
30
+ # set(CMAKE_BUILD_TYPE MinSizeRel)
31
+ set(CMAKE_BUILD_TYPE Release)
32
+ endif()
33
+
34
+ SET(MAS_DIRECTORY "${CMAKE_BINARY_DIR}/MAS/")
35
+ SET(MAS_DIR "${CMAKE_BINARY_DIR}/_deps/mas-src/")
36
+ SET(MKF_DIR "${CMAKE_BINARY_DIR}/_deps/mkf-src/")
37
+ SET(FETCHCONTENT_QUIET FALSE)
38
+
39
+ message(STATUS MAS_DIRECTORY)
40
+ message(STATUS ${MAS_DIRECTORY})
41
+ message(STATUS MAS_DIR)
42
+ message(STATUS ${MAS_DIR})
43
+ message(STATUS MKF_DIR)
44
+ message(STATUS ${MKF_DIR})
45
+
46
+ include(FetchContent)
47
+
48
+ message(STATUS "Fetching https://github.com/nlohmann/json.git")
49
+ FetchContent_Declare(json
50
+ GIT_REPOSITORY https://github.com/nlohmann/json.git
51
+ GIT_TAG tags/v3.11.3
52
+ GIT_PROGRESS TRUE
53
+ )
54
+ FetchContent_MakeAvailable(json)
55
+ include_directories("${CMAKE_BINARY_DIR}/_deps/json-src/include/nlohmann/")
56
+ include_directories("${CMAKE_BINARY_DIR}/_deps/json-src/include/")
57
+
58
+ message(STATUS "Fetching pybind11")
59
+ FetchContent_Declare(pybind11
60
+ GIT_REPOSITORY https://github.com/pybind/pybind11.git)
61
+
62
+ message(STATUS "Fetching pybind11_json")
63
+ FetchContent_Declare(pybind11_json
64
+ GIT_REPOSITORY https://github.com/pybind/pybind11_json.git)
65
+
66
+ FetchContent_MakeAvailable( pybind11 pybind11_json)
67
+ include_directories("${CMAKE_BINARY_DIR}/_deps/pybind11-src/include/")
68
+ include_directories("${CMAKE_BINARY_DIR}/_deps/pybind11_json-src/include/")
69
+
70
+ message(STATUS "Fetching spline")
71
+ FetchContent_Declare(spline
72
+ GIT_REPOSITORY https://github.com/AlfVII/spline.git)
73
+ FetchContent_MakeAvailable(spline)
74
+ include_directories("${CMAKE_BINARY_DIR}/_deps/spline-src/src")
75
+
76
+ FetchContent_Declare(levmar
77
+ GIT_REPOSITORY https://github.com/AlfVII/levmar.git
78
+ GIT_TAG main)
79
+ FetchContent_MakeAvailable(levmar)
80
+ include_directories("${CMAKE_BINARY_DIR}/_deps/levmar-src")
81
+
82
+ FetchContent_Declare(svg
83
+ GIT_REPOSITORY https://github.com/AlfVII/svg)
84
+ FetchContent_MakeAvailable(svg)
85
+ include_directories("${CMAKE_BINARY_DIR}/_deps/svg-src/src")
86
+
87
+ message(STATUS "Fetching magic-enum")
88
+ FetchContent_Declare(magic-enum
89
+ GIT_REPOSITORY https://github.com/Neargye/magic_enum
90
+ GIT_TAG tags/v0.9.6)
91
+ FetchContent_MakeAvailable(magic-enum)
92
+ include_directories("${CMAKE_BINARY_DIR}/_deps/magic-enum-src/include/magic_enum")
93
+
94
+ message(STATUS "Fetching matplotplusplus")
95
+ FetchContent_Declare(matplotplusplus
96
+ GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus.git
97
+ GIT_TAG tags/v1.2.1)
98
+ FetchContent_GetProperties(matplotplusplus)
99
+ if(NOT matplotplusplus_POPULATED)
100
+ FetchContent_Populate(matplotplusplus)
101
+ add_subdirectory(${matplotplusplus_SOURCE_DIR} ${matplotplusplus_BINARY_DIR} EXCLUDE_FROM_ALL)
102
+ endif()
103
+
104
+ FetchContent_Declare(rapidfuzz
105
+ GIT_REPOSITORY https://github.com/rapidfuzz/rapidfuzz-cpp.git
106
+ GIT_TAG main)
107
+ FetchContent_MakeAvailable(rapidfuzz)
108
+
109
+ message(STATUS "Fetching MKF")
110
+ FetchContent_Declare(MKF
111
+ GIT_REPOSITORY https://github.com/OpenMagnetics/MKF.git
112
+ GIT_TAG main)
113
+
114
+ message(STATUS "Fetching mas")
115
+ # Skip Git LFS to avoid bandwidth quota issues - data files are optional for build
116
+ set(ENV{GIT_LFS_SKIP_SMUDGE} "1")
117
+ FetchContent_Declare(
118
+ mas
119
+ GIT_REPOSITORY https://github.com/OpenMagnetics/MAS.git
120
+ GIT_TAG main
121
+ )
122
+
123
+ message(STATUS "Fetching Properties mas")
124
+ FetchContent_GetProperties(mas)
125
+ message(STATUS "Fetching Properties MKF")
126
+ FetchContent_GetProperties(MKF)
127
+ message(STATUS ${MAS_POPULATED})
128
+ if(NOT MAS_POPULATED)
129
+ message(STATUS "Populating MKF")
130
+ FetchContent_Populate(mas)
131
+ endif()
132
+ message(STATUS ${MKF_POPULATED})
133
+ if(NOT MKF_POPULATED)
134
+ message(STATUS "Populating MKF")
135
+ FetchContent_Populate(MKF)
136
+ endif()
137
+ message(STATUS ${MAS_SOURCE_DIR})
138
+
139
+ message(STATUS "Compiling MAS")
140
+
141
+
142
+ add_custom_command(
143
+ OUTPUT "${MAS_DIRECTORY}/MAS.hpp"
144
+ COMMAND quicktype -l c++ -s schema ${MAS_DIR}/schemas/MAS.json
145
+ -S ${MAS_DIR}/schemas/magnetic.json
146
+ -S ${MAS_DIR}/schemas/magnetic/core.json
147
+ -S ${MAS_DIR}/schemas/magnetic/coil.json
148
+ -S ${MAS_DIR}/schemas/utils.json
149
+ -S ${MAS_DIR}/schemas/magnetic/core/gap.json
150
+ -S ${MAS_DIR}/schemas/magnetic/core/shape.json
151
+ -S ${MAS_DIR}/schemas/magnetic/core/material.json
152
+ -S ${MAS_DIR}/schemas/magnetic/insulation/material.json
153
+ -S ${MAS_DIR}/schemas/magnetic/insulation/wireCoating.json
154
+ -S ${MAS_DIR}/schemas/magnetic/bobbin.json
155
+ -S ${MAS_DIR}/schemas/magnetic/core/piece.json
156
+ -S ${MAS_DIR}/schemas/magnetic/core/spacer.json
157
+ -S ${MAS_DIR}/schemas/magnetic/wire/basicWire.json
158
+ -S ${MAS_DIR}/schemas/magnetic/wire/round.json
159
+ -S ${MAS_DIR}/schemas/magnetic/wire/rectangular.json
160
+ -S ${MAS_DIR}/schemas/magnetic/wire/foil.json
161
+ -S ${MAS_DIR}/schemas/magnetic/wire/planar.json
162
+ -S ${MAS_DIR}/schemas/magnetic/wire/litz.json
163
+ -S ${MAS_DIR}/schemas/magnetic/wire/material.json
164
+ -S ${MAS_DIR}/schemas/magnetic/wire.json
165
+ -S ${MAS_DIR}/schemas/utils.json
166
+ -S ${MAS_DIR}/schemas/magnetic/insulation/wireCoating.json
167
+ -S ${MAS_DIR}/schemas/magnetic/insulation/material.json
168
+ -S ${MAS_DIR}/schemas/inputs.json
169
+ -S ${MAS_DIR}/schemas/outputs.json
170
+ -S ${MAS_DIR}/schemas/outputs/coreLossesOutput.json
171
+ -S ${MAS_DIR}/schemas/inputs/designRequirements.json
172
+ -S ${MAS_DIR}/schemas/inputs/operatingConditions.json
173
+ -S ${MAS_DIR}/schemas/inputs/operatingPoint.json
174
+ -S ${MAS_DIR}/schemas/inputs/operatingPointExcitation.json
175
+ -S ${MAS_DIR}/schemas/inputs/topologies/flyback.json
176
+ -S ${MAS_DIR}/schemas/inputs/topologies/currentTransformer.json
177
+ -S ${MAS_DIR}/schemas/inputs/topologies/boost.json
178
+ -S ${MAS_DIR}/schemas/inputs/topologies/buck.json
179
+ -S ${MAS_DIR}/schemas/inputs/topologies/flybuck.json
180
+ -S ${MAS_DIR}/schemas/inputs/topologies/forward.json
181
+ -S ${MAS_DIR}/schemas/inputs/topologies/isolatedBuck.json
182
+ -S ${MAS_DIR}/schemas/inputs/topologies/isolatedBuckBoost.json
183
+ -S ${MAS_DIR}/schemas/inputs/topologies/pushPull.json
184
+ -o ${MAS_DIRECTORY}/MAS.hpp --namespace MAS --source-style single-source --type-style pascal-case --member-style underscore-case --enumerator-style upper-underscore-case --no-boost
185
+ USES_TERMINAL)
186
+
187
+ add_custom_target(PyMASGeneration
188
+ /bin/echo "RUNNING PyMASGeneration"
189
+ DEPENDS "${MAS_DIRECTORY}/MAS.hpp")
190
+
191
+ message(STATUS "Compiling PyOpenMagnetics with modular structure")
192
+ file(GLOB SOURCES src/*.cpp
193
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/*.cpp
194
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/advisers/*.cpp
195
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/constructive_models/*.cpp
196
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/converter_models/*.cpp
197
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/physical_models/*.cpp
198
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/processors/*.cpp
199
+ ${CMAKE_BINARY_DIR}/_deps/mkf-src/src/support/*.cpp
200
+ )
201
+ message(STATUS SOURCES)
202
+ message(STATUS ${SOURCES})
203
+ pybind11_add_module(PyOpenMagnetics ${SOURCES})
204
+
205
+ add_dependencies(PyOpenMagnetics PyMASGeneration)
206
+
207
+ target_link_libraries(PyOpenMagnetics PUBLIC nlohmann_json::nlohmann_json matplot levmar rapidfuzz::rapidfuzz)
208
+
209
+ file(DOWNLOAD "https://raw.githubusercontent.com/vector-of-bool/cmrc/master/CMakeRC.cmake"
210
+ "${CMAKE_BINARY_DIR}/CMakeRC.cmake")
211
+ include("${CMAKE_BINARY_DIR}/CMakeRC.cmake")
212
+
213
+ include_directories("${CMAKE_BINARY_DIR}/_deps/mkf-src/")
214
+
215
+ cmrc_add_resource_library(insulation_standards ALIAS data::insulation_standards NAMESPACE insulationData WHENCE ${MKF_DIR}/ ${MKF_DIR}/src/data/insulation_standards/IEC_60664-1.json ${MKF_DIR}/src/data/insulation_standards/IEC_60664-4.json ${MKF_DIR}/src/data/insulation_standards/IEC_60664-5.json ${MKF_DIR}/src/data/insulation_standards/IEC_62368-1.json ${MKF_DIR}/src/data/insulation_standards/IEC_61558-1.json ${MKF_DIR}/src/data/insulation_standards/IEC_61558-2-16.json ${MKF_DIR}/src/data/insulation_standards/IEC_60335-1.json)
216
+ target_link_libraries(PyOpenMagnetics PUBLIC data::insulation_standards)
217
+
218
+
219
+ cmrc_add_resource_library(data ALIAS data::data NAMESPACE data WHENCE ${MAS_DIR} PREFIX MAS ${MAS_DIR}/data/core_materials.ndjson ${MAS_DIR}/data/core_shapes.ndjson ${MAS_DIR}/data/cores.ndjson ${MAS_DIR}/data/bobbins.ndjson ${MAS_DIR}/data/insulation_materials.ndjson ${MAS_DIR}/data/wire_materials.ndjson ${MAS_DIR}/data/wires.ndjson)
220
+ target_link_libraries(PyOpenMagnetics PUBLIC data::data)
221
+
222
+
223
+ include_directories("${CMAKE_BINARY_DIR}/_deps/json-src/include/nlohmann/")
224
+ include_directories("${CMAKE_BINARY_DIR}/_deps/pybind11-src/include/")
225
+ include_directories("${CMAKE_BINARY_DIR}/_deps/pybind11_json-src/include/pybind11_json/")
226
+ include_directories("${CMAKE_BINARY_DIR}/_deps/json-src/include/nlohmann/")
227
+ include_directories("${CMAKE_BINARY_DIR}/_deps/magic-enum-src/include")
228
+ include_directories("${CMAKE_BINARY_DIR}/_deps/svg-src/src")
229
+ include_directories("${CMAKE_BINARY_DIR}/_deps/spline-src/src")
230
+ include_directories("${CMAKE_BINARY_DIR}/_deps/json-src/include/")
231
+ include_directories("${CMAKE_BINARY_DIR}/_deps/mkf-src/src/")
232
+ include_directories("${CMAKE_BINARY_DIR}/_cmrc/include")
233
+ include_directories("${MAS_DIRECTORY}")
234
+ include_directories("src/")
235
+
236
+ # target_link_libraries(PyOpenMagnetics PUBLIC MKF)
237
+
238
+
239
+
240
+ install(TARGETS PyOpenMagnetics LIBRARY DESTINATION .)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OpenMagnetics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.