From fa780229e0fd43f1dad39322d7625899f7ec9be0 Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm <philipp@uvos.xyz> Date: Thu, 5 Jan 2023 00:00:00 +0100 Subject: [PATCH] fix several minor bugs --- eisgenerator/eistype.h | 4 +++- eistype.cpp | 11 ++++++++++- main.cpp | 9 ++++++++- model.cpp | 9 +++++---- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/eisgenerator/eistype.h b/eisgenerator/eistype.h index edd83ff..595ecb8 100644 --- a/eisgenerator/eistype.h +++ b/eisgenerator/eistype.h @@ -32,12 +32,13 @@ public: { return at(step); } + fvalue at(size_t index) const { assert(index < count); if(count < 2) return start; - return log ? pow(10, stepSize()*index+start) : stepSize()*index+start; + return log ? pow(10, stepSize()*index+log10(start)) : stepSize()*index+start; } fvalue operator[](size_t index) const { @@ -63,6 +64,7 @@ public: Range() = default; void print(int level) const; std::string getString() const; + bool isSane() const; static std::vector<Range> rangesFromParamString(const std::string& paramStr, size_t count); }; diff --git a/eistype.cpp b/eistype.cpp index ad2fbd6..148487b 100644 --- a/eistype.cpp +++ b/eistype.cpp @@ -79,7 +79,16 @@ std::string eis::Range::getString() const if(count > 1) ss<<'~'<<end; if(log) - ss<<'F'; + ss<<'L'; return ss.str(); } + +bool eis::Range::isSane() const +{ + if(log && (start == 0 || end == 0)) + return false; + if(end < start) + return false; + return true; +} diff --git a/main.cpp b/main.cpp index 6df9952..e96ce37 100644 --- a/main.cpp +++ b/main.cpp @@ -85,11 +85,12 @@ static void runParamSweep(Config config, eis::Model& model) auto start = std::chrono::high_resolution_clock::now(); for(size_t i = 0; i < count; ++i) { + eis::Log(eis::Log::DEBUG)<<"Executeing sweep for "<<i; std::vector<eis::DataPoint> data = model.executeSweep(config.omegaRange, i); size_t outputSize = data.size(); data = eis::reduceRegion(data); data = eis::rescale(data, outputSize); - eis::saveToDisk(data, std::string(PARA_SWEEP_OUTPUT_DIR)+std::string("/")+std::to_string(++i)+".csv"); + eis::saveToDisk(data, std::string(PARA_SWEEP_OUTPUT_DIR)+std::string("/")+std::to_string(i)+".csv"); eis::Log(eis::Log::INFO, false)<<'.'; } auto end = std::chrono::high_resolution_clock::now(); @@ -108,6 +109,12 @@ int main(int argc, char** argv) if(config.hertz) config.omegaRange = config.omegaRange*static_cast<fvalue>(2*M_PI); + if(!config.omegaRange.isSane()) + { + eis::Log(eis::Log::INFO)<<"The Omega range: "<<config.omegaRange.getString()<<" is invalid"; + return 1; + } + if(config.inputType == INPUT_TYPE_BOUKAMP) config.modelStr = eis::cdcToEis(config.modelStr); else if(config.inputType == INPUT_TYPE_RELAXIS) diff --git a/model.cpp b/model.cpp index 02e3a68..74c0bb7 100644 --- a/model.cpp +++ b/model.cpp @@ -277,21 +277,22 @@ void Model::resolveSteps(int64_t index) std::vector<size_t> placeMagnitude; placeMagnitude.reserve(flatRanges.size()); + Log(Log::DEBUG)<<"Magnitudes:"; for(size_t i = 0; i < flatRanges.size(); ++i) { size_t magnitude = 1; for(int64_t j = static_cast<int64_t>(i)-1; j >= 0; --j) - { magnitude = magnitude*flatRanges[j]->count; - } placeMagnitude.push_back(magnitude); + Log(Log::DEBUG)<<placeMagnitude.back(); } - for(int64_t i = flatRanges.size(); i >= 0 && index > 0; --i) + Log(Log::DEBUG)<<"Steps for index "<<index<<" ranges "<<flatRanges.size()<<" Ranges:"; + for(int64_t i = flatRanges.size()-1; i >= 0; --i) { flatRanges[i]->step = index/placeMagnitude[i]; index = index % placeMagnitude[i]; - Log(Log::DEBUG)<<placeMagnitude[i]<<'('<<flatRanges[i]->step<<')'<<(i == 0 ? "\n" : " + "); + Log(Log::DEBUG)<<placeMagnitude[i]<<'('<<flatRanges[i]->step<<')'<<(i == 0 ? "" : " + "); } } -- GitLab