Giter Club home page Giter Club logo

Comments (15)

svkarash avatar svkarash commented on July 22, 2024 1
  1. Try to run for more iterations and more points. If your loss is

Dear Reza [@AJAXJR24]
Thanks for your suggestions.
I'm planning to implement your suggestions. I think that the predicted eta plot would align with the initial condition at t=0, but unfortunately, the outcome is far from accurate.
Similarly, I had expected the values on the left and right to match the level H, yet this is not the case.

from deepxde.

jdellag avatar jdellag commented on July 22, 2024

What happens when you decrease your domain size and/or increase the amount of training points?

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

What happens when you decrease your domain size and/or increase the amount of training points?

Thanks for your reply.
In both scenarios, the estimation of eta leading to unexpected results, and the shapes are not correct. fore example the result is

data = dde.data.TimePDE(
    geomtime,
    pde,
    [left_bc_psi,right_bc_psi,left_bc_eta,right_bc_eta,
     bottom_bc_psi_x, bottom_bc_psi_z,
     surface_bc1, surface_bc2, surface_bc3,
     ic_psi, ic_eta],
    num_domain=800,
    num_boundary=400,
    num_initial=400,
    num_test=400
)

image

model.compile("L-BFGS-B")
losshistory, train_state = model.train(iterations=1000)

Then

num_points_x = 400
num_points_t = 5

x = np.linspace(0, L, num_points_x)  # L is the domain length in x
t = np.linspace(0, T, num_points_t)  # T is the total time
X, T = np.meshgrid(x, t)
XT_flat = np.vstack((X.flatten(), T.flatten())).T
z_value = H  
Z_flat = np.full((XT_flat.shape[0],), z_value)
test_data = np.column_stack((XT_flat, Z_flat))

U_pred = model.predict(test_data)

the results are

psi_pred = U_pred[:, 0]  # First predicted value for each point
eta_pred = U_pred[:, 1]  

and plotted below. Clearly the result is not what I expected and physics predicts

image

[@engsbk, ]

from deepxde.

jdellag avatar jdellag commented on July 22, 2024

Do you have any memory limitations? I only ask because I try to use as many points as I can within my domain and boundary. For example, my resulting plots after training look something like this:
Untitled

It may also be worth looking into using Anchors to specify specific points in your domain and/or on your boundary so that the PINN is forced to learn the solutions at these specific points.

from deepxde.

AJAXJR24 avatar AJAXJR24 commented on July 22, 2024

Dear @svkarash
Well I am not sure about the things I am going to say but it's worth trying.

  1. your Points and iterations seem not enough. Try to run for more iterations and more points. If your loss is ok and your problem converges that may not be the case.
  2. In definition of boundary and initial conditions try to use x[:,0:1] for example np.zeros_like(x[:, 0:1]) because the shape of np.zeros_like(x[:, 0]) and aforementioned form are different.
  3. review your code to see whether everything has been defined correctly especially in your pde because I assume the surface_bcs you defined in pde is not needed.

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

It may also be worth looking into using Anchors to specify specific points in your domain and/or on your boundary so that the PINN is forced to learn the solutions at these specific points

Dear @jdellag
Since I am using the free plan of Google Colab, there are indeed memory limitations. This can affect the scale and complexity of the models I work with. However, in this particular case, I don't believe that memory is the root cause of the issue. The x-z plot should be zero on the left and right boundaries, and it's concerning that they are not.
As for your suggestion about using Anchors, I must admit that I am not familiar with this concept in the context of PINNs. I would greatly appreciate any insights or resources you could share on how to implement Anchors in the code.

from deepxde.

jdellag avatar jdellag commented on July 22, 2024

Heres an example using the Laplace equation on a disk.

Say I wanted to have Anchor points evenly distributed around the disk, I could have a function that generates anchors like:

# Function to generate anchor points. Anchors can be used to improve the performance of the model by ensuring that 
# certain important points in the domain are always included in the training set.
def generate_points(n):
    """
    Generate anchor points in polar coordinates.
    
    Parameters:
    - n (int): Number of points to generate for both radius (r) and angle (theta).
    
    Returns:
    - np.array: Array of [r, theta] pairs.
    """
    # Define radius values ranging from 0 to 1
    r_values = np.linspace(0, 1.0, n)
    # Define angle values ranging from 0 to 2pi
    theta_values = np.linspace(0, 2*np.pi, n)
    points = []
    # Generate cartesian product of r_values and theta_values to get all combinations of [r, theta]
    for r in r_values:
        for theta in theta_values:
            points.append([r, theta])
    return np.array(points)


