diff --git a/eisgenerator/model.h b/eisgenerator/model.h index 45f7a4569cbff11416e04ac534645db33de9d5f5..b07edcf5d2f5c4cadca5f2376de405001b558a0f 100644 --- a/eisgenerator/model.h +++ b/eisgenerator/model.h @@ -4,7 +4,7 @@ #include <string> #include <vector> #include <functional> - +#include "eistype.h" #include "componant.h" namespace eis @@ -27,6 +27,22 @@ struct Range { return (end-start)/count; } + Range operator*(fvalue in) const + { + return Range(start*in, end*in, count, log); + } + Range operator/(fvalue in) const + { + return operator*(static_cast<fvalue>(1.0)/in); + } + Range operator*(int in) const + { + return operator*(static_cast<fvalue>(in)); + } + Range operator/(int in) const + { + return operator*(static_cast<fvalue>(1.0)/in); + } Range(double startI, double endI, size_t countI, bool logI = false): start(startI), end(endI), count(countI), log(logI){} Range() = default; }; diff --git a/main.cpp b/main.cpp index dbb50f97865ce81620f328a500084c432b55939b..7e80c028ae16b8aa5192941d2e783774205e5f06 100644 --- a/main.cpp +++ b/main.cpp @@ -1,12 +1,14 @@ #include <iostream> #include <complex> #include <chrono> +#include <cmath> #include "model.h" #include "log.h" #include "options.h" #include "normalize.h" + static void printComponants(eis::Model& model) { eis::Log(eis::Log::DEBUG)<<"Compnants:"; @@ -31,7 +33,7 @@ static void paramSweepCb(std::vector<eis::DataPoint>& data, const std::vector<do std::cout<<'.'<<std::flush; } -static void runSweep(const std::string& modelString, eis::Range omega, bool normalize = false, bool reduce = false) +static void runSweep(const std::string& modelString, eis::Range omega, bool normalize = false, bool reduce = false, bool hertz = false, bool invert = false) { std::vector<eis::DataPoint> results; @@ -59,10 +61,10 @@ static void runSweep(const std::string& modelString, eis::Range omega, bool norm eis::Log(eis::Log::INFO)<<"results:"; } - eis::Log(eis::Log::INFO)<<"omega,real,im"; + eis::Log(eis::Log::INFO)<<(hertz ? "freqency" : "omega")<<",real,im"; for(const eis::DataPoint& res : results) - std::cout<<res.omega<<','<<res.im.real()<<','<<res.im.imag()<<'\n'; + std::cout<<res.omega/(2*M_PI)<<','<<res.im.real()<<','<<(invert ? 0-res.im.imag() : res.im.imag())<<'\n'; eis::Log(eis::Log::INFO)<<"time taken: "<<duration.count()<<" us"; } @@ -96,10 +98,13 @@ int main(int argc, char** argv) Config config; argp_parse(&argp, argc, argv, 0, 0, &config); + if(config.hertz) + config.omegaRange = config.omegaRange*2*M_PI; + switch(config.mode) { case MODE_SWEEP: - runSweep(config.modelStr, config.omegaRange, config.normalize, config.reduce); + runSweep(config.modelStr, config.omegaRange, config.normalize, config.reduce, config.hertz, config.invert); break; case MODE_PARAM_SWEEP: runParamSweep();