@alters, can you build CADET from source or do you need binaries?
I don’t want to put something untested / unfinished into the main branch. I’d prefer to have a feature branch that you can download and compile (or receive binaries from).
I am a bit unfamiliar with how to build from source, so it would be easiest to have the binaries.
Thanks for the help, Sam
That’s probably fine. What OS are you using (i.e., Windows, Linux, Mac)?
I can do Windows binaries. For Linux and Mac you need to compile yourself (instructions are available).
I am using Windows 10 OS.
Hey @Seemansgarn and @alters, I’ve finished the first take on the isotherms.
cadet-4.3.0-win10-x64-SIPS-Freundlich.zip (4.4 MB)
The zip file contains the cadet-cli
binary and the corresponding cadet.dll
. The code is in the feature/freundlich_sips_isotherms branch on GitHub. There you’ll also find the docs for the Freundlich and Sips isotherms.
The implemented linear driving force multi component Freundlich equations are
Here, \tau > 0 is some small constant that should hopefully ensure numerical stability. I’d try values of 1e-8
to 1e-10
first (assuming the liquid phase concentration has order of magnitude 1.0
).
The matrix a is expected in row-major ordering: Assuming 3 components, we’d have
a_00, a_01, a_02, a_10, a_11, a_12, a_20, a_21, a_22
The implemented multi component Sips model is
The reference concentrations c_{\text{ref}} (SIPS_REFC0
) and q_{\text{ref}} (SIPS_REFQ
) are set to 1.0
by default.
There’s another parameter, SIPS_LINEAR_THRESHOLD
, that determines the interpolation threshold: Since the power c_{p,i}^{n_i} can cause numerical problems (not differentiable in the origin for n_i < 1), we use a quadratic polynomial if c_{p,i} < \mathrm{SIPS\_LINEAR\_THRESHOLD}. I’d also try values of 1e-8
to 1e-10
provided the typical order of magnitude for c_{p,i} is around 1.0
.
Please report bugs and let me know if you want changes to the models.
Thanks a lot, Sam! I will let you know how the model works.
Hi Sam,
I am using CADET in MATLAB which I believe will require me to recompile the CadetMex to be able to use the Sips model. I created the binding model in the bindings folder but receive an error when I try to run the simulator calling the MULTI_COMPONENT_SIPS (errors shown below). Is there a tutorial available to recompile the CadetMex so that I can use this model?
Error using CadetMex
Error in simulation: Unknown binding model MULTI_COMPONENT_SIPS
Error in MexSimulator/configureCadet (line 1192)
CadetMex('conf', obj.mexHandle, cadetInput);
Error in MexSimulator/set.model (line 459)
obj.configureCadet(false);
Error in BTSipsSingleSampling (line 147)
sim.model = mSys;
Oh, I wasn’t aware of you using Matlab. You need to replace the CadetMex.mexw64
file in the bin
folder with the one in the attached zip file.
CadetMex.zip (3.2 MB)
Great, thanks Sam. Sorry I forgot to mention that we are using MATLAB. I was wondering how you compiled the mex file, since we will need to do this in the near future when adding ML-type binding models (working with Jazib). I would rather not have to bother you (although your help is very much appreciated) with this kind of request, especially since are aware that the support for CADET MATLAB is being discontinued.
With this knowledge, I could help with the front end work in CADET MATLAB if that’s something you guys want support for.
Thanks,
Scott
We have some instructions, but they are probably a bit dated.
We also have a CI script that appears to work for Windows builds. Based on this script, the following instructions should (hopefully) work:
Assumptions of installed software:
- 7zip
- CMake
- nuget
- Compiler (e.g., Visual Studio 2017 or better, the community edition is sufficient; alternatively: Visual Studio Build Tools)
We will install dependencies and libraries to C:/deps
, put CADET code into C:/cadet/code
, build it in C:/cadet/build/
. You should be able to change the paths, but make sure that they do not contain spaces.
Instructions:
- Install MKL via nuget:
Ifnuget.exe
is available, install via Command Prompt:
You can also install using some GUI (e.g., nuget Package Manager).nuget install intelmkl.devel.win-x64 -Version 2020.1.216 -OutputDirectory C:\deps\packages
A newer version should work provided you adjust the paths in the following commands. - Start Visual Studio x64 command prompt. Use this terminal for all following commands.
- Run (possibly adjust path to selected MKL version)
Depending on the version of your Visual Studio (or build tools), you need to set one ofset MKLROOT=C:/deps/packages/intelmkl.devel.win-x64.2020.1.216/lib/native/win-x64 set "GENERATOR=Visual Studio 16 2019" set NTHREADS=2
Visual Studio 15 2017
,Visual Studio 16 2019
, orVisual Studio 17 2022
in theGENERATOR
environment variable.
TheNTHREADS
variable controls the number of CPU cores used for compiling the code. - Download Intel TBB binary release (downloads
tbb-2020.2-win.zip
) - Run (adjust path to downloaded
tbb-2020.2-win.zip
file:7z x C:\path\to\tbb-2020.2-win.zip -oC:\deps\tbb\ -y > nul cd C:\deps\tbb\ rename tbb install
- Download HDF5 CMake-enabled source (downloads
CMake-hdf5-1.12.0.zip
) - Run (adjust path to downloaded
CMake-hdf5-1.12.0.zip
)
Please change the argument7z x C:\path\to\CMake-hdf5-1.12.0.zip -oC:\deps\hdf5\code -y > nul cd C:\deps\hdf5\code\CMake-hdf5-1.12.0 cmake -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=ON -DHDF5_BUILD_FORTRAN:BOOL=OFF -DHDF5_ENABLE_F2003:BOOL=OFF -DHDF5_BUILD_JAVA:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=C:\deps\hdf5\install -DCTEST_CONFIGURATION_TYPE:STRING=Release -DBUILD_TESTING=OFF -DHDF5_BUILD_TOOLS=OFF -DHDF5_BUILD_EXAMPLES=OFF -DHDF5_BUILD_HL_LIB=OFF -DHDF5_BUILD_CPP_LIB=OFF -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=TGZ -DTGZPATH:PATH=C:\deps\hdf5\code\CMake-hdf5-1.12.0 -DHDF5_PACKAGE_EXTLIBS:BOOL=ON -DSITE:STRING=WIN7VS201764.XXXX -DBUILDNAME:STRING=Windows-WIN10-vs2019-STATIC -G "%GENERATOR%" -A x64 hdf5-1.12.0\ cd C:\deps\hdf5\code\CMake-hdf5-1.12.0 msbuild.exe INSTALL.vcxproj /p:Configuration=Release;Platform=x64 /maxcpucount:%NTHREADS%
-DBUILDNAME:STRING=Windows-WIN10-vs2019-STATIC
in thecmake
call to the Visual Studio version you’re using (e.g.,vs2022
,vs2017
). - Download the CADET code of the feature/crystallization branch and unzip into
C:\cadet\code
- Run
set HDF5_ROOT=C:\deps\hdf5\install set TBB_ROOT=C:\deps\tbb\install cd C:\cadet mkdir build cd build cmake ..\code -DTBB_LIB_PATH_SUFFIX="lib/intel64/vc14" -DBLA_VENDOR=Intel10_64lp_seq -G "%GENERATOR%" -A x64 -DCMAKE_INSTALL_PREFIX="C:\cadet\cadet" -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC_LINK_DEPS=ON -DENABLE_CADET_MEX=ON msbuild.exe INSTALL.vcxproj /p:Configuration=Release;Platform=x64 /maxcpucount:%NTHREADS%
- Copy runtime libraries to
C:\cadet\cadet\bin
by runningcopy C:\deps\tbb\install\bin\intel64\vc14\tbb.dll C:\cadet\cadet\bin\ copy C:\deps\tbb\install\bin\intel64\vc14\tbb_preview.dll C:\cadet\cadet\bin\ copy C:\deps\packages\intelmkl.redist.win-x64.2020.1.216\runtimes\win-x64\native\mkl_sequential.dll C:\cadet\cadet\bin\ copy C:\deps\packages\intelmkl.redist.win-x64.2020.1.216\runtimes\win-x64\native\mkl_core.dll C:\cadet\cadet\bin\ copy C:\deps\packages\intelmkl.redist.win-x64.2020.1.216\runtimes\win-x64\native\mkl_avx2.dll C:\cadet\cadet\bin\ copy C:\deps\packages\intelmkl.redist.win-x64.2020.1.216\runtimes\win-x64\native\mkl_def.dll C:\cadet\cadet\bin\
- Test CADET by creating and running an example
cd C:\cadet\cadet\bin\ createLWE.exe cadet-cli.exe LWE.h5
Thanks for the detailed instructions, Sam. I will be trying this soon and will let you know how it goes.
While copying / translating the CI script, I forgot to remove the part where building the Matlab interface (MEX file) is disabled.
In the cmake
call in step 9, you need to remove
-DENABLE_CADET_MEX=OFF
Instead, please do
cmake ..\code -DTBB_LIB_PATH_SUFFIX="lib/intel64/vc14" -DBLA_VENDOR=Intel10_64lp_seq -G "%GENERATOR%" -A x64 -DCMAKE_INSTALL_PREFIX="C:\cadet\cadet" -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC_LINK_DEPS=ON -DENABLE_CADET_MEX=ON
This should now build the MEX file, which is probably located in C:\cadet\cadet\matlab\
.
I’ve updated the post with the instructions as well.