eisgenerator 1.0.x
simple.cpp

A simple example in how to use eisgenerator.

A simple example in how to use eisgenerator.

//SPDX-License-Identifier: MIT
#include <iostream>
#include <eisgenerator/model.h>
#include <eisgenerator/log.h>
int main(int argc, char** argv)
{
// Set the verbosity of libeisgenerator
// Create a model object from a circuit string
eis::Model model("r{100}-r{50}p{1e-3, 0.8}");
// Generate a signle impedance at omega = 10 rad/s
eis::DataPoint point = model.execute(10);
std::cout<<"A calculated data point: "<<point<<'\n';
// Create an omega range for a sweep
// from 1 to 1e4 rad/s, with 100 points
// and spaced logarithmically
eis::Range omegaRange(1, 1e4, 25, true);
// Print the values in this range
std::vector<fvalue> omegaVector = omegaRange.getRangeVector();
std::cout<<"A Range:\n";
for(fvalue omega : omegaVector)
std::cout<<omega<<'\n';
std::cout<<'\n';
// Get a spectra from the model and the omega range
std::vector<eis::DataPoint> data = model.executeSweep(omegaRange);
// Construct a EisSpectra object for output
eis::EisSpectra spectra(data, model.getModelStrWithParam(), "My first spectra");
// Print the spectra
std::cout<<"Spectra:\n"<<spectra<<'\n';
// Save it to disk
spectra.saveToDisk("./spectra.csv");
}
Basic singular EIS data point.
Definition eistype.h:47
Definition eistype.h:260
bool saveToDisk(const std::filesystem::path &path) const
Saves the spectra to disk.
static Level level
Minimum Level required for output to be printed.
Definition log.h:56
@ WARN
Non fatal errors or problems affecting performance or numeric precision
Definition log.h:42
The main class of eisgenerator representing an equivalent circuit model.
Definition model.h:47
std::vector< DataPoint > executeSweep(const Range &omega, size_t index=0)
Executes a frequency sweep along the given range.
std::string getModelStrWithParam(size_t index)
Returns the model string corresponding to this model object, with embedded parameters.
DataPoint execute(fvalue omaga, size_t index=0)
Gets the impedance at the given frequency.
A range.
Definition eistype.h:110
std::vector< fvalue > getRangeVector() const
This function constructs a vector that contains all elements of this range.