Closed ziyinyuan closed 1 year ago
Hello @ziyinyuan,
The issue is that the SINDy.predict
function returns the right hand side of the SINDy model, which corresponds to the time derivatives of the input data rather than the input itself. So your sol1[i,:]
should be compared to ps.FiniteDifference(d=1,axis=1)._differentiate(u,dt)[i,:]
. Note also that the time derivatives for i=1
are all almost zero, so they are a little noisy. You'll see a better comparison if you use, say i=200
, as in
sol1=model1.predict(u1)
plt.figure()
for i in range(200,201):
plt.plot(t,ps.FiniteDifference(d=1,axis=1)._differentiate(u,dt)[i,:])
plt.plot(t,sol1[i,:],'k--')
plt.grid(True)
PS: if you'd like to use the SINDy model to predict the values of u
from an initial conditions rather than the time derivative, you'd need to numerically integrate the SINDy model. This is only implemented in PySINDy for ODE models (with the model.simulate
function), since numerically integrating PDE models requires many specific choices, including boundary conditions and discretization methods. I'd recommend looking into either PDE integration with spectral or finite different methods and implementing something outside of PySINDy by retrieving the model coefficients with the model.optimizer.coef_
attribute, for example.
I am trying apply SINDy on PDE using the kdv example you have. So I first start with loading the kdv file from matlab and just to plot the first set to see the result:
And then just follow along with the pde_lib, optimizer, and create the SINDy model:
But the result is not matching when I plot it out:
Can someone help me with this? I'll be greatly appreciated.