angularsen / UnitsNet

Makes life working with units of measurement just a little bit better.
https://www.nuget.org/packages/UnitsNet/
MIT No Attribution
2.19k stars 380 forks source link

Missing CoefficientOfThermalExpansion operators and units. #1259

Closed tm-ren closed 1 year ago

tm-ren commented 1 year ago

A typical use case for a coefficient of thermal expansion is to calculate a change in length due to a change in temperature. dL = (cte * dT) * L;

dL is a change in length. cte is a coefficient of thermal expansion. dT is a temperature delta, the change in temperature from some reference temperature. L is a length at the reference temperature.

It would be useful if there were operators of the form: public static double operator * (CoefficientOfThermalExpansion cte, TemperatureDelta dt) And:

public static double operator * (TemperatureDelta dt, CoefficientOfThermalExpansion cte)

angularsen commented 1 year ago

Hi, this should be straight forward to add. Would you be interested in attempting a pull request? I'm happy to assist.

  1. Create UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs and add the first method there. See how other files do it.
  2. Add the second method to the existing file: https://github.com/angularsen/UnitsNet/blob/master/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs
tm-ren commented 1 year ago

Also propose inclusion of additional units to the CoefficientOfThermalExpansion type, e.g. "PartsPerMillionPerDegreesCelsius".

tm-ren commented 1 year ago

Hi, this should be straight forward to add. Would you be interested in attempting a pull request? I'm happy to assist.

  1. Create UnitsNet/CustomCode/Quantities/CoefficientOfThermalExpansion.extra.cs and add the first method there. See how other files do it.
  2. Add the second method to the existing file: https://github.com/angularsen/UnitsNet/blob/master/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs

Yes happy to contribute if you can give me a bit of guidance for your process?

tm-ren commented 1 year ago

I have two change branches for the above but I don't have write access to the project to be able to push and create pull requests. Are you able to give me write access?

angularsen commented 1 year ago

Sorry for late reply, was on vacation.

There are detailed steps here on adding units: https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit

As for write access; see this section: https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit#6-create-pull-request