# Transient Heat Transfer | Simple One-Layer Wall

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 14, 2022, 03:37 Transient Heat Transfer | Simple One-Layer Wall #1 Member   Khan Join Date: Jul 2018 Posts: 45 Rep Power: 7 Hello All, I try to build a transient heat transfer model for a simple one-layer wall by use of the Resistance-Capacitance (RC) approach. However, the transient temperature distribution shows weird numbers in time. Would you please check my approach and code? Heat balance for each capacitance can be written as: Forward-Euler Discretization (one-dimensional) gives: At each time step this calculation procedure is run: Here is the Python code to calculate the temperature distribution in time: Code: ```import numpy as np """ Input Parameters """ # Wall height_w = 3 # [m] height of the wall wide_w = 5 # [m] wide of the wall thick_w = 0.3 # [m] thickness of the wall volume_w = height_w * wide_w * thick_w # [m3] volume of the wall area_w= height_w * wide_w # [m2] wall area # Room deep_r = 4 # [m] deepness of room volume_r = height_w * wide_w * deep_r # [m3] volume of the room air # Initial Temperature T_in = 20 # [°C] indoor temperature T_out = 2 # [°C] outdoor temperature # Thermal h_in = 8 # [W/m2K] heat transfer coefficient (indoor) h_out = 15 # [W/m2K] heat transfer coefficient (outdoor) # see: Balaji NC et al. Thermal performance of the building walls k_w = 0.811 # [W/mK] thermal conductivity (brick) rho_w = 1820 # [kg/m3] density (brick) Cp_w = 880 # [J/kgK] specific heat capacity (brick) # Air rho_a = 1.204 # [kg/m3] density (air at 20 °C) Cp_a = 1006 # [J/kgK] specific heat capacity (air at 20 °C) """ Preliminary Calculations """ delta_t = 1 # [s] C_a = rho_a * Cp_a * volume_r # [J/K] C_w = rho_w * Cp_w * volume_w # [J/K] R_in = 1 / (h_in * area_w) # [K/W] R_out = 1 / (h_out * area_w) # [K/W] R_w = thick_w / (k_w * area_w) # [K/W] # print('R_in = ',R_in) # print('R_out = ',R_out) # print('R_w = ',R_w) """ Numeric Constants """ A = np.zeros( (4, 4) ) A[0][0]=1+delta_t/(C_a*R_in) A[0][1]=-delta_t/(C_a*R_in) A[1][0]=4*delta_t/(C_w*R_in) A[1][1]=1-4*delta_t/C_w*(1/R_in+2/R_w) A[1][2]=8*delta_t/(C_w*R_w) A[2][1]=4*delta_t/(C_w*R_w) A[2][2]=1-2*delta_t/C_w*(2/R_w+2/R_w) A[2][3]=4*delta_t/(C_w*R_w) A[3][2]=8*delta_t/(C_w*R_w) A[3][3]=1-4*delta_t/C_w*(2/R_w+1/R_out) B = np.zeros((4,1)) B[3][0]=4*delta_t*T_out/(C_w*R_out) """ Numerical Simulation """ T_init=np.ones((4,1))*15 for i in range(1): T=np.matmul(A,T_init)+B T_init=T``` Last edited by HumanistEngineer; January 15, 2022 at 05:21.

 January 15, 2022, 05:54 #2 Member   Khan Join Date: Jul 2018 Posts: 45 Rep Power: 7 I found the error: The first heat balance shall be replaced with: C_in*(dT_in/dt)=- (T_in - T_w1) / R_in

 July 29, 2022, 20:03 #3 Senior Member   Agustín Villa Join Date: Apr 2013 Location: Alcorcón Posts: 313 Rep Power: 15 If you are using Python you could use Scipy to solve your state-space equations.