# Set the number of anchor points to be generated
n = 50
anchors = generate_points(n)

Then use these points when you define your dataset like so:

data = dde.data.PDE(
    geom,
    pde,
    bc,
    num_domain = 9500, 
    num_boundary = 1500,
    anchors = anchors
)

As far as limitations go, I can take care of most of my simulations using 1/10 of an A100 (i.e. under 8GB of memory using all 64bit floats for the ~12500 datapoints used above). While I have an allocation through ACCESS, if I look on RunPod I see that you can use a RTX A4000 for .34/hour.

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

anchors = anchors

Dear @jdellag,
Thank you so much for sharing the link and code. I am very excited to read and apply it. hope it help me

from deepxde.

Nimava avatar Nimava commented on July 22, 2024

Dear @svkarash ,

I already tried to solve almost the same problem. Based on the help of @forxltk , may be you should define the free surface geometry first and then apply the BC on it. something like this:

fs_condition = tf.less(tf.abs(x[:, 1:2] - zeta), tol)
lmbd = tf.where(fs_condition, tf.ones_like(zeta), tf.zeros_like(zeta))

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

Dear @svkarash ,

I already tried to solve almost the same problem. Based on the help of @forxltk , may be you should define the free surface geometry first and then apply the BC on it. something like this:

fs_condition = tf.less(tf.abs(x[:, 1:2] - zeta), tol)
lmbd = tf.where(fs_condition, tf.ones_like(zeta), tf.zeros_like(zeta))

Hi @Nimava,
First of all thanks for yor comment.
If I uderstand your point correctly, you're suggesting that I ought to initially specify the characteristics of the fluid and air, such as defining their presence in the domain, before attempting to solve the equation. This methodology aligns with the approach employed by CFD software like OpenFOAM.

image

I've implemented this for setting up initial conditions. Nevertheless, I'm inclined to think that this approach may not be suitable for Deepxde, as it seems necessary to define everything from the outset. This includes not only adjusting boundary conditions but also modifying the partial differential equations (PDEs).
I will try to implement your approach which is mentioned above.
I would also appreciate it if you could modify necessary section and comment them.

thanks in advance

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

@Nimava,
I'd like to connect with you to discuss certain aspects of the problem and learn more from you.
How can I get in touch with you?

from deepxde.

Nimava avatar Nimava commented on July 22, 2024

Dear @svkarash,
Thanks, Here is my email but I am not sure that I can help you or not.
[email protected]

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

[email protected]

thanks

from deepxde.

svkarash avatar svkarash commented on July 22, 2024

Dear @Nimava and experts
I changed the code as @Nimava advised. I only altered the surface equations in the PDE function and kept the surface boundaries the same. The results improved but are still incorrect. The first problem is the incorrect results at the left and right boundaries. Next, the initial wave at t=0 doesn't match the initial condition. Lastly, the wave's peak shifts to the left near x=2 instead of x=5.

image
initial condition

image
predicted $\zeta$

Please let me know how can I solve the issues

data = dde.data.TimePDE(
    geomtime,
    pde,
    [left_bc_psi,right_bc_psi,left_bc_eta,right_bc_eta,
     bottom_bc_psi_x, bottom_bc_psi_z,
     surface_bc1, surface_bc2, surface_bc3,
     ic_psi, ic_eta],
    num_domain=5090,
    num_boundary=2048,
    num_initial=2048,
    num_test=5090
)

layers = [3, [50] * 2, [50] * 2, 2]
net = dde.nn.PFNN(layers, "tanh", "Glorot uniform")

from deepxde.

Nimava avatar Nimava commented on July 22, 2024

May be these changing can improve the code:

1- You used Drichlet BC for all points of left and right walls but based on my experience in CFD, may be it is better that the uppest points of them (I mean the points that connect to free surface) should be without BC. In this condition, the free surface BCs are applied to these points.

2- I generally used Neumann Bc for these type of problems. You can check it too.

return on_boundary and np.isclose(x,1)

3- What is your initial wave amplitude? It should be very small to have linear waves.

from deepxde.

Related Issues (20)

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.