#include "Attractor.hpp" #include "Logger.hpp" #include #include #include #include "stfu/stf.hpp" #include "AttractorKernel.hpp" #include "Projector.hpp" Attractor::Attractor(const std::string& filename) { // opening file LogInfo("Reading file '%s'...\n", filename.c_str()); stfu::node system; system.read(filename.c_str()); stfu::node attractor = system.getChild("AttractorKernel"); myAttractor = AttractorKernel::createAttractorKernel(attractor); } Attractor::~Attractor(){ delete myAttractor; } // this should probably done in the projector section void Attractor::init_range() { // stabilize attractor for ( unsigned int i = 0; i < 100000; i++ ) { iterate(); } // initialize projectors with dimension and first point const unsigned int dimension = myAttractor->getDimension(); const double * point = myAttractor->vector(); for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { (*it)->extern_dim = dimension; (*it)->intern_dim = 2; (*it)->init(point); } // update ranges for ( unsigned int i = 0; i < 100000; i++ ) { iterate(); for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { (*it)->update_range(point); } } for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { (*it)->finish_range(); } } bool Attractor::is_chaos() { /* check existence of attractor: Escaping Single point attractor Lyapunov exponent */ /* double sum = 0; for ( unsigned int i = 0; i < dim; i++ ) { const double dist = 0; //new_point[i] - point[i]; sum += dist*dist; } if ( sum >= 1.0e7 ) { // big change => Escaping return false; } if ( sum <= 1.0e-7 ) { // small change => singularity return false; } return true; */ return true; } void Attractor::iterate() { (*myAttractor)(); } void Attractor::plot() { for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { const double * point = myAttractor->vector(); (*it)->plot(point); } } /* IO & control */ void Attractor::output() { const unsigned int dimension = myAttractor->getDimension(); const double * point = myAttractor->vector(); for ( unsigned int i = 0; i < dimension; i++ ) { LogMoreInfo("%f, ", point[i]); } LogMoreInfo("\n"); }