-
Notifications
You must be signed in to change notification settings - Fork 391
Ohm's Law Overloads for ElectricPotentialAc & ElectricPotentialDc #1296
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
Comments
I think that you should go with As we can see, theses special AC/DC units were added in commit f82e49e . Frst, I think that Moreover, we can see that the same commit added The direct way to solve this misunderstanding would be to remove theses 2 quantities : We could also implement complex quantities, using complex numbers, for AC current and potential, which would partially solve this issue, however, we would still need to include the frequency parameter with theses quantities. Outrageous complexity... |
I have no strong opinion here, but a few thoughts:
Proposal:
Not sure if DC benefits from such wrapper types or if it is already covered by ElectricPotential, ElectricCurrent etc. As always, it is best for someone actually working in this domain to help decide what is a good design for UnitsNet. I can help making the changes fit in UnitsNet. |
With #1312 I've put together a straw man for both removing the ElectricPotentialAc and ElectricPotentialDc types, as well as creating a wrapper type for ElectricCurrent (for starters). My main concern at this point is getting the terminology correct. For example, ElectricCurrent as alternating current measured as root-mean square is supposed to be equivalent to a direct current when applied to a resistive load. However, that doesn't make them identical, although my current "implementation" treats them as such. It's trivial to calculate the peak current and peak-to-peak current from there, but then what happens when an AC ElectricCurrent has a DC ElectricCurrent added to it? In reality, the RMS and peak would change because of the resulting bias offset, but the peak-to-peak (distance between peaks) would remain the same? I'm not sure if I'm capturing too much information, or not enough information, to enable these kinds of transforms. |
I need some time to get around to this and understand the proposal. |
I posted an initial review of #1312 , let's continue the discussion there. |
So I've spent some time thinking about this, and to be honest, I think the best answer is to remove both ElectricalAc and ElectricalDc, have just Electrical* quantities, and tell anyone who wants to map more functionality into it (volts RMS, phase angle, etc.) to just use a named tuple. That allows the implementer to contain as much or as little information as they would like, while using multiple quantities available in Units.Net. |
@McNeight I totally agree with you. We can see these Electrical quantities as instant measurements, so they are not concerned by the frequency and phase shift. If we really want to implement such power calculation, in addition to frequency and phase shift, we'll also need to consider the waveform (sine, triangular, square wave)... Which I think is "off topic" for this library. |
Thanks for the input guys, closing for now then. |
Is anyone up for creating a pull request against release/v6 branch, to make these changes? XMLDoc for the quantities should have remarks explaining what you said above, that advanced functionality like RMS, phase angle etc should be handled outside the library. |
Related discussion: |
Describe the bug
Per Ohm's Law, multiplying an ElectricPotential object with an ElectricCurrent object results in a Power object. Attempting to use an ElectricPotentialAc or ElectricPotentialDc object results in error CS0019.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
x is a Power object of 10 Watts.
Additional context
Perhaps I'm not understanding the purpose of the Ac and Dc objects and their difference from the "basic" ElectricPotential unit? I'm not sure if adding more operators to cover the Ac and Dc classes, or possibly having them inherit the operator from a base class is the better approach.
The text was updated successfully, but these errors were encountered: