-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: handle units #205
base: dev
Are you sure you want to change the base?
feat: handle units #205
Conversation
@connorferster, please let me elaborate on your comment to #105 here. In our group we have been discussing how to handle units for a while. We do not want to create an advanced library for unit handling, since these already exist, like e.g. pint or forallpeople which of course are very well aware of 😃 However, we are investigating how we can make it easier for our users to perform calculations with our material, geometry and section classes using different units, without introducing too much overhead for users and maintainers. As you mention in your comment, it could be a good idea to leave unit handling outside of structuralcodes, let a well-established library deal with it, and instead make structuralcodes compatible with that library. But from our initial investigations, we realized that a minimum of internal implementation would be to handle length and force units and derive stress units from these, and we could do this on our material class. In my first attempt to implement this, I actually used your forallpeople library. However, since we only needed some relation between length units and force units, we decided to simply hardcode a dict with these relations, and create a simple unit converter that could be used in our material classes. Of course, as we proceed, we see that there are other units to consider as well, and without a clear direction ahead, my progress on this topic stopped a couple of months ago. In your original comment, you suggested to make structuralcodes compatible with pint and let users handle their own units. I am not too familiar with that library, so please excuse my question, but what would be required from structuralcodes to be compatible with pint as you see it? Thanks in advance! |
Description
An attempt to handle units. Note: this is still a very immature draft!
Two classes are added to
core
:UnitSet
andUnitConverter
.UnitSet
is adataclass
responsible for storing a set of units intended to be used by aMaterial
class.UnitConverter
uses twoUnitSet
s to convert between them.Example
This example shows how two sets of units are selected and passed to the unit converter. Furthermore, it shows how to convert stress, lengeth and force with the unit converter.
To do
UnitSet
andUnitConverter
.UnitSet
s.UnitSet
s in code specific material classes.fracture_energy_unit
or similar.modulus_unit
or similar?