ROOT Version: 5.34/36
Platform: Windows 10 64bit
Compiler: Microsoft Visual Studio 2015
Good afternoon,
I am new to the forum and please forgive my nooby mistakes.
So: My task is to write a program with differential equations later on. But right now I am struggling with the steady state variables. I want to use the GSLMultiRootFinder solution (class? function?, not completely sure which one it is). So Basically I have the 3 equations as show below and the cling tells me:
Error in <ROOT::Math::GSLMultiRootFinder::Solve>: Error initializing the solver
Equation 2 is not necessarily needed, but for future reference I’d like to know what my mistake is.
// possible changable parameters
double c0_as = 0.74;
double F_as = 3 /1000/60;
double F_ws = 40 /1000/60;
double T_in = 295.15;
double Vr = 298 /1000;
// constant parameters
const double rho_a = 1082;
const double M_a = 102.9;
const double n = 1;
const double EA = 44.35;
const double k_inf = 139390;
const double d_Hr = -55.5;
const double rhocp = 4.186;
//const double R = 8.314;
const double R = TMath::R() /1000;
const double F_s = F_as + F_ws;
void Test()
{
// x[0] = concentration A
// x[1] = concentration B
// x[2] = temperature
//TF2 *dcdt = new TF2("dcdt","F_s/Vr *(c0_as - x[0]) - k_inf*exp(-EA /R /x[2])*x[0]");
TF3 *dcdt = new TF3("dcdt","[0]/[1]*([2] - x[0]) - [3] *exp(-[4]/[5]/x[2])*x[0]");
dcdt->SetParameters( F_s,Vr, c0_as, k_inf, EA, R);
//TF2 *dcESdt = new TF2("dcESdt","-F_s/Vr *x[1] + 2*k_inf*exp(-EA /R /x[2])*x[0]");
TF3 *dcESdt = new TF3("dcESdt","-[0]/[1]*x[1] + 2*[2] *exp(-[3]/[4]/x[2])*x[0]");
//dcESdt->SetParameters( F_s,Vr, k_inf, EA, R);
//TF2 *dTdt = new TF2("dTdt","F_s/Vr *(T_in - x[2]) + (-d_Hr)/rhocp*k_inf*exp(-EA /R /x[2])*x[0]");
TF3 *dTdt = new TF3("dTdt","[0]/[1]*([2] - x[2]) + (-[3]) /[4] *[5] *exp(-[6]/[7]/x[2])*x[0]");
dTdt->SetParameters( F_s,Vr, T_in, d_Hr, rhocp,k_inf, EA, R);
ROOT::Math::WrappedMultiTF1 g1(*dcdt,3);
ROOT::Math::WrappedMultiTF1 g2(*dcESdt,3);
ROOT::Math::WrappedMultiTF1 g3(*dTdt,3);
ROOT::Math::GSLMultiRootFinder r;
//r.SetType("dnewton");
//r.SetDefaultTolerance(1E-10);
//r.SetDefaultMaxIterations(200);
r.AddFunction(g1);
r.AddFunction(g2);
r.AddFunction(g3);
r.SetPrintLevel(1);
// Startwerte
double x0[3] = {0.5*c0_as, 1.5*c0_as, T_in};
r.Solve(x0);
// cout << r.Root() << endl;
}
Intrestingly, if I change the program to just the 2 equations (1 and 3, also using TF2 instead of TF3), I do get results, but the results are signifficant different to the one I’ve calculated beforehand in Matlab. The solution I get with Matlab is (0.3700 1.1100 295.1500).
I am looking forward to be part of this stunning forum