Solving Non-Linear Schrodinger Equation in fibre optics with deepxde #1663
Replies: 2 comments 2 replies
-
Dear Prof, |
Beta Was this translation helpful? Give feedback.
-
@Gocoderunav def complex_pde(x, y): def boundary(_, on_initial): def main():
if name == 'main': |
Beta Was this translation helpful? Give feedback.
-
Dear professor,
I'm trying to solve the Non-Linear Schrodinger Equation in fibre optics with deepxde I have attached the image also. I'm reading your code on solving Schrodinger equation with deepxde. In my case the derivatives wrt to x and t are swapped you can understand by looking at image also .
I'm seeking your assistance in understanding and correcting this issue. I've been studying your code for solving the Schrödinger equation with deepxde, but I'm unsure how to address this particular problem.
Thank you for taking the time to read my message. Your guidance on this matter would be greatly appreciated.
Image:-
@source:-[https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9489953]
--> My Questions is:-
Q-1 I'm using a Gaussian-like initial pulse, shaped as sech(t), applied at z=0. While it's periodic in time, existing classes like PeriodicBC are designed for spatial periodicity. Can I still use PeriodicBC to enforce boundary conditions effectively?"
Q-2 The real and imaginary parts of the Schrödinger equation seem inconsistent when solving it using either h=u+iv or h=u-iv. Can you please review this?
Here's the code I'm using to solve the NLSE in fiber optics
Code `:-import numpy as np
import deepxde as dde
For plotting
import matplotlib.pyplot as plt
x_lower = 0
from scipy.interpolate import griddata
x_upper = 4
t_lower= -24
t_upper = 24
x =np.linspace(x_lower ,x_upper , 256)
t =np.linspace(t_lower ,t_upper , 201)
X,T =np.meshgrid(x,t)
X_star = np.hstack((X.flatten()[:, None], T.flatten()[:, None]))
space_domain = dde.geometry.Interval(x_lower,x_upper)
def pde(x,y):
time_domain = dde.geometry.TimeDomain(t_lower,t_upper)
geomtime = dde.geometry.GeometryXTime(space_domain ,time_domain)
"""
INPUTS:
x: x[:,0] is x-coordinate
x[:,1] is t-coordinate
y: Network output, in this case:
y[:,0] is u(x,t) the real part
y[:,1] is v(x,t) the imaginary part
OUTPUT:
The pde in standard form i.e. something that must be zero
"""
u = y[:, 0:1] # real part
v = y[:,1:2] #imag part
u_z = dde.grad.jacobian( y, x, i=0 , j=0)
v_z = dde.grad.jacobian( y, x, i=1 , j=0)
In 'hessian', i and j are both input components. (The Hessian could be in principle something like d^2y/dxdt, d^2y/d^2x etc)
bc_u_0 = dde.icbc.PeriodicBC( geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=0 ) bc_u_1 = dde.icbc.PeriodicBC( geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=0 ) bc_v_0 = dde.icbc.PeriodicBC( geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=0, component=1 ) bc_v_1 = dde.icbc.PeriodicBC( geomtime, 0, lambda _, on_boundary: on_boundary, derivative_order=1, component=1 )
`# Initial condition
def init_cond_u(x):
def init_cond_v(x):
return 0
ic_u = dde.icbc.IC(geomtime, init_cond_u, lambda _, on_initial: on_initial, component=0)
ic_v = dde.icbc.IC(geomtime, init_cond_v, lambda _, on_initial: on_initial, component=1)
data = dde.data.TimePDE(
geomtime,
pde,
[bc_u_0, bc_u_1, bc_v_0, bc_v_1, ic_u, ic_v],
num_domain=10000,
num_boundary=20,
num_initial=200,
train_distribution="pseudo",
)
Network architecture
net = dde.nn.FNN([2] + [100] * 4 + [2], "tanh", "Glorot normal")
model = dde.Model(data, net)
model.compile("adam", lr=1e-3, loss="MSE")
model.train(iterations=10000, display_every=1000)`
Beta Was this translation helpful? Give feedback.
All reactions