-
I am trying to solve the Fermi-Pasta-Ulam problem using
My questions:
Thank you so much for your earlier response and the work on this package! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I am a little confused about your problem:
Do you want to use one BC only or both BCs? If you use zero boundary condition on left and right boundary, then it is automatically periodic BC, right? (The PDE is third order, and thus you need 3 BCs?) Could you show some details why you think the BC doesn't work? For the prediction, you predict the whole field directly, and then reshape, but this may be hard to debug. An easy way is to predict one timeframe by one timeframe. e.g., to predict
You can put this code in your |
Beta Was this translation helpful? Give feedback.
-
This is a great help to display and understand results via animation! import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import matplotlib
matplotlib.use('Qt5Agg')
%matplotlib inline
x = np.linspace(-1, 1, 256)
y = np.linspace(-1, 1, 256)
#t = np.linspace(0, 0.99, 100)
t = np.zeros_like(x)
X = np.vstack((x,y,t)).T
res = np.ravel(model.predict(X))
#Initially
fig, ax = plt.subplots(figsize=(5, 3))
ax.set_aspect('equal')
xx, yy= np.meshgrid(x,y)
X_star = np.vstack((xx.flatten()[:,None], yy.flatten()[:,None]))
print ("X_star:", X_star.shape)
print ("res:", res.shape)
res2D = griddata(X, res.flatten(), (xx, yy), method='linear')
cax = ax.pcolormesh(x, y, res2D, vmin=-1, vmax=1, cmap='Blues')
fig.colorbar(cax)
print ("res:", res.shape)
def animate(i):
t = np.zeros_like(x)+(i/100)
X = np.vstack((x,y,t)).T
res = np.ravel(model.predict(X))
xx, yy = np.meshgrid(x,y)
X_star = np.vstack((xx.flatten()[:,None], yy.flatten()[:,None]))
res2D = griddata(X, res.flatten(), (xx, yy), method='linear')
cax.set_array(res2D)
ax.set_title('t = ' + str(i/100))
anim = FuncAnimation(
fig, animate, interval=100, frames=len(t)-1)
plt.draw()
plt.show()
anim.save('2D_wave' + '.gif', writer='imagemagick') but I got the following error:
Please note that |
Beta Was this translation helpful? Give feedback.
-
Have no experience on 2d case. If I do this, I would save all the figures first, which is easy, and then use other software to combine figures into video. |
Beta Was this translation helpful? Give feedback.
I am a little confused about your problem:
y(-10, t) = y(10, t)
? Your code is rightbcl = dde.PeriodicBC(geomtime, 0, boundary_l)
, and you only need eitherbcl
orbcr
.y(-10, t) = y(10,t) = 0
? Your code is rightbc = dde.DirichletBC(geomtime, lambda x: np.zeros((len(x), 1)), lambda _, on_boundary: on_boundary)
Do you want to use one BC only or both BCs? If you use zero boundary condition on left and right boundary, then it is automatically periodic BC, right? (The PDE is third order, and thus you need 3 BCs?) Could you show some details why you think the BC doesn't work?
For the predi…