New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set up different materials in the electrical field? #480
Comments
Use |
Thanks for your reply! |
Hello, Dr. Lu @lululxvi
What might be the problem with this representation? |
The code looks OK. What doesn't work as expected? |
Instead of |
Thanks for your help! |
Hello lululxvi |
You can find the examples at https://deepxde.readthedocs.io/en/latest/demos/pinn_inverse.html Use |
Hello Lululxvi ep*dEz/dt -dHy/dx+dHx/dy=0
#this is the condtion of ep ===> ep=2 if 0<=x<=0.5 and ep=1 if 0.5<=x<=1
It is true?/?? |
epsilon_1 = 1
epsilon_2 = 2 |
@lululxvi def epsilon(x):
#the center of the circle (1,1), radius 0.5
if (x[:,0:1]-1)**2 + (x[:,1:2]-1)**2 <0.25:
ep = 4
else:
ep = 1
return ep
def pde(x,u,ex):
du_x = dde.grad.jacobian(u, x, i=0, j=0)
du_y = dde.grad.jacobian(u, x, i=0, j=1)
result=dde.grad.jacobian(epsilon*du_x, x, i=0, j=0)+dde.grad.jacobian(epsilon*du_x, x, i=0, j=1)
return result
data = dde.data.PDE(
geom,
pde,
[bc],
num_domain=400,
num_boundary=2,
auxiliary_var_function=epsilon,
) Thank you. |
Looks good. |
@chang-change Please let me know if your code is run without any error. |
@ach14012022 I don't have the complete code, I just modified this piece of code. Hence, I don't know if it will work successfully. |
|
In fact, I used a little trick that I saw in a paper 10.1021/acsphotonics.0c01202. You can read it if you are interested. Another method is to use tf.where as the corresponding dielectric constant for residual points in different positions as mentioned above.
|
Hello, Lu Lu
I am trying to set up different materials in the electrical field. But I have no idea how to set the permittivity in different regions. Could you please give me some advice?
Thanks a lot
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_2: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
The error occurred in the code:
model.compile("adam", lr=1.0e-3)
The details are as follows :
NotImplementedError Traceback (most recent call last)
in
2 model = dde.Model(data, net)
3
----> 4 model.compile("adam", lr=1.0e-3)
5 #model.train(epochs=10000)
6 #model.compile("L-BFGS")
D:\Anaconda3\lib\site-packages\deepxde\utils\internal.py in wrapper(*args, **kwargs)
20 def wrapper(*args, **kwargs):
21 ts = timeit.default_timer()
---> 22 result = f(*args, **kwargs)
23 te = timeit.default_timer()
24 print("%r took %f s\n" % (f.name, te - ts))
D:\Anaconda3\lib\site-packages\deepxde\model.py in compile(self, optimizer, lr, loss, metrics, decay, loss_weights, external_trainable_variables)
105
106 if backend_name == "tensorflow.compat.v1":
--> 107 self._compile_tensorflow_compat_v1(lr, loss_fn, decay, loss_weights)
108 elif backend_name == "tensorflow":
109 self._compile_tensorflow(lr, loss_fn, decay, loss_weights)
D:\Anaconda3\lib\site-packages\deepxde\model.py in _compile_tensorflow_compat_v1(self, lr, loss_fn, decay, loss_weights)
125
126 # Data losses
--> 127 losses = self.data.losses(self.net.targets, self.net.outputs, loss_fn, self)
128 if not isinstance(losses, list):
129 losses = [losses]
D:\Anaconda3\lib\site-packages\deepxde\data\pde.py in losses(self, targets, outputs, loss, model)
127 if self.pde is not None:
128 if get_num_args(self.pde) == 2:
--> 129 f = self.pde(model.net.inputs, outputs)
130 elif get_num_args(self.pde) == 3:
131 if self.auxiliary_var_fn is None:
in pde(x, u)
11 #du_yy=geom_cir.inside(x)1dde.grad.jacobian(du_y, x, i=0, j=1)+(~geom_cir.inside(x)4dde.grad.jacobian(du_y, x, i=0, j=1))
12 #du_xx=perm(x)*dde.grad.jacobian(du_x, x, i=0, j=0)
---> 13 du_xx=np.heaviside(x[:,:1],1)*dde.grad.jacobian(du_x, x, i=0, j=0)
14 #return du_xx+du_yy
15 return du_xx
D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in array(failed resolving arguments)
918 def array(self, dtype=None):
919 del dtype
--> 920 raise NotImplementedError(
921 "Cannot convert a symbolic Tensor ({}) to a numpy array."
922 " This error may indicate that you're trying to pass a Tensor to"
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_2: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
The text was updated successfully, but these errors were encountered: