The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
newRPL: Handling of units
09-23-2015, 03:38 PM
Post: #1
newRPL: Handling of units
I'm well advanced into implementing units in newRPL (the 4 basic operations work, as well as UVAL, UBASE and CONVERT).
While all this works fine, I reached now a difficult subject: Temperatures!
Here's a quote from hpcalc.org FAQ's:
Quote:...the G/GX will only add or subtract temperatures if the units are the same; it is now an error if they are not.

If the units attached to the number consists only of a temperature and nothing else, operations are done using an absolute temperature scale (relative to absolute zero). If the units consists of a temperature and something else, such as degrees/minute, the operation will not be done using an absolute temperature scale.

For the most part it does make sense, until you try to calculate entropy. s=Q/T, I'm trying to think if there's a way to implement a proper operation, if you divide for example 3_J / 30_°C, the operation should convert to Kelvin before proceeding. However, this would mess up equations where the temperature is a difference in temperatures. Perhaps there should be a different unit for temperature change (Δ°C maybe), which has the relative conversion factors for all formulas where the temperature change is involved.

Thinking out loud, it should work more or less like this:
* All operations involving an argument with a pure temperature, will convert that argument to its respective absolute scale (Kelvin or Rankine) before doing the operation.
* Subtraction of pure temperatures: As all other operations, the system would convert first to an absolute scale, then do the difference. The resulting unit should keep the unit of the first argument, but the absolute units would be converted to a Delta unit, so 30_°C - 10_°C = 20_Δ°C.
* Addition of temperatures: physically has no meaning, but it might be a byproduct of an algebraic manipulation, A+(-B), where -B is perhaps -10_°C. The system would have to process it as a difference of temperatures, by changing the sign of the second argument. 30_°C + 10_°C = 30_°C - (-10_°C) = 40_Δ°C (note the same change from absolute to delta degrees).

For the user, the visible changes would be:
* Automatic conversions of temperature during subtraction (currently it's an error)
* The user would have to distinguish between a temperature value and a temperature change, and provide proper units (for example, if a formula Q=m*C*Δt, then Δt should have delta units (Δ°C instead of just °C). This is true also for the units of the coefficients (C in this case).
* Perhaps the most confusing (though correct), is that °C would be replaced by K and °F by °R in formulas automatically without the user consent (except for addition/subtraction, which would keep the original unit converted to delta).

I think this covers all cases quite well:
Normal heat equations:
Q=m*C*(t2-t1) --> the system would change t2 and t1 into a delta unit after the difference.
Q=m*C*Δt --> The user needs to put Δ units into Δt.

Stefan–Boltzmann: When the system finds a T^4, the power operation would convert the temperature to absolute, so it works.

Entropy: Q/T --> The system would convert to absolute before doing the division.

Temperature conversions: Using absolute or relative scales depending on the units. Delta units are considered inconsistent with pure temperature ones.

Any other cases that I could be missing?

Any thoughts / objections before I implement this?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
newRPL: Handling of units - Claudio L. - 09-23-2015 03:38 PM
RE: newRPL: Handling of units - Han - 09-27-2015, 02:29 PM
RE: newRPL: Handling of units - Claudio L. - 09-28-2015, 01:50 PM
RE: newRPL: Handling of units - Claudio L. - 09-30-2015, 06:02 PM
RE: newRPL: Handling of units - JoJo1973 - 05-08-2016, 01:30 PM
RE: newRPL: Handling of units - JoJo1973 - 05-08-2016, 04:28 PM
RE: newRPL: Handling of units - Claudio L. - 05-08-2016, 05:38 PM
RE: newRPL: Handling of units - Claudio L. - 05-09-2016, 05:42 PM
RE: newRPL: Handling of units - JoJo1973 - 05-09-2016, 06:05 PM
RE: newRPL: Handling of units - Vtile - 05-11-2016, 02:27 PM
RE: newRPL: Handling of units - JoJo1973 - 05-08-2016, 06:21 PM
RE: newRPL: Handling of units - Claudio L. - 05-08-2016, 06:24 PM
RE: newRPL: Handling of units - JoJo1973 - 05-08-2016, 10:44 PM
RE: newRPL: Handling of units - emece67 - 05-08-2016, 09:06 PM
RE: newRPL: Handling of units - Claudio L. - 05-09-2016, 12:41 AM
RE: newRPL: Handling of units - emece67 - 05-08-2016, 10:01 PM
RE: newRPL: Handling of units - Claudio L. - 05-09-2016, 12:59 AM
RE: newRPL: Handling of units - emece67 - 05-09-2016, 05:55 AM
RE: newRPL: Handling of units - JoJo1973 - 05-09-2016, 09:22 AM
RE: newRPL: Handling of units - Claudio L. - 05-09-2016, 01:46 PM
RE: newRPL: Handling of units - JoJo1973 - 05-09-2016, 09:27 PM
RE: newRPL: Handling of units - Claudio L. - 05-11-2016, 02:49 AM
RE: newRPL: Handling of units - JoJo1973 - 05-12-2016, 11:18 AM
RE: newRPL: Handling of units - Claudio L. - 05-09-2016, 09:51 AM
RE: newRPL: Handling of units - Claudio L. - 05-11-2016, 05:01 PM
RE: newRPL: Handling of units - Helix - 05-12-2016, 01:07 PM
RE: newRPL: Handling of units - Claudio L. - 05-12-2016, 04:58 PM
RE: newRPL: Handling of units - Helix - 05-12-2016, 11:58 PM
RE: newRPL: Handling of units - Claudio L. - 05-13-2016, 01:43 AM
RE: newRPL: Handling of units - Claudio L. - 05-13-2016, 01:35 PM
RE: newRPL: Handling of units - Helix - 05-13-2016, 11:12 PM
RE: newRPL: Handling of units - Claudio L. - 05-14-2016, 02:57 AM



User(s) browsing this thread: 2 Guest(s)