eisgenerator 1.0.x
|
The main class of eisgenerator representing an equivalent circuit model. More...
#include <model.h>
Public Member Functions | |
Model (const std::string &str, size_t paramSweepCount=100, bool defaultToRange=true) | |
Constructor. | |
Model (const Model &in) | |
Model & | operator= (const Model &in) |
size_t | setParamSweepCountClosestTotal (size_t totalCount) |
Adjusts the sweep count so that the total of spectra that need to be generated in the parameter sweep is close to the given value. | |
DataPoint | execute (fvalue omaga, size_t index=0) |
Gets the impedance at the given frequency. | |
std::vector< DataPoint > | executeSweep (const Range &omega, size_t index=0) |
Executes a frequency sweep along the given range. | |
std::vector< DataPoint > | executeSweep (const std::vector< fvalue > &omega, size_t index=0) |
Executes a frequency sweep with the given omega values. | |
std::vector< std::vector< DataPoint > > | executeSweeps (const Range &omega, const std::vector< size_t > &indecies, bool parallel=false) |
Executes a frequency and parameter sweep at the given parameter indecies. | |
std::vector< std::vector< DataPoint > > | executeSweeps (const std::vector< fvalue > &omega, const std::vector< size_t > &indecies, bool parallel=false) |
Executes a frequency and parameter sweep at the given parameter indecies. | |
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 parameter sweep. | |
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 | getModelStrWithParam () const |
Returns the model string corresponding to this model object, with embedded parameters. | |
size_t | getUuid () const |
Returns a unique id. | |
std::vector< Componant * > | getFlatComponants (Componant *model=nullptr) |
Returns a vector of pointers to the circuit elements in this model. | |
std::vector< fvalue > | getFlatParameters () |
Gets the values of the parameters of the circuit elements at the current parameter sweep step. | |
std::vector< Range > | getFlatParameterRanges () |
Gets the ranges of the parameters of the circuit elements. | |
std::vector< Range > | getDefaultParameters () |
Gets the default ranges of the parameters of each type of circuit element used in the model. | |
size_t | getParameterCount () |
Gets the total number of parameters used by all the circuit elements in this model. | |
bool | compile () |
This function compiles the model into native vectorized code for faster execution. | |
bool | isReady () |
This member determines if the model is in a state ready to execute. | |
void | resolveSteps (int64_t index) |
This member resolves the parameters of all circuit elements at the given parameter sweep step. | |
size_t | getRequiredStepsForSweeps () |
Gets the total number of parameter sweep steps for the applied sweep. | |
bool | isParamSweep () |
Checks if the model is a sweep (i.e. | |
std::string | getCode () |
Compiles this model into efficient c++ code corresponding to the circuit of this model. | |
std::string | getTorchScript () |
Compiles this model into TorchScript. | |
std::string | getCompiledFunctionName () const |
Gets the function name in the code for this model. | |
std::vector< size_t > | getRecommendedParamIndices (eis::Range omegaRange, double distance, bool threaded=false) |
Gets a set of indecies that together create a iso-difference set of spectra. | |
The main class of eisgenerator representing an equivalent circuit model.
eis::Model::Model | ( | const std::string & | str, |
size_t | paramSweepCount = 100, | ||
bool | defaultToRange = true ) |
Constructor.
parse_errror | If the model string or its parameters include invalid syntax. |
str | The model string to create a model object for. |
paramSweepCount | Optionally the number of sweep point to use for parameter sweeps. |
defaultToRange | Optionally a bool that if true, circuit elements not given in str are defaulted to a range instead of a fixed value. |
bool eis::Model::compile | ( | ) |
This function compiles the model into native vectorized code for faster execution.
This function compiles a shared-object for this model that is then loaded by eisgenerator to speed up execution of this model by a factor of 10 or more by employing vectorization and avoiding function calls.
This function is slow, but results are cached for the lifetime of process linked to libeisgenerator so that a circuit has to be compiled only once and can then be used by any number of Model objects.
This function is only implemented on UNIX, on other platforms this function will always return false. This function also requires that GCC be available in PATH.
DataPoint eis::Model::execute | ( | fvalue | omaga, |
size_t | index = 0 ) |
Gets the impedance at the given frequency.
This method calls resolveSteps.
omega | The frequency in rad/s to calculate the impedance at. |
index | An optional index to the parameter sweep step at which to calculate the impedance. |
Executes a frequency sweep with the given omega values for each parameter combination in the applied parameter sweep.
This method calls resolveSteps.
omega | The range along which to execute a frequency sweep. |
Executes a frequency sweep along the given range.
This method calls resolveSteps.
omega | The range along which to execute a frequency sweep. |
index | An optional index to the parameter sweep step at which to calculate the impedance. |
std::vector< DataPoint > eis::Model::executeSweep | ( | const std::vector< fvalue > & | omega, |
size_t | index = 0 ) |
Executes a frequency sweep with the given omega values.
omega | A vector of frequencies in rad/s to calculate the impedance at. |
index | An optional index to the parameter sweep step at which to calculate the impedance. |
std::vector< std::vector< DataPoint > > eis::Model::executeSweeps | ( | const Range & | omega, |
const std::vector< size_t > & | indecies, | ||
bool | parallel = false ) |
Executes a frequency and parameter sweep at the given parameter indecies.
omega | The range along which to execute the frequency sweep. |
indecies | the parameter indecies to include in the sweep |
parallel | if this is set to true, the parameter sweep is executed in parallel |
std::vector< std::vector< DataPoint > > eis::Model::executeSweeps | ( | const std::vector< fvalue > & | omega, |
const std::vector< size_t > & | indecies, | ||
bool | parallel = false ) |
Executes a frequency and parameter sweep at the given parameter indecies.
omega | A vector of frequencies in rad/s to calculate the impedance at. |
indecies | the parameter indecies to include in the sweep |
parallel | if this is set to true, the parameter sweep is executed in parallel |
std::string eis::Model::getCode | ( | ) |
Compiles this model into efficient c++ code corresponding to the circuit of this model.
std::string eis::Model::getCompiledFunctionName | ( | ) | const |
Gets the function name in the code for this model.
std::vector< Range > eis::Model::getDefaultParameters | ( | ) |
Gets the default ranges of the parameters of each type of circuit element used in the model.
Returns a vector of pointers to the circuit elements in this model.
The pointers can only be assumed to be valid until the next non-const member call to this model object.
model | For internal use only. |
std::vector< Range > eis::Model::getFlatParameterRanges | ( | ) |
Gets the ranges of the parameters of the circuit elements.
std::vector< fvalue > eis::Model::getFlatParameters | ( | ) |
Gets the values of the parameters of the circuit elements at the current parameter sweep step.
std::string eis::Model::getModelStr | ( | ) | const |
Returns the model string corresponding to this model object, without embedded parameters.
std::string eis::Model::getModelStrWithParam | ( | ) | const |
Returns the model string corresponding to this model object, with embedded parameters.
Yhe parameter sweep index of the last call to resolveSteps or 0 is used.
std::string eis::Model::getModelStrWithParam | ( | size_t | index | ) |
Returns the model string corresponding to this model object, with embedded parameters.
This method calls resolveSteps.
index | The parameter sweep index for which to embed the parameters. |
size_t eis::Model::getParameterCount | ( | ) |
Gets the total number of parameters used by all the circuit elements in this model.
std::vector< size_t > eis::Model::getRecommendedParamIndices | ( | eis::Range | omegaRange, |
double | distance, | ||
bool | threaded = false ) |
Gets a set of indecies that together create a iso-difference set of spectra.
Note: this function generates a signifcant fraction of the number of spectra in the models range use getRequiredStepsForSweeps for an estimate of the complexity. It is strongly recommended to call compile() before using this function.
threaded | if this is set to true eisgenerator will spawn nproc number of threads to service this request. |
distance | the target distance between subisquent spectra relative to eis::eisDistance. |
size_t eis::Model::getRequiredStepsForSweeps | ( | ) |
Gets the total number of parameter sweep steps for the applied sweep.
std::string eis::Model::getTorchScript | ( | ) |
Compiles this model into TorchScript.
Can be compiled to GPU kernel bytecode by torch::jit::compile.
size_t eis::Model::getUuid | ( | ) | const |
Returns a unique id.
This id is only unique for the given circuit description string, not for this object as sutch.
bool eis::Model::isParamSweep | ( | ) |
Checks if the model is a sweep (i.e.
has at least one parameter with a range).
bool eis::Model::isReady | ( | ) |
This member determines if the model is in a state ready to execute.
void eis::Model::resolveSteps | ( | int64_t | index | ) |
This member resolves the parameters of all circuit elements at the given parameter sweep step.
index | The index to the sweep step to resolve to. |
size_t eis::Model::setParamSweepCountClosestTotal | ( | size_t | totalCount | ) |
Adjusts the sweep count so that the total of spectra that need to be generated in the parameter sweep is close to the given value.
totalCount | The total number of spectra to target. |