lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.71k stars 752 forks source link

Regarding anchors points with some observed values. #739

Open JerolSOIBAM opened 2 years ago

JerolSOIBAM commented 2 years ago

Hi Lulu,

First of all, thank you for making this amazing library open source.

I had a question regarding adding of anchor point based on residual of pde.

Let say i am solving an inverse NS problem with few observed data points (T, u, v, p etc.) in the domain. Assuming that this few data points come from sensors. And i put these few data points inside the bcs given under data:

_data = dde.data.PDE(geo, NS_SS, bcs, num_domain = 9000, num_boundary = 3000, numtest= 5000)

Then i train the network like this:

_layer_size = [2] + [425] 13 + [4] activation = "tanh" initializer = "Glorot uniform" net = dde.nn.FNN(layer_size, activation, initializer) # dde.maps.FNN model = dde.Model(data, net) model.compile( "adam", lr = 1e-6) checkpointer = dde.callbacks.ModelCheckpoint("model2/model.ckpt", save_better_only=True, period=10000) losshistory, train_state = model.train(epochs = 20000, display_every = 100, callbacks=[checkpointer]) dde.saveplot(losshistory, trainstate, issave = True, isplot = True)

###################### Once i have finished training i want to further improve the accuracy of my prediction so i try to find the biggest residual in the domain for the operator=pde.

_X1 = geo1.random_points(10000)

f = model.predict(X1, operator=pde2) err_eq = np.absolute(f) err = np.mean(err_eq) print("Mean residual: %.3e" % (err))

x_id = np.argmax(err_eq) print("Adding new point:", X1[xid], "\n") Adding new point: [0.63151854 0.46451408]

so i get the coordinate where it has the maximum residual and i want to add velocity value in this coordinate. But i am not sure how i can do this since the data.add_anchors accepts only the x&y coordinate but in my case i also want to include a new velocity point at this point. So, that i avoid re initializing the network and train from beginning.

I tried looking into the documents and issue but i could not find anything related to this. Could you suggest how to tackle this.

Thank you in advanced!

lululxvi commented 2 years ago

Do you want to add more data of velocity? Then why not using all of these data directly?

JerolSOIBAM commented 2 years ago

Hi @lululxvi , thanks for the reply. That would be possible if it was using CFD simulation. However, i am targeting towards experimental data. Hence i want to add data based on the max residual location obtained from PDE.

lululxvi commented 2 years ago

It is possible to do. You need to write a for loop. See the RAR code at https://github.com/lu-group/gpinn

JerolSOIBAM commented 2 years ago

@lululxvi Thanks i will have a look at it and get back once i have resolve it.