Coder Social home page Coder Social logo

Question about to_string() function about units HOT 8 CLOSED

llnl avatar llnl commented on June 26, 2024
Question about to_string() function

from units.

Comments (8)

phlptp avatar phlptp commented on June 26, 2024 1

I am going to add a few tests that play around with strain and some example problems, after which I will close this issue.

from units.

phlptp avatar phlptp commented on June 26, 2024

The string output is driven by a large map, which generally defaults to including mostly SI based units, and probably could use improvements. The two cases you mentioned I could see adding to the to_string(...) output as they are common enough.

However, in the mean time if there are specific outputs/inputs you want to display that are different than what exists currently.

addUserDefinedUnit("kHz", precise::kilo*precise::Hz);
addUserDefinedUnit("lbf",precise::lbf);

I will make some adjustments based on your comments in the near future, so this shouldn't be necessary but you can use this at present.

from units.

milad-gh avatar milad-gh commented on June 26, 2024

Thank you so much for your response it solved the issues,

Another issue maybe related and currently I'm struggling with is regarding Strain, As Strain is a dimensionless value I can use "precise::one" or "precise::percentage" to show it and it works fine but when it comes to Strain rate i.e. "one/s" it becomes dimensionally equivalent to Hz and my software shows it as it is frequency but I need to show it as 1/s or s-1 which is standard strain rate unit.

The problem is that if I override the behavior with addUserDefinedUnit("1/s",precise::one/s); it will also affect showing of frequency units which should be Hz as it it.

I think although Strain is dimensionless but it needs to be distinguished from other dimensionless types,
I saw some flags like count, rad and I tried to handle it with them but I thought maybe you have a better suggestion for it.

from units.

phlptp avatar phlptp commented on June 26, 2024

The units of strain should be
strain=precise::pu*precise::m. I am not a mechanical engineer but assuming I understand it right strain is a measure of deformation relative to the original length, which matches up nicely with the per unit definition.

Then you can use this in the string definitions of your choice, including strain rate and it will be distinct from precise::one so shouldn't be conflicting with other frequency units.

from units.

milad-gh avatar milad-gh commented on June 26, 2024

Yes strain is "deformation/original length" but it is a unitless value or 1.

I think it can't be strain=precise::pu*precise::m because then it would be dimensionally equal to Length and it will not be unitless.

And also I don't have much information about per unit system as I understood it seems that per unit system is mostly used in power electronics is that true? is it then OK to use it with strain ?

from units.

phlptp avatar phlptp commented on June 26, 2024

When per unit values are used in power systems they are dimensionless units as well for example puMW, is actual power/power base. This simplifies a lot of calculations, but also maintains certain relationships. puV*puA=puW still hold true.

So to me strain would function similarly using perunit meters.

The other option is to define it as strain=precise::one*precise::eflag Basically wanting some way to discriminate from the regular ratio. To me the perunit route is your best bet since there is an underlying unit(m) there.

In the units library the pu flag is meant as an indicator that the unit is dimensionless. This admittedly gets a little fuzzy when mixing things like strain rate but I have had things like puMW/hr and the calculations work out fine. I would be interested in knowing how this might play out in a different field.

from units.

milad-gh avatar milad-gh commented on June 26, 2024

Thanks for the explanation; I think I get the concept.

i did make a trade off between these two approaches and I think using eflag is better for my use case because it preserves the base units which I need to analyze elsewhere in of my software.

from units.

phlptp avatar phlptp commented on June 26, 2024

Strain Application Note

from units.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.