Replies: 1 comment 2 replies
-
Hello, Thank you for your interest in pyleecan. Can you share a screenshot of the topology you are trying to simulate ? In pyleecan, the best way would be to check if you are able to define a machine that would be equivalent to your topology and if needed add the corresponding missing object. Then you will be able to use pyleecan FEA couplings. Best regards, |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have written this code in motorcad and also want to write something similar in pyleecan, to design a spider arm and halbach breadloaf magnet and a sleeve around it. How do I approach this correctly.
PS: pyleecan is new to me
import ansys.motorcad.core as pymotorcad
from ansys.motorcad.core.geometry import Arc, Coordinate, Line, Region, rt_to_xy
import ansys.motorcad.core.geometry_drawing as geometry_drawing
import math
import statistics
Connect to Motor-CAD
mc = pymotorcad.MotorCAD()
rotor = mc.get_region("Rotor")
rotor.colour = (186,85,211)
mc.set_region(rotor)
#geometry_drawing.draw_regions(rotor)
#rotor.is_closed()
duplications = 16
rotorPitchAngle = 360/duplications
originCo = Coordinate(0,0)
Create new shaft
shaft = mc.get_region("Shaft")
entity0 = shaft.entities[0]
entity1 = shaft.entities[1]
entity2 = shaft.entities[2]
entity3 = shaft.entities[3]
shaft.remove_entity(entity0)
shaft.remove_entity(entity1)
shaft.remove_entity(entity2)
shaft.remove_entity(entity3)
shaftInnerRadius = 18
shaftOuterRadius = 25.5
x1_new, y1_new = rt_to_xy(shaftInnerRadius,0)
x2_new, y2_new = rt_to_xy(shaftOuterRadius,0)
x3_new, y3_new = rt_to_xy(shaftInnerRadius,rotorPitchAngle)
x4_new, y4_new = rt_to_xy(shaftOuterRadius,rotorPitchAngle)
p1_new = Coordinate(x1_new,y1_new)
p2_new = Coordinate(x2_new,y2_new)
p3_new = Coordinate(x3_new,y3_new)
p4_new = Coordinate(x4_new,y4_new)
arc_1 = Arc(p2_new,p4_new,originCo,shaftOuterRadius)
line_1 = Line(p4_new, p3_new)
arc_2 = Arc(p1_new, p3_new, originCo,shaftInnerRadius)
line_2 = Line(p1_new,p2_new)
shaft.add_entity(arc_1)
shaft.add_entity(line_1)
shaft.add_entity(arc_2)
shaft.add_entity(line_2)
#shaft.is_closed()
#geometry_drawing.draw_regions(shaft)
mc.set_region(shaft)
Create new spider arm
spiderArm = mc.get_region("Shaft_1")
entity0 = spiderArm.entities[0]
entity1 = spiderArm.entities[1]
entity2 = spiderArm.entities[2]
entity3 = spiderArm.entities[3]
spiderArm.remove_entity(entity0)
spiderArm.remove_entity(entity1)
spiderArm.remove_entity(entity2)
spiderArm.remove_entity(entity3)
spiderArm_outerRadius = 171.263/2
x5_new, y5_new = rt_to_xy(spiderArm_outerRadius,0)
x6_new, y6_new = rt_to_xy(spiderArm_outerRadius,rotorPitchAngle)
p5_new = Coordinate(x5_new,y5_new)
p6_new = Coordinate(x6_new,y6_new)
line_3 = Line(p2_new,p5_new)
arc_3 = Arc(p5_new,p6_new,originCo,spiderArm_outerRadius)
line_4 = Line(p4_new,p6_new)
spiderArm.add_entity(arc_3)
spiderArm.add_entity(line_4)
spiderArm.add_entity(arc_1)
spiderArm.add_entity(line_3)
#spiderArm.is_closed()
#geometry_drawing.draw_regions(spiderArm)
mc.set_region(spiderArm)
Create spider rim
spiderRim = mc.get_region("Rotor")
entity0 = spiderRim.entities[0]
entity1 = spiderRim.entities[1]
entity2 = spiderRim.entities[2]
entity3 = spiderRim.entities[3]
spiderRim.remove_entity(entity0)
spiderRim.remove_entity(entity1)
spiderRim.remove_entity(entity2)
spiderRim.remove_entity(entity3)
spiderRim_transitionRadius = 181.36/2
spiderRim_centralRadius = 180/2
x7_new = spiderRim_transitionRadius
y7_new = 0
x8_new = x7_new
y8_new = (spiderRim_centralRadius/math.cos(rotorPitchAngle/2math.pi/180) - spiderRim_transitionRadius)/math.tan(rotorPitchAngle/2math.pi/180)
alpha = math.atan(y8_new/x8_new) # radians
r8 = math.sqrt(x8_new2 + y8_new2)
beta = rotorPitchAngle*math.pi/180 - alpha # radians
x9_new, y9_new = rt_to_xy(r8, beta*180/math.pi)
x10_new, y10_new = rt_to_xy(spiderRim_transitionRadius, rotorPitchAngle)
p7_new = Coordinate(x7_new,y7_new)
p8_new = Coordinate(x8_new,y8_new)
p9_new = Coordinate(x9_new,y9_new)
p10_new = Coordinate(x10_new,y10_new)
line_5 = Line(p5_new,p7_new)
line_6 = Line(p7_new,p8_new)
line_7 = Line(p8_new,p9_new)
line_8 = Line(p9_new,p10_new)
line_9 = Line(p6_new,p10_new)
spiderRim.add_entity(line_6)
spiderRim.add_entity(line_7)
spiderRim.add_entity(line_8)
spiderRim.add_entity(line_9)
spiderRim.add_entity(arc_3)
spiderRim.add_entity(line_5)
#spiderRim.is_closed()
#geometry_drawing.draw_regions(spiderRim)
mc.set_region(spiderRim)
Create magnet 2 (central magnet)
magnet2 = mc.get_region("2Magnet1")
entity0 = magnet2.entities[0]
entity1 = magnet2.entities[1]
entity2 = magnet2.entities[2]
entity3 = magnet2.entities[3]
magnet2.remove_entity(entity0)
magnet2.remove_entity(entity1)
magnet2.remove_entity(entity2)
magnet2.remove_entity(entity3)
magnetSide = statistics.mean([8.37, 8.502, 8.009, 8.242, 8.129, 8.24, 8.194, 8.159])
x12_new = x8_new + magnetSide * math.cos(rotorPitchAngle/2 * math.pi/180)
y12_new = y8_new + magnetSide * math.sin(rotorPitchAngle/2 * math.pi/180)
x13_new = x9_new + magnetSide * math.cos(rotorPitchAngle/2 * math.pi/180)
y13_new = y9_new + magnetSide * math.sin(rotorPitchAngle/2 * math.pi/180)
r12 = math.sqrt(x12_new2 + y12_new2)
p12_new = Coordinate(x12_new,y12_new)
p13_new = Coordinate(x13_new,y13_new)
arc_5 = Arc(p12_new,p13_new,originCo,r12)
line_12 = Line(p8_new,p12_new)
line_13 = Line(p9_new,p13_new)
magnet2.add_entity(arc_5)
magnet2.add_entity(line_13)
magnet2.add_entity(line_7)
magnet2.add_entity(line_12)
#magnet2.is_closed()
#geometry_drawing.draw_regions(magnet2)
mc.set_region(magnet2)
Create magnet 1 (transition magnet)
magnet1 = mc.get_region("1Magnet1")
entity0 = magnet1.entities[0]
entity1 = magnet1.entities[1]
entity2 = magnet1.entities[2]
entity3 = magnet1.entities[3]
magnet1.remove_entity(entity0)
magnet1.remove_entity(entity1)
magnet1.remove_entity(entity2)
magnet1.remove_entity(entity3)
x11_new = r12
y11_new = 0
p11_new = Coordinate(x11_new,y11_new)
line_11 = Line(p7_new,p11_new)
arc_4 = Arc(p11_new,p12_new,originCo,r12)
magnet1.add_entity(arc_4)
magnet1.add_entity(line_12)
magnet1.add_entity(line_6)
magnet1.add_entity(line_11)
#magnet1.is_closed()
#geometry_drawing.draw_regions(magnet1)
mc.set_region(magnet1)
Create magnet 3 (transition magnet)
magnet3 = mc.get_region("3Magnet1")
entity0 = magnet3.entities[0]
entity1 = magnet3.entities[1]
entity2 = magnet3.entities[2]
entity3 = magnet3.entities[3]
magnet3.remove_entity(entity0)
magnet3.remove_entity(entity1)
magnet3.remove_entity(entity2)
magnet3.remove_entity(entity3)
x14_new = r12 * math.cos(rotorPitchAnglemath.pi/180)
y14_new = r12 * math.sin(rotorPitchAnglemath.pi/180)
p14_new = Coordinate(x14_new,y14_new)
line_14 = Line(p10_new,p14_new)
arc_6 = Arc(p13_new,p14_new,originCo,r12)
magnet3.add_entity(line_13)
magnet3.add_entity(arc_6)
magnet3.add_entity(line_14)
magnet3.add_entity(line_8)
#magnet3.is_closed()
#geometry_drawing.draw_regions(magnet3)
mc.set_region(magnet3)
Create banding
banding = mc.get_region("Banding")
entity0 = banding.entities[0]
entity1 = banding.entities[1]
entity2 = banding.entities[2]
entity3 = banding.entities[3]
entity4 = banding.entities[4]
entity5 = banding.entities[5]
banding.remove_entity(entity0)
banding.remove_entity(entity1)
banding.remove_entity(entity2)
banding.remove_entity(entity3)
banding.remove_entity(entity4)
banding.remove_entity(entity5)
bandingThickness = 2.2
r15 = r12 + bandingThickness
x15_new = r15
y15_new = 0
x16_new, y16_new = rt_to_xy(r15, rotorPitchAngle)
p15_new = Coordinate(x15_new,y15_new)
p16_new = Coordinate(x16_new,y16_new)
line_15 = Line(p11_new,p15_new)
line_16 = Line(p14_new,p16_new)
arc_7 = Arc(p15_new,p16_new,originCo,r15)
banding.add_entity(arc_7)
banding.add_entity(line_16)
banding.add_entity(arc_6)
banding.add_entity(arc_5)
banding.add_entity(arc_4)
banding.add_entity(line_15)
#banding.is_closed()
#geometry_drawing.draw_regions(banding)
mc.set_region(banding)
Beta Was this translation helpful? Give feedback.
All reactions