Message Boards Message Boards

Couple space-dependent and space-independent equations in NDSolve?

Posted 8 years ago

Hello,

I'm trying to model a trickle bed reactor. For this, I need to couple a stirred phase, where the concentrations are not location-dependent, and a non-stirred phase, where concentrations are location dependent. I'm trying to do this with NDSolveValue, however, mathematica is returning an initial-value error. I'll first give my code:

output2 = NDSolveValue[{
   (* H2 dynamic *)
   ul2*chld2'[x] == 
    kexgl2 (solh2*pin2 - chld2[x]) - 
     kexll2 (1 - fs2) (chld2[x] - chls2[x]) - 
     fld2*klsd2*als2*(chld2[x] - chs2[x]), chld2[0] == 0.0,
   (* H2 stationary *)
   kexll2*(1 - fs2)*(chld2[x] - chls2[x]) == 
    fls2*klss2*als2*(chls2[x] - chs2[x]),
   (* H2 solid *)
   fld2*klsd2*als2*(chld2[x] - chs2[x]) + 
     fls2*klss2*als2*(chls2[x] - chs2[x]) + 
     fg2*kgs2*als2*(solh2*pin2 - chs2[x]) == 
    4*dwashcoat2/dpart2*fs2*3*kr3*Exp[-eact3/(rgas*temp2[x])]*
     Sqrt[chs2[x]]*cfus2[x]*densitys2*loading2*eff2[x], chs2[0] == 0.0,
   (* fu dynamic *)
   ul2*cfuld2'[x] == -kexll2*(1 - fs2)*(cfuld2[x] - cfuls2[x]) - 
     fld2*klsd2*als2*(cfuld2[x] - cfus2[x]), cfuld2[0] == cfuor1,
   (* fu stationary *)
   kexll2*(1 - fs2)*(cfuld2[x] - cfuls2[x]) == 
    fls2*klss2*als2*(cfuls2[x] - cfus2[x]),
   (* fu solid *)
   fls2*klss2*als2*(cfuls2[x] - cfus2[x]) + 
     fld2*klsd2*als2*(cfuld2[x] - cfus2[x]) == 
    4*dwashcoat2/dpart2*fs2*kr3*Exp[-eact3/(rgas*temp2[x])]*
     Sqrt[chs2[x]]*cfus2[x]*densitys2*loading2*eff2[x], 
   cfus2[0] == 0.0,

   (* temperature *)
   ul2*densityl2*cpl2*
     temp2'[x] == -rheat3* 4*dwashcoat2/dpart2*fs2*kr3*
      Exp[-eact3/(rgas*temp2[x])]*Sqrt[chs2[x]]*cfus2[x]*densitys2*
      loading2*eff2[x] - kheat*4/dreac2*(temp2[x] - tcool), 
   temp2[0] == tempin2,

   (* efficiency *)
   thiele2[x] == 
    dwashcoat2*Sqrt[kr3*Exp[-eact3/(rgas*temp2[x])/dheff2]], 
   eff2[x] == Tanh[thiele2[x]]/thiele2[x]

   }, {chld2, chls2, chs2, cfuld2, cfuls2, cfus2, temp2, thiele2, 
   eff2}, {x, 0, lreac2}]

In the list of dependent variables, chls2 and cfuls2 are actually not depending on x. However, if I remove the [x] in the equations, mathematica states that the system is overdetermined. If I keep the [x], the following error pops up:

NDSolveValue::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. 

Now I'm fairly confident that the equations and initial values are correct. I've tried every trick in the book I know of, error tolerance, initial step size, IDA solver, but I can't seem to get a solution. Has anyone else encountered this problem?

Thanks for your help!

POSTED BY: Tim Nijssen

It might help to differentiate the algebraic equations so as to make them instead differential equations. Also removing square roots e.g. by redefining variables a la x-->x^2 could be useful. No guarantees, but at least this could make for less reliance in the internal code on root finding.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract