Open engsbk opened 2 years ago
According to your error, it seems you have a type mismatch. Try to force ulb
to tf.float32
:
ulb = tf.expand_dims(tf.math.sin(4 * np.pi * tf.convert_to_tensor(freq * ut, dtype=tf.float32)), -1)
I'm not sure, but it should do the trick.
Update: It worked great! Thank you for your suggestion! I'm also trying to test two cases of this equation:
Case1: An increased frequency. So, instead of sin(4pit), I'll use sin(16pit).
frequency = 4 shows: However, I did not succeed in obtaining the expected results when changing the frequency to 16 (looks reversed for some reason):
Case2: A heterogenous domain. In the original equation, I'd like to assign the value of c
as a function dependent on the location. For instance, I defined it within f_model()
to be as such:
c1 = 1
c2 = 0.5
# Implementing mask c = c1 * (x<=0.5) + c2 *(x>0.5)
c_s = tf.where(x[:, 0:1] <= 0.5, x[:, 0:1] *0 + c1, x[:, 0:1] * 0 + c2)
but the results were not accurate enough:
The fixes I tried so far for case1 are:
pop_size
mse_lb
with values (1.5, 5, and 10).
These have improved the prediction of the curve partially, but it did not fix the reverse propagation.The fixes I tried so far for case2 are:
n_iter
mse_f
with values (1.5, 5, and 10).
These fixes did not improve the accuracy. Any suggestions would be helpful. Thanks again!
I'm sorry for the delay, it's have been a busy week. Did you only change the `lower boundary condition between cases 1 and 2? Strange indeed. Especially for this "inverse" movement. I think I'll have some free time during the weekend, so I can review your example and try to figure out if there is only a parametrization problem or something else. Did you try it with a traditional PINN?
Can you share your experiments? I tried to reproduce it based on the shared code but didn't get much success.
I apologize for the delayed response. Thank you for looking into this. Not much of a change in the other two experiments.
In case 1:
I only changed this line:
ulb = tf.expand_dims(tf.math.sin(4 * np.pi * tf.convert_to_tensor(freq * ut, dtype=tf.float32)), -1)
to
ulb = tf.expand_dims(tf.math.sin(16 * np.pi * tf.convert_to_tensor(freq * ut, dtype=tf.float32)), -1)
In case 2:
I added this code to f_model()
c1 = 1
c2 = 0.5
# Implementing mask c = c1 * (x>0.5) + c2 *(x<=0.5)
c_s = tf.where(x[:, 0:1] <= 0.5, x[:, 0:1] *0 + c1, x[:, 0:1] * 0 + c2)
f_u = u_tt - (c_s ** 2) * u_xx
Please let me know if you're able to reproduce the problem.
Hello, and thank you for the fantastic framework!
I tried changing plugging in a different equation:
f_u = u_tt - (c**2) * u_xx
with IC: u(x,0) = 0 and BC: u(0,t) = sin(4 pi freq * t) u(1,t) = 0
The following is my code implementation:
I encountered what seems like a simple error, but I cannot resolve it. The error script is:
Any ideas?