In [ ]:
import tensorflow as tf
In [2]:
from tensorflow import where
from tensorflow.math import greater_equal
from tensorflow.math import less
from tensorflow.math import logical_and
from tensorflow.math import greater
from tensorflow.math import pow
from tensorflow.math import log
def _lambdifygenerated(
T,
LIQUID0AL,
LIQUID0CU,
LIQUID0ZR,
):
return 8.3145 * T * (1.0 * where(greater(LIQUID0AL, 1.0e-16),
LIQUID0AL * log(LIQUID0AL), 0) / (1.0
* LIQUID0AL + 1.0 * LIQUID0CU + 1.0
* LIQUID0ZR) + 1.0 * where(greater(LIQUID0CU,
1.0e-16), LIQUID0CU * log(LIQUID0CU), 0)
/ (1.0 * LIQUID0AL + 1.0 * LIQUID0CU + 1.0
* LIQUID0ZR) + 1.0 * where(greater(LIQUID0ZR,
1.0e-16), LIQUID0ZR * log(LIQUID0ZR), 0)
/ (1.0 * LIQUID0AL + 1.0 * LIQUID0CU + 1.0
* LIQUID0ZR)) + (LIQUID0AL
* where(logical_and(greater_equal(T, 298.14), less(T,
700.0)), 7.9337e-20 * pow(T, 7) - 11.841867 * T
+ where(logical_and(greater_equal(T, 298.14), less(T,
700.0)), -8.77664e-7 * pow(T, 3) - 0.001884662 * pow(T, 2)
- 24.3671976 * T * log(T) + 137.093038 * T - 7976.15
+ 74092 / T, where(logical_and(greater_equal(T, 700.0),
less(T, 933.47)), -5.764227e-6 * pow(T, 3) + 0.018531982
* pow(T, 2) - 38.5844296 * T * log(T) + 223.048446 * T
- 11276.24 + 74092 / T, where(logical_and(greater_equal(T,
933.47), less(T, 2900.0)), -31.748192 * T * log(T)
+ 188.684153 * T - 11278.378 - 1.230524e+28 / pow(T, 9),
0))) + 11005.029, where(logical_and(greater_equal(T,
700.0), less(T, 933.47)), 7.9337e-20 * pow(T, 7)
- 11.841867 * T + where(logical_and(greater_equal(T,
298.14), less(T, 700.0)), -8.77664e-7 * pow(T, 3)
- 0.001884662 * pow(T, 2) - 24.3671976 * T * log(T)
+ 137.093038 * T - 7976.15 + 74092 / T,
where(logical_and(greater_equal(T, 700.0), less(T,
933.47)), -5.764227e-6 * pow(T, 3) + 0.018531982 * pow(T,
2) - 38.5844296 * T * log(T) + 223.048446 * T - 11276.24
+ 74092 / T, where(logical_and(greater_equal(T, 933.47),
less(T, 2900.0)), -31.748192 * T * log(T) + 188.684153 * T
- 11278.378 - 1.230524e+28 / pow(T, 9), 0))) + 11005.03,
where(logical_and(greater_equal(T, 933.47), less(T,
2900.0)), -31.748192 * T * log(T) + 177.430178 * T
- 795.996, 0))) + LIQUID0CU
* where(logical_and(greater_equal(T, 298.14), less(T,
1357.77)), -5.8489e-21 * pow(T, 7) - 9.511904 * T
+ where(logical_and(greater_equal(T, 298.14), less(T,
1357.77)), 1.29223e-7 * pow(T, 3) - 0.00265684 * pow(T, 2)
- 24.112392 * T * log(T) + 130.485235 * T - 7770.458
+ 52478 / T, where(logical_and(greater_equal(T, 1357.77),
less(T, 3200.0)), -31.38 * T * log(T) + 183.803828 * T
- 13542.026 + 3.64167e+29 / pow(T, 9), 0)) + 12964.735,
where(logical_and(greater_equal(T, 1357.77), less(T,
3200.0)), -31.38 * T * log(T) + 173.881484 * T - 46.545,
0)) + LIQUID0ZR * where(logical_and(greater_equal(T,
130.0), less(T, 2128.0)), 1.6275e-22 * pow(T, 7) - 9.080812
* T + where(logical_and(greater_equal(T, 130.0), less(T,
2128.0)), -0.00437791 * pow(T, 2) - 24.1618 * T * log(T)
+ 125.64905 * T - 7827.595 + 34971 / T,
where(logical_and(greater_equal(T, 2128.0), less(T,
6000.0)), -42.144 * T * log(T) + 262.724183 * T - 26085.921
- 1.342896e+31 / pow(T, 9), 0)) + 18147.69,
where(logical_and(greater_equal(T, 2128.0), less(T,
6000.0)), -42.144 * T * log(T) + 253.812609 * T - 8281.26,
0))) / (1.0 * LIQUID0AL + 1.0 * LIQUID0CU + 1.0
* LIQUID0ZR) + (LIQUID0AL * LIQUID0CU * LIQUID0ZR
* (-1 / 3 * LIQUID0AL + 2 / 3
* LIQUID0CU - 1 / 3 * LIQUID0ZR + 1
/ 3)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)),
150013.2, 0) + LIQUID0AL
* LIQUID0CU * LIQUID0ZR * (2 / 3
* LIQUID0AL - 1 / 3 * LIQUID0CU - 1
/ 3 * LIQUID0ZR + 1 / 3)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 100.2335
* T - 417439.6, 0) + LIQUID0AL
* LIQUID0CU * pow(LIQUID0AL
- LIQUID0CU, 3)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 5.5 * T
- 7290, 0) + LIQUID0AL * LIQUID0CU
* pow(LIQUID0AL - LIQUID0CU, 2)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 5915
- 5.889 * T, 0) + LIQUID0AL
* LIQUID0CU * (LIQUID0AL
- LIQUID0CU)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 32148
- 7.118 * T, 0) + LIQUID0AL
* LIQUID0CU
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 8.555
* T - 67094, 0) + LIQUID0AL
* LIQUID0ZR * pow(LIQUID0AL
- LIQUID0ZR, 2)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 48183.91
- 10.62301 * T, 0) + LIQUID0AL
* LIQUID0ZR * (LIQUID0AL
- LIQUID0ZR)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 7.35154
* T - 20276.51, 0) + LIQUID0AL
* LIQUID0ZR
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 50.03303
* T - 184477.95, 0) + LIQUID0CU
* LIQUID0ZR * pow(LIQUID0CU
- LIQUID0ZR, 3)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), -13.6488
* T * log(T) + 119.5438 * T
- 22368.721, 0) + LIQUID0CU
* LIQUID0ZR * pow(LIQUID0CU
- LIQUID0ZR, 2)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), 36.8512
* T * log(T) - 307.3817 * T
+ 56633.154, 0) + LIQUID0CU
* LIQUID0ZR * (LIQUID0CU
- LIQUID0ZR)
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), -9.6125
* T * log(T) + 84.9923 * T
- 22066.212, 0) + LIQUID0CU
* LIQUID0ZR
* where(logical_and(greater_equal(T,
298.15), less(T, 6000.0)), -51.3121
* T * log(T) + 444.1606 * T
- 140638.632, 0)) / (1.0
* LIQUID0AL + 1.0 * LIQUID0CU + 1.0 * LIQUID0ZR)
In [3]:
%%timeit
func_xla = tf.function(experimental_compile=True)(_lambdifygenerated)
In [4]:
func_xla = tf.function(experimental_compile=True)(_lambdifygenerated)
In [10]:
# SymEngine/LLVM: 2.68 µs ± 64.1 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
%timeit func_xla(300., 0.3, 0.3, 0.4)
In [ ]: