ehsanhaghighat/sciann

SciANN example for heat transfer problem

Closed this issue · 2 comments

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 , Thanks a lot for your help.