3#include "CLHEP/GenericFunctions/RKIntegrator.hh"
4#include "CLHEP/GenericFunctions/AdaptiveRKStepper.hh"
5#include "CLHEP/GenericFunctions/Variable.hh"
45 if (_data->
_fx.empty()) {
49 for (
size_t f=0;
f<nvar;
f++) {
56 if (t==0)
return (*_data->
_fx.begin()).variable[_index];
60 std::set<RKData::Data>::iterator l =_data->
_fx.lower_bound(dt);
63 if (l!=_data->
_fx.end() && (*l).time==t) {
64 return (*l).variable[_index];
68 std::set<RKData::Data>::iterator u =_data->
_fx.upper_bound(dt);
70 while (u==_data->
_fx.end()) {
74 _data->
_fx.insert(l,newData);
76 u = _data->
_fx.upper_bound(dt);
88RKIntegrator::RKData::~RKData() {
89 for (
size_t i=0;i<_startingValParameter.size();i++)
delete _startingValParameter[i];
90 for (
size_t i=0;i<_controlParameter.size();i++)
delete _controlParameter[i];
91 for (
size_t i=0;i<_diffEqn.size(); i++)
delete _diffEqn[i];
105 for (
size_t i=0;i<_fcn.size();i++)
delete _fcn[i];
109 const std::string &variableName,
110 double defStartingValue,
112 double defValueMax) {
113 Parameter *par =
new Parameter(variableName, defStartingValue, defValueMin, defValueMax);
117 _fcn.push_back(
new RKFunction(_data,(
unsigned int)_fcn.size()));
126 double defStartingValue,
127 double startingValueMin,
128 double startingValueMax) {
130 Parameter *par =
new Parameter(variableName, defStartingValue, startingValueMin, startingValueMax);
147 unsigned int size = (
unsigned int)
_diffEqn.size();
148 for (
size_t i=0;i<size;i++) {
149 if (!(
_diffEqn[i]->dimensionality()==size))
throw std::runtime_error(
"Runtime error in RKIntegrator");
161 for (
size_t p=0;p<_startingValParameter.size();p++) {
162 if (_startingValParameter[p]->getValue()!=_startingValParameterCache[p]) {
163 _startingValParameterCache[p]=_startingValParameter[p]->getValue();
171 for (
size_t p=0;p<_controlParameter.size();p++) {
172 if (_controlParameter[p]->getValue()!=_controlParameterCache[p]) {
173 _controlParameterCache[p]=_controlParameter[p]->getValue();
181 _fx.erase(_fx.begin(),_fx.end());
#define FUNCTION_OBJECT_IMP(classname)
virtual AbsFunction * clone() const =0
std::vector< Parameter * > _startingValParameter
std::vector< double > _startingValParameterCache
std::vector< double > _controlParameterCache
std::vector< const AbsFunction * > _diffEqn
std::vector< Parameter * > _controlParameter
const RKStepper * _stepper
RKFunction(RKData *data, unsigned int index)
virtual double operator()(double argument) const override
virtual void step(const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &sdata, RKIntegrator::RKData::Data &ddata, double timeLimit=0) const =0
virtual RKStepper * clone() const =0
Parameter * addDiffEquation(const AbsFunction *diffEquation, const std::string &variableName="anon", double defStartingValue=0.0, double startingValueMin=0.0, double startingValueMax=0.0)
Parameter * createControlParameter(const std::string &variableName="anon", double defStartingValue=0.0, double startingValueMin=0.0, double startingValueMax=0.0)
RKIntegrator(const RKStepper *stepper=NULL)
const RKFunction * getFunction(unsigned int i) const
std::vector< double > variable