eisdrt 1.0.x
libeisdrt manual

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://git-ce.rwth-aachen.de/carl_philipp.klemm/libdrt
$ 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;
// specify the angular frequency range of the spectra to be
// simulated to be 1-1*10^6 Hz with 3 steps and log10 distrobution
eis::Range omega(1, 1e6, 3, true);
// specify circuit to be simulated
eis::Model model("r{10}-r{50}p{0.02, 0.8}");
// execute a simulation
std::vector<eis::DataPoint> data = model.executeSweep(omega);
// print the specrum
printImpedance(data);
// allocate a FitMetrics struct on the stack
// calculate the drt for this spectrum
std::vector<fvalue> x = calcDrt(data, fm, FitParameters(1000));
// print some info on the drt
std::cout<<"Iterations: "<<fm.iterations<<'\n';
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
Definition types.h:58

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