I get a converging solution while trying to solve a Partial Differential Equation attached below.
In my code, I want to calculate a volume flow rate over time by integrating 2pir*v(r)*dr . I have used scipy.integrate.trapz to solve this inside the code m.GEKKO().
I want to have a graph of Qgap vs time. When I execute the code, I get a single Qgap value in the solution.
Please help me.
All the details can be easily found through this article <<Modeling of a hydraulic damper with shear thinning fluid for damping mechanism analysis>> by Sujuan Jiao et al.
The velocity profile is discretised by 100 points in space between r1 and r1+delta with BC at r1=u (piston velocity) and 0 at the wall.
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate
amp=10e-2
freq=10
tf = 2/freq
omega=2*np.pi*freq
npt = 101
time = np.linspace(0,tf,npt)
xglob=amp*np.sin(omega*time)
uglob=amp*omega*np.cos(omega*time)
delta=0.007
npx=100
dx=np.float32(delta/npx)
r1=0.01
r2=0.004
xpos = np.linspace(r1,r1+delta,npx)
Ap=np.pi*(r1**2-r2**2)
rho=850
beta=5e8
L=0.06
l=0.01
pressf=12*amp*0.707*uglob\
*np.cos(2*np.pi*freq*time)/(delta**2)\
*630*(1+(0.05*(0.707*uglob/delta)**2))**(-0.23)
m = GEKKO()
def Q(r,v):
Q=(2*np.pi*r*np.transpose(np.array(v)))
return scipy.integrate.trapz(Q,r)
m.time = time
t=m.Param(m.time)
x=m.MV(ub=amp+1)
x.value=np.ones(npt)*xglob
u=m.MV(ub=10)
u.value=np.ones(npt)*uglob
pf=m.MV(lb=20)
pf.value=np.ones(npt)*pressf
u1=[m.Var(1) for i in range(npx)]
p1=m.Var(800000)
p2=m.Var(800000)
Qgap=Q(xpos,u1)
m.Equation(u1[0].dt()==-1*(p1-p2+pf)/l \
+ ((630 * (1+(0.05*((u-u1[0])/dx))**2)**(-0.23))/rho)\
*((u-2*u1[0]+u1[1])/(dx*dx)))
m.Equations([(u1[i].dt()==-1*(p1-p2+pf)/l \
+ ((630 * (1+(0.05*((u1[i+1]-u1[i-1])/(2*dx)))**2)**(-0.23))/rho)\
*((u1[i+1]-2*u1[i]+u1[i-1])/(dx*dx))) for i in range(1,npx-1)])
m.Equation(u1[-1].dt()==-1*(p1-p2+pf)/l \
+ (((630 * (1+(0.05*((u1[-1]-0)/dx))**2)**(-0.23)))/rho)\
*((u1[-2]-2*u1[-1]+0)/(dx*dx)))
m.Equation(p1.dt()==(beta/(Ap*(L-x)))*(-Qgap+Ap*u))
m.Equation(p2.dt()==(beta/(Ap*(L+x)))*(Qgap-Ap*u))
# simulation
m.options.IMODE = 4
m.options.solver=1
m.options.nodes=3
m.solve(disp=True)