SciANN example for heat transfer problem
Closed this issue · 2 comments
Ali1990dashti commented
Dear Cummunity,
Firstly, I do appreciate your help regarding my trivial question. I am new to SciANN and PINN. I am trying to make a PINN model for a simple 1d heat equation problem. This is my PDE:
rho*cp dT/dt = lamda d2T/dx2
I am using Python 3.8.12
, SciANN 0.6.8.4
and tensorflow 2.7.0
. My code is presented in the following but it gives the error discussed here.
import sciann as sn
from sciann.utils.math import diff
rho, lamda, cp = 1, 1, 1 # parametrization
t_ic = 50 # IC
t_left = 70 # left side BC
t_right = 40 # right side BC
x = sn.Variable('x')
t = sn.Variable('t')
T = sn.Functional('T', [t,x], 4*[20], 'tanh')
L1 = diff(T, t, order=1) - lamda/(rho* cp)*diff(T, x, order=2)
BC_left = (x==0.)*(t_left)
BC_right = (x==L)*(t_right)
IC = (t==0.)*(t_ic)
m = sn.SciModel([x, t], [L1, BC_left, BC_right, IC])
x_data, t_data = np.meshgrid(
np.linspace(0, 1, 100),
np.linspace(0, 60, 100)
)
h = m.train([x_data, t_data], 4*['zero'], learning_rate=0.002, epochs=500)
Thanks again for you help. I very much appreciate if anyone can provide me with a SciANN example dealing with heat conduction and convection.
Cheers
Ali
ehsanhaghighat commented
Your BCs are not correctly defined:
> BC_left = (x==0.)*(T - t_left)
BC_right = (x==L)*(T - t_right)
IC = (t==0.)*(T - t_ic)
… On Nov 24, 2022, at 6:18 AM, Ali Dashti ***@***.***> wrote:
Dear Cummunity,
Firstly, I do appreciate your help regarding my trivial question. I am new to SciANN and PINN. I am trying to make a PINN model for a simple 1d heat equation problem. This is my PDE:
rho*cp dT/dt = lamda d2T/dx2
I am using Python 3.8.12, SciANN 0.6.8.4 and tensorflow 2.7.0. My code is presented in the following but it gives the error discussed here <https://github.com/sciann/sciann/issues/11>.
import sciann as sn
from sciann.utils.math import diff
rho, lamda, cp = 1, 1, 1 # parametrization
t_ic = 50 # IC
t_left = 70 # left side BC
t_right = 40 # right side BC
x = sn.Variable('x')
t = sn.Variable('t')
T = sn.Functional('T', [t,x], 4*[20], 'tanh')
L1 = diff(T, t, order=1) - lamda/(rho* cp)*diff(T, x, order=2)
BC_left = (x==0.)*(t_left)
BC_right = (x==L)*(t_right)
IC = (t==0.)*(t_ic)
m = sn.SciModel([x, t], [L1, BC_left, BC_right, IC])
x_data, t_data = np.meshgrid(
np.linspace(0, 1, 100),
np.linspace(0, 60, 100)
)
h = m.train([x_data, t_data], 4*['zero'], learning_rate=0.002, epochs=500)
Thanks again for you help. I very much appreciate if anyone can provide me with a SciANN example dealing with heat conduction and convection.
Cheers
Ali
—
Reply to this email directly, view it on GitHub <https://github.com/sciann/sciann/issues/72>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AHMBIZYGCVPTRYRK6FISITTWJ52L3ANCNFSM6AAAAAASKOMSNY>.
You are receiving this because you are subscribed to this thread.
Ali1990dashti commented
@ehsanhaghighat , Thanks a lot for your help.