New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imposing BC using ids in Burger's equation #13
Comments
Hi, I just saw the ids example in the SciANN-SolidMechanics-BCs.py code. So I assume that the ids_ic_bc and U_ic_bc are just 1d vectors. The values inside ids_ic_bc will correspond to the indices inside U_ic_bc where the BC are imposed, is that so? However, the x,y locations where the BCs are imposed are not specified. Is the code able to infer from the data where the BCs are actually imposed? Because in the SciANN-SolidMechanics-BCs.py code, data_d1 is the displacement x values. data_d1 is obtained thru dispx(input_data) and input_data has a rather special list type format containing x and y. Must it be done this way? Thanks. |
Hi, thanks for pointing this out. Regarding the XY data grid, note that internally I re-shape the data to (-1,1) which is the way Keras accepts the data. Therefore the assumption is that you assign ids of boundaries according to (x,y) points when reshaped to (-1,1). For now, I suggest you to reshape your grid and everything should work fine after that. However, I think if I allow a binary (True,False) id for the boundaries, then you would be able to pass a one-to-one xy grid for ids as well. I will implement that in the next version. Thanks for your comment.
… On Jan 4, 2021, at 7:54 PM, zonexo ***@***.***> wrote:
Hi,
I just saw the ids example in the SciANN-SolidMechanics-BCs.py code.
So I assume that the ids_ic_bc and U_ic_bc are just 1d vectors.
The values inside ids_ic_bc will correspond to the indices inside U_ic_bc where the BC are imposed, is that so?
However, the x,y locations where the BCs are imposed are not specified. Is the code able to infer from the data where the BCs are actually imposed? Because in the SciANN-SolidMechanics-BCs.py code, data_d1 is the displacement x values. data_d1 is obtained thru dispx(input_data) and input_data has a rather special list type format containing x and y. Must it be done this way?
Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hi, thanks for the clarifications. I have modify the code slightly to use the ids for the BC: ` #initial condition U_ic = np.zeros((100)) for i in range(100):
#BC condition U_bc = np.zeros((200)) #left BC
#right BC
ids_ic_bc = np.concatenate([ids_ic,ids_bc]) ids_ic_bc = ids_ic_bc.astype(int) #Training However, I got the error: IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed May I know what's wrong? I have also used x/t_data_reshape instead in m.train but it gave the same error. Hope you can help. |
Hi, I have changed the code slightly to follow the syntax used in the SciANN-SolidMechanics-BCs.py code: `input_data = [x_data.reshape(-1, 1), t_data.reshape(-1, 1)] #initial condition U_ic = np.zeros((100)) ids_ic = np.zeros((100)) for i in range(100):
#BC condition U_bc = np.zeros((200)) ids_bc = np.zeros((200)) #left BC
#right BC
ids_ic_bc = np.concatenate([ids_ic,ids_bc]) target_data = [(ids_ic_bc, U_ic_bc), #Training #h = m.train([x_data,t_data],['zeros',(ids_ic_bc,U_ic_bc)],batch_size=256,epochs=100) h = m.train( So is this the correct way? The code is no longer complaining. I ran the code to see if I can get similar results compared to using equations to implement the BCs. However, my answer is not the same, so most likely somewhere is wrong. I also increase the batch size to 2560 and the result is abit different, but still wrong. The loss is around 1e-6. https://i.ibb.co/1swqp93/sciann-burger-bc-output.jpg Hope you can help. Thank! |
The last code looks fine, and I cannot spot any problem here. Have you checked the code for the Burgers problem? |
Hi, That's the code I modified. The original code uses some eqns to impose the BC so I changed to using the ids implementation. Do you have any suggestion? Thanks. |
I found an error in my code and it's working now. Thanks for the help. Here's the modified part: m = sn.SciModel ([x, t], [u, L1], "mse", "Adam") #Sampling (collocation) grid #To train the network, we need to define a sampling (collocation) grid. x_data, t_data = np.meshgrid( x_data_reshape = x_data.reshape(-1, 1) input_data = [x_data.reshape(-1, 1), t_data.reshape(-1, 1)] #initial condition U_ic = np.zeros((100)) ids_ic = np.zeros((100)) for i in range(100):
#BC condition U_bc = np.zeros((200)) ids_bc = np.zeros((200)) #left BC
#right BC
#ids_ic_bc = np.unique(np.concatenate([ids_ic,ids_bc])) target_data = [(ids_ic_bc, U_ic_bc), #Training #h = m.train([x_data,t_data],['zeros',(ids_ic_bc,U_ic_bc)],batch_size=256,epochs=100) h = m.train( |
why isn't this code anywhere in the examples?, still cannot find how to use the ids |
Hi, I have read your papers and looked into the Burgers problem.
From the paper, it mentions that to implement BC using ids, I should use:
m = sn.SciModel ([t, x], [L1 , u], "mse", "Adam")
m.train([x_data,t_data],['zeros',(ids_ic_bc,U_ic_bc)],batch_size=256,epochs=10000)
I check and found that x_data and t_data are arrays of size (100,100).
But what is the array size of ids_ic_bc and U_ic_bc?
Thanks for the clarifications.
The text was updated successfully, but these errors were encountered: