deepxde
deepxde copied to clipboard
Coupled equations
Hi! I am trying to implement 2 pdes, solving one at a time. From the first one I obtain a variable that I need to include in the second one.
The implementation of the first and second equations are:
def pde1(x, y):
rhoS=100
dUs_z = dde.grad.jacobian(y, x, i=0, j=0)
return rhoS*dUs_z - 1
def bio(x, y):
Us = model.predict(x)
y2 = Us*y
drho_z = dde.grad.jacobian(y2, x, i=0, j=0)
drho_t = dde.grad.jacobian(y, x, i=0, j=1)
return drho_t + drho_z - 1
But I'm getting the following error:
def array(self, dtype=None): 990 del dtype --> 991 raise NotImplementedError( 992 "Cannot convert a symbolic Tensor ({}) to a numpy array." 993 " This error may indicate that you're trying to pass a Tensor to" 994 " a NumPy call, which is not supported".format(self.name))
NotImplementedError: Cannot convert a symbolic Tensor (Placeholder_302:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported. Could you please help me? I think it is something wrong with Us = model.predict(x). Thanks in advance.
This is not supported directly, but it is doable to re-implement code in another way to solve the problem.
Hi! I implemented all equations in the same function. But I am having a problem with a second order equation. I define many variables as,
Us = y[:, 0:1]
rhoS = [y[:, 1:2], y[:, 2:3], y[:, 3:4]]
rhoGm = y[:,4:5]
Ug = y[:,5:6]
rhoG = [y[:,6:7]]
and identify each derivative according to the component index. For example, for this case I use
d2rhoG_z = dde.grad.hessian(y, x, component=6, j=0)
to write the equation: y_rhoG = d2rhoG_z
However, it does not obtain a linear equation as expected. I also used the following boundary conditions:
def boundaryL(x, on_boundary):
return on_boundary and np.isclose(x[0], 0)
def boundaryR(x, on_boundary):
return on_boundary and np.isclose(x[0], 0.655)
bcL_rhoG0 = dde.DirichletBC(geomtime, lambda x: 10, boundaryL)
bcR_rhoG0 = dde.DirichletBC(geomtime, lambda x: 0, boundaryR)
ic_rhoG0 = dde.IC(geomtime, lambda x: 0, lambda _, on_initial: on_initial)
I don't know what the error can be. I tried to write the function just for rhoG, not needing the component and it worked. Then, it has something to do with the component?
Thanks in advance for your answer.
I cannot understand your question. Could you explain more with a better code style?