libeisdrt is a c++ shared library to compute Distribution of Relaxation Times using Tikhonov regularization. libeisdrt is well integrated to eisgenerator, Eigen and PyTorch.
This manual is divided in the following sections depending on what datatypes you want to use libeisdrt with:
Building
the main development platform of libeisdrt is Linux, and libeisdrt works best on UNIX-like systems, however libeisdrt is fully portable and should compile on any platform that supports the requirements below
Requirements
- git is required to get the source
- a C++20 compliant compiler like GCC
- cmake version 3.19 or later
- libtorch is optional, but is required for libtorch Tensor support
- eisgenerator is optional, but is required for eisgenerator DataPoint support
- PkgConfig is optional, but is required for eisgenerator support
- eigen version 4.0 or later
Procedure
$ git clone https:
$ mkdir libdrt/build
$ cd libdrt/build
$ cmake ..
$ make
$ make install
$ make doc
Usage
The usage of this library can be inferred from the API documentation linked above and from the following eisgenerator based example.
Example usage:
#include <iostream>
#include <eisgenerator/model.h>
#include <eisgenerator/eistype.h>
#include <eisdrt/eisdrt.h>
void printImpedance(const std::vector<eis::DataPoint>& data)
{
std::cout<<'[';
size_t colcount = 0;
for(const eis::DataPoint& point : data)
{
std::cout<<point.im;
std::cout<<' ';
if(++colcount > 1)
{
std::cout<<'\n';
colcount = 0;
}
}
std::cout<<"]\n";
}
void printFvalueVector(const std::vector<fvalue>& data)
{
std::cout<<'[';
size_t colcount = 0;
for(fvalue point : data)
{
std::cout<<point;
std::cout<<' ';
if(++colcount > 1)
{
std::cout<<'\n';
colcount = 0;
}
}
std::cout<<"]\n";
}
int main(int argc, char** argv)
{
std::cout<<std::scientific;
eis::Range omega(1, 1e6, 3, true);
eis::Model model("r{10}-r{50}p{0.02, 0.8}");
std::vector<eis::DataPoint> data = model.executeSweep(omega);
printImpedance(data);
std::cout<<
"fx "<<fm.
fx<<
"\ndrt: ";
printFvalueVector(x);
return 0;
}
Eigen::VectorX< fv > calcDrt(Eigen::VectorX< std::complex< fv > > &impedanceSpectra, Eigen::VectorX< fv > &omegaTensor, FitMetrics &fm, const FitParameters &fp, fv *rSeries=nullptr)
Calculates the drt using Eigen datatypes.
This is used to return information on a fit.
Definition types.h:51
int iterations
how many iterations where used
Definition types.h:52
double fx
error function value remaining after fit
Definition types.h:53
License
libeisdrt is licensed to you under the LGPL version 3 , or (at your option) any later version. see lgpl-3.0.txt or LGPL for details