femagtools 1.5.7__py3-none-any.whl → 1.6.0__py3-none-any.whl
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.
- femagtools/__init__.py +1 -1
- femagtools/bch.py +14 -1
- femagtools/dxfsl/area.py +2 -3
- femagtools/dxfsl/converter.py +10 -2
- femagtools/dxfsl/fslrenderer.py +1 -2
- femagtools/dxfsl/functions.py +24 -27
- femagtools/dxfsl/geom.py +116 -80
- femagtools/dxfsl/machine.py +16 -7
- femagtools/dxfsl/plotrenderer.py +2 -2
- femagtools/dxfsl/shape.py +68 -17
- femagtools/femag.py +21 -3
- femagtools/fsl.py +14 -2
- femagtools/machine/__init__.py +13 -33
- femagtools/machine/afpm.py +22 -21
- femagtools/machine/pm.py +22 -21
- femagtools/machine/utils.py +112 -58
- femagtools/mcv.py +27 -1
- femagtools/model.py +4 -2
- femagtools/nc.py +7 -0
- femagtools/opt.py +1 -1
- femagtools/parstudy.py +5 -2
- femagtools/plot/__init__.py +1 -0
- femagtools/plot/bch.py +2 -0
- femagtools/plot/fieldlines.py +37 -0
- femagtools/templates/basic_modpar.mako +8 -0
- femagtools/templates/bertotti.mako +40 -0
- femagtools/templates/modified_steinmetz.mako +39 -0
- femagtools/ts.py +1 -1
- femagtools/utils.py +7 -1
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/METADATA +1 -1
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/RECORD +38 -35
- tests/test_bchreader.py +12 -1
- tests/test_femag.py +1 -1
- tests/test_fsl.py +1 -1
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/LICENSE +0 -0
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/WHEEL +0 -0
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/entry_points.txt +0 -0
- {femagtools-1.5.7.dist-info → femagtools-1.6.0.dist-info}/top_level.txt +0 -0
femagtools/dxfsl/geom.py
CHANGED
@@ -16,7 +16,8 @@ import logging
|
|
16
16
|
import sys
|
17
17
|
from .corner import Corner
|
18
18
|
from .area import Area
|
19
|
-
from .shape import Element, Shape, Circle, Arc, Line, Point
|
19
|
+
from .shape import Element, Shape, Circle, Arc, Line, Point
|
20
|
+
from .shape import is_Circle, is_Arc, is_Line
|
20
21
|
from .machine import Machine
|
21
22
|
from .functions import less_equal, less, greater, greater_equal
|
22
23
|
from .functions import distance, alpha_line, alpha_points, alpha_angle
|
@@ -112,10 +113,17 @@ def add_or_split(el, x, out_elements, rtol, atol):
|
|
112
113
|
out_elements[x] = None
|
113
114
|
split_el = el.split(points, rtol, atol)
|
114
115
|
return split_el
|
115
|
-
|
116
116
|
return []
|
117
117
|
|
118
118
|
|
119
|
+
def add_element(geom, e, rtol, atol):
|
120
|
+
n = geom.find_nodes(e.start(), e.end())
|
121
|
+
try:
|
122
|
+
add_or_join(geom, n[0], n[1], e, rtol, atol)
|
123
|
+
except Exception as ex:
|
124
|
+
logger.warn("EXCEPTION in add_element: %s", ex)
|
125
|
+
|
126
|
+
|
119
127
|
def add_or_join(geom, n1, n2, entity, rtol, atol):
|
120
128
|
""" adds a new entity to graph or joins entity with existing
|
121
129
|
geom: Geometry
|
@@ -125,7 +133,50 @@ def add_or_join(geom, n1, n2, entity, rtol, atol):
|
|
125
133
|
if n1 == n2:
|
126
134
|
logger.debug(
|
127
135
|
"Tiny element with same node on both sides ignored: %s", n1)
|
136
|
+
logger.debug(
|
137
|
+
" -- element: %s", entity)
|
138
|
+
|
128
139
|
else:
|
140
|
+
e = geom.get_edge_element(n1, n2)
|
141
|
+
if e:
|
142
|
+
logger.debug("Duplicate connection: %s <--> %s", n1, n2)
|
143
|
+
if is_Line(e):
|
144
|
+
if is_Line(entity):
|
145
|
+
logger.debug("add_or_join(): Duplicate Lines ignored")
|
146
|
+
return # its ok
|
147
|
+
|
148
|
+
if is_Arc(e):
|
149
|
+
if is_Arc(entity):
|
150
|
+
if points_are_close(e.center, entity.center, rtol=rtol, atol=atol):
|
151
|
+
if points_are_close(e.p1, entity.p1):
|
152
|
+
logger.debug("add_or_join(): Duplicate Arcs ignored")
|
153
|
+
return # its ok
|
154
|
+
|
155
|
+
if is_Circle(entity):
|
156
|
+
if is_Circle(e):
|
157
|
+
logger.debug("add_or_join(): Duplicate Circle ignored")
|
158
|
+
return # its ok
|
159
|
+
|
160
|
+
if is_Circle(entity) or is_Circle(e):
|
161
|
+
e1, e2 = entity.cut_into_halves()
|
162
|
+
logger.debug("===== add_or_join(): Element near circle is cut into halves =====")
|
163
|
+
add_element(geom, e1, rtol, atol)
|
164
|
+
add_element(geom, e2, rtol, atol)
|
165
|
+
return # halves installed
|
166
|
+
|
167
|
+
m1 = e.center_of_connection()
|
168
|
+
m2 = entity.center_of_connection()
|
169
|
+
logger.debug("midpoints: %s -- %s", m1, m2)
|
170
|
+
if points_are_close(m1, m2, rtol, 1e-2):
|
171
|
+
logger.debug("Elements are close together")
|
172
|
+
return # ok
|
173
|
+
|
174
|
+
e1, e2 = entity.cut_into_halves()
|
175
|
+
logger.debug("===== add_or_join(): cut into halves =====")
|
176
|
+
add_element(geom, e1, rtol, atol)
|
177
|
+
add_element(geom, e2, rtol, atol)
|
178
|
+
return # halves installed
|
179
|
+
|
129
180
|
geom.add_edge(n1, n2, entity)
|
130
181
|
|
131
182
|
|
@@ -221,7 +272,7 @@ def polylines(entity, lf, rf, xoff=0.0, yoff=0.0, rotation=0.0):
|
|
221
272
|
p1 = points[i]
|
222
273
|
try:
|
223
274
|
p2 = points[i+1]
|
224
|
-
except Exception
|
275
|
+
except Exception:
|
225
276
|
if not entity.is_closed:
|
226
277
|
break
|
227
278
|
p2 = points[0]
|
@@ -276,6 +327,7 @@ def lw_polyline(entity, lf, xoff=0.0, yoff=0.0, rotation=0.0):
|
|
276
327
|
xoff=xoff, yoff=yoff,
|
277
328
|
rotation=rotation)
|
278
329
|
|
330
|
+
|
279
331
|
def ellipse(entity, lf, xoff=0.0, yoff=0.0, rotation=0.0):
|
280
332
|
w = np.linalg.norm(entity.major_axis) * 2
|
281
333
|
h = entity.ratio * w
|
@@ -294,7 +346,7 @@ def ellipse(entity, lf, xoff=0.0, yoff=0.0, rotation=0.0):
|
|
294
346
|
x, y = np.dot(R, [x, y])
|
295
347
|
x += entity.center[0]
|
296
348
|
y += entity.center[1]
|
297
|
-
points = np.array((x,y)).T
|
349
|
+
points = np.array((x, y)).T
|
298
350
|
p1 = points[0]
|
299
351
|
for p2 in points[1:]:
|
300
352
|
yield Line(Element(start=p1, end=p2), lf,
|
@@ -488,7 +540,7 @@ def dxfshapes(dxffile, mindist=0.01, layers=[]):
|
|
488
540
|
# dwg.header['$LUNITS']
|
489
541
|
lf = 1
|
490
542
|
if dwg.header.get('$LUNITS', 0) == 1:
|
491
|
-
#conv = [1, 2.54e-2, 10.12, 633.0, 1e-3, 1e-2, 1]
|
543
|
+
# conv = [1, 2.54e-2, 10.12, 633.0, 1e-3, 1e-2, 1]
|
492
544
|
lf = 2.54e3
|
493
545
|
|
494
546
|
rf = np.pi/180
|
@@ -919,11 +971,13 @@ class Geometry(object):
|
|
919
971
|
|
920
972
|
def add_edge(self, n1, n2, entity):
|
921
973
|
if points_are_close(n1, n2):
|
922
|
-
logger.debug("WARNING in add_edge(): Points
|
923
|
-
|
974
|
+
logger.debug("WARNING in add_edge(): Points of %s are close together",
|
975
|
+
entity.classname())
|
976
|
+
logger.debug(" n1 = %s, n2 = %s", n1, n2)
|
977
|
+
logger.debug(" p1 = %s, p2 = %s", entity.p1, entity.p2)
|
924
978
|
|
925
979
|
entity.set_nodes(n1, n2)
|
926
|
-
logger.debug("add_edge %s - %s", n1, n2)
|
980
|
+
logger.debug("add_edge %s - %s (%s)", n1, n2, entity.classname())
|
927
981
|
self.g.add_edge(n1, n2, object=entity)
|
928
982
|
|
929
983
|
def get_edge(self, eg):
|
@@ -984,7 +1038,6 @@ class Geometry(object):
|
|
984
1038
|
self.rtol,
|
985
1039
|
self.atol)
|
986
1040
|
|
987
|
-
|
988
1041
|
def elements(self, type):
|
989
1042
|
"""return lists of objects"""
|
990
1043
|
return [e[2]['object'] for e in self.g.edges(data=True)
|
@@ -1004,19 +1057,19 @@ class Geometry(object):
|
|
1004
1057
|
rem_lines = []
|
1005
1058
|
for p1, p2, data in [e for e in self.g.edges(data=True)
|
1006
1059
|
if isinstance(e[2]['object'], Line)]:
|
1007
|
-
|
1008
|
-
if
|
1009
|
-
p =
|
1010
|
-
new_lines +=
|
1060
|
+
ln = data['object']
|
1061
|
+
if ln.length() > length:
|
1062
|
+
p = ln.center_of_connection()
|
1063
|
+
new_lines += ln.split([p])
|
1011
1064
|
rem_lines.append((p1, p2))
|
1012
1065
|
|
1013
1066
|
for p1, p2 in rem_lines:
|
1014
1067
|
self._remove_edge(p1, p2)
|
1015
|
-
for
|
1068
|
+
for new_ln in new_lines:
|
1016
1069
|
add_or_join(self,
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1070
|
+
new_ln.node1(ndec),
|
1071
|
+
new_ln.node2(ndec),
|
1072
|
+
new_ln,
|
1020
1073
|
self.rtol,
|
1021
1074
|
self.atol)
|
1022
1075
|
|
@@ -1157,7 +1210,7 @@ class Geometry(object):
|
|
1157
1210
|
rtol = 1e-4
|
1158
1211
|
atol = 1e-4
|
1159
1212
|
|
1160
|
-
logger.debug("repair_hull_line(center=%s, angle=%s)", center, angle)
|
1213
|
+
logger.debug("begin repair_hull_line(center=%s, angle=%s)", center, angle)
|
1161
1214
|
|
1162
1215
|
if len(corners) < 2:
|
1163
1216
|
# no hull without more than 1 corners
|
@@ -1182,6 +1235,7 @@ class Geometry(object):
|
|
1182
1235
|
# Both points are in the hull
|
1183
1236
|
el = data['object']
|
1184
1237
|
if isinstance(el, Line):
|
1238
|
+
logger.debug("remove Line: %s <> %s", p1, p2)
|
1185
1239
|
self._remove_edge(p1, p2)
|
1186
1240
|
else:
|
1187
1241
|
[corner.set_keep_node() for corner in clist_p1]
|
@@ -1217,6 +1271,8 @@ class Geometry(object):
|
|
1217
1271
|
|
1218
1272
|
# Rebuild Corner-list after correction
|
1219
1273
|
corners = self.get_corner_list(center, angle, rtol, atol)
|
1274
|
+
for c in corners:
|
1275
|
+
logger.debug("Correct Corner: %s", c)
|
1220
1276
|
|
1221
1277
|
if with_center:
|
1222
1278
|
c_corner = Corner(center, tuple(center))
|
@@ -1255,8 +1311,8 @@ class Geometry(object):
|
|
1255
1311
|
|
1256
1312
|
corners = self.get_corner_list(self.center, angle)
|
1257
1313
|
assert(corners)
|
1258
|
-
c_min = Corner(center, point(self.center, self.min_radius, angle, ndec))
|
1259
|
-
c_max = Corner(center, point(self.center, self.max_radius, angle, ndec))
|
1314
|
+
c_min = Corner(self.center, point(self.center, self.min_radius, angle, ndec))
|
1315
|
+
c_max = Corner(self.center, point(self.center, self.max_radius, angle, ndec))
|
1260
1316
|
|
1261
1317
|
c_first = corners[0]
|
1262
1318
|
if not c_min.is_same_corner(c_first):
|
@@ -1276,7 +1332,7 @@ class Geometry(object):
|
|
1276
1332
|
|
1277
1333
|
def complete_hull_arc(self, startangle, startcorner,
|
1278
1334
|
endangle, endcorner, radius):
|
1279
|
-
nodes = self.radius_nodes(center, radius, 1e-04, 1e-04)
|
1335
|
+
nodes = self.radius_nodes(self.center, radius, 1e-04, 1e-04)
|
1280
1336
|
|
1281
1337
|
if startcorner.is_new_point:
|
1282
1338
|
start_p = startcorner.point()
|
@@ -1284,9 +1340,9 @@ class Geometry(object):
|
|
1284
1340
|
if not points_are_close(start_p, n)]
|
1285
1341
|
nodes_sorted.sort()
|
1286
1342
|
p = nodes_sorted[0][1]
|
1287
|
-
angle_p = alpha_line(center, p)
|
1343
|
+
angle_p = alpha_line(self.center, p)
|
1288
1344
|
self.add_edge(start_p, p, Arc(
|
1289
|
-
Element(center=center, radius=radius,
|
1345
|
+
Element(center=self.center, radius=radius,
|
1290
1346
|
start_angle=startangle*180/np.pi,
|
1291
1347
|
end_angle=angle_p*180/np.pi)))
|
1292
1348
|
|
@@ -1296,9 +1352,9 @@ class Geometry(object):
|
|
1296
1352
|
if not points_are_close(end_p, n)]
|
1297
1353
|
inx = len(nodes_sorted)-1
|
1298
1354
|
p = nodes_sorted[inx][1]
|
1299
|
-
angle_p = alpha_line(center, p)
|
1355
|
+
angle_p = alpha_line(self.center, p)
|
1300
1356
|
self.add_edge(p, end_p, Arc(
|
1301
|
-
Element(center=center, radius=radius,
|
1357
|
+
Element(center=self.center, radius=radius,
|
1302
1358
|
start_angle=angle_p*180/np.pi,
|
1303
1359
|
end_angle=endangle*180/np.pi)))
|
1304
1360
|
|
@@ -1693,7 +1749,7 @@ class Geometry(object):
|
|
1693
1749
|
def the_point_is_inside(self, p, rtol=1e-04, atol=1e-04):
|
1694
1750
|
for e in self.elements(Shape):
|
1695
1751
|
if e.is_point_inside(p, rtol=rtol, atol=atol, include_end=True):
|
1696
|
-
#logger.info("point %s is inside %s", p, e)
|
1752
|
+
# logger.info("point %s is inside %s", p, e)
|
1697
1753
|
return True
|
1698
1754
|
return False
|
1699
1755
|
|
@@ -1824,13 +1880,14 @@ class Geometry(object):
|
|
1824
1880
|
alpha_start = alpha_line(e.center, e.p1)
|
1825
1881
|
for x, p2 in sorted_points:
|
1826
1882
|
alpha_end = alpha_line(e.center, p2)
|
1827
|
-
pm = middle_point_of_arc(e.center, e.radius, p1, p2, rtol=rtol)
|
1883
|
+
pm = middle_point_of_arc(e.center, e.radius, p1, p2, rtol=rtol, atol=atol)
|
1828
1884
|
if is_point_inside_region(pm, center,
|
1829
|
-
inner_circle.radius,
|
1830
|
-
|
1831
|
-
|
1885
|
+
inner_circle.radius,
|
1886
|
+
outer_circle.radius,
|
1887
|
+
start_angle, end_angle,
|
1888
|
+
rtol=rtol, atol=atol):
|
1832
1889
|
if not (len(points) > 1 and
|
1833
|
-
points_are_close(p1, p2,
|
1890
|
+
points_are_close(p1, p2, rtol=rtol, atol=atol)):
|
1834
1891
|
if len(points) == 1 and e.rtheta is not None:
|
1835
1892
|
a = Arc(Element(center=e.center,
|
1836
1893
|
radius=e.radius,
|
@@ -1846,7 +1903,6 @@ class Geometry(object):
|
|
1846
1903
|
radius=e.radius,
|
1847
1904
|
start_angle=alpha_start*180/np.pi,
|
1848
1905
|
end_angle=alpha_end*180/np.pi))
|
1849
|
-
|
1850
1906
|
new_elements.append(a)
|
1851
1907
|
alpha_start = alpha_end
|
1852
1908
|
p1 = p2
|
@@ -1862,7 +1918,6 @@ class Geometry(object):
|
|
1862
1918
|
durch die Parameter definierten Teilkreisfläche befinden.
|
1863
1919
|
"""
|
1864
1920
|
assert(isinstance(e, Circle))
|
1865
|
-
|
1866
1921
|
if is_same_angle(start_angle, end_angle):
|
1867
1922
|
pts_inner = inner_circle.intersect_circle(e,
|
1868
1923
|
rtol,
|
@@ -1912,47 +1967,24 @@ class Geometry(object):
|
|
1912
1967
|
sorted_points.sort()
|
1913
1968
|
|
1914
1969
|
x, px = sorted_points[0]
|
1915
|
-
|
1970
|
+
sorted_points.append((x, px))
|
1916
1971
|
p1 = px
|
1917
1972
|
alpha_start = alpha_line(e.center, p1)
|
1918
|
-
for x, p2 in sorted_points:
|
1973
|
+
for x, p2 in sorted_points[1:]:
|
1919
1974
|
alpha_end = alpha_line(e.center, p2)
|
1920
|
-
pm = middle_point_of_arc(e.center, e.radius, p1, p2, rtol=rtol)
|
1975
|
+
pm = middle_point_of_arc(e.center, e.radius, p1, p2, rtol=rtol, atol=atol)
|
1921
1976
|
if is_point_inside_region(pm, center,
|
1922
1977
|
inner_circle.radius,
|
1923
1978
|
outer_circle.radius,
|
1924
|
-
start_angle, end_angle
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
radius=e.radius,
|
1932
|
-
start_angle=alpha_middle*180/np.pi,
|
1933
|
-
end_angle=alpha_end*180/np.pi))
|
1934
|
-
new_elements.append(arc1)
|
1935
|
-
new_elements.append(arc2)
|
1936
|
-
|
1979
|
+
start_angle, end_angle,
|
1980
|
+
rtol=rtol, atol=atol):
|
1981
|
+
a = Arc(Element(center=e.center,
|
1982
|
+
radius=e.radius,
|
1983
|
+
start_angle=alpha_start*180/np.pi,
|
1984
|
+
end_angle=alpha_end*180/np.pi))
|
1985
|
+
new_elements.append(a)
|
1937
1986
|
alpha_start = alpha_end
|
1938
1987
|
p1 = p2
|
1939
|
-
|
1940
|
-
alpha_end = alpha_line(e.center, px)
|
1941
|
-
pm = middle_point_of_arc(e.center, e.radius, p1, px, rtol=rtol)
|
1942
|
-
if is_point_inside_region(pm, center,
|
1943
|
-
inner_circle.radius, outer_circle.radius,
|
1944
|
-
start_angle, end_angle):
|
1945
|
-
alpha_middle = middle_angle(alpha_start, alpha_end)
|
1946
|
-
arc1 = Arc(Element(center=e.center,
|
1947
|
-
radius=e.radius,
|
1948
|
-
start_angle=alpha_start*180/np.pi,
|
1949
|
-
end_angle=alpha_middle*180/np.pi))
|
1950
|
-
arc2 = Arc(Element(center=e.center,
|
1951
|
-
radius=e.radius,
|
1952
|
-
start_angle=alpha_middle*180/np.pi,
|
1953
|
-
end_angle=alpha_end*180/np.pi))
|
1954
|
-
new_elements.append(arc1)
|
1955
|
-
new_elements.append(arc2)
|
1956
1988
|
return new_elements
|
1957
1989
|
|
1958
1990
|
def copy_shape(self,
|
@@ -1970,12 +2002,15 @@ class Geometry(object):
|
|
1970
2002
|
""" Die Funktion kopiert die Teile von Shape-Objekten, welche sich in
|
1971
2003
|
der durch die Parameter definierten Teilkreisfläche befinden.
|
1972
2004
|
"""
|
1973
|
-
logger.debug('copy_shape(%s, %s)', startangle, endangle)
|
2005
|
+
logger.debug('begin copy_shape(%s, %s)', startangle, endangle)
|
1974
2006
|
|
1975
2007
|
if not rtol:
|
1976
2008
|
rtol = self.rtol
|
1977
2009
|
if not atol:
|
1978
2010
|
atol = self.atol
|
2011
|
+
rtol = 1e-5
|
2012
|
+
atol = 1e-4
|
2013
|
+
logger.debug(' -> rtol=%s, atol=%s', rtol, atol)
|
1979
2014
|
|
1980
2015
|
if is_same_angle(startangle, endangle):
|
1981
2016
|
start_line = Line(
|
@@ -2028,7 +2063,6 @@ class Geometry(object):
|
|
2028
2063
|
atol=atol,
|
2029
2064
|
points_inner=pts_inner,
|
2030
2065
|
points_outer=pts_outer)
|
2031
|
-
|
2032
2066
|
elif isinstance(e, Circle):
|
2033
2067
|
new_elements += self.copy_circle(
|
2034
2068
|
self.center, radius, startangle, endangle,
|
@@ -2074,8 +2108,8 @@ class Geometry(object):
|
|
2074
2108
|
logger.debug('new Geometry with split')
|
2075
2109
|
geom = Geometry(new_elements,
|
2076
2110
|
center=center,
|
2077
|
-
rtol=
|
2078
|
-
atol=
|
2111
|
+
rtol=self.rtol,
|
2112
|
+
atol=self.atol,
|
2079
2113
|
is_inner=self.is_inner,
|
2080
2114
|
is_outer=self.is_outer,
|
2081
2115
|
split=split)
|
@@ -2090,7 +2124,7 @@ class Geometry(object):
|
|
2090
2124
|
if delete_appendices:
|
2091
2125
|
geom.delete_all_appendices()
|
2092
2126
|
geom.set_center(self.center)
|
2093
|
-
|
2127
|
+
logger.debug('end copy_shape')
|
2094
2128
|
return geom
|
2095
2129
|
|
2096
2130
|
def copy_all_elements(self, alpha):
|
@@ -2450,7 +2484,7 @@ class Geometry(object):
|
|
2450
2484
|
elif np.isclose(width*2, height, self.rtol, self.atol):
|
2451
2485
|
radius = width
|
2452
2486
|
logger.info("check for half machine")
|
2453
|
-
set_center([mm[1], mm[3]-width])
|
2487
|
+
self.set_center([mm[1], mm[3]-width])
|
2454
2488
|
if self.check_hull(radius, mm[1], None, self.rtol, atol):
|
2455
2489
|
logger.info(" - it is a half")
|
2456
2490
|
return Machine(self, radius, np.pi/2.0, -np.pi/2.0)
|
@@ -2922,7 +2956,7 @@ class Geometry(object):
|
|
2922
2956
|
else:
|
2923
2957
|
logger.warning(" %s already removed ?!", id)
|
2924
2958
|
|
2925
|
-
#for area in self.list_of_areas():
|
2959
|
+
# for area in self.list_of_areas():
|
2926
2960
|
# logger.info("Inside %s is:", area.identifier())
|
2927
2961
|
# for id in area.areas_inside:
|
2928
2962
|
# logger.info(" ++ %s", id)
|
@@ -3189,27 +3223,29 @@ class Geometry(object):
|
|
3189
3223
|
if a.is_point_inside(p):
|
3190
3224
|
return a.id
|
3191
3225
|
return 0
|
3226
|
+
|
3192
3227
|
# -------------------------
|
3193
3228
|
def connection_thru_main_area(pts):
|
3194
3229
|
if len(pts) < 3:
|
3195
|
-
return True #ok
|
3230
|
+
return True # ok
|
3196
3231
|
if len(areas_inside) < 2:
|
3197
|
-
return True #ok
|
3232
|
+
return True # ok
|
3198
3233
|
|
3199
3234
|
id = id_of_inside_area(pts[0])
|
3200
3235
|
if id == 0: # strange
|
3201
|
-
return False #bad
|
3236
|
+
return False # bad
|
3202
3237
|
|
3203
3238
|
next_id = id_of_inside_area(pts[1])
|
3204
3239
|
if next_id == 0:
|
3205
|
-
return True #ok
|
3240
|
+
return True # ok
|
3206
3241
|
|
3207
3242
|
id = next_id
|
3208
3243
|
next_id = id_of_inside_area(pts[2])
|
3209
3244
|
if id == next_id: # thru inside-area
|
3210
|
-
return True #ok
|
3245
|
+
return True # ok
|
3211
3246
|
|
3212
3247
|
return False
|
3248
|
+
|
3213
3249
|
# ----------
|
3214
3250
|
def takeSecond(elem):
|
3215
3251
|
return elem[1]
|
@@ -3243,7 +3279,7 @@ class Geometry(object):
|
|
3243
3279
|
color=aux_color,
|
3244
3280
|
linestyle=aux_linestyle)
|
3245
3281
|
arc.set_attribute('iron_sep')
|
3246
|
-
|
3282
|
+
self.split_and_get_intersect_points(arc)
|
3247
3283
|
n = self.find_nodes(pts[0], pts[1])
|
3248
3284
|
self.add_edge(n[0], n[1], arc)
|
3249
3285
|
|
@@ -3745,7 +3781,7 @@ class Geometry(object):
|
|
3745
3781
|
try:
|
3746
3782
|
self._remove_edge(n0, n1)
|
3747
3783
|
self.add_edge(nn, n1, el)
|
3748
|
-
except Exception
|
3784
|
+
except Exception:
|
3749
3785
|
logger.debug("delete of %s - %s failed", n0, n)
|
3750
3786
|
logger.debug("Element %s", el)
|
3751
3787
|
return c
|
femagtools/dxfsl/machine.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
from __future__ import print_function
|
6
6
|
import numpy as np
|
7
7
|
import logging
|
8
|
-
from .shape import Element, Circle, Arc, Line
|
8
|
+
from .shape import Element, Circle, Arc, Line
|
9
9
|
from .corner import Corner
|
10
10
|
from .functions import point, points_are_close, distance
|
11
11
|
from .functions import alpha_angle, normalise_angle, middle_angle, third_angle
|
@@ -14,6 +14,7 @@ from .functions import within_interval, part_of_circle
|
|
14
14
|
from .functions import less, less_equal, greater, greater_equal
|
15
15
|
logger = logging.getLogger('femagtools.geom')
|
16
16
|
|
17
|
+
|
17
18
|
#############################
|
18
19
|
# Machine #
|
19
20
|
#############################
|
@@ -231,6 +232,7 @@ class Machine(object):
|
|
231
232
|
return clone.get_machine()
|
232
233
|
|
233
234
|
def copy_mirror(self, startangle, midangle, endangle):
|
235
|
+
logger.debug("begin of copy_mirror")
|
234
236
|
geom1 = self.geom.copy_shape(self.radius,
|
235
237
|
startangle,
|
236
238
|
midangle,
|
@@ -254,6 +256,7 @@ class Machine(object):
|
|
254
256
|
machine.mirror_geom = geom2
|
255
257
|
machine.mirror_startangle = midangle
|
256
258
|
machine.mirror_endangle = endangle
|
259
|
+
logger.debug("end of copy_mirror")
|
257
260
|
return machine
|
258
261
|
|
259
262
|
def has_mirrored_windings(self):
|
@@ -279,16 +282,16 @@ class Machine(object):
|
|
279
282
|
self.endangle += angle
|
280
283
|
|
281
284
|
def airgap(self, correct_airgap=0.0, correct_airgap2=0.0, atol=0.1):
|
282
|
-
logger.debug('locking for airgap')
|
285
|
+
logger.debug('begin airgap (locking for airgap)')
|
283
286
|
self.airgap_radius = 0.0
|
284
287
|
self.airgap2_radius = 0.0
|
285
288
|
|
286
289
|
if np.isclose(self.radius, 0.0):
|
287
|
-
logger.debug('no radius')
|
290
|
+
logger.debug('end airgap: no radius')
|
288
291
|
return False
|
289
292
|
|
290
293
|
if correct_airgap < 0:
|
291
|
-
logger.debug('no airgap')
|
294
|
+
logger.debug('end airgap: no airgap (%s)', correct_airgap)
|
292
295
|
return False # no airgap
|
293
296
|
|
294
297
|
self.airgaps = []
|
@@ -354,33 +357,39 @@ class Machine(object):
|
|
354
357
|
logger.error("No airgap with radius {} found"
|
355
358
|
.format(correct_airgap))
|
356
359
|
self.show_airgap_candidates(airgap_candidates, False)
|
360
|
+
logger.debug("end airgap: bad")
|
357
361
|
return True # bad exit
|
358
362
|
|
359
363
|
if correct_airgap2 > 0.0 and self.airgap2_radius == 0.0:
|
360
364
|
logger.error("No airgap2 with radius {} found"
|
361
365
|
.format(correct_airgap2))
|
362
366
|
self.show_airgap_candidates(airgap_candidates, False)
|
367
|
+
logger.debug("end airgap: bad")
|
363
368
|
return True # bad exit
|
364
369
|
|
365
370
|
if len(self.airgaps) == 0:
|
366
|
-
logger.debug('No airgap found')
|
371
|
+
logger.debug('end airgap: No airgap found')
|
367
372
|
return False # no airgaps found
|
368
373
|
|
369
374
|
if self.airgap_radius > 0.0:
|
375
|
+
logger.debug("end airgap: radius=%s", self.airgap_radius)
|
370
376
|
return False # correct airgap set
|
371
377
|
|
372
378
|
gaps = [c for b, c, d in airgap_candidates if b == 0]
|
373
379
|
|
374
380
|
if len(gaps) == 1: # one candidate without border intersection
|
375
381
|
self.airgap_radius = gaps[0].radius
|
382
|
+
logger.debug("end airgap: radius=%s", self.airgap_radius)
|
376
383
|
return False # ok
|
377
384
|
|
378
385
|
if len(airgap_candidates) == 1: # one candidate found
|
379
386
|
self.airgap_radius = airgap_candidates[0][1].radius
|
387
|
+
logger.debug("end airgap: radius=%s", self.airgap_radius)
|
380
388
|
return False # ok
|
381
389
|
|
382
390
|
self.airgap_radius = self.show_airgap_candidates(airgap_candidates,
|
383
391
|
True)
|
392
|
+
logger.debug("end airgap: radius=%s", self.airgap_radius)
|
384
393
|
return False # ok
|
385
394
|
|
386
395
|
def show_airgap_candidates(self, airgap_candidates, get_one):
|
@@ -451,7 +460,7 @@ class Machine(object):
|
|
451
460
|
self.geom.delete_circle((0.0, 0.0), first_dist)
|
452
461
|
|
453
462
|
def repair_hull(self):
|
454
|
-
logger.debug('repair_hull')
|
463
|
+
logger.debug('begin repair_hull(%s, %s)', self.startangle, self.endangle)
|
455
464
|
if self.is_full() and not self.has_airgap():
|
456
465
|
self.delete_center_circle()
|
457
466
|
|
@@ -468,7 +477,7 @@ class Machine(object):
|
|
468
477
|
logger.debug('end of repair_hull')
|
469
478
|
|
470
479
|
def repair_hull_geom(self, geom, startangle, endangle):
|
471
|
-
logger.debug('repair_hull_geom')
|
480
|
+
logger.debug('begin repair_hull_geom (%s, %s)', startangle, endangle)
|
472
481
|
|
473
482
|
c_corner = Corner(self.center, self.center)
|
474
483
|
start_corners = geom.get_corner_list(self.center, startangle)
|
femagtools/dxfsl/plotrenderer.py
CHANGED
@@ -287,7 +287,7 @@ class PlotRenderer(object):
|
|
287
287
|
|
288
288
|
self.ax.axis('scaled')
|
289
289
|
self.ax.set_aspect('equal')
|
290
|
-
|
290
|
+
|
291
291
|
self.ax.set_xlim(x_min, x_max)
|
292
292
|
self.ax.set_ylim(y_min, y_max)
|
293
293
|
|
@@ -360,7 +360,7 @@ class PlotRenderer(object):
|
|
360
360
|
area.render(self, 'red', with_nodes=True)
|
361
361
|
|
362
362
|
self.ax.axis('scaled')
|
363
|
-
self.ax.set_aspect('equal')
|
363
|
+
self.ax.set_aspect('equal')
|
364
364
|
pl.show()
|
365
365
|
|
366
366
|
def draw_slot(self, id, slot, ax):
|