-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Abstract
Enable mach_cad to handle default unit systems in JMAG
Context
When we launch JMAG geometry editor through mach_cad, the only available unit system is SI Unit, e.g., length units are restricted to meters. See below:
eMach/mach_cad/tools/jmag/jmag.py
Lines 410 to 423 in a86c775
| def set_default_length_unit(self, user_unit): | |
| """Set the default length unit in JMAG. Only DimMeter supported. | |
| Args: | |
| user_unit: String representing the unit the user wishes to set as default. | |
| Raises: | |
| TypeError: Incorrect dimension passed | |
| """ | |
| if user_unit == "DimMeter": | |
| self.default_length = user_unit | |
| self.model.SetUnitCollection("SI_units") | |
| else: | |
| raise Exception("Unsupported length unit") |
However, we often prefer millimeters when designing the electric machines, which is actually the default unit system within JMAG. This means that mach_cad tries to change this default unit to be SI unit. It looks like mach_cad already has functionality to switch unit systems, but if we specify any unit system other than SI unit, it results in error as "Unsupported length unit"
Approach
One possible improvement is to modify to support JMAG’s default unit system and allow switching to not SI units without causing errors. For example,
def set_default_length_unit(self, user_unit):
"""Set the default length unit in JMAG. Only DimMeter supported.
Args:
user_unit: String representing the unit the user wishes to set as default.
Raises:
TypeError: Incorrect dimension passed
"""
if user_unit == "DimMeter":
self.default_length = user_unit
self.model.SetUnitCollection("SI_units")
elif user_unit == "default":
self.default_length = user_unit
self.model.SetUnitCollection("default")
else:
raise Exception("Unsupported length unit")