Skip to content

Enable mach_cad to handle default unit systems in JMAG #353

Description

@noguchi-takahiro

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:

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")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions