Replies: 1 comment 2 replies
-
|
I have never seen this problem. Not sure if someone else can reproduce the issue here. |
Beta Was this translation helpful? Give feedback.
2 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.
-
Hi, my code runs with nothing to show, i dont know what happened?
It is a simple diffusion PDE,
import deepxde as dde
import torch
import numpy as np
import scipy.io as scio
def gen_trainingdata():
data_ = scio.loadmat("D:\All in AI\2\Code\SPMe_outputs.mat")
Cs_p_ = data_["X_Cs"]
t = np.linspace(0, 3600, 36000)
x = np.linspace(0, Rs_p, 20)
xx, tt = np.meshgrid(x, t)
X = np.reshape(xx, (-1, 1))
T = np.reshape(tt, (-1, 1))
Cs_p_ = np.reshape(Cs_p_, (-1, 1))
return np.hstack((X, T)), Cs_p_
Ds_p = dde.Variable(1e-13)
def pde(x, y):
dy_t = dde.grad.jacobian(y, x, i=0, j=1)
dy_x = dde.grad.jacobian(y, x, i=0, j=0)
dy_xx = dde.grad.hessian(y, x, i=0, j=0)
return (
dy_t
- Ds_p * (2 * dy_x / x[:, 0:1] + dy_xx)
)
def boundary_r(x, on_boundary):
return on_boundary and np.isclose(x[0], Rs_p)
def boundary_l(x, on_boundary):
return on_boundary and np.isclose(x[0], 0 )
def func_bc(x):
Ds_p_ = Ds_p.detach().numpy()
Jr_p = i_L * x[:, 0:1] / ((3 * 0.42) * L_n * S_n * F * Ds_p_ )
def func_initial(x):
return Cs_initial
geom = dde.geometry.Interval(0, Rs_p)
timedomain = dde.geometry.TimeDomain(0, 3600)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
bc_r = dde.icbc.NeumannBC(geomtime, func_bc, boundary_r)
bc_l = dde.icbc.NeumannBC(geomtime, func_bc, boundary_l)
ic = dde.icbc.IC(geomtime, func_initial, lambda _, on_initial: on_initial)
observe_x, y = gen_trainingdata()
observe_y = dde.icbc.PointSetBC(observe_x, y, component=0)
data = dde.data.TimePDE(
geomtime,
pde,
[bc_r, bc_l, ic, observe_y],
num_domain=3600,
num_boundary=20,
num_initial=100,
anchors=observe_x,
num_test=10000,
)
layer_size = [2] + [32] * 3 + [1]
activation = "tanh"
initializer = "Glorot uniform"
net = dde.nn.FNN(layer_size, activation, initializer)
model = dde.Model(data, net)
model.compile("adam", lr=1e-3,metrics=["l2 relative error"], external_trainable_variables= Ds_p)
model.train(epochs=15000)
model.compile("L-BFGS")
variable = dde.callbacks.VariableValue(Ds_p, period=10000, filename="variable_Ds_p.dat")
losshistory, train_state = model.train(epochs=500000, callbacks=[variable])
dde.saveplot(losshistory, train_state, issave=True, isplot=True)`
and the result is :
`Compiling model...
'compile' took 0.000672 s
Training model...`
Nothing to show,,,
Beta Was this translation helpful? Give feedback.
All reactions