Skip to content

evalieben/ODEsolver-PINNS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

ODEsolver-PINNS

solve ODE, ODE system and PDE with DNN in pytorch

Requirements

packages: python==3.9, pytorch== CUDA1.16, numpy, matplotlib.pyplot

Instruction for single ODE

===1.create an equation===

Input: xmin, xmax, samples ODE1 = ODE(1,5,16000)

===2.set the equation===

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)- 3
exp(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)")

===3.set exact solution===

Input: function,display function,
ODE1.setExact(log(ODE1.xVar()),"lnx")
Input None if not known

===4.add boundaries===

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)

===5.start solving===

Input: network_layers, cells, learn_rate, weight_decay, max_steps, threads, reduction
ODE1.solve(7,40,1e-4,0.0001,20001,2,"sum")

Instruction for ODE system

===1.create equations===

Input: xmin, xmax, samples ODE1 = ODE(1,5,16000)
ODE2 = ODE(1,5,16000)
ODE3 = ODE(1,5,16000)

===2.set equations (at least 2)===

example:
dy/dt-dx/dt = x*(A-By)
dz/dt-dy/dt = -y
(C-Dx)
dz/dt
dx/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],"z
x-y*z+ODE1.xVar()")

===3.set exact solution===

Input: function,display function,
ODE1.setExact(log(ODE1.xVar()),"lnx")
ODE2.setExact(None,None)
Input None if not known

===4.add boundaries===

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)

===5.start solving===

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

Instruction for PDE

===CODING===

About

solve ODE, ODE system and PDE with DNN in pytorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages