polecraft 0.0.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 (51) hide show
  1. polecraft-0.0.1/CHANGELOG.md +54 -0
  2. polecraft-0.0.1/LICENSE +201 -0
  3. polecraft-0.0.1/MANIFEST.in +5 -0
  4. polecraft-0.0.1/PKG-INFO +146 -0
  5. polecraft-0.0.1/README.md +114 -0
  6. polecraft-0.0.1/designs/qdd_outer_12s10p.yaml +51 -0
  7. polecraft-0.0.1/designs/qdd_outer_24s28p.yaml +51 -0
  8. polecraft-0.0.1/designs/qdd_outer_36s42p.yaml +53 -0
  9. polecraft-0.0.1/examples/mesh_a_design.py +44 -0
  10. polecraft-0.0.1/polecraft/__init__.py +17 -0
  11. polecraft-0.0.1/polecraft/__main__.py +7 -0
  12. polecraft-0.0.1/polecraft/cli.py +94 -0
  13. polecraft-0.0.1/polecraft/core/__init__.py +5 -0
  14. polecraft-0.0.1/polecraft/core/geometry.py +281 -0
  15. polecraft-0.0.1/polecraft/core/mesh.py +480 -0
  16. polecraft-0.0.1/polecraft/core/winding.py +204 -0
  17. polecraft-0.0.1/polecraft/data/__init__.py +1 -0
  18. polecraft-0.0.1/polecraft/design.py +292 -0
  19. polecraft-0.0.1/polecraft/machines/__init__.py +34 -0
  20. polecraft-0.0.1/polecraft/machines/base.py +85 -0
  21. polecraft-0.0.1/polecraft/machines/qdd_outer.py +490 -0
  22. polecraft-0.0.1/polecraft/plot.py +119 -0
  23. polecraft-0.0.1/polecraft/studies/__init__.py +1 -0
  24. polecraft-0.0.1/polecraft/timing.py +39 -0
  25. polecraft-0.0.1/polecraft/validation.py +272 -0
  26. polecraft-0.0.1/polecraft.egg-info/PKG-INFO +146 -0
  27. polecraft-0.0.1/polecraft.egg-info/SOURCES.txt +49 -0
  28. polecraft-0.0.1/polecraft.egg-info/dependency_links.txt +1 -0
  29. polecraft-0.0.1/polecraft.egg-info/entry_points.txt +2 -0
  30. polecraft-0.0.1/polecraft.egg-info/requires.txt +10 -0
  31. polecraft-0.0.1/polecraft.egg-info/top_level.txt +1 -0
  32. polecraft-0.0.1/pyproject.toml +59 -0
  33. polecraft-0.0.1/setup.cfg +4 -0
  34. polecraft-0.0.1/tests/conftest.py +115 -0
  35. polecraft-0.0.1/tests/core/test_geometry.py +277 -0
  36. polecraft-0.0.1/tests/core/test_mesh.py +493 -0
  37. polecraft-0.0.1/tests/core/test_mesh_without_gmsh.py +29 -0
  38. polecraft-0.0.1/tests/core/test_winding.py +357 -0
  39. polecraft-0.0.1/tests/data/duplicate_key.yaml +5 -0
  40. polecraft-0.0.1/tests/data/valid_design.yaml +45 -0
  41. polecraft-0.0.1/tests/machines/test_machine_contract.py +161 -0
  42. polecraft-0.0.1/tests/machines/test_qdd_outer.py +148 -0
  43. polecraft-0.0.1/tests/machines/test_qdd_outer_geometry.py +502 -0
  44. polecraft-0.0.1/tests/test_cli.py +246 -0
  45. polecraft-0.0.1/tests/test_design.py +548 -0
  46. polecraft-0.0.1/tests/test_examples.py +34 -0
  47. polecraft-0.0.1/tests/test_package.py +32 -0
  48. polecraft-0.0.1/tests/test_plot.py +250 -0
  49. polecraft-0.0.1/tests/test_release.py +86 -0
  50. polecraft-0.0.1/tests/test_timing.py +47 -0
  51. polecraft-0.0.1/tests/test_validation.py +244 -0
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ All notable changes to Pole-Craft are listed here, newest first. Version
4
+ numbers follow [semantic versioning](https://semver.org); while the version
5
+ is 0.0.x the design-file format and the Python interface may change between
6
+ releases.
7
+
8
+ ## [0.0.1] - 2026-11-16
9
+
10
+ First release. It loads a design file, builds the geometry of an outer-rotor
11
+ motor, meshes it and saves a picture. There is no field solver yet, so it
12
+ does not report torque, back-EMF or losses.
13
+
14
+ ### Added
15
+
16
+ - Design files in YAML (`format_version: 1`) for outer-rotor surface-magnet
17
+ motors (`type: qdd_outer`), with strict checking: unknown fields, wrong
18
+ types and values out of range are all reported in one message, and
19
+ dimensions that do not fit together are then reported one at a time.
20
+ - Symmetry slice and winding layout for any balanced three-phase slot and
21
+ pole combination with a double-layer tooth-wound winding, and its winding
22
+ factor.
23
+ - Cross-section geometry as labelled regions (stator and rotor steel, coil
24
+ sides, magnets, air), for the repeating slice or the whole machine.
25
+ - Triangle meshing through Gmsh, with a sliding band in the air gap prepared
26
+ for rotation without remeshing.
27
+ - `polecraft mesh <design.yaml>` command: saves a coloured picture of the
28
+ mesh (PNG, SVG or PDF) and prints the mesh size and a timing report.
29
+ - The same steps from Python (`load_design`, `machine_for`, `build_mesh`,
30
+ `plot_mesh`), with an example script in `examples/`.
31
+ - Three example designs: 36 slots with 42 poles, 24 slots with 28 poles and
32
+ 12 slots with 10 poles. Their dimensions are placeholders, not measured or
33
+ optimised designs.
34
+
35
+ ### Known limits
36
+
37
+ - No field solution: nothing is simulated yet.
38
+ - Outer-rotor surface-magnet motors only, with parallel-sided teeth.
39
+ - Meshing needs the optional Gmsh package (`pip install "polecraft[mesh]"`).
40
+ On Linux, Gmsh also needs a few system libraries; the README lists them.
41
+ - The material names in a design file are stored but not yet checked against
42
+ a material library.
43
+ - Winding, lengthwise and temperature values are read but not used yet: for
44
+ example, nothing checks that the turns fit in the slot.
45
+ - There is no air region outside the rotor yoke or inside the stator bore.
46
+ - The air-gap band is one layer of triangles. Very fine meshes (`--size`
47
+ below about 0.5) and slot and pole counts with little in common give thin
48
+ triangles in the air gap.
49
+ - Pictures of very fine meshes look dark, because the triangle edge lines do
50
+ not thin out.
51
+ - Meshing cannot be interrupted part-way; Ctrl-C takes effect when the mesher
52
+ returns.
53
+
54
+ [0.0.1]: https://github.com/pole-craft/pole-craft/releases/tag/v0.0.1
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include CHANGELOG.md
2
+ graft tests
3
+ graft designs
4
+ graft examples
5
+ global-exclude *.py[cod]
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: polecraft
3
+ Version: 0.0.1
4
+ Summary: Open-source design and simulation tool for quasi-direct-drive (QDD) motors.
5
+ Author: Varun Pandithurai
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Repository, https://github.com/pole-craft/pole-craft
8
+ Project-URL: Issues, https://github.com/pole-craft/pole-craft/issues
9
+ Project-URL: Changelog, https://github.com/pole-craft/pole-craft/blob/main/CHANGELOG.md
10
+ Keywords: motor,electric machine,finite element,QDD,BLDC,PMSM
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Physics
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.26
24
+ Requires-Dist: scipy>=1.11
25
+ Requires-Dist: matplotlib>=3.8
26
+ Requires-Dist: PyYAML>=6.0
27
+ Provides-Extra: mesh
28
+ Requires-Dist: gmsh>=4.11; extra == "mesh"
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8.0; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # Pole-Craft
34
+
35
+ Open-source design and simulation tool for quasi-direct-drive (QDD) motors.
36
+
37
+ > **Status: early development (version 0.0.1).** Pole-Craft loads a motor design file and checks it, works out the winding layout and the slice of the motor that repeats, builds the cross-section of an outer-rotor motor as labelled regions (steel, coils, magnets, air), meshes it with triangles and saves a picture with the `polecraft mesh` command. **It does not simulate anything yet:** there is no field solver, so it reports no torque, back-EMF or losses. The roadmap below shows what comes next.
38
+
39
+ ![Mesh of the repeating slice of a 36-slot, 42-pole outer-rotor motor](https://raw.githubusercontent.com/pole-craft/pole-craft/main/docs/images/mesh_36s42p.png)
40
+
41
+ ## What it will do
42
+
43
+ Pole-Craft takes a motor described in a simple design file and tells you how it performs:
44
+
45
+ - Builds the motor geometry from parameters (slots, poles, diameters, magnet shape)
46
+ - Runs 2D electromagnetic finite-element analysis
47
+ - Reports torque, cogging, back-EMF, torque constant, losses and efficiency
48
+ - Lets you change magnet grade, steel grade, wire size and turns, and compare the results
49
+ - Sweeps many design variants to find the best one for a target
50
+
51
+ The first focus is surface-magnet outer-rotor and inner-rotor motors of the kind used in QDD robot actuators.
52
+
53
+ ## Why
54
+
55
+ Commercial motor design tools are expensive, and their free student versions cannot be used for commercial work. Existing open-source tools are general-purpose. Pole-Craft aims to make exploring QDD motor designs fast, scriptable and free for anyone to use.
56
+
57
+ ## Install
58
+
59
+ Needs Python 3.11 or newer.
60
+
61
+ ```
62
+ pip install "polecraft[mesh]"
63
+ ```
64
+
65
+ The `mesh` extra installs [Gmsh](https://gmsh.info), which does the meshing. Gmsh is licensed under the GPL, so it is kept optional: Pole-Craft does not include any Gmsh code and only calls it if you install it. Plain `pip install polecraft` gives everything except meshing.
66
+
67
+ On Linux, Gmsh needs a few system libraries that servers, containers and WSL often lack. If `polecraft mesh` reports `libGLU.so.1: cannot open shared object file` (or a similar library name), install them. On Debian or Ubuntu:
68
+
69
+ ```
70
+ sudo apt-get install libglu1-mesa libxcursor1 libxft2 libxinerama1 libxrender1 libgomp1
71
+ ```
72
+
73
+ ## Try it
74
+
75
+ Save an example design, for instance [qdd_outer_36s42p.yaml](https://raw.githubusercontent.com/pole-craft/pole-craft/main/designs/qdd_outer_36s42p.yaml), into the folder you are working in. The others are in the [designs folder](https://github.com/pole-craft/pole-craft/tree/main/designs), and a clone of the repository contains them all. Then mesh it and save a picture:
76
+
77
+ ```
78
+ polecraft mesh qdd_outer_36s42p.yaml
79
+ ```
80
+
81
+ This writes `qdd_outer_36s42p_mesh.png` in the current folder and prints the mesh size and how long each stage took. Only the slice of the motor that repeats is meshed; add `--full` for the whole machine, `-o` to choose the output file (`.png`, `.svg` or `.pdf`), and `--size 0.5` for a finer mesh.
82
+
83
+ The design files are plain YAML, with lengths in millimetres. The dimensions in the examples are placeholders typical of each motor size, not measured or optimised designs. The design-file format may change between 0.0.x versions.
84
+
85
+ ## Use from Python
86
+
87
+ The same steps can be run from a script:
88
+
89
+ ```python
90
+ from polecraft import load_design, machine_for
91
+ from polecraft.core.mesh import build_mesh
92
+ from polecraft.plot import plot_mesh
93
+
94
+ design = load_design("qdd_outer_36s42p.yaml")
95
+ machine = machine_for(design)
96
+ print(machine.symmetry()) # the slice that repeats
97
+
98
+ geometry = machine.build_geometry() # full=True for the whole machine
99
+ mesh = build_mesh(geometry, size=1.0) # needs Gmsh; smaller size, finer mesh
100
+ print(len(mesh.nodes), len(mesh.triangles))
101
+
102
+ plot_mesh(mesh, geometry, "motor.png")
103
+ ```
104
+
105
+ A longer example that also prints the winding layout is in [examples/mesh_a_design.py](https://github.com/pole-craft/pole-craft/blob/main/examples/mesh_a_design.py). The Python interface may change between 0.0.x versions.
106
+
107
+ ## Roadmap
108
+
109
+ - [x] Parametric geometry and meshing for QDD motors (outer rotor; inner rotor to follow)
110
+ - [ ] 2D field solver with saturated steel and permanent magnets
111
+ - [ ] Rotation: cogging torque, back-EMF, torque ripple
112
+ - [ ] Material and winding library
113
+ - [ ] Losses, torque-speed curve and efficiency map
114
+ - [ ] Parallel and GPU-accelerated design sweeps
115
+ - [ ] Validation against FEMM and measured motors
116
+ - [ ] Gear module for actuator-level results
117
+ - [ ] 3D verification
118
+
119
+ Changes in each release are listed in the [changelog](https://github.com/pole-craft/pole-craft/blob/main/CHANGELOG.md).
120
+
121
+ ## Built with
122
+
123
+ Python, [Gmsh](https://gmsh.info) for meshing, and [FEMM](https://www.femm.info) as an independent reference for validation.
124
+
125
+ ## Development setup and running the tests
126
+
127
+ Clone the repository, then install it in a virtual environment together with the test tools:
128
+
129
+ ```
130
+ git clone https://github.com/pole-craft/pole-craft.git
131
+ cd pole-craft
132
+ python -m venv .venv
133
+ .venv\Scripts\activate # Linux/macOS: source .venv/bin/activate
134
+ pip install -e ".[dev,mesh]"
135
+ pytest
136
+ ```
137
+
138
+ Without the `mesh` extra everything except meshing works, and the meshing tests are skipped.
139
+
140
+ ## Contributing
141
+
142
+ The project is just starting. Ideas, questions, bug reports and motor data for validation are welcome: please [open an issue](https://github.com/pole-craft/pole-craft/issues).
143
+
144
+ ## License
145
+
146
+ Apache License 2.0. See [LICENSE](https://github.com/pole-craft/pole-craft/blob/main/LICENSE).
@@ -0,0 +1,114 @@
1
+ # Pole-Craft
2
+
3
+ Open-source design and simulation tool for quasi-direct-drive (QDD) motors.
4
+
5
+ > **Status: early development (version 0.0.1).** Pole-Craft loads a motor design file and checks it, works out the winding layout and the slice of the motor that repeats, builds the cross-section of an outer-rotor motor as labelled regions (steel, coils, magnets, air), meshes it with triangles and saves a picture with the `polecraft mesh` command. **It does not simulate anything yet:** there is no field solver, so it reports no torque, back-EMF or losses. The roadmap below shows what comes next.
6
+
7
+ ![Mesh of the repeating slice of a 36-slot, 42-pole outer-rotor motor](https://raw.githubusercontent.com/pole-craft/pole-craft/main/docs/images/mesh_36s42p.png)
8
+
9
+ ## What it will do
10
+
11
+ Pole-Craft takes a motor described in a simple design file and tells you how it performs:
12
+
13
+ - Builds the motor geometry from parameters (slots, poles, diameters, magnet shape)
14
+ - Runs 2D electromagnetic finite-element analysis
15
+ - Reports torque, cogging, back-EMF, torque constant, losses and efficiency
16
+ - Lets you change magnet grade, steel grade, wire size and turns, and compare the results
17
+ - Sweeps many design variants to find the best one for a target
18
+
19
+ The first focus is surface-magnet outer-rotor and inner-rotor motors of the kind used in QDD robot actuators.
20
+
21
+ ## Why
22
+
23
+ Commercial motor design tools are expensive, and their free student versions cannot be used for commercial work. Existing open-source tools are general-purpose. Pole-Craft aims to make exploring QDD motor designs fast, scriptable and free for anyone to use.
24
+
25
+ ## Install
26
+
27
+ Needs Python 3.11 or newer.
28
+
29
+ ```
30
+ pip install "polecraft[mesh]"
31
+ ```
32
+
33
+ The `mesh` extra installs [Gmsh](https://gmsh.info), which does the meshing. Gmsh is licensed under the GPL, so it is kept optional: Pole-Craft does not include any Gmsh code and only calls it if you install it. Plain `pip install polecraft` gives everything except meshing.
34
+
35
+ On Linux, Gmsh needs a few system libraries that servers, containers and WSL often lack. If `polecraft mesh` reports `libGLU.so.1: cannot open shared object file` (or a similar library name), install them. On Debian or Ubuntu:
36
+
37
+ ```
38
+ sudo apt-get install libglu1-mesa libxcursor1 libxft2 libxinerama1 libxrender1 libgomp1
39
+ ```
40
+
41
+ ## Try it
42
+
43
+ Save an example design, for instance [qdd_outer_36s42p.yaml](https://raw.githubusercontent.com/pole-craft/pole-craft/main/designs/qdd_outer_36s42p.yaml), into the folder you are working in. The others are in the [designs folder](https://github.com/pole-craft/pole-craft/tree/main/designs), and a clone of the repository contains them all. Then mesh it and save a picture:
44
+
45
+ ```
46
+ polecraft mesh qdd_outer_36s42p.yaml
47
+ ```
48
+
49
+ This writes `qdd_outer_36s42p_mesh.png` in the current folder and prints the mesh size and how long each stage took. Only the slice of the motor that repeats is meshed; add `--full` for the whole machine, `-o` to choose the output file (`.png`, `.svg` or `.pdf`), and `--size 0.5` for a finer mesh.
50
+
51
+ The design files are plain YAML, with lengths in millimetres. The dimensions in the examples are placeholders typical of each motor size, not measured or optimised designs. The design-file format may change between 0.0.x versions.
52
+
53
+ ## Use from Python
54
+
55
+ The same steps can be run from a script:
56
+
57
+ ```python
58
+ from polecraft import load_design, machine_for
59
+ from polecraft.core.mesh import build_mesh
60
+ from polecraft.plot import plot_mesh
61
+
62
+ design = load_design("qdd_outer_36s42p.yaml")
63
+ machine = machine_for(design)
64
+ print(machine.symmetry()) # the slice that repeats
65
+
66
+ geometry = machine.build_geometry() # full=True for the whole machine
67
+ mesh = build_mesh(geometry, size=1.0) # needs Gmsh; smaller size, finer mesh
68
+ print(len(mesh.nodes), len(mesh.triangles))
69
+
70
+ plot_mesh(mesh, geometry, "motor.png")
71
+ ```
72
+
73
+ A longer example that also prints the winding layout is in [examples/mesh_a_design.py](https://github.com/pole-craft/pole-craft/blob/main/examples/mesh_a_design.py). The Python interface may change between 0.0.x versions.
74
+
75
+ ## Roadmap
76
+
77
+ - [x] Parametric geometry and meshing for QDD motors (outer rotor; inner rotor to follow)
78
+ - [ ] 2D field solver with saturated steel and permanent magnets
79
+ - [ ] Rotation: cogging torque, back-EMF, torque ripple
80
+ - [ ] Material and winding library
81
+ - [ ] Losses, torque-speed curve and efficiency map
82
+ - [ ] Parallel and GPU-accelerated design sweeps
83
+ - [ ] Validation against FEMM and measured motors
84
+ - [ ] Gear module for actuator-level results
85
+ - [ ] 3D verification
86
+
87
+ Changes in each release are listed in the [changelog](https://github.com/pole-craft/pole-craft/blob/main/CHANGELOG.md).
88
+
89
+ ## Built with
90
+
91
+ Python, [Gmsh](https://gmsh.info) for meshing, and [FEMM](https://www.femm.info) as an independent reference for validation.
92
+
93
+ ## Development setup and running the tests
94
+
95
+ Clone the repository, then install it in a virtual environment together with the test tools:
96
+
97
+ ```
98
+ git clone https://github.com/pole-craft/pole-craft.git
99
+ cd pole-craft
100
+ python -m venv .venv
101
+ .venv\Scripts\activate # Linux/macOS: source .venv/bin/activate
102
+ pip install -e ".[dev,mesh]"
103
+ pytest
104
+ ```
105
+
106
+ Without the `mesh` extra everything except meshing works, and the meshing tests are skipped.
107
+
108
+ ## Contributing
109
+
110
+ The project is just starting. Ideas, questions, bug reports and motor data for validation are welcome: please [open an issue](https://github.com/pole-craft/pole-craft/issues).
111
+
112
+ ## License
113
+
114
+ Apache License 2.0. See [LICENSE](https://github.com/pole-craft/pole-craft/blob/main/LICENSE).
@@ -0,0 +1,51 @@
1
+ # 12-slot, 10-pole outer-rotor surface-magnet motor, 50 mm outer diameter.
2
+ #
3
+ # The dimensions are placeholders typical of a small motor of this class, not
4
+ # a measured or optimised design. Lengths are in millimetres.
5
+
6
+ format_version: 1
7
+ type: qdd_outer
8
+ slots: 12
9
+ poles: 10
10
+
11
+ # Cross-section, from the outside in. The bore comes out at 19.2 mm diameter.
12
+ geometry:
13
+ air_gap_mm: 0.5
14
+ rotor:
15
+ outer_diameter_mm: 50
16
+ yoke_thickness_mm: 3.5 # back iron behind the magnets
17
+ magnet:
18
+ thickness_mm: 2.0
19
+ arc_fraction: 0.85 # magnet angle / pole angle
20
+ magnetisation: parallel # parallel | radial
21
+ stator:
22
+ tooth_width_mm: 5.0 # parallel-sided teeth
23
+ slot_opening_mm: 2.0
24
+ tooth_tip_height_mm: 0.6
25
+ tooth_tip_taper_mm: 0.8
26
+ slot_depth_mm: 5.0
27
+ yoke_thickness_mm: 3.0
28
+
29
+ # Lengthwise data. The 2D solve uses it only in correction formulas.
30
+ axial:
31
+ stack_length_mm: 10
32
+ magnet_overhang_mm: 0 # per end
33
+ skew_deg: 0
34
+ end_winding_overhang_mm: null # per end; null = estimate from the slot geometry
35
+
36
+ magnet:
37
+ material: N42SH
38
+ temperature_C: 80
39
+
40
+ winding:
41
+ wire_diameter_mm: 0.4 # bare copper
42
+ turns_per_coil: 20
43
+ parallel_strands: 1
44
+ conductor: copper
45
+ connection: star # star | delta
46
+ temperature_C: 100
47
+
48
+ steel:
49
+ stator: M270-35A
50
+ rotor: M270-35A
51
+ stacking_factor: 0.95
@@ -0,0 +1,51 @@
1
+ # 24-slot, 28-pole outer-rotor surface-magnet motor, 70 mm outer diameter.
2
+ #
3
+ # The dimensions are placeholders typical of a motor of this class, not a
4
+ # measured or optimised design. Lengths are in millimetres.
5
+
6
+ format_version: 1
7
+ type: qdd_outer
8
+ slots: 24
9
+ poles: 28
10
+
11
+ # Cross-section, from the outside in. The bore comes out at 34.4 mm diameter.
12
+ geometry:
13
+ air_gap_mm: 0.6
14
+ rotor:
15
+ outer_diameter_mm: 70
16
+ yoke_thickness_mm: 2.5 # back iron behind the magnets
17
+ magnet:
18
+ thickness_mm: 2.5
19
+ arc_fraction: 0.85 # magnet angle / pole angle
20
+ magnetisation: parallel # parallel | radial
21
+ stator:
22
+ tooth_width_mm: 3.4 # parallel-sided teeth
23
+ slot_opening_mm: 1.5
24
+ tooth_tip_height_mm: 0.6
25
+ tooth_tip_taper_mm: 0.6
26
+ slot_depth_mm: 8.0
27
+ yoke_thickness_mm: 3.0
28
+
29
+ # Lengthwise data. The 2D solve uses it only in correction formulas.
30
+ axial:
31
+ stack_length_mm: 12
32
+ magnet_overhang_mm: 0 # per end
33
+ skew_deg: 0
34
+ end_winding_overhang_mm: null # per end; null = estimate from the slot geometry
35
+
36
+ magnet:
37
+ material: N42SH
38
+ temperature_C: 80
39
+
40
+ winding:
41
+ wire_diameter_mm: 0.5 # bare copper
42
+ turns_per_coil: 20
43
+ parallel_strands: 1
44
+ conductor: copper
45
+ connection: star # star | delta
46
+ temperature_C: 100
47
+
48
+ steel:
49
+ stator: M270-35A
50
+ rotor: M270-35A
51
+ stacking_factor: 0.95
@@ -0,0 +1,53 @@
1
+ # Reference design: 36-slot, 42-pole outer-rotor surface-magnet motor,
2
+ # about 90 mm outer diameter.
3
+ #
4
+ # The dimensions are placeholders typical of a motor of this class, not a
5
+ # measured or optimised design. Lengths are in millimetres.
6
+
7
+ format_version: 1
8
+ type: qdd_outer
9
+ slots: 36
10
+ poles: 42
11
+
12
+ # Cross-section, from the outside in. Every radius follows from the outer
13
+ # diameter and the thicknesses below; the bore comes out at 52 mm diameter.
14
+ geometry:
15
+ air_gap_mm: 0.6
16
+ rotor:
17
+ outer_diameter_mm: 90
18
+ yoke_thickness_mm: 2.5 # back iron behind the magnets
19
+ magnet:
20
+ thickness_mm: 2.5
21
+ arc_fraction: 0.85 # magnet angle / pole angle
22
+ magnetisation: parallel # parallel | radial
23
+ stator:
24
+ tooth_width_mm: 3.0 # parallel-sided teeth
25
+ slot_opening_mm: 1.5
26
+ tooth_tip_height_mm: 0.6
27
+ tooth_tip_taper_mm: 0.6
28
+ slot_depth_mm: 9.0
29
+ yoke_thickness_mm: 3.2
30
+
31
+ # Lengthwise data. The 2D solve uses it only in correction formulas.
32
+ axial:
33
+ stack_length_mm: 12
34
+ magnet_overhang_mm: 0 # per end
35
+ skew_deg: 0
36
+ end_winding_overhang_mm: null # per end; null = estimate from the slot geometry
37
+
38
+ magnet:
39
+ material: N42SH
40
+ temperature_C: 80
41
+
42
+ winding:
43
+ wire_diameter_mm: 0.5 # bare copper
44
+ turns_per_coil: 20
45
+ parallel_strands: 1
46
+ conductor: copper
47
+ connection: star # star | delta
48
+ temperature_C: 100
49
+
50
+ steel:
51
+ stator: M270-35A
52
+ rotor: M270-35A
53
+ stacking_factor: 0.95