why results is different with matlab #388
Replies: 1 comment
-
matlab function u0 = pdex1ic(x) function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
from math import pi
from pde import CartesianGrid, MemoryStorage, PDEBase, ScalarField, plot_kymograph,DiffusionPDE
class KortewegDeVriesPDE(PDEBase):
"""Korteweg-de Vries equation"""
def init(self, k=54, diffusivity=[0.1,0.0025],bc="auto_periodic_neumann"):
super().init()
self.k = k
self.ro=7272
self.c=420
self.a=self.k/(self.roself.c)
self.q=7152
self.h1=39.6
#self.diffusivity = diffusivity # spatial mobility
bc_x_left = {"derivative":self.q/-self.k}
bc_y = {"type": "mixed", "value": self.h1/self.k, "const":self.h122/self.k}
self.bc = [bc_x_left,bc_y] # boundary condition
#self.bc = bc
def evolution_rate(self, state,t=0):
"""implement the python version of the evolution equation"""
assert state.grid.dim == 1 # ensure the state is one-dimensional
grad_x = state.laplace(self.bc)
grad_x1=state.gradient(self.bc)[0]
grad_x2=grad_x1.gradient(self.bc)[0]
return grad_x*self.a
initialize the equation and the space
#grid = CartesianGrid([[0, 10]],shape= [32], periodic=False)
grid = CartesianGrid([[0,0.055]],shape= [100])
#state = ScalarField.from_expression(grid, "10")
state= ScalarField.random_normal(grid,20)
solve the equation and store the trajectory
storage = MemoryStorage()
eq = KortewegDeVriesPDE()
eq.solve(state, t_range=[0,100],tracker=storage.tracker(0.5))
plot the trajectory as a space-time plot
plot_kymograph(storage)
Beta Was this translation helpful? Give feedback.
All reactions