@@ -53,6 +53,20 @@ def calculate_core_extension(area: float, radius: float, opening_width: float) -
5353
5454
5555class Core :
56+ """A magnetic core object
57+
58+ Args:
59+ centerpost_radius: The centerpost radius in mm
60+ window_width: The winding window width in mm
61+ window_height: The winding window height in mm
62+ opening_width: The core termination opening widths in mm
63+ gap: The core cap in mm
64+
65+ Attributes:
66+ centerpost_area: The area of the centerpost in square mm
67+ volume: The core volume in cubic mm
68+ """
69+
5670 def __init__ (
5771 self ,
5872 centerpost_radius : float ,
@@ -108,6 +122,9 @@ def get_coreloss(
108122 """Calculate the coreloss using steinmetz parameters
109123 """
110124
125+ # This is not tested, so raise error
126+ raise NotImplementedError
127+
111128 k , alpha , beta = ferrite .get_steinmetz_parameters (temperature )
112129
113130 Pv = k * f ** alpha * B ** beta
@@ -117,7 +134,7 @@ def get_coreloss(
117134 def to_parts (
118135 self ,
119136 freecad_path : str = "C:/Program Files/FreeCAD 0.19/bin" ,
120- tol : float = 0.1e-3 ,
137+ tol : float = 0.1 ,
121138 spacer_thickness : float = 0.0 ,
122139 ):
123140
@@ -132,97 +149,82 @@ def to_parts(
132149 import Part
133150
134151 # create the center piece
135- circle = Part .makeCircle (1e3 * self .centerpost_radius )
152+ circle = Part .makeCircle (self .centerpost_radius )
136153 wire = Part .Wire (circle )
137154 disk = Part .Face (wire )
138- centerpost = disk .extrude (cad .Vector (0 , 0 , 1e3 * self .window_height / 2 ))
155+ centerpost = disk .extrude (cad .Vector (0 , 0 , self .window_height / 2 ))
139156 to_gap = self .centerpost_radius + self .window_width / 2 - self .gap / 2
140- circle = Part .makeCircle (
141- 1e3 * to_gap , cad .Vector (0 , 0 , 1e3 * self .window_height / 2 )
142- )
157+ circle = Part .makeCircle (to_gap , cad .Vector (0 , 0 , self .window_height / 2 ))
143158 wire = Part .Wire (circle )
144159 disk = Part .Face (wire )
145- topplate = disk .extrude (cad .Vector (0 , 0 , 1e3 * self .plate_thickness ))
160+ topplate = disk .extrude (cad .Vector (0 , 0 , self .plate_thickness ))
146161 centerpiece = centerpost .fuse (topplate )
147162
148163 # create the top plate
149164 square = Part .makePlane (
150- 1e3 * self .width ,
151- 1e3 * self .width ,
152- cad .Vector (
153- - 1e3 * self .width / 2 ,
154- - 1e3 * self .width / 2 ,
155- 1e3 * self .window_height / 2 ,
156- ),
165+ self .width ,
166+ self .width ,
167+ cad .Vector (- self .width / 2 , - self .width / 2 , self .window_height / 2 ,),
157168 )
158169 circle = Part .makeCircle (
159- 1e3 * ( to_gap + self .gap ) , cad .Vector (0 , 0 , 1e3 * self .window_height / 2 )
170+ to_gap + self .gap , cad .Vector (0 , 0 , self .window_height / 2 )
160171 )
161172 wire = Part .Wire (circle )
162173 disk = Part .Face (wire )
163174 topplate_face = square .cut (disk )
164- topplate = topplate_face .extrude (cad .Vector (0 , 0 , 1e3 * self .plate_thickness ))
175+ topplate = topplate_face .extrude (cad .Vector (0 , 0 , self .plate_thickness ))
165176
166177 # create the legs
167178 opening_left_to_right = Part .makePlane (
168- 1e3 * self .width ,
169- 1e3 * self .opening_width ,
179+ self .width ,
180+ self .opening_width ,
170181 cad .Vector (
171- - 1e3 * self .width / 2 ,
172- - 1e3 * self .opening_width / 2 ,
173- 1e3 * self .window_height / 2 ,
182+ - self .width / 2 , - self .opening_width / 2 , self .window_height / 2 ,
174183 ),
175184 )
176185 opening_front_to_back = Part .makePlane (
177- 1e3 * self .opening_width ,
178- 1e3 * self .width ,
186+ self .opening_width ,
187+ self .width ,
179188 cad .Vector (
180- - 1e3 * self .opening_width / 2 ,
181- - 1e3 * self .width / 2 ,
182- 1e3 * self .window_height / 2 ,
189+ - self .opening_width / 2 , - self .width / 2 , self .window_height / 2 ,
183190 ),
184191 )
185192 circle = Part .makeCircle (
186- 1e3 * self .outerpost_radius , cad .Vector (0 , 0 , 1e3 * self .window_height / 2 ),
193+ self .outerpost_radius , cad .Vector (0 , 0 , self .window_height / 2 ),
187194 )
188195 wire = Part .Wire (circle )
189196 disk = Part .Face (wire )
190197 leg_face = square .cut (disk )
191198 legs_face = leg_face .cut (opening_left_to_right )
192199 legs_face = legs_face .cut (opening_front_to_back )
193- legs = legs_face .extrude (cad .Vector (0 , 0 , - 1e3 * self .window_height / 2 ))
200+ legs = legs_face .extrude (cad .Vector (0 , 0 , - self .window_height / 2 ))
194201
195202 # fuse the legs to the top plate
196203 topplate = topplate .fuse (legs )
197204
198205 # create the spacer
199206 circle = Part .makeCircle (
200- 1e3 * (self .outerpost_radius - tol ),
201- cad .Vector (0 , 0 , 1e3 * self .window_height / 2 ),
207+ self .outerpost_radius - tol , cad .Vector (0 , 0 , self .window_height / 2 ),
202208 )
203209 wire = Part .Wire (circle )
204210 disk = Part .Face (wire )
205211 circle = Part .makeCircle (
206- 1e3 * (self .centerpost_radius + tol ),
207- cad .Vector (0 , 0 , 1e3 * self .window_height / 2 ),
212+ self .centerpost_radius + tol , cad .Vector (0 , 0 , self .window_height / 2 ),
208213 )
209214 wire = Part .Wire (circle )
210215 cutout = Part .Face (wire )
211216 washer = disk .cut (cutout )
212- spacer = washer .extrude (cad .Vector (0 , 0 , - 1e3 * spacer_thickness ))
217+ spacer = washer .extrude (cad .Vector (0 , 0 , - spacer_thickness ))
213218 circle = Part .makeCircle (
214- 1e3 * (to_gap + self .gap - tol ),
215- cad .Vector (0 , 0 , 1e3 * self .window_height / 2 ),
219+ to_gap + self .gap - tol , cad .Vector (0 , 0 , self .window_height / 2 ),
216220 )
217221 wire = Part .Wire (circle )
218222 disk = Part .Face (wire )
219- circle = Part .makeCircle (
220- 1e3 * (to_gap + tol ), cad .Vector (0 , 0 , 1e3 * self .window_height / 2 )
221- )
223+ circle = Part .makeCircle (to_gap + tol , cad .Vector (0 , 0 , self .window_height / 2 ))
222224 wire = Part .Wire (circle )
223225 cutout = Part .Face (wire )
224226 washer = disk .cut (cutout )
225- gap_spacer = washer .extrude (cad .Vector (0 , 0 , 1e3 * self .plate_thickness ))
227+ gap_spacer = washer .extrude (cad .Vector (0 , 0 , self .plate_thickness ))
226228 spacer = spacer .fuse (gap_spacer )
227229
228230 if not self .gap :
@@ -275,9 +277,7 @@ def to_step(
275277 # # bottom_half = top_half.mirror(cad.Vector(0, 0, 0), cad.Vector(0, 0, -1))
276278 part .exportStep (filename )
277279
278- def create_pcb_cutouts (
279- self , center : Point = Point (0 , 0 ), clearance : float = 0.5e-3
280- ):
280+ def create_pcb_cutouts (self , center : Point = Point (0 , 0 ), clearance : float = 0.5 ):
281281 """Generate cutout polygons"""
282282
283283 # calculate the radius of the outer post cutouts
@@ -295,7 +295,7 @@ def create_pcb_cutouts(
295295 centerpost = Polygon (
296296 [Arc (center , self .centerpost_radius + clearance , - math .pi , math .pi )],
297297 "Edge.Cuts" ,
298- 0.1e-3 ,
298+ 0.1 ,
299299 "none" ,
300300 )
301301
@@ -308,31 +308,31 @@ def create_pcb_cutouts(
308308 corner1 = arc .end + Point (0 , cutout_extension )
309309 corner3 = arc .start + Point (cutout_extension , 0 )
310310 corner2 = Point (corner3 .x , corner1 .y )
311- leg1 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1e-3 , "none" )
311+ leg1 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1 , "none" )
312312
313313 start_angle += math .pi / 2
314314 end_angle += math .pi / 2
315315 arc = Arc (center , outer_cutout_radius , start_angle , end_angle )
316316 corner1 = arc .end + Point (- cutout_extension , 0 )
317317 corner3 = arc .start + Point (0 , cutout_extension )
318318 corner2 = Point (corner1 .x , corner3 .y )
319- leg2 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1e-3 , "none" )
319+ leg2 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1 , "none" )
320320
321321 start_angle += math .pi / 2
322322 end_angle += math .pi / 2
323323 arc = Arc (center , outer_cutout_radius , start_angle , end_angle )
324324 corner1 = arc .end + Point (0 , - cutout_extension )
325325 corner3 = arc .start + Point (- cutout_extension , 0 )
326326 corner2 = Point (corner3 .x , corner1 .y )
327- leg3 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1e-3 , "none" )
327+ leg3 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1 , "none" )
328328
329329 start_angle += math .pi / 2
330330 end_angle += math .pi / 2
331331 arc = Arc (center , outer_cutout_radius , start_angle , end_angle )
332332 corner1 = arc .end + Point (cutout_extension , 0 )
333333 corner3 = arc .start + Point (0 , - cutout_extension )
334334 corner2 = Point (corner1 .x , corner2 .y )
335- leg4 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1e-3 , "none" )
335+ leg4 = Polygon ([arc , corner1 , corner2 , corner3 ], "Edge.Cuts" , 0.1 , "none" )
336336
337337 cutouts = [centerpost , leg1 , leg2 , leg3 , leg4 ]
338338
@@ -341,5 +341,5 @@ def create_pcb_cutouts(
341341
342342if __name__ == "__main__" :
343343
344- core = Core (8.6e-3 , 6e-3 , 6e-3 , 3e- 3 , 0.5e-3 )
344+ core = Core (8.6 , 6 , 6 , 3 , 0.5 )
345345 core .to_step ("core.step" )
0 commit comments