Skip to content

Commit

Permalink
Added function to read template files
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-ansys committed Jul 27, 2023
1 parent d5cea1e commit c896c39
Showing 1 changed file with 51 additions and 240 deletions.
291 changes: 51 additions & 240 deletions src/ansys/motorcad/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,243 +51,54 @@ def rt_to_xy(radius, theta):

return x, y

def template_list():
""" Returns List of templates avaialbe with Motor-CAD
Individual template information is in dictionary format
for example
[{'Template': 'a1',
'Sector': 'Aerospace',
' Machine_Type': ' Surface PM',
'Application': ' Generator',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': ' 10,000',
'Power(kW)': ' 14',
' Cooling': 'Oil cooled',
' Drive_Type': 'Sine'},]
"""
list=[{'Template': 'a1',
'Sector': 'Aerospace',
'Machine_Type': ' Surface PM',
'Application': ' Generator',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': ' 10,000',
'Power(kW)': ' 14',
'Cooling': 'Oil cooled',
'Drive_Type': 'Sine'},
{'Template': 'a2',
'Sector': 'Aerospace',
'Machine_Type': ' Surface PM',
'Application': ' Motor',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': ' 1,500',
'Power(kW)': ' 195',
'Cooling': 'Air cooled',
'Drive_Type': 'Sine'},
{'Template': 'a3',
'Sector': 'Aerospace',
'Machine_Type': 'SPM outer rotor',
'Application': 'UAV Motor',
'Winding_Type': 'Concentrated',
'Max_Speed(rpm)': ' 3,000',
'Power(kW)': '0.120',
'Cooling': 'Air cooled',
'Drive_Type': 'Sine'},
{'Template': 'e10',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'Automotive',
'Winding_Type': 'Hairpin',
'Max_Speed(rpm)': '15000',
'Power(kW)': '200',
'Cooling': 'Oil Cooled',
'Drive_Type': 'Sine'},
{'Template': 'e1_eMobility_IPM_150kW',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'P4-Automotive',
'Winding_Type': 'Stranded distributed',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '150',
'Cooling': 'Water Jacket + Internal Air',
'Drive_Type': 'Sine'},
{'Template': 'e2_eMobility_IPM_hairpin_150kW',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'P4-Automotive',
'Winding_Type': 'Hairpin distributed',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '150',
'Cooling': 'Water Jacket + Oil Spray',
'Drive_Type': 'Sine'},
{'Template': 'e3_eMobility_WFSM_150kW',
'Sector': 'eMobility',
'Machine_Type': 'SYNC',
'Application': 'P4-Automotive',
'Winding_Type': 'Stranded distributed',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '150',
'Cooling': 'Water Jacket',
'Drive_Type': 'Sine'},
{'Template': 'e4a_EMobility_IPM',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'Automotive',
'Winding_Type': 'Hairpin',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '150',
'Cooling': 'Water Jacket + Shaft cooling',
'Drive_Type': 'Sine'},
{'Template': 'e4_eMobility_BPMOR_hairpin',
'Sector': 'eMobility',
'Machine_Type': 'BPMOR',
'Application': 'P4-Automotive',
'Winding_Type': 'Hairpin',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '200',
'Cooling': 'Axle water jacket',
'Drive_Type': 'Sine'},
{'Template': 'e5_eMobility_IM_150kW',
'Sector': 'eMobility',
'Machine_Type': 'IM',
'Application': 'P4-Automotive',
'Winding_Type': 'Stranded distributed',
'Max_Speed(rpm)': '12,000',
'Power(kW)': '150',
'Cooling': 'Water Jacket + Rotor cooling',
'Drive_Type': 'Sine'},
{'Template': 'e6_emobility_SRM_100kW',
'Sector': 'eMobility',
'Machine_Type': 'SRM',
'Application': 'Automotive',
'Winding_Type': 'Stranded Distributed',
'Max_Speed(rpm)': '10,000',
'Power(kW)': '18',
'Cooling': 'Water Jacket',
'Drive_Type': 'Square'},
{'Template': 'e7_eMobility_SPM_20kW',
'Sector': 'eMobility',
'Machine_Type': 'SPM',
'Application': 'Turbocharger',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '150,000',
'Power(kW)': '20',
'Cooling': 'Water Jacket',
'Drive_Type': 'Sine'},
{'Template': 'e8_eMobility_IPM',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'Automotive',
'Winding_Type': 'Stranded Distributed',
'Max_Speed(rpm)': '10,000',
'Power(kW)': '80',
'Cooling': 'Water Jacket',
'Drive_Type': 'Sine'},
{'Template': 'e9_eMobility_IPM',
'Sector': 'eMobility',
'Machine_Type': 'IPM',
'Application': 'Automotive',
'Winding_Type': 'Stranded Distributed',
'Max_Speed(rpm)': '10,000',
'Power(kW)': '120',
'Cooling': 'Water Jacket',
'Drive_Type': 'Sine'},
{'Template': 'i1_Industrial_SPM_square',
'Sector': 'Industrial',
'Machine_Type': 'SPM',
'Application': 'Pump/Fan',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '3,000',
'Power(kW)': '3.5',
'Cooling': 'Fan cooled',
'Drive_Type': 'Square'},
{'Template': 'i2_Industrial_SPM_sine',
'Sector': 'Industrial',
'Machine_Type': 'SPM',
'Application': 'Pump/Fan',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '3,000',
'Power(kW)': '5',
'Cooling': 'Fan cooled',
'Drive_Type': 'Sine'},
{'Template': 'i3_Industrial_SyncRel',
'Sector': 'Industrial',
'Machine_Type': 'SyncRel',
'Application': 'Pump/Fan',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '3,000',
'Power(kW)': ' ',
'Cooling': 'Fan cooled',
'Drive_Type': 'Sine'},
{'Template': 'i4_Industrial_IM',
'Sector': 'Industrial',
'Machine_Type': 'IM',
'Application': 'Pump/Fan',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '3,000',
'Power(kW)': '',
'Cooling': 'Fan cooled',
'Drive_Type': 'Direct online'},
{'Template': 'i5_Industrial_SPM_Servo_Tooth_Wound',
'Sector': 'Industrial',
'Machine_Type': 'SPM',
'Application': 'Servo',
'Winding_Type': 'Concentrated',
'Max_Speed(rpm)': '3,000',
'Power(kW)': '1.1',
'Cooling': 'Totally Enclosed Non Ventilated (TENV)',
'Drive_Type': 'Sine'},
{'Template': 'i6a_HV_1MW_FOC',
'Sector': 'Industrial',
'Machine_Type': 'IM',
'Application': 'Oil/Gas',
'Winding_Type': 'Round wire',
'Max_Speed(rpm)': '',
'Power(kW)': '1,000',
'Cooling': 'Axial through vent',
'Drive_Type': 'FOC'},
{'Template': 'i6b_HV_IM_oilgas',
'Sector': 'Industrial',
'Machine_Type': 'IM',
'Application': 'Oil/Gas',
'Winding_Type': 'Form Wound',
'Max_Speed(rpm)': '1,500',
'Power(kW)': '650',
'Cooling': 'Axial through vent',
'Drive_Type': 'Direct online'},
{'Template': 'i7_IM_1MW_Generator',
'Sector': 'Industrial',
'Machine_Type': 'IM',
'Application': 'Power Generation',
'Winding_Type': 'Form Wound',
'Max_Speed(rpm)': '3,000',
'Power(kW)': '1,000',
'Cooling': 'Radial through vent',
'Drive_Type': 'Direct online generator'},
{'Template': 'i8_IEEJ_IPM_D-Model',
'Sector': 'Industrial',
'Machine_Type': 'IPM',
'Application': 'Benchmark Motor',
'Winding_Type': 'Distributed',
'Max_Speed(rpm)': '2,000',
'Power(kW)': '0.7',
'Cooling': 'Axial through vent',
'Drive_Type': 'Sine'},
{'Template': 'i9_SYNC_HV_325kW_Generator',
'Sector': 'Industrial',
'Machine_Type': ' SYNC',
'Application': ' Power Generation',
'Winding_Type': ' Form Wound',
'Max_Speed(rpm)': ' 1,000',
'Power(kW)': ' 325',
'Cooling': 'Water Jacket',
'Drive_Type': 'Passive Gen'},
{'Template': 'r1',
'Sector': 'Renewable',
'Machine_Type': 'Surface PM',
'Application': 'Direct Drive Wind Turbine',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': '150',
'Power(kW)': '6',
'Cooling': 'Air cooled',
'Drive_Type': ' Rectifier'}]
return list

