Advection equation on the domain of super ellipse #732
Replies: 9 comments 3 replies
-
Dr. Lu Lu |
Beta Was this translation helpful? Give feedback.
-
Could you add more details? |
Beta Was this translation helpful? Give feedback.
-
I try to solve advection equation using ANN on the domain of super ellipse. |
Beta Was this translation helpful? Give feedback.
-
'''''''''''''''''''''''This is the domain what i need. '''''''''''''''' import matplotlib.pyplot as plt plotting the curveplt.axis('equal') |
Beta Was this translation helpful? Give feedback.
-
I didn't get your question. What is the difficulty? What have you tried? |
Beta Was this translation helpful? Give feedback.
-
Dr. Lu Lu
Ok, as i told you by using Deepxde library, try to code using ANN for
solving advection equations on super ellipse geometry.
So the result must be on super ellipse geometry.
Q 1, How to get the super ellipse result ?
[image: supar ellipse.png]
The result on the above graph for the advection equation.
Please can I get the code?
…On Wed, Jun 15, 2022 at 11:36 PM Lu Lu ***@***.***> wrote:
I didn't get your question. What is the difficulty? What have you tried?
—
Reply to this email directly, view it on GitHub
<#732 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYV4JA6OW4X5K4TNI4NAYRLVPI5FJANCNFSM5YN2IMSA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
DeepXDE doesn't support super ellipse geometry. You need to either implement a new geometry or use |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks. What about for circles in 2d advection equation.
…On Wed, 22 Jun 2022, 7:20 pm Lu Lu, ***@***.***> wrote:
DeepXDE doesn't support super ellipse geometry. You need to either
implement a new geometry or use anchors. See FAQ Q: More details and
examples about geometry. and Q: How does DeepXDE choose the training
points? How can I use some specific training points?
—
Reply to this email directly, view it on GitHub
<#732 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYV4JAY7SRMJPERR3M2B7JTVQM4NJANCNFSM5YN2IMSA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll check it out.
…On Mon, Jun 27, 2022 at 9:18 PM Lu Lu ***@***.***> wrote:
Circle is supported, see
https://deepxde.readthedocs.io/en/latest/modules/deepxde.geometry.html
—
Reply to this email directly, view it on GitHub
<#732 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYV4JA3JX76465WTED3RXFDVRHV5TANCNFSM5YN2IMSA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello Dr. Lu Lu and Deepxde community.
I try to write a code for advection equation on super ellipse domain but, it is not work. How can write the domain? Please some body help me.
with bast regard.
import deepxde as dde
import matplotlib.pyplot as plt
import numpy as np
#from numpy import flot
def advection_eq_exact_solution(x, t):
"""Returns the exact solution for a given x and t (for sinusoidal initial conditions).
def gen_exact_solution():
"""Generates exact solution for the advection equation for the given values of x and t."""
# Number of points in each dimension:
x_dim, t_dim = (256, 201)
def gen_testdata():
"""Import and preprocess the dataset with the exact solution."""
# Load the data:
data = np.load("advection_eq_data.npz")
# Obtain the values for t, x, and the excat solution:
t, x, exact = data["t"], data["x"], data["usol"].T
# Process the data and flatten it out (like labels and features):
xx, tt = np.meshgrid(x, t)
X = np.vstack((np.ravel(xx), np.ravel(tt))).T
y = exact.flatten()[:, None]
return X, y
Problem parameters:
a = 0.4 # Thermal diffusivity
b = 1
c = 1
L = 1 # Length of the bar
n = 1 / 2 # Frequency of the sinusoidal initial conditions
Generate a dataset with the exact solution (if you dont have one):
gen_exact_solution()
def pde(x, y):
"""Expresses the PDE residual of the advection equation."""
dy_tt = dde.grad.jacobian(y, x, i=0, j=1)
dy_xx = dde.grad.hessian(y, x, i=0, j=0)
return dy_tt + a * dy_xx
Computational geometry:
geom = dde.geometry.Interval(0, L)
timedomain = dde.geometry.TimeDomain(0, 2 * np.pi)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
Initial and boundary conditions:
bc = dde.icbc.DirichletBC(geomtime, lambda x: (abs(b) * ((np.cos(x)) ** 2 / n)), lambda t: (abs(c) * ((np.sin(t)) ** 2 / n)))
ic = dde.icbc.IC(
geomtime,
lambda x: np.sin(n * np.pi * x[:, 0:1] / L),
lambda _, on_initial: on_initial,
)
Define the PDE problem and configurations of the network:
data = dde.data.TimePDE(
geomtime,
pde,
[bc, ic],
num_domain=2540,
num_boundary=80,
num_initial=160,
num_test=2540,
)
net = dde.nn.FNN([2] + [20] * 3 + [1], "tanh", "Glorot normal")
model = dde.Model(data, net)
Build and train the model:
model.compile("adam", lr=1e-3)
model.train(epochs=200)
model.compile("L-BFGS")
losshistory, train_state = model.train()
Plot/print the results
dde.saveplot(losshistory, train_state, issave=True, isplot=True)
X, y_true = gen_testdata()
y_pred = model.predict(X)
f = model.predict(X, operator=pde)
print("Mean residual:", np.mean(np.absolute(f)))
print("L2 relative error:", dde.metrics.l2_relative_error(y_true, y_pred))
np.savetxt("test.dat", np.hstack((X, y_true, y_pred)))
Beta Was this translation helpful? Give feedback.
All reactions