Select Git revision
-
Carl Philipp Klemm authoredCarl Philipp Klemm authored
main.cpp 6.53 KiB
#include <iostream>
#include <complex>
#include <chrono>
#include <cmath>
#include <cassert>
#include <filesystem>
#include "basicmath.h"
#include "model.h"
#include "log.h"
#include "options.h"
#include "normalize.h"
#include "translators.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static constexpr double DIST_THRESH = 0.01;
static constexpr char PARA_SWEEP_OUTPUT_DIR[] = "./sweep";
static void printComponants(eis::Model& model)
{
eis::Log(eis::Log::DEBUG)<<"Compnants:";
for(eis::Componant* componant : model.getFlatComponants())
{
eis::Log(eis::Log::DEBUG, false)<<componant->getComponantChar()<<"{";
std::vector<eis::Range>& ranges = componant->getParamRanges();
assert(componant->paramCount() == ranges.size());
for(size_t i = 0; i < componant->paramCount(); ++i)
{
eis::Log(eis::Log::DEBUG, false)<<ranges[i].getString();
if(i != componant->paramCount()-1)
eis::Log(eis::Log::DEBUG, false)<<", ";
}
eis::Log(eis::Log::DEBUG)<<"}";
}
}
static void runSweep(const Config& config, eis::Model& model)
{
std::vector<eis::DataPoint> results;
eis::Range omega = config.omegaRange;
auto start = std::chrono::high_resolution_clock::now();
results = model.executeSweep(omega);
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
if(config.reduce)
{
eis::Log(eis::Log::INFO)<<"reduced normalized results:";
results = eis::reduceRegion(results);
}
else if(config.normalize)
{
eis::Log(eis::Log::INFO)<<"normalized results:";
eis::normalize(results);
}
else
{
eis::Log(eis::Log::INFO)<<"results:";
}
if(config.noise > 0)
eis::noise(results, config.noise, false);
std::cout<<(config.hertz ? "freqency" : "omega")<<",real,im\n";