def template_list(self):
"""Return List of templates available in Motor-CAD.
Individual template information is in dictionary format
for example
[{'Template': 'a1',
'Sector': 'Aerospace',
' Machine_Type': ' Surface PM',
'Application': ' Generator',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': ' 10,000',
'Power(kW)': ' 14',
' Cooling': 'Oil cooled',
' Drive_Type': 'Sine'},]
"""
import os

Check warning on line 70 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L70

Added line #L70 was not covered by tests

# Motor-CAD installation directory in PC
mcad_install_dir = self.get_variable("CurrentExeDir_MotorLAB")
directory = mcad_install_dir + r"Motor-CAD Data\templates"
template_list1 = []
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if filename.endswith(".mtt"):
with open(f, "r") as file:
print(filename)
for l_no, line in enumerate(file):

Check warning on line 81 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L73-L81

Added lines #L73 - L81 were not covered by tests
# search string
if "Data_File_Notes[1]" in line:
print("string found in a file")
print("Line Number:", l_no)
print("Line:", line)

Check warning on line 86 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L83-L86

Added lines #L83 - L86 were not covered by tests
# don't look for next lines
list1 = line.split(";")
list1[0] = list1[0][19:]
dict1 = {

Check warning on line 90 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L88-L90

Added lines #L88 - L90 were not covered by tests
"Template": filename.split(".")[0],
"Sector": list1[0],
"Machine_Type": list1[1],
"Application": list1[2],
"Winding_Type": list1[3],
"Max_Speed(rpm)": list1[4],
"Power(kW)": list1[5],
"Cooling": list1[6],
"Drive_Type": list1[7],
}
template_list1.append(dict1)
break

Check warning on line 102 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L101-L102

Added lines #L101 - L102 were not covered by tests

return template_list1

Check warning on line 104 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L104

Added line #L104 was not covered by tests

0 comments on commit c896c39

Please sign in to comment.