Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start the units subpackage #2

Closed
7 tasks
RobPasMue opened this issue Aug 30, 2022 · 2 comments · Fixed by #38
Closed
7 tasks

Start the units subpackage #2

RobPasMue opened this issue Aug 30, 2022 · 2 comments · Fixed by #38
Assignees

Comments

@RobPasMue
Copy link
Member

An important aspect of CAD libraries are the units. It is expected that, behind the scenes, all objects work in SI units, but users should be able to provide their values in different units. Let's get this module started!

  • Implement the units module
  • Create a `Quantity`` (enum) class handling the units accepted
  • Create a Conversion class which will contain a Quantity (enum) value and a conversion factor
  • Implement units inside the datamodel.objects package
  • All units inside the objects must be stored in SI, but users will be able to provide different Quantity values. Conversions should be handled in construction and representation. Inside operations and operations between objects will always take place in SI
  • Add testing (must be intensive, this is a critical module)
  • Add documentation

See the following picture for having an idea of the location of the units subpackage
image

@RobPasMue
Copy link
Member Author

This task is dependent on #1. Let's get that one ready first. I'll take care of this one afterwards

@RobPasMue RobPasMue self-assigned this Aug 30, 2022
@RobPasMue RobPasMue mentioned this issue Aug 30, 2022
9 tasks
@jorgepiloto
Copy link
Member

After @akaszynski suggested using pint, I think we could have a simple the following code in the root base __init__.py:

from pint import UnitRegistry

units = UnitRegistry()
"""Unit manager."""

This leads to the following user experience:

from ansys.geometry.core import units as u

length_A, length_B = 1.00 * u.m, 2.5 * u.inches
length_C = length_A + length_B
print(length_C)
>>> 1.0635 meter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants