TabProps merge requestshttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests2023-11-14T15:58:06Zhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/13lowering tolerance for what is considered uniform spacing2023-11-14T15:58:06ZElizabeth Armstronglowering tolerance for what is considered uniform spacingWe ran into an issue of the following "high res" data not being interpolated correctly (which was a scaled version of an enthalpy defect). Lowering the uniform spacing tolerance addressed the issue.
"""
import numpy as np
from pytabprop...We ran into an issue of the following "high res" data not being interpolated correctly (which was a scaled version of an enthalpy defect). Lowering the uniform spacing tolerance addressed the issue.
"""
import numpy as np
from pytabprops import LagrangeInterpolant1D, StateTable
import matplotlib.pyplot as plt
x = np.array([1. , 2.02321341, 3.04642683, 4.06964024])
x2 = np.array([1.000000000000000e+00, 2.023213414585707e+00, 3.046426829171402e+00, 4.069640243757108e+00])
y = np.array([950.29194127, 945.06973705, 939.99250336, 935.04420355]) - 934.
y += 4.*(x-1)**2
kind = 1
interp = LagrangeInterpolant1D(kind, x, y, True)
interp2 = LagrangeInterpolant1D(kind, x2, y, True)
tbl = StateTable()
tbl.add_entry("val", interp, ['x'])
tbl.add_entry("val2", interp2, ['x'])
interpolant = lambda x: tbl.query("val", x)
interpolant2 = lambda x: tbl.query("val2", x)
query = np.linspace(x[0],x[-1],100)
plt.plot(x,y,'k*')
plt.plot(query, interpolant(query), label='low res')
plt.plot(query, interpolant2(query), label='high res')
plt.grid()
plt.legend()
plt.show()
print('low res',np.max(np.abs(y-interpolant(x))))
print('high res',np.max(np.abs(y-interpolant2(x2))))
"""James SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/12Add pytabprops support for the mixing model without Cantera2021-04-20T13:52:13ZMike HansenAdd pytabprops support for the mixing model without CanteraHi @james and @elizabeth! Pytabprops and conda-based toolchains have me excited about using Spitfire and TabProps together. Being able to use the PDFs and integrator in Python would be a nice addition. I'd like to take a reaction model b...Hi @james and @elizabeth! Pytabprops and conda-based toolchains have me excited about using Spitfire and TabProps together. Being able to use the PDFs and integrator in Python would be a nice addition. I'd like to take a reaction model built in Spitfire and, with pytabprops, entirely in Python without intermediate tables or input files, create and visualize a table for a turbulent flow.
This change grafts on a new CMake variable that lets me build the mixing model code without Cantera (only needed for the _reaction_ preprocessors) and puts a simple interface (pybind is so cool!) around the Beta and Clipped Gaussian PDFs. I can call `get_pdf` and `integrate(LagrangeInterpolant1D)` from Python. I'll note that TabProps' integrator is about 200x faster than using scipy's `quad_vec` with a scipy interpolant and `lambda x: scipyinterp(x) * mdl.get_pdf(x)` as the integrand. There could be a number of reasons for the performance difference, but I really don't care since I can just use TabProps anyway ;).
There's also a little Python test setup in here, which could be expanded for the higher-dimensional interpolants, and which could include correctness testing on the PDFs, although I'm not sure that's totally warranted at this level. We could probably just verify that the Python API is working correctly - the mean/variance are correct, etc.
So the best part about this is skipping the cantera source build and using conda to get boost. I didn't install a single TPL myself. Here's the configure script I was running with the environment setup commented out. Note `boost-cpp` in there. CMake not being too smart with Python (it finds system Python even with the conda environment active) is annoying but could possibly be resolved with an environment variable prior to running `cmake` for automated builds.
```
# set up the tool chain
# conda create --name cppenv python=3.7
# conda activate cppenv
# conda install numpy scipy matplotlib
# conda install -c anaconda cmake
# conda install -c conda-forge boost-cpp
# conda install -c conda-forge pybind11
# set up a build dir
# mkdir build
# cd build
# and then run this script (../configure), build, and test
cmake .. \
-DPYTHON_LIBRARY=/opt/anaconda3/envs/cppenv/lib/libpython3.7m.a \
-DPYTHON_INCLUDE_DIR=/opt/anaconda3/envs/cppenv/bin/python3.7m \
-DPYTHON_EXECUTABLE=/opt/anaconda3/envs/cppenv/bin/python3.7 \
-DENABLE_PYTHON=ON \
-DENABLE_MIXMDL=ON \
-DTabProps_UTILS=ON \
-DTabProps_PREPROCESSOR=OFF \
-DTabProps_ENABLE_TESTING=ON \
-DCMAKE_BUILD_TYPE=Release
# make -j4 install
# ctest
# or ctest -R "pytabprops"
```James SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/11- add ability to create TabProps table from Spitfire flamelet data2020-04-09T15:54:51ZElizabeth Armstrong- add ability to create TabProps table from Spitfire flamelet dataAdded SpitfireToTabProps file to create a TabProps table from Spitfire flamelet txt files.Added SpitfireToTabProps file to create a TabProps table from Spitfire flamelet txt files.James SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/10- fix to index_finder2020-02-04T23:22:33ZElizabeth Armstrong- fix to index_finderChanged Regula Falsi to std::lower_bound for CPUChanged Regula Falsi to std::lower_bound for CPUJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/9Move assert() from 1D constructor to its second_derivative method.2016-09-22T21:55:02ZJames SutherlandMove assert() from 1D constructor to its second_derivative method.This will assure that there are enough number of points for second order derivative. Also lets the interpolator to run the value() method with less points (order+1)This will assure that there are enough number of points for second order derivative. Also lets the interpolator to run the value() method with less points (order+1)James SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/5Add derivative member on CUDA2016-07-27T21:05:52ZJames SutherlandAdd derivative member on CUDASilence warningsSilence warningsJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/2Gpu engine2016-06-01T23:57:23ZJames SutherlandGpu engineThe GPU engine
- manages the memory allocation and transfer on the GPU
- gpu kernel for value()
- have test files for tables with 1-5 dimension
* (==) operator does not support gpu memories. I am working on a gpu_vec_co...The GPU engine
- manages the memory allocation and transfer on the GPU
- gpu kernel for value()
- have test files for tables with 1-5 dimension
* (==) operator does not support gpu memories. I am working on a gpu_vec_compare() kernel that compares two gpu array (double *).
James SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/3Resolve the error on the Debug_GPU2016-06-02T20:07:24ZJames SutherlandResolve the error on the Debug_GPUJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/4Change vector<double*> to vector<const double*>2016-07-23T17:49:01ZJames SutherlandChange vector<double*> to vector<const double*>Copy variables in the class cloneCopy variables in the class cloneJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/7Add derivative() on GPU2016-07-29T16:40:31ZJames SutherlandAdd derivative() on GPUJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/8Improve GPU performance in derivatove1d by unrolling for loop for 1st and 2nd...2016-08-22T21:11:49ZJames SutherlandImprove GPU performance in derivatove1d by unrolling for loop for 1st and 2nd orderJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/6Gpu error2016-07-27T21:07:15ZJames SutherlandGpu errorJames SutherlandJames Sutherlandhttps://gitlab.multiscale.utah.edu/common/TabProps/-/merge_requests/1Turn on serilization test for 4D and 5D testfiles.2016-05-18T19:22:18ZJames SutherlandTurn on serilization test for 4D and 5D testfiles.The tests are passed with no errors! The tests are passed with no errors! James SutherlandJames Sutherland