eisgenerator 1.0.x
compileing.cpp

An example on how to use the eisgenerator compiled execution model.

An example on how to use the eisgenerator compiled execution model.

//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
eis::Model model("r{100}-r{1000}p{1e-3, 0.5}");
// Print the corrisponding code for this model
std::cout<<"C++ code for "<<model.getModelStr()<<":\n"<<model.getCode()<<'\n';
// Compile the model
model.compile();
// Create a model object from a circuit string this time its a parameter sweep
// This is simply to demonstate that caching is employed
eis::Model modelSweep("r{10~100}-r{50~1000}p{1e-3, 0.5~0.8}", 50);
// This now goes quickly
modelSweep.compile();
// Create an omega range for a sweep
// from 1 to 1e4 rad/s, with 100 points
// and spaced logarithmically
eis::Range omegaRange(1, 1e4, 10, true);
// Do a sweep along omegaRange for eatch
// combination of parameters in the model
std::vector<std::vector<eis::DataPoint>> data = modelSweep.executeAllSweeps(omegaRange);
std::cout<<"Got "<<data.size()<<" sweeps with "<<data.size()*data[0].size()<<" total datapoints\n";
// Print a couple of random ones
eis::EisSpectra spectraSix(data[6], modelSweep.getModelStrWithParam(6), "Sweep at 6");
std::cout<<spectraSix<<'\n';
eis::EisSpectra spectraTen(data[10000], modelSweep.getModelStrWithParam(10000), "Sweep at 10000");
std::cout<<spectraTen<<'\n';
}
Definition eistype.h:260
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::string getModelStr() const
Returns the model string corresponding to this model object, without embedded parameters.
std::string getModelStrWithParam(size_t index)
Returns the model string corresponding to this model object, with embedded parameters.
std::string getCode()
Compiles this model into efficient c++ code corresponding to the circuit of this model.
bool compile()
This function compiles the model into native vectorized code for faster execution.
std::vector< std::vector< DataPoint > > executeAllSweeps(const Range &omega)
Executes a frequency sweep with the given omega values for each parameter combination in the applied ...
A range.
Definition eistype.h:110