Skip to content

Commit

Permalink
Similar for C++ implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaclach committed Feb 21, 2020
1 parent cd7e842 commit 3c402d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CaseStudies/noPCM/src/Cpp/Calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ using std::vector;

vector<double> func_T_W(InputParameters inParams) {
NoPCMODE ode = NoPCMODE(inParams.T_C, inParams.tau_W);
vector<double> T_W(0);
vector<double> T_W;
vector<double> init {inParams.T_init};
boost::numeric::odeint::integrate_const(boost::numeric::odeint::make_controlled(inParams.A_tol, inParams.R_tol, boost::numeric::odeint::runge_kutta_dopri5<vector<double>>()), ode, init, 0.0, inParams.t_final, inParams.t_step, Populate_T_W(T_W));
boost::numeric::odeint::runge_kutta_dopri5<vector<double>> rk = boost::numeric::odeint::runge_kutta_dopri5<vector<double>>();
auto stepper = boost::numeric::odeint::make_controlled(inParams.A_tol, inParams.R_tol, rk);
boost::numeric::odeint::integrate_const(stepper, ode, init, 0.0, inParams.t_final, inParams.t_step, Populate_T_W(T_W));

return T_W;
}
6 changes: 3 additions & 3 deletions CaseStudies/noPCM/src/Cpp/NoPCMODE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ NoPCMODE::NoPCMODE(double T_C, double tau_W) {
this->tau_W = tau_W;
}

void NoPCMODE::operator()(vector<double> T_W , vector<double> &dT_Wdt , double t) {
void NoPCMODE::operator()(vector<double> T_W, vector<double> &dT_Wdt, double t) {
dT_Wdt.at(0) = (1/tau_W) * (T_C - T_W.at(0));
}

Populate_T_W::Populate_T_W(vector<double> &T_W) : T_W(T_W) {}

void Populate_T_W::operator() (vector<double> &T_W , double t) {
this->T_W.push_back(T_W.at(0));
void Populate_T_W::operator() (vector<double> &y , double t) {
this->T_W.push_back(y.at(0));
}
2 changes: 1 addition & 1 deletion CaseStudies/noPCM/src/Cpp/NoPCMODE.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Populate_T_W {

Populate_T_W(vector<double> &T_W);

void operator() (vector<double> &T_W, double t);
void operator() (vector<double> &y, double t);
};

#endif

0 comments on commit 3c402d1

Please sign in to comment.