Coder Social home page Coder Social logo

odesolver-pinns's Introduction

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===

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.