tuscan 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +3 -0
- data/lib/tuscan/iec60584.rb +383 -0
- data/lib/tuscan/iec60751.rb +35 -0
- data/lib/tuscan/its90.rb +107 -0
- data/lib/tuscan/version.rb +3 -0
- data/lib/tuscan.rb +14 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/tuscan/iec60584_spec.rb +116 -0
- data/spec/tuscan/iec60751_spec.rb +47 -0
- data/spec/tuscan/its90_spec.rb +91 -0
- data/spec/tuscan_spec.rb +8 -0
- data/tasks/rspec.rake +3 -0
- data/tuscan.gemspec +25 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2543badcdb3312b2f5b8137766cddc323887e10f
|
4
|
+
data.tar.gz: 5dc2685148190c63c30277e384fc5b272631bd91
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d3dd9a95da487edd7a192cc273df640d9599ef068ec26ad7214e6c0abfb6369a96815cc196f736dbc07343db35d6fb10e68c78bf84930ed865fb75198701665
|
7
|
+
data.tar.gz: 159021a9b23eaa493f9462fde5b363819181364840a878a77f66fb2b8d92ca93d05ad3271545efdfea30a4519b80c642ef3226ce77bd45615593da49d09f0062
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Luis Bacelar
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# **TUSCAn**
|
2
|
+
### **T**emperat**U**re **S**ensor **CA**lculator
|
3
|
+
|
4
|
+
Makes available functions for:
|
5
|
+
|
6
|
+
* ITS-90 compatible temperature sensors (Standard Platinum Resistance Thermometers), allowing:
|
7
|
+
* Retrieval of reference resistance ratio _Wr_ from _t90r_ reference temperature
|
8
|
+
* Retrieval of reference temperature _t90r_ from _Wr_ reference resistance ratio
|
9
|
+
* Given sensor coefficient's: _sub-range_, _Rtpw_, _a_, _b_, _c_, _d_, _W660_, _c1_, _c2_, _c3_, _c4_, _c5_
|
10
|
+
* Retrieval of resistance ratio deviation _Wdev_ from _t90_, for each of the 11 sub-ranges of ITS-90
|
11
|
+
* Retrieval of _t90_ temperature from sensor's resistance _r_.
|
12
|
+
* IEC 60751 compatible temperature sensors (Platinum Resistance Thermometers), allowing:
|
13
|
+
* Given sensor coefficient's: _R0_, _A_, _B_, _C_
|
14
|
+
* Retrieval of sensor's resistance _r_ from _t90_ temperature
|
15
|
+
* Retrieval of temperature _t90_ from sensor's resistance _r_
|
16
|
+
* IEC 60584 compatible temperature sensors (Thermocouples), allowing, for a given _type_:
|
17
|
+
* Retrieval of reference voltage _emfr_ from _t90r_ reference temperature
|
18
|
+
* Retrieval of reference temperature _t90r_ from reference voltage _emfr_
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'tuscan'
|
27
|
+
```
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install tuscan
|
36
|
+
|
37
|
+
## Usage examples
|
38
|
+
|
39
|
+
**ITS-90**
|
40
|
+
```ruby
|
41
|
+
Tuscan.wr(:its90, 23.456) # t90 in ºC
|
42
|
+
Tuscan.t90r(:its90, 1.15) # wr in Ohm / Ohm
|
43
|
+
|
44
|
+
Tuscan.wdev(:its90, 23.456, subrange: 4, a: -1.2579994e-04, b: 1.0678395e-05)
|
45
|
+
|
46
|
+
Tuscan.t90(:its90, r: 28.3433, rtpw: 25.319871, subrange: 7, a: -1.2134e-04, b: -9.9190e-06)
|
47
|
+
```
|
48
|
+
|
49
|
+
**IEC 60751**
|
50
|
+
```ruby
|
51
|
+
Tuscan.t90(:iec60751, r: 110) # t90 in ºC, r in Ohm
|
52
|
+
Tuscan.res(:iec60751, t: 10, r0: 99.876, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12)
|
53
|
+
```
|
54
|
+
|
55
|
+
**IEC 60584**
|
56
|
+
```ruby
|
57
|
+
Tuscan.t90r(:iec60584, emf: 1.234, type: :k) # emf im mV
|
58
|
+
Tuscan.emfir(:iec60584, t: 10.123, type: :k) # t90 in ºC
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
### Notes
|
63
|
+
* `t90` aliased to `t`, `temperature`
|
64
|
+
* `res` aliased to `r`, `resistance`
|
65
|
+
* `emf` aliased to `v`, `voltage`
|
66
|
+
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it ( https://github.com/[my-github-username]/tuscan/fork )
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
module Tuscan
|
2
|
+
module Iec60584
|
3
|
+
include Math
|
4
|
+
extend self
|
5
|
+
|
6
|
+
|
7
|
+
def emfr t90, type, range_check = true
|
8
|
+
a = emf_a_coeffs t90, type
|
9
|
+
result = emf_c_coeffs(t90, type).each_with_index.map{ |c,i| c*t90**i }.reduce(:+)
|
10
|
+
result += a[0] * exp(a[1] * (t90 - a[2])**2)
|
11
|
+
end
|
12
|
+
|
13
|
+
def t90r emf, type, err_limit: 0.1, num_iter: 1000
|
14
|
+
t90_coeffs(emf, type).each_with_index.map{ |d,i| d*emf**i }.reduce(:+)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
def emf_c_coeffs t90, type
|
20
|
+
case type
|
21
|
+
when :b then emf_c_coeffs_b t90
|
22
|
+
when :c then emf_c_coeffs_c t90
|
23
|
+
when :e then emf_c_coeffs_e t90
|
24
|
+
when :j then emf_c_coeffs_j t90
|
25
|
+
when :k then emf_c_coeffs_k t90
|
26
|
+
when :n then emf_c_coeffs_n t90
|
27
|
+
when :r then emf_c_coeffs_r t90
|
28
|
+
when :s then emf_c_coeffs_s t90
|
29
|
+
when :t then emf_c_coeffs_t t90
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def emf_c_coeffs_b t90
|
34
|
+
# 0.000..630.615
|
35
|
+
# 630.615..1820.00
|
36
|
+
if t90 < 630.615
|
37
|
+
[ 0.000000000000e+00, -0.246508183460e-03, 0.590404211710e-05,
|
38
|
+
-0.132579316360e-08, 0.156682919010e-11, -0.169445292400e-14,
|
39
|
+
0.629903470940e-18 ]
|
40
|
+
else
|
41
|
+
[ -0.389381686210e+01, 0.285717474700e-01, -0.848851047850e-04,
|
42
|
+
0.157852801640e-06, -0.168353448640e-09, 0.111097940130e-12,
|
43
|
+
-0.445154310330e-16, 0.989756408210e-20, -0.937913302890e-24 ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def emf_c_coeffs_c t90
|
48
|
+
# 0.0..2320.0
|
49
|
+
[ -3.109077870000e-04, 1.338547130000e-02, 1.226236040000e-05,
|
50
|
+
-1.050537530000e-08, 3.613274640000e-12, -4.990804550000e-16,
|
51
|
+
6.434651840000e-22 ]
|
52
|
+
end
|
53
|
+
|
54
|
+
def emf_c_coeffs_e t90
|
55
|
+
# -270.0..0.0
|
56
|
+
# 0.0..1000.0
|
57
|
+
if t90 < 0.0
|
58
|
+
[ 0.000000000000e+00, 0.586655087080e-01, 0.454109771240e-04,
|
59
|
+
-0.779980486860e-06, -0.258001608430e-07, -0.594525830570e-09,
|
60
|
+
-0.932140586670e-11, -0.102876055340e-12, -0.803701236210e-15,
|
61
|
+
-0.439794973910e-17, -0.164147763550e-19, -0.396736195160e-22,
|
62
|
+
-0.558273287210e-25, -0.346578420130e-28 ]
|
63
|
+
else
|
64
|
+
[ 0.000000000000e+00, 0.586655087100e-01, 0.450322755820e-04,
|
65
|
+
0.289084072120e-07, -0.330568966520e-09, 0.650244032700e-12,
|
66
|
+
-0.191974955040e-15, -0.125366004970e-17, 0.214892175690e-20,
|
67
|
+
-0.143880417820e-23, 0.359608994810e-27 ]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def emf_c_coeffs_j t90
|
72
|
+
# -210.0..760.0
|
73
|
+
# 760.0..1200.0
|
74
|
+
if t90 < 760.0
|
75
|
+
[ 0.000000000000e+00, 0.503811878150e-01, 0.304758369300e-04,
|
76
|
+
-0.856810657200e-07, 0.132281952950e-09, -0.170529583370e-12,
|
77
|
+
0.209480906970e-15, -0.125383953360e-18, 0.156317256970e-22 ]
|
78
|
+
else
|
79
|
+
[ 0.296456256810e+03, -0.149761277860e+01, 0.317871039240e-02,
|
80
|
+
-0.318476867010e-05, 0.157208190040e-08, -0.306913690560e-12 ]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def emf_c_coeffs_k t90
|
85
|
+
# -270.0..0.0
|
86
|
+
# 0.0..1372.0
|
87
|
+
if t90 < 0.0
|
88
|
+
[ 0.000000000000e+00, 0.394501280250e-01, 0.236223735980e-04,
|
89
|
+
-0.328589067840e-06, -0.499048287770e-08, -0.675090591730e-10,
|
90
|
+
-0.574103274280e-12, -0.310888728940e-14, -0.104516093650e-16,
|
91
|
+
-0.198892668780e-19, -0.163226974860e-22 ]
|
92
|
+
else
|
93
|
+
[ -0.176004136860e-01, 0.389212049750e-01, 0.185587700320e-04,
|
94
|
+
-0.994575928740e-07, 0.318409457190e-09, -0.560728448890e-12,
|
95
|
+
0.560750590590e-15, -0.320207200030e-18, 0.971511471520e-22,
|
96
|
+
-0.121047212750e-25 ]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def emf_c_coeffs_n t90
|
101
|
+
# -270.0..0.0
|
102
|
+
# 0.0..1300.0
|
103
|
+
if t90 < 0.0
|
104
|
+
[ 0.000000000000e+00, 0.261591059620e-01, 0.109574842280e-04,
|
105
|
+
-0.938411115540e-07, -0.464120397590e-10, -0.263033577160e-11,
|
106
|
+
-0.226534380030e-13, -0.760893007910e-16, -0.934196678350e-19 ]
|
107
|
+
else
|
108
|
+
[ 0.000000000000e+00, 0.259293946010e-01, 0.157101418800e-04,
|
109
|
+
0.438256272370e-07, -0.252611697940e-09, 0.643118193390e-12,
|
110
|
+
-0.100634715190e-14, 0.997453389920e-18, -0.608632456070e-21,
|
111
|
+
0.208492293390e-24, -0.306821961510e-28 ]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def emf_c_coeffs_r t90
|
116
|
+
# -50.00..1064.18
|
117
|
+
# 1064.18..1664.50
|
118
|
+
# 1664.50..1768.10
|
119
|
+
if t90 < 1064.18
|
120
|
+
[ 0.000000000000e+00, 0.528961729765e-02, 0.139166589782e-04,
|
121
|
+
-0.238855693017e-07, 0.356916001063e-10, -0.462347666298e-13,
|
122
|
+
0.500777441034e-16, -0.373105886191e-19, 0.157716482367e-22,
|
123
|
+
-0.281038625251e-26 ]
|
124
|
+
elsif t90 < 1664.50
|
125
|
+
[ 0.295157925316e+01, -0.252061251332e-02, 0.159564501865e-04,
|
126
|
+
-0.764085947576e-08, 0.205305291024e-11, -0.293359668173e-15 ]
|
127
|
+
else
|
128
|
+
[ 0.152232118209e+03, -0.268819888545e+00, 0.171280280471e-03,
|
129
|
+
-0.345895706453e-07, -0.934633971046e-14 ]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def emf_c_coeffs_s t90
|
134
|
+
# -50.00..1064.18
|
135
|
+
# 1064.18..1664.50
|
136
|
+
# 1664.50..1768.10
|
137
|
+
if t90 < 1064.18
|
138
|
+
[ 0.000000000000e+00, 0.540313308631e-02, 0.125934289740e-04,
|
139
|
+
-0.232477968689e-07, 0.322028823036e-10, -0.331465196389e-13,
|
140
|
+
0.255744251786e-16, -0.125068871393e-19, 0.271443176145e-23 ]
|
141
|
+
elsif t90 < 1664.50
|
142
|
+
[ 0.132900444085e+01, 0.334509311344e-02, 0.654805192818e-05,
|
143
|
+
-0.164856259209e-08, 0.129989605174e-13 ]
|
144
|
+
else
|
145
|
+
[ 0.146628232636e+03, -0.258430516752e+00, 0.163693574641e-03,
|
146
|
+
-0.330439046987e-07, -0.943223690612e-14 ]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def emf_c_coeffs_t t90
|
151
|
+
# -270.0..0.0
|
152
|
+
# 0.0..400.0
|
153
|
+
if t90 < 0.0
|
154
|
+
[ 0.000000000000e+00, 0.387481063640e-01, 0.441944343470e-04,
|
155
|
+
0.118443231050e-06, 0.200329735540e-07, 0.901380195590e-09,
|
156
|
+
0.226511565930e-10, 0.360711542050e-12, 0.384939398830e-14,
|
157
|
+
0.282135219250e-16, 0.142515947790e-18, 0.487686622860e-21,
|
158
|
+
0.107955392700e-23, 0.139450270620e-26, 0.797951539270e-30 ]
|
159
|
+
else
|
160
|
+
[ 0.000000000000e+00, 0.387481063640e-01, 0.332922278800e-04,
|
161
|
+
0.206182434040e-06, -0.218822568460e-08, 0.109968809280e-10,
|
162
|
+
-0.308157587720e-13, 0.454791352900e-16, -0.275129016730e-19 ]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def emf_a_coeffs t90, type
|
167
|
+
case type
|
168
|
+
when :b then emf_a_coeffs_b t90
|
169
|
+
when :c then emf_a_coeffs_c t90
|
170
|
+
when :e then emf_a_coeffs_e t90
|
171
|
+
when :j then emf_a_coeffs_j t90
|
172
|
+
when :k then emf_a_coeffs_k t90
|
173
|
+
when :n then emf_a_coeffs_n t90
|
174
|
+
when :r then emf_a_coeffs_r t90
|
175
|
+
when :s then emf_a_coeffs_s t90
|
176
|
+
when :t then emf_a_coeffs_t t90
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def emf_a_coeffs_b t90
|
181
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
182
|
+
end
|
183
|
+
|
184
|
+
def emf_a_coeffs_c t90
|
185
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
186
|
+
end
|
187
|
+
|
188
|
+
def emf_a_coeffs_e t90
|
189
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
190
|
+
end
|
191
|
+
|
192
|
+
def emf_a_coeffs_j t90
|
193
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
194
|
+
end
|
195
|
+
|
196
|
+
def emf_a_coeffs_k t90
|
197
|
+
if t90 < 0.0
|
198
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
199
|
+
else
|
200
|
+
[ 0.1185976e+00, -0.1183432e-03, 0.1269686e+03 ]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def emf_a_coeffs_n t90
|
205
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
206
|
+
end
|
207
|
+
|
208
|
+
def emf_a_coeffs_r t90
|
209
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
210
|
+
end
|
211
|
+
|
212
|
+
def emf_a_coeffs_s t90
|
213
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
214
|
+
end
|
215
|
+
|
216
|
+
def emf_a_coeffs_t t90
|
217
|
+
[ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00 ]
|
218
|
+
end
|
219
|
+
|
220
|
+
|
221
|
+
def t90_coeffs emf, type
|
222
|
+
case type
|
223
|
+
when :b then t90_coeffs_b emf
|
224
|
+
when :e then t90_coeffs_e emf
|
225
|
+
when :j then t90_coeffs_j emf
|
226
|
+
when :k then t90_coeffs_k emf
|
227
|
+
when :n then t90_coeffs_n emf
|
228
|
+
when :r then t90_coeffs_r emf
|
229
|
+
when :s then t90_coeffs_s emf
|
230
|
+
when :t then t90_coeffs_t emf
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def t90_coeffs_b emf
|
235
|
+
# 0.290..2.431
|
236
|
+
# 2.431..13.821
|
237
|
+
if emf < 2.431
|
238
|
+
[ 9.8423321e+01, 6.9971500e+02, -8.4765304e+02,
|
239
|
+
1.0052644e+03, -8.3345952e+02, 4.5508542e+02,
|
240
|
+
-1.5523037e+02, 2.9886750e+01, -2.4742860e+00 ]
|
241
|
+
else
|
242
|
+
[ 2.1315071e+02, 2.8510504e+02, -5.2742887e+01,
|
243
|
+
9.9160804e+00, -1.2965303e+00, 1.1195870e-01,
|
244
|
+
-6.0625199e-03, 1.8661696e-04, -2.4878585e-06 ]
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def t90_coeffs_e emf
|
249
|
+
# -8.825..0.000
|
250
|
+
# 0.000..76.373
|
251
|
+
if emf < 0.0
|
252
|
+
[ 0.0000000e+00, 1.6977288e+01, -4.3514970e-01,
|
253
|
+
-1.5859697e-01, -9.2502871e-02, -2.6084314e-02,
|
254
|
+
-4.1360199e-03, -3.4034030e-04, -1.1564890e-05,
|
255
|
+
0.0000000e+00 ]
|
256
|
+
else
|
257
|
+
[ 0.0000000e+00, 1.7057035e+01, -2.3301759e-01,
|
258
|
+
6.5435585e-03, -7.3562749e-05, -1.7896001e-06,
|
259
|
+
8.4036165e-08, -1.3735879e-09, 1.0629823e-11,
|
260
|
+
-3.2447087e-14 ]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def t90_coeffs_j emf
|
265
|
+
# -8.096..0.000
|
266
|
+
# 0.000..42.919
|
267
|
+
# 42.919..69.554
|
268
|
+
if emf < 0.0
|
269
|
+
[ 0.0000000e+00, 1.9528268e+01, -1.2286185e+00,
|
270
|
+
-1.0752178e+00, -5.9086933e-01, -1.7256713e-01,
|
271
|
+
-2.8131513e-02, -2.3963370e-03, -8.3823321e-05 ]
|
272
|
+
elsif emf < 42.919
|
273
|
+
[ 0.000000e+00, 1.978425e+01, -2.001204e-01,
|
274
|
+
1.036969e-02, -2.549687e-04, 3.585153e-06,
|
275
|
+
-5.344285e-08, 5.099890e-10 ]
|
276
|
+
else
|
277
|
+
[ -3.11358187e+03, 3.00543684e+02, -9.94773230e+00,
|
278
|
+
1.70276630e-01, -1.43033468e-03, 4.73886084e-06 ]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def t90_coeffs_k emf
|
283
|
+
# -5.892..0.000
|
284
|
+
# 0.000..20.644
|
285
|
+
# 20.644..54.887
|
286
|
+
if emf < 0.0
|
287
|
+
[ 0.0000000e+00, 2.5173462e+01, -1.1662878e+00,
|
288
|
+
-1.0833638e+00, -8.9773540e-01, -3.7342377e-01,
|
289
|
+
-8.6632643e-02, -1.0450598e-02, -5.1920577e-04 ]
|
290
|
+
elsif emf < 20.644
|
291
|
+
[ 0.000000e+00, 2.508355e+01, 7.860106e-02,
|
292
|
+
-2.503131e-01, 8.315270e-02, -1.228034e-02,
|
293
|
+
9.804036e-04, -4.413030e-05, 1.057734e-06,
|
294
|
+
-1.052755e-08 ]
|
295
|
+
else
|
296
|
+
[ -1.318058e+02, 4.830222e+01, -1.646031e+00,
|
297
|
+
5.464731e-02, -9.650715e-04, 8.802193e-06,
|
298
|
+
-3.110810e-08 ]
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
def t90_coeffs_n emf
|
303
|
+
# -3.991..0.000
|
304
|
+
# 0.000..20.613
|
305
|
+
# 20.613..47.513
|
306
|
+
if emf < 0.0
|
307
|
+
[ 0.0000000e+00, 3.8436847e+01, 1.1010485e+00,
|
308
|
+
5.2229312e+00, 7.2060525e+00, 5.8488586e+00,
|
309
|
+
2.7754916e+00, 7.7075166e-01, 1.1582665e-01,
|
310
|
+
7.3138868e-03 ]
|
311
|
+
elsif emf < 20.613
|
312
|
+
[ 0.00000e+00, 3.86896e+01, -1.08267e+00,
|
313
|
+
4.70205e-02, -2.12169e-06, -1.17272e-04,
|
314
|
+
5.39280e-06, -7.98156e-08 ]
|
315
|
+
else
|
316
|
+
[ 1.972485e+01, 3.300943e+01, -3.915159e-01,
|
317
|
+
9.855391e-03, -1.274371e-04, 7.767022e-07 ]
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def t90_coeffs_r emf
|
322
|
+
# -0.227..1.923
|
323
|
+
# 1.923..13.228
|
324
|
+
# 11.361..19.739
|
325
|
+
# 19.739..21.103
|
326
|
+
if emf < 1.923
|
327
|
+
[ 0.0000000E+00, 1.8891380E+02, -9.3835290E+01,
|
328
|
+
1.3068619E+02, -2.2703580E+02, 3.5145659E+02,
|
329
|
+
-3.8953900E+02, 2.8239471E+02, -1.2607281E+02,
|
330
|
+
3.1353611E+01, -3.3187769E+00 ]
|
331
|
+
elsif emf < 13.228
|
332
|
+
[ 1.334584505E+01, 1.472644573E+02, -1.844024844E+01,
|
333
|
+
4.031129726E+00, -6.249428360E-01, 6.468412046E-02,
|
334
|
+
-4.458750426E-03, 1.994710149E-04, -5.313401790E-06,
|
335
|
+
6.481976217E-08 ]
|
336
|
+
elsif emf < 19.739
|
337
|
+
[ -8.199599416E+01, 1.553962042E+02, -8.342197663E+00,
|
338
|
+
4.279433549E-01, -1.191577910E-02, 1.492290091E-04 ]
|
339
|
+
else
|
340
|
+
[ 3.406177836E+04, -7.023729171E+03, 5.582903813E+02,
|
341
|
+
-1.952394635E+01, 2.560740231E-01 ]
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def t90_coeffs_s emf
|
346
|
+
# -0.236..1.874
|
347
|
+
# 1.874..11.950
|
348
|
+
# 10.332..17.536
|
349
|
+
# 17.536..18.693
|
350
|
+
if emf < 1.874
|
351
|
+
[ 0.00000000E+00, 1.84949460E+02, -8.00504062E+01,
|
352
|
+
1.02237430E+02, -1.52248592E+02, 1.88821343E+02,
|
353
|
+
-1.59085941E+02, 8.23027880E+01, -2.34181944E+01,
|
354
|
+
2.79786260E+00 ]
|
355
|
+
elsif emf < 11.950
|
356
|
+
[ 1.291507177E+01, 1.466298863E+02, -1.534713402E+01,
|
357
|
+
3.145945973E+00, -4.163257839E-01, 3.187963771E-02,
|
358
|
+
-1.291637500E-03, 2.183475087E-05, -1.447379511E-07,
|
359
|
+
8.211272125E-09 ]
|
360
|
+
elsif emf < 17.536
|
361
|
+
[ -8.087801117E+01, 1.621573104E+02, -8.536869453E+00,
|
362
|
+
4.719686976E-01, -1.441693666E-02, 2.081618890E-04 ]
|
363
|
+
else
|
364
|
+
[ 5.333875126E+04, -1.235892298E+04, 1.092657613E+03,
|
365
|
+
-4.265693686E+01, 6.247205420E-01 ]
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
def t90_coeffs_t emf
|
370
|
+
# -5.603..0.000
|
371
|
+
# 0.000..20.872
|
372
|
+
if emf < 0.0
|
373
|
+
[ 0.0000000E+00, 2.5949192E+01, -2.1316967E-01,
|
374
|
+
7.9018692E-01, 4.2527777E-01, 1.3304473E-01,
|
375
|
+
2.0241446E-02, 1.2668171E-03 ]
|
376
|
+
else
|
377
|
+
[ 0.000000E+00, 2.592800E+01, -7.602961E-01,
|
378
|
+
4.637791E-02, -2.165394E-03, 6.048144E-05,
|
379
|
+
-7.293422E-07 ]
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Tuscan
|
2
|
+
module Iec60751
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def r t90, r0: 100.0, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12
|
6
|
+
t90 >= 0 ?
|
7
|
+
r0*(1 + a*t90 + b*t90**2) :
|
8
|
+
r0*(1 + a*t90 + b*t90**2 - 100*c*t90**3 + c*t90**4)
|
9
|
+
end
|
10
|
+
alias_method :res, :r
|
11
|
+
alias_method :resistance, :r
|
12
|
+
|
13
|
+
def t90 r, r0: 100.0, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12, err_limit: 1e-4, num_iter: 10
|
14
|
+
return 0 if r == r0
|
15
|
+
t = t90_approximation r
|
16
|
+
return Float::NAN if t.is_a? Complex
|
17
|
+
num_iter.times do
|
18
|
+
slope = (r - r0) / t
|
19
|
+
r_calc = r(t)
|
20
|
+
break if (r_calc - r).abs < slope * err_limit
|
21
|
+
t -= (r_calc - r) / slope
|
22
|
+
end
|
23
|
+
t
|
24
|
+
end
|
25
|
+
alias_method :t, :t90
|
26
|
+
alias_method :temperature, :t90
|
27
|
+
|
28
|
+
private
|
29
|
+
def t90_approximation r, r0: 100.0, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12
|
30
|
+
r >= r0 ?
|
31
|
+
(-a + (a**2 - 4 * b * (1 - r / r0))**(0.5)) / (2 * b) :
|
32
|
+
((r / r0) - 1) / (a + 100 * b)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/tuscan/its90.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
module Tuscan
|
2
|
+
module Its90
|
3
|
+
include Math
|
4
|
+
extend self
|
5
|
+
|
6
|
+
A = [ -2.13534729, 3.1832472, -1.80143597,
|
7
|
+
0.71727204, 0.50344027, -0.61899395,
|
8
|
+
-0.05332322, 0.28021362, 0.10715224,
|
9
|
+
-0.29302865, 0.04459872, 0.11868632,
|
10
|
+
-0.05248134 ]
|
11
|
+
|
12
|
+
B = [ 0.183324722, 0.240975303, 0.209108771,
|
13
|
+
0.190439972, 0.142648498, 0.077993465,
|
14
|
+
0.012475611, -0.032267127, -0.075291522,
|
15
|
+
-0.05647067, 0.076201285, 0.123893204,
|
16
|
+
-0.029201193, -0.091173542, 0.001317696,
|
17
|
+
0.026025526 ]
|
18
|
+
|
19
|
+
C = [ 2.78157254, 1.64650916, -0.1371439,
|
20
|
+
-0.00649767, -0.00234444, 0.00511868,
|
21
|
+
0.00187982, -0.00204472, -0.00046122,
|
22
|
+
0.00045724 ]
|
23
|
+
|
24
|
+
D = [ 439.932854, 472.41802, 37.684494,
|
25
|
+
7.472018, 2.920828, 0.005184,
|
26
|
+
-0.963864, -0.188732, 0.191203,
|
27
|
+
0.049025 ]
|
28
|
+
|
29
|
+
def t90 r, rtpw:, **args
|
30
|
+
w = r / rtpw
|
31
|
+
Its90.t90r w - wdev(Its90.t90r(w), args)
|
32
|
+
end
|
33
|
+
alias_method :t, :t90
|
34
|
+
alias_method :temperature, :t90
|
35
|
+
|
36
|
+
# SUBRANGES = 1..11
|
37
|
+
|
38
|
+
# T90_RANGE = -259.4467..961.88
|
39
|
+
# WR_RANGE = 0.00119007..4.28642053
|
40
|
+
|
41
|
+
#
|
42
|
+
# VALID TEMPERATURE RANGES
|
43
|
+
#
|
44
|
+
# def range
|
45
|
+
# WDEV_EQUATIONS[subrange - 1][:valid]
|
46
|
+
# end
|
47
|
+
|
48
|
+
|
49
|
+
#
|
50
|
+
# ITS-90 REFERENCE FUNCTIONS
|
51
|
+
#
|
52
|
+
def self.wr t90
|
53
|
+
# return nil unless T90_RANGE.include? t90
|
54
|
+
if t90< 0.01
|
55
|
+
exp(A.each_with_index.collect{ |a, i| a*( (log((t90+273.15)/273.16) + 1.5)/1.5 )**i }.reduce(:+))
|
56
|
+
else
|
57
|
+
C.each_with_index.collect{ |c, i| c*((t90-481)/481)**i }.reduce(:+)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.t90r wr
|
62
|
+
# return nil unless WR_RANGE.include? wr
|
63
|
+
if wr < 1.0
|
64
|
+
B.each_with_index.collect{ |b, i| b*(((wr)**(1.0/6)-0.65)/0.35)**i }.reduce(:+) * 273.16 - 273.15
|
65
|
+
else
|
66
|
+
D.each_with_index.collect{ |d, i| d*((wr-2.64)/1.64)**i }.reduce(:+)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# ITS-90 DEVIATION FUNCTIONS
|
72
|
+
#
|
73
|
+
WDEV_EQUATIONS = [ { valid: (-259.4467..0.01), k: %w(c1 c2 c3 c4 c5), n: 2 },
|
74
|
+
{ valid: (-248.5939..0.01), k: %w(c1 c2 c3 ), n: 0 },
|
75
|
+
{ valid: (-218.7916..0.01), k: %w(c1 ), n: 1 },
|
76
|
+
{ valid: (-189.3442..0.01), k: %w( ) },
|
77
|
+
{ valid: (0.0..961.78), k: %w(a b c d ) },
|
78
|
+
{ valid: (0.0..660.323), k: %w(a b c ) },
|
79
|
+
{ valid: (0.0..419.527), k: %w(a b ) },
|
80
|
+
{ valid: (0.0..231.928), k: %w(a b ) },
|
81
|
+
{ valid: (0.0..156.5985), k: %w(a ) },
|
82
|
+
{ valid: (0.0..29.7646), k: %w(a ) },
|
83
|
+
{ valid: (-38.8344..29.7646), k: %w(a b ) } ]
|
84
|
+
|
85
|
+
def wdev t90, subrange: ,
|
86
|
+
a: 0.0, b: 0.0, c: 0.0, d: 0.0, w660: 0.0,
|
87
|
+
c1: 0.0, c2: 0.0, c3: 0.0, c4: 0.0, c5: 0.0
|
88
|
+
equation = WDEV_EQUATIONS[subrange - 1]
|
89
|
+
# return nil unless equation[:valid].include? t90
|
90
|
+
wr_t90 = Its90.wr t90
|
91
|
+
case subrange
|
92
|
+
when 1..4
|
93
|
+
wdev = a * (wr_t90 - 1)
|
94
|
+
subrange == 4 ?
|
95
|
+
wdev += b * (wr_t90 - 1) * log(wr_t90) :
|
96
|
+
wdev += b * (wr_t90 - 1)**2
|
97
|
+
wdev += equation[:k].each_with_index.
|
98
|
+
collect{ |k, i| eval("#{k}") * log(wr_t90)**(i + equation[:n]) }.reduce(:+) || 0
|
99
|
+
when 5..11
|
100
|
+
wdev = d * (wr_t90 - w660)**2 if equation[:k].delete('d')
|
101
|
+
wdev ||= 0
|
102
|
+
wdev += equation[:k].each_with_index.
|
103
|
+
collect{ |k, i| eval("#{k}") * (wr_t90 - 1)**(i+1) }.reduce(:+)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/tuscan.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'tuscan/version'
|
2
|
+
require 'tuscan/its90'
|
3
|
+
require 'tuscan/iec60751'
|
4
|
+
require 'tuscan/iec60584'
|
5
|
+
|
6
|
+
module Tuscan
|
7
|
+
extend self
|
8
|
+
|
9
|
+
private
|
10
|
+
def method_missing method, *args, &block
|
11
|
+
subject, *remaining_args = args
|
12
|
+
const_get(subject.to_s.capitalize).send method, *remaining_args, &block
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'tuscan'
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#
|
4
|
+
# TODO:
|
5
|
+
# 1. compute inverse of emfr by iterative process (will pass R, B examples)
|
6
|
+
# 2. get aproximate t90 valid fro -270.0..-200.0 (will pass E, K, N, T examples)
|
7
|
+
# 3. implement deviation function (polynomial)
|
8
|
+
#
|
9
|
+
module Tuscan
|
10
|
+
describe Iec60584 do
|
11
|
+
context 'reference functions' do
|
12
|
+
examples = {
|
13
|
+
b: [
|
14
|
+
# { emf: 0.000, t90: 0.0 },
|
15
|
+
{ emf: 0.291, t90: 250.0 },
|
16
|
+
{ emf: 1.975, t90: 630.0 },
|
17
|
+
{ emf: 1.981, t90: 631.0 },
|
18
|
+
{ emf: 5.780, t90:1100.0 },
|
19
|
+
{ emf: 13.820, t90:1820.0 }
|
20
|
+
],
|
21
|
+
c: [
|
22
|
+
{ emf: 0.000, t90: 0.0 },
|
23
|
+
{ emf: 1.451, t90: 100.0 },
|
24
|
+
{ emf: 11.778, t90: 660.0 },
|
25
|
+
{ emf: 20.066, t90:1100.0 },
|
26
|
+
{ emf: 29.402, t90:1680.0 },
|
27
|
+
{ emf: 37.107, t90:2320.0 }
|
28
|
+
],
|
29
|
+
e: [
|
30
|
+
# { emf: -9.835, t90:-270.0 },
|
31
|
+
{ emf: -8.825, t90:-200.0 },
|
32
|
+
{ emf: -5.237, t90:-100.0 },
|
33
|
+
{ emf: 0.000, t90: 0.0 },
|
34
|
+
{ emf: 6.319, t90: 100.0 },
|
35
|
+
{ emf: 49.917, t90: 660.0 },
|
36
|
+
{ emf: 76.373, t90:1000.0 }
|
37
|
+
],
|
38
|
+
j: [
|
39
|
+
{ emf: -8.095, t90:-210.0 },
|
40
|
+
{ emf: -4.633, t90:-100.0 },
|
41
|
+
{ emf: 0.000, t90: 0.0 },
|
42
|
+
{ emf: 36.675, t90: 660.0 },
|
43
|
+
{ emf: 43.559, t90: 770.0 },
|
44
|
+
{ emf: 69.553, t90:1200.0 }
|
45
|
+
],
|
46
|
+
k: [
|
47
|
+
# { emf: -6.458, t90:-270.0 },
|
48
|
+
{ emf: -5.891, t90:-200.0 },
|
49
|
+
{ emf: -3.554, t90:-100.0 },
|
50
|
+
{ emf: 0.000, t90: 0.0 },
|
51
|
+
{ emf: 5.206, t90: 127.0 },
|
52
|
+
{ emf: 27.447, t90: 660.0 },
|
53
|
+
{ emf: 54.886, t90:1372.0 }
|
54
|
+
],
|
55
|
+
n: [
|
56
|
+
# { emf: -4.345, t90:-270.0 },
|
57
|
+
{ emf: -3.990, t90:-200.0 },
|
58
|
+
{ emf: -2.407, t90:-100.0 },
|
59
|
+
{ emf: 0.000, t90: 0.0 },
|
60
|
+
{ emf: 2.774, t90: 100.0 },
|
61
|
+
{ emf: 22.958, t90: 660.0 },
|
62
|
+
{ emf: 47.513, t90:1300.0 }
|
63
|
+
],
|
64
|
+
r: [
|
65
|
+
# { emf: -0.226, t90: -50.0 },
|
66
|
+
{ emf: -0.123, t90: -25.0 },
|
67
|
+
{ emf: 0.000, t90: 0.0 },
|
68
|
+
{ emf: 6.273, t90: 660.0 },
|
69
|
+
{ emf: 11.850, t90:1100.0 },
|
70
|
+
{ emf: 21.101, t90:1768.0 }
|
71
|
+
],
|
72
|
+
s: [
|
73
|
+
{ emf: -0.236, t90: -50.0 },
|
74
|
+
{ emf: -0.127, t90: -25.0 },
|
75
|
+
{ emf: 0.000, t90: 0.0 },
|
76
|
+
{ emf: 5.857, t90: 660.0 },
|
77
|
+
{ emf: 10.757, t90:1100.0 },
|
78
|
+
{ emf: 18.693, t90:1768.0 }
|
79
|
+
],
|
80
|
+
t: [
|
81
|
+
# { emf: -6.258, t90:-270.0 },
|
82
|
+
{ emf: -5.603, t90:-200.0 },
|
83
|
+
{ emf: -3.379, t90:-100.0 },
|
84
|
+
{ emf: 0.000, t90: 0.0 },
|
85
|
+
{ emf: 4.279, t90: 100.0 },
|
86
|
+
{ emf: 9.288, t90: 200.0 },
|
87
|
+
{ emf: 20.872, t90: 400.0 }
|
88
|
+
]
|
89
|
+
}
|
90
|
+
|
91
|
+
context 'emfr computation' do
|
92
|
+
%i{ b c e j k n r s t }.each do |type|
|
93
|
+
context "on a type #{type.upcase} thermocouple" do
|
94
|
+
examples[type].each do |example|
|
95
|
+
it "yields #{example[:emf]} mV when t90 equals #{example[:t90]} ºC" do
|
96
|
+
expect(Iec60584.emfr(example[:t90], type)).to be_within(1e-3).of(example[:emf])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 't90r computation' do
|
104
|
+
%i{ b e j k n r s t }.each do |type|
|
105
|
+
context "on a type #{type.upcase} thermocouple" do
|
106
|
+
examples[type].each do |example|
|
107
|
+
it "yields #{example[:t90]} ºC when emf equals #{example[:emf]} mV" do
|
108
|
+
expect(Iec60584.t90r(example[:emf], type)).to be_within(0.1).of(example[:t90])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tuscan
|
4
|
+
describe Iec60751 do
|
5
|
+
examples = [ { r: 18.5201, t90: -200.0000 },
|
6
|
+
{ r: 60.2558, t90: -100.0000 },
|
7
|
+
{ r: 100.0000, t90: 0.0000 },
|
8
|
+
{ r: 247.0920, t90: 400.0000 },
|
9
|
+
{ r: 390.4811, t90: 850.0000 } ]
|
10
|
+
|
11
|
+
context 'resistance computation' do
|
12
|
+
context 'standard coefficients' do
|
13
|
+
examples.each do |example|
|
14
|
+
it "yields #{example[:r]} Ohm when t90 equals #{example[:t90]} Celsius" do
|
15
|
+
expect(Iec60751.r example[:t90]).to be_within(1e-4).of(example[:r])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'non-standard coefficients' do
|
21
|
+
it 'yields 101.0 Ohm when temperature equals 0.0 Celsius for r0 = 101.0 Ohm' do
|
22
|
+
expect(Iec60751.r 0, r0: 101.0).to be_within(1e-4).of(101)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'temperature computation' do
|
28
|
+
it 'yields complex temperatures as NaN' do
|
29
|
+
expect(Iec60751.t90 1000).to be Float::NAN
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'standard coefficients' do
|
33
|
+
examples.each do |example|
|
34
|
+
it "yields #{example[:t90]} Celius when resistance equals #{example[:r]} Ohm" do
|
35
|
+
expect(Iec60751.t90 example[:r]).to be_within(1e-4).of(example[:t90])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'non-standard coefficients' do
|
41
|
+
it 'yields 0.0 Celsius when resistance equals 101.0 Ohm on a FUNCTION with r0 = 101.0 Ohm' do
|
42
|
+
expect(Iec60751.t90 101, r0: 101.0).to be_within(1e-4).of(0)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tuscan
|
4
|
+
describe Its90 do
|
5
|
+
context 'reference funtions' do
|
6
|
+
examples = [
|
7
|
+
{ fixed_point: 'e-H2 Tp', t90: -259.3467, wr: 0.00119007 },
|
8
|
+
{ fixed_point: 'Ne Tp', t90: -248.5939, wr: 0.00844974 },
|
9
|
+
{ fixed_point: 'O2 Tp', t90: -218.7916, wr: 0.09171804 },
|
10
|
+
{ fixed_point: 'Ar Tp', t90: -189.3442, wr: 0.21585975 },
|
11
|
+
{ fixed_point: 'Hg Tp', t90: -38.8344, wr: 0.84414211 },
|
12
|
+
{ fixed_point: 'H2O Tp', t90: 0.01, wr: 1.00000000 },
|
13
|
+
{ fixed_point: 'Ga Mp', t90: 29.7646, wr: 1.11813889 },
|
14
|
+
{ fixed_point: 'In Fp', t90: 156.5985, wr: 1.60980185 },
|
15
|
+
{ fixed_point: 'Sn Fp', t90: 231.9280, wr: 1.89279768 },
|
16
|
+
{ fixed_point: 'Zn Fp', t90: 419.5270, wr: 2.56891730 },
|
17
|
+
{ fixed_point: 'Al Fp', t90: 660.3230, wr: 3.37600860 },
|
18
|
+
{ fixed_point: 'Ag Fp', t90: 961.7800, wr: 4.28642053 }
|
19
|
+
]
|
20
|
+
|
21
|
+
context 'wr computation' do
|
22
|
+
examples.each do |example|
|
23
|
+
it "complies on #{example[:fixed_point]} fixed point" do
|
24
|
+
expect(Its90.wr example[:t90]).to be_within(1e-8).of(example[:wr])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 't90r computation' do
|
30
|
+
examples.each do |example|
|
31
|
+
it "complies on #{example[:fixed_point]} fixed point" do
|
32
|
+
expect(Its90.t90r example[:wr]).to be_within(0.00013).of(example[:t90])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'deviation functions' do
|
39
|
+
context 'wdev computation' do
|
40
|
+
context 'range 4' do
|
41
|
+
# Examples valid for sub-range = 4, a = -1.2579994e-04, b = 1.0678395e-05 as per NIST SP250-81
|
42
|
+
sprt = { subrange: 4, a: -1.2579994e-04, b: 1.0678395e-05 }
|
43
|
+
examples = [
|
44
|
+
{ t90: -189.3442, wdev: 0.000111482 },
|
45
|
+
{ t90: -100.0000, wdev: 0.000053258 },
|
46
|
+
{ t90: -38.8344, wdev: 0.000019889 },
|
47
|
+
{ t90: 0.0000, wdev: 0.000000005 }
|
48
|
+
]
|
49
|
+
|
50
|
+
examples.each do |example|
|
51
|
+
it "complies with NIST SP250-81 example on range 4, #{example[:t90]} Celsius" do
|
52
|
+
expect(Its90.wdev example[:t90], sprt).to be_within(1e-8).of(example[:wdev])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'range 6' do
|
58
|
+
sprt = { subrange: 6, a: -1.6462789e-04, b: -8.4598339e-06, c: 1.8898584e-06 }
|
59
|
+
examples = [
|
60
|
+
{ t90: 0.000, wdev: 0.000000007},
|
61
|
+
{ t90: 100.000, wdev: -0.000065852},
|
62
|
+
{ t90: 231.928, wdev: -0.000152378},
|
63
|
+
{ t90: 419.527, wdev: -0.000271813},
|
64
|
+
{ t90: 660.323, wdev: -0.000413567}
|
65
|
+
]
|
66
|
+
|
67
|
+
examples.each do |example|
|
68
|
+
it "complies with NIST SP250-81 example on range 6, #{example[:t90]} Celsius" do
|
69
|
+
expect(Its90.wdev example[:t90], sprt).to be_within(1e-8).of(example[:wdev])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 't90 function' do
|
77
|
+
sprt = { rtpw: 25.319871, subrange: 7, a: -1.2134e-04, b: -9.9190e-06 }
|
78
|
+
examples = [
|
79
|
+
{ r: 25.319871, t90: 0.010 },
|
80
|
+
{ r: 47.922451, t90: 231.928 },
|
81
|
+
{ r: 65.039218, t90: 419.527 }
|
82
|
+
]
|
83
|
+
|
84
|
+
examples.each do |example|
|
85
|
+
it "complies with IPQ cert. 501.20/1241312 range 7, #{example[:t90]} Celsius" do
|
86
|
+
expect(Its90.t90 example[:r], sprt).to be_within(0.0001).of(example[:t90])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/tuscan_spec.rb
ADDED
data/tasks/rspec.rake
ADDED
data/tuscan.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tuscan/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tuscan"
|
8
|
+
spec.version = Tuscan::VERSION
|
9
|
+
spec.authors = ["Luis Bacelar"]
|
10
|
+
spec.email = ["lmbacelar@gmail.com"]
|
11
|
+
spec.summary = %q{Converts to and from temperature for standard (S)PRT's and thermocouples}
|
12
|
+
spec.description = %q{Converts from electrical signal to temperature and vice-versa for ITS-90 SPRT's, IEC 60751 PRT's and IEC 60584 thermocouples}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'byebug'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tuscan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luis Bacelar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Converts from electrical signal to temperature and vice-versa for ITS-90
|
70
|
+
SPRT's, IEC 60751 PRT's and IEC 60584 thermocouples
|
71
|
+
email:
|
72
|
+
- lmbacelar@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/tuscan.rb
|
84
|
+
- lib/tuscan/iec60584.rb
|
85
|
+
- lib/tuscan/iec60751.rb
|
86
|
+
- lib/tuscan/its90.rb
|
87
|
+
- lib/tuscan/version.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/tuscan/iec60584_spec.rb
|
90
|
+
- spec/tuscan/iec60751_spec.rb
|
91
|
+
- spec/tuscan/its90_spec.rb
|
92
|
+
- spec/tuscan_spec.rb
|
93
|
+
- tasks/rspec.rake
|
94
|
+
- tuscan.gemspec
|
95
|
+
homepage: ''
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.4.5
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Converts to and from temperature for standard (S)PRT's and thermocouples
|
119
|
+
test_files:
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/tuscan/iec60584_spec.rb
|
122
|
+
- spec/tuscan/iec60751_spec.rb
|
123
|
+
- spec/tuscan/its90_spec.rb
|
124
|
+
- spec/tuscan_spec.rb
|