00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_TPTR_GEOSERIES_H 00024 #define O2SCL_TPTR_GEOSERIES_H 00025 00026 #include <iostream> 00027 #include <o2scl/collection.h> 00028 #include <o2scl/tptr_schedule.h> 00029 00030 #ifndef DOXYGENP 00031 namespace o2scl { 00032 #endif 00033 00034 /** 00035 \brief Temperature schedule for a geometric series 00036 00037 The temperature begins at \c start, and is divided by 00038 \c ratio, until it is smaller than \c end. The ending 00039 value is divided by \c sqrt(ratio) to avoid finite 00040 precision problems for series when \c start/end 00041 is an integral power of \c ratio. 00042 00043 The default schedule is \f$T=1/(1.01)^{n}\f$ for 00044 \f$n=0,1,2,3,...,463\f$ (until \f$T<0.01\f$) 00045 given by \c ustart=1, \c uend=0.01, \c uratio=1.01. 00046 00047 */ 00048 template<class vec_t=ovector_view> 00049 class tptr_geoseries : public tptr_schedule<vec_t> { 00050 public: 00051 00052 tptr_geoseries() { 00053 dstart=1.0; 00054 end=1.0e-2; 00055 ratio=1.01; 00056 last=dstart*ratio; 00057 } 00058 00059 virtual ~tptr_geoseries() {} 00060 00061 /// Set the limits for the geometric series 00062 int set_series(double udstart, double uend, double uratio) { 00063 if ((udstart>uend && uratio<1.0) || (udstart<uend && uratio>1.0)) { 00064 set_err_ret("Series will never end in tptr_geoseries::set_series()", 00065 gsl_einval); 00066 } 00067 dstart=udstart; 00068 end=uend; 00069 ratio=uratio; 00070 last=dstart*ratio; 00071 return 0; 00072 } 00073 00074 /// Get the number of temperatures in the series 00075 int get_npoints() { 00076 double n=log(dstart/end*sqrt(ratio))/log(ratio); 00077 return ((int)n)+1; 00078 } 00079 00080 virtual double start(double min, int nv, const vec_t &best, void *vp) { 00081 last=dstart; 00082 return last; 00083 } 00084 00085 virtual double next(double min, int nv, const vec_t &best, void *vp) { 00086 last=last/ratio; 00087 return last; 00088 } 00089 00090 virtual bool done(double min, int nv, const vec_t &best, void *vp) { 00091 if (last<end/sqrt(ratio)) return true; 00092 return false; 00093 } 00094 00095 /// Return string denoting type ("tptr_geoseries") 00096 virtual const char *type() { return "tptr_geoseries"; } 00097 00098 protected: 00099 00100 #ifndef DOXYGEN_INTERNAL 00101 00102 /// \name parameters for the schedule 00103 //@{ 00104 double dstart, end, ratio; 00105 //@} 00106 00107 /// The last temperature returned 00108 double last; 00109 00110 #endif 00111 00112 }; 00113 00114 #ifndef DOXYGENP 00115 } 00116 #endif 00117 00118 #endif 00119
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page