GithubHelp home page GithubHelp logo

benmoseley / harmonic-oscillator-pinn Goto Github PK

View Code? Open in Web Editor NEW
493.0 15.0 136.0 2.65 MB

Code accompanying my blog post: So, what is a physics-informed neural network?

License: MIT License

Jupyter Notebook 100.00%
neural-networks physics-informed-ml physics-informed-neural-networks pinns sciml

harmonic-oscillator-pinn's Introduction

harmonic-oscillator-pinn's People

Contributors

benmoseley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

harmonic-oscillator-pinn's Issues

How to formulate the problem with the semi-implicit Euler Formula?

Hello Ben,

how would you tackle the whole thing if you determine the next position and velocity with the Euler method? This approach is mainly used to simulate physics in video games and produces an approximate discrete solution by iterating position and velocity. Here, b is the damping, which is typically between 0 and 1, and d is the position in force equilibrium.

function step(x_0, v_0) {
  a_spring = k * (d - x_0)
  v_1 = b * v_0 + a_spring * delta_t
  x_1 = x_0 + v_1 * delta_t
  return [x_1, v_1]
}

What I would like to get in the end is a neural network that does the following:

x_n+1, v_n+1 = NN(x_n, v_n)

I think I would treat it essentially like a time series forecasting but how would I formulate the "physics loss"?

Actually learning the solution?

Hi, first of all congratulations for the very nice work, the blog-post and the code, I enjoyed them very much!
Not a real issue here, just wanted to share what I found playing around with the code and I think could be interesting.

So basically I restricted the range of x_physiscs , i.e. the range where the physics loss is evaluated, to a smaller interval (e.g. [0,0.6] to see whether the network was able to generalize beyond training data.
Here is what I get:
image
So in my understanding the network is not learning the solution of the differential equation, but only a polynomial approximation which fits the training data only in a specific range. Thus if you would like to use the network to make predictions, you have to make sure that the training data points for the physics loss do cover the range you would like to predict.

This raises another possible issue, i.e. describing many oscillations of the system may require very high order polynomials and this could go beyond the expressive power of the NN. In the spirit of "physics informed networks" maybe some priors on the solutions could be used to engineer a network which indeed has the capability of parameterize the exact solution, such as periodic activation functions, to mention one.

Best,

P.

2D Oscillator instead of 1D Oscillator

Hello and great contribution!

I'm want to make sure of how to expand the current example to 2D instead of 1D (even further 2D + 1D for time). I assume that in the code, I need to change:

  1. The network input
  2. The xphysics structure
  3. The gradients equations

It does seem to be straightforward as I have faced errors when doing this. A 2D example would be hugely helpful.

Thanks!

Question about loss2

Hello, your work is very impressive and I learned a lot from it, thank you!
Here I have one question about loss2. I noticed that the loss2 is mutiply by 1e-4, I can understand you want to make the training faster, but may I ask why you choose this number and do you have any experience and this figure?
Another question is about the initial conditions, you didn't show them explicit in the code, does it means we do not need to think about these conditions when we use PINN for ODEs?

What if we do not have the analytical solution for differential eqn??

Hello Ben,

For the given differential equation, what if we do not have the analytical solution...
Then we do not have those data points (x_data, y_data) by which we have got loss_1, and if we train our model only by physics-based loss "loss_2", we won't get accurate results.
In Raissi et. al. paper on PINNs, they have taken the loss_1 term corresponding to the boundary and initial conditions.
So can we get an accurate result for the given differential equation(1 SDOF) if we incorporate the two initial conditions given in the question in the loss
and not the data points we have taken from the analytical solution of the differential equation?

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.