From cd2802a05d0765e25aafd2e54b7271c6dd466d0a Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Thu, 8 Apr 2010 10:49:05 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@113 ed2142bd-67ad-457f-ba7c-d818d4011675 --- dynamical_models/lin1d.cpp | 49 ++++++++++++++++++++++++++++ dynamical_models/vt_temperature.cpp | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 dynamical_models/lin1d.cpp create mode 100644 dynamical_models/vt_temperature.cpp (limited to 'dynamical_models') diff --git a/dynamical_models/lin1d.cpp b/dynamical_models/lin1d.cpp new file mode 100644 index 0000000..de43a42 --- /dev/null +++ b/dynamical_models/lin1d.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +using namespace std; +using namespace opt_utilities; +template +class lin1d + :public model,std::string> +{ +private: + model >* do_clone()const + { + return new lin1d(*this); + } + + const char* do_get_type_name()const + { + return "1d linear model"; + } +public: + lin1d() + { + this->push_param_info(param_info >("k",1)); + this->push_param_info(param_info >("b",0)); + } + +public: + T do_eval(const T& x,const std::vector& param) + { + return x*get_element(param,0)+get_element(param,1); + } + +private: + std::string do_get_information()const + { + return " f(x;k,b)=k x+b \ + \ +"; + } +}; + +static lin1d _model; + + +extern "C" model,std::string>* +create_model_object() +{ + return &_model; +} diff --git a/dynamical_models/vt_temperature.cpp b/dynamical_models/vt_temperature.cpp new file mode 100644 index 0000000..39b474c --- /dev/null +++ b/dynamical_models/vt_temperature.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +using namespace std; +using namespace opt_utilities; +class vk_temperature + :public opt_utilities::model,std::string> +{ +private: + opt_utilities::model,std::string>* do_clone()const; +public: + vk_temperature(); + double do_eval(const double& r,const std::vector& param); + +}; + + +model,std::string>* vk_temperature::do_clone()const +{ + return new vk_temperature(*this); +} + +vk_temperature::vk_temperature() +{ + this->push_param_info(param_info >("T0",2,0.1,10)); + this->push_param_info(param_info >("rcool",1e22,0.001,10)); + this->push_param_info(param_info >("acool",1)); + this->push_param_info(param_info >("Tmin",1,0.1,10)); + this->push_param_info(param_info >("rt",1e22,0.001,10)); + this->push_param_info(param_info >("a",1,-10,10)); + this->push_param_info(param_info >("c",1,-10,10)); + this->push_param_info(param_info >("b",1,-10,10)); +} + + + + + +double vk_temperature::do_eval(const double& r,const std::vector& param) +{ + double T0=param[0]; + double rcool=param[1]; + double acool=param[2]; + double Tmin=param[3]; + double rt=param[4]; + double a=param[5]; + double c=param[6]; + double b=param[7]; + double x=pow(r/rcool,acool); + double tcool=(x+Tmin/T0)/(x+1); + double t=pow(r/rt,-a)/pow(1+pow(r/rt,b),c/b); + return T0*t*tcool; +} + + +static vk_temperature _model; + +extern "C" model,std::string>* +create_model_object() +{ + return &_model; +} -- cgit v1.2.2