deepxde icon indicating copy to clipboard operation
deepxde copied to clipboard

How to define inputs out of the geometry and average of output as an input

Open AJAXJR24 opened this issue 1 year ago • 4 comments

Dear @lululxvi I want to solve a system of equation consist of an energy balance PDE and Arrhenisu equation. My inputs are the Spatial and Temporal dimensions and the ambient temperature. My outputs are T which is the function of all dimensions and c which is the function of time. How can I define the ambient temperature (is a function of time) as an input? the temperature in the Arrhenius equation is the average temperature in the whole domain in each time step. How can I define the mean Temperature in the Arrhenius equation? Since the temperature is getting solved in each node. Thanks

AJAXJR24 avatar Oct 05 '23 15:10 AJAXJR24

Sorry this is not my background, but why do you need ambient temperature as the input to the network? Can you write the PDEs your are trying to solve?

Also, to answer your question, it is quite challenging to solve problems with PINN where the inputs to the network is dependent on the output. The training takes excessively long time to converge even for simple problems. This is because your inputs are not constant, it is changing in each training iteration.

praksharma avatar Oct 17 '23 10:10 praksharma

Sorry this is not my background, but why do you need ambient temperature as the input to the network? Can you write the PDEs your are trying to solve?

There is really no need for that. I was Just saying it exists. I already defined it seperately.

Also, to answer your question, it is quite challenging to solve problems with PINN where the inputs to the network is dependent on the output. The training takes excessively long time to converge even for simple problems. This is because your inputs are not constant, it is changing in each training iteration.

Is there a way though??

AJAXJR24 avatar Oct 19 '23 02:10 AJAXJR24

Yes you just need a train the problem for a longer duration. If you provide us with the code, I can look into and give you insights.

praksharma avatar Oct 25 '23 07:10 praksharma

Yes you just need a train the problem for a longer duration. If you provide us with the code, I can look into and give you insights.

Thanks for your reply My problem has changed. I got a convection-conduction balance boundary condition where the T_ambient is a function of time as below: BTW is that tf.reduce_mean ok to define the average temperature in each time step?

Screenshot 2023-11-07 041151

How can I define this? if it could be defined by tf.where what should be the shape of the T_amb tensor (shape of time or shape of the whole domain)? Or is there a better way to define this Temperature?

def pde(x,y):

  x = tf.cast(x, tf.float64)

  y = tf.cast(y, tf.float64)

  T_xx = dde.grad.hessian(y,x,component=0,i=0,j=0)

  T_yy = dde.grad.hessian(y,x,component=0,i=1,j=1)

  T_t = dde.grad.jacobian(y,x,i=0,j=2)

  c_t = dde.grad.jacobian(y,x,i=1,j=2)

  ###########################################
  ###########################################

  return [T_t  - (kx/ky)* T_xx  - T_yy + ((H*W)/(ρ*cp*delta_T))*c_t,
              A * y[:,1:2] * (He**2/alpha_y) * tf.exp(-E/(Rc * (tf.reduce_mean(y[:,0:1],axis=0)*delta_T + T_min)))  + c_t]

BC:?

def func_conv_x(x,y):
  x = tf.cast(x, tf.float64)
  y = tf.cast(y, tf.float64)
  condition_1 = tf.less(x[:,2:3],48.604069896509976)
  condition_2 = tf.greater(x[:,2:3],72.90610484476497)
  condition_3 = tf.math.logical_and(x[:,2:3] >= 48.604069896509976, x[:,2:3] <= 72.90610484476497)
  #################################################################################################
  mm = 0.03647356906232812
  yy = -1.6921837228041898
  #################################################################################################
  T_ext_1 = tf.where(condition_1, tf.ones_like(x[:,2:3])*0.08058017727639, tf.zeros_like(x[:,2:3]))
  T_ext_2 = tf.where(condition_2, tf.ones_like(x[:,2:3])*0.96696212731668,tf.zeros_like(x[:,2:3]))
  T_ext_3 = tf.where(condition_3, mm * x[:,2:3] + yy, tf.zeros_like(x[:,2:3]))
  T_ext = tf.add_n([T_ext_1,T_ext_2,T_ext_3])
  tf.ones_like(x)*T_ext,y[:,0:1]
  print((x[:,0:1].shape),(x[:,1:2].shape),(x[:,2:3].shape))
  return ((h*He)/kx) * (tf.ones_like(x)*T_ext-y[:,0:1])

I used one Neural Network with 3 inputs and 2 outputs but the project I am working on said that there are 2 different Neural Networks each with three inputs and one output. Is my approach correct? If not what is the solution? Thanks

AJAXJR24 avatar Nov 07 '23 00:11 AJAXJR24