CVDEquation¤
The Callendar-Van Dusen (CVD) equation describes the relationship between resistance, \(R\), and temperature, \(t\), of platinum resistance thermometers (PRT). It is defined in two temperature ranges
where, \(R_0 = R(0~^{\circ}\text{C})\) is the resistance at \(t=0~^{\circ}\text{C}\) and \(A\), \(B\), \(C\) and \(D\) are the CVD coefficients. The \(D\) coefficient is typically zero but may be non-zero if \(t \gtrsim 200~^{\circ}\text{C}\).
Suppose you have a variable named cvd
(which is an instance of CVDEquation) that represents the following information in an equipment register for a PRT
<cvdCoefficients>
<R0>100.0189</R0>
<A>3.913e-3</A>
<B>-6.056e-7</B>
<C>1.372e-12</C>
<D>0</D>
<uncertainty variables="">0.0056/2</uncertainty>
<range>
<minimum>-10</minimum>
<maximum>70</maximum>
</range>
</cvdCoefficients>
You can access the CVD coefficients, degrees of freedom and comment as attributes of cvd
,
>>> cvd.R0
100.0189
>>> cvd.A
0.003913
>>> cvd.B
-6.056e-07
>>> cvd.C
1.372e-12
>>> cvd.D
0.0
>>> cvd.degree_freedom
inf
>>> cvd.comment
''
evaluate the uncertainty,
>>> print(cvd.uncertainty())
0.0026
calculate resistance from temperature,
>>> print(cvd.resistance(12.4))
104.86262358516764
>>> cvd.resistance([-5, 0, 5, 10, 15, 20, 25])
array([ 98.06051774, 100.0189 , 101.97425549, 103.92658241,
105.87588076, 107.82215054, 109.76539174])
and calculate temperature from resistance
>>> print(cvd.temperature(109.1))
23.287055698724505
>>> cvd.temperature([98.7, 99.2, 100.4, 101.7, 103.8])
array([-3.36816839, -2.09169544, 0.9738958 , 4.29823964, 9.67558125])
A number or any sequence of numbers, i.e., a list, tuple or ndarray may be used to calculate the temperature or resistance (tip: using ndarray will improve performance since a copy of the values is not required).
When calculating resistance or temperature, the values of the inputs are checked to ensure that the values are within the range that the CVD coefficients are valid for. The XML data above shows that the temperature must be in the range \(-10~^\circ\text{C}\) to \(70~^\circ\text{C}\), which has a corresponding resistance range of \(96.099~\Omega\) to \(127.118~\Omega\) from the equation above. If you calculate resistance from \(t=-10.2~^\circ\text{C}\) or temperature from \(R=96.0~\Omega\) a ValueError is raised, since the value is outside the range.
>>> cvd.ranges
{'t': Range(minimum=-10, maximum=70), 'r': Range(minimum=96.099, maximum=127.118)}
>>> cvd.resistance(-10.2)
Traceback (most recent call last):
...
ValueError: The value -10.2 is not within the range [-10, 70]
>>> cvd.temperature(96)
Traceback (most recent call last):
...
ValueError: The value 96.0 is not within the range [96.099, 127.118]
You can bypass range checking by including a check_range=False
keyword argument
>>> print(cvd.resistance(-10.2, check_range=False))
96.02059984653798
>>> print(cvd.temperature(96, check_range=False))
-10.252469261526016
CVDEquation
dataclass
¤
CVDEquation(
R0: float,
A: float,
B: float,
C: float,
D: float,
uncertainty: Evaluable,
ranges: dict[str, Range] = dict(),
degree_freedom: float = float("inf"),
comment: str = "",
)
The Callendar-Van Dusen (CVD) equation based on the cvdCoefficients element in an equipment register.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
R0
|
float
|
The value, in \(\Omega\), of the resistance at \(0~^\circ\text{C}\), \(R_0\). |
required |
A
|
float
|
The value, in \((^\circ\text{C})^{-1}\), of the A coefficient, \(A \cdot t\). |
required |
B
|
float
|
The value, in \((^\circ\text{C})^{-2}\), of the B coefficient, \(B \cdot t^2\). |
required |
C
|
float
|
The value, in \((^\circ\text{C})^{-4}\), of the C coefficient, \(C \cdot t^3 \cdot (t-100)\). |
required |
D
|
float
|
The value, in \((^\circ\text{C})^{-3}\), of the D coefficient, \(D \cdot t^3\). The \(D\) coefficient is typically zero but may be non-zero if \(t \gtrsim 200~^{\circ}\text{C}\). If a calibration report does not specify the \(D\) coefficient, set the value to be 0. |
required |
uncertainty
|
Evaluable
|
The equation to evaluate to calculate the standard uncertainty. |
required |
ranges
|
dict[str, Range]
|
The temperature range, in \((^\circ)\text{C}\), and the resistance range, in \(\Omega\),
that the CVD coefficients are valid. The temperature key must be |
dict()
|
degree_freedom
|
float
|
The degrees of freedom. |
float('inf')
|
comment
|
str
|
A comment to associate with the CVD equation. |
''
|
A
instance-attribute
¤
A: float
The value, in \((^\circ\text{C})^{-1}\), of the A coefficient, \(A \cdot t\).
B
instance-attribute
¤
B: float
The value, in \((^\circ\text{C})^{-2}\), of the B coefficient, \(B \cdot t^2\).
C
instance-attribute
¤
C: float
The value, in \((^\circ\text{C})^{-4}\), of the C coefficient, \(C \cdot t^3 \cdot (t-100)\).
D
instance-attribute
¤
D: float
The value, in \((^\circ\text{C})^{-3}\), of the D coefficient, \(D \cdot t^3\).
R0
instance-attribute
¤
R0: float
The value, in \(\Omega\), of the resistance at \(0~^\circ\text{C}\), \(R_0\).
comment
class-attribute
instance-attribute
¤
comment: str = ''
A comment associated with the Callendar-Van Dusen equation.
degree_freedom
class-attribute
instance-attribute
¤
The degrees of freedom.
ranges
class-attribute
instance-attribute
¤
The temperature range, in \(^\circ\text{C}\), and the resistance range, in \(\Omega\), that the Callendar-Van Dusen coefficients are valid.
uncertainty
instance-attribute
¤
uncertainty: Evaluable
The equation to evaluate to calculate the standard uncertainty.
from_xml
classmethod
¤
from_xml(element: Element[str]) -> CVDEquation
Convert an XML element into a CVDEquation instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
Element[str]
|
A cvdCoefficients XML element from an equipment register. |
required |
Returns:
Type | Description |
---|---|
CVDEquation
|
The CVDEquation instance. |
Source code in src/msl/equipment/schema.py
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 |
|
resistance
¤
Calculate resistance from temperature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature
|
ArrayLike
|
The temperature values, in \(^\circ\text{C}\). |
required |
check_range
|
bool
|
Whether to check that the temperature values are within the allowed range. |
True
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
The resistance values. |
Source code in src/msl/equipment/schema.py
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
|
temperature
¤
Calculate temperature from resistance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resistance
|
ArrayLike
|
The resistance values, in \(\Omega\). |
required |
check_range
|
bool
|
Whether to check that the resistance values are within the allowed range. |
True
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
The temperature values. |
Source code in src/msl/equipment/schema.py
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 |
|
to_xml
¤
Convert the CVDEquation class into an XML element.
Returns:
Type | Description |
---|---|
Element[str]
|
The CVDEquation as an XML element. |
Source code in src/msl/equipment/schema.py
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
|