solve ODE, ODE system and PDE with DNN in pytorch
packages: python==3.9, pytorch== CUDA1.16, numpy, matplotlib.pyplot
Input: xmin, xmax, samples
ODE1 = ODE(1,5,16000)
Input: coeffs, variables, left_part, right_part
example:
xf''(x) - 3f'(x)f'(x) + f(x)f'(x) = cosx/sinx + x^2 - 3e^x + f(x)lnx + logx +5
==> ODE1.setEquation([ODE1.xVar(),ODE1.diff(1,-3),ODE1.yVar()],[None],[2,1,1],"cos(x)/sin(x)+pow(x,2)- 3exp(x)+y*log(x)+log10(x)+5")
single constant in right part should use ODE.constant()
if only 1 equation set the variables as [None]
ODE1.setEquation([ODE1.diff(1,1),1],[None],[2,0],"log(x)-pow(x,-3)")
Input: function,display function,
ODE1.setExact(log(ODE1.xVar()),"lnx")
Input None if not known
Input: (max<=3), x(float), value(float)
ODE1.addBoundary(0,1.0,0.0)
ODE1.addBoundary(1,1.0,1.0)
ODE1.addBoundary(2,0.0,0.5)
Input: network_layers, cells, learn_rate, weight_decay, max_steps, threads, reduction
ODE1.solve(7,40,1e-4,0.0001,20001,2,"sum")
Input: xmin, xmax, samples
ODE1 = ODE(1,5,16000)
ODE2 = ODE(1,5,16000)
ODE3 = ODE(1,5,16000)
example:
dy/dt-dx/dt = x*(A-By)
dz/dt-dy/dt = -y(C-Dx)
dz/dtdx/dt = zx-yz+t)
==> ODE1.setEquation([1,-1],[y,x],[1,1],"x*(A-By)")
ODE2.setEquation([1,-1],[y,x],[1,1],"-y(C-Dx)")
ODE3.setEquation([ODE1.dx],[z],[1],"zx-y*z+ODE1.xVar()")
Input: function,display function,
ODE1.setExact(log(ODE1.xVar()),"lnx")
ODE2.setExact(None,None)
Input None if not known
Input: diff_level(max<=3), x(float), value(float)
ODE1.addBoundary(0,2.0,6.86)
ODE2.addBoundary(0,2.0,3.46)
ODE3.addBoundary(0,2.0,5.21)
Input: network_layers, cells, learn_rate, weight_decay, max_steps, threads, reduction
ODE1.solve_with(ODE2,ODE3,8,60,1e-5,0.005,40001,2,"mean")
if only 2 equations set ODE3 as None