2

I am trying to solve a PDE with gekko library which involves calculating volume flow rate by integrating velocity with the space at a certain time.

Qgap==scipy.integrate.trapz(2*np.pi*xpos*np.array(u1))

where u1 is discretized at each xpos 1000 points. I get this error:

 APM model error: string >       15000  characters
 Consider breaking up the line into multiple equations
 
 The may also be due to only using newline character CR
   instead of CR LF (for Windows) or LF (for MacOS/Linux) 
 To fix this problem, save APM file with appropriate newline characters
 
 STOPPING...

What should I do to solve this problem? Does m.integral(u1,xpos) option works or m.integral() only works with integral with time only?

1 Answers1

1

The scipy.integrate.trapz function works with gekko because it produces a symbolic result as shown here: Problem on Solving a 1D Navier Stokes with Compressible Mass Conservation (Hydraulic Damper) However, this symbolic form increases in complexity with the integrating dimension. In tests on the earlier problem, it is limited to somewhere between 150 and 200 spatial discretization steps. At 200 or beyond, I recommend programming your own trapezoidal equation that uses m.sum() to break up the equation

John Hedengren
  • 12,068
  • 1
  • 21
  • 25