EES Integration Example 3.2-1a

download EES Integration Example 3.2-1a

of 10

Transcript of EES Integration Example 3.2-1a

  • 8/13/2019 EES Integration Example 3.2-1a

    1/10

    EXAMPLE 3.2-1(a): Oven Brazing (EES)

    A brazing operation is carried out in an oven. The metal pieces to be brazed have a complex

    geometry; they are made of bronze (with k = 50 W/m-K, c = 500 J/kg-K, and = 8700 kg/m3)

    and have a total volume V = 10 cm3and total surface areaAs = 35 cm

    2. The pieces are heated by

    radiation heat transfer from the walls of the oven. A detailed presentation of radiation heattransfer is presented in Chapter 10. For this problem, assume that the emissivity of the surface of

    the piece is = 0.8 and that the wall of the oven is black. In this limit, the radiation heat transfer

    from the wall to the piece ( radq ) may be written as:

    ( )4 4rad s wq A T T =

    where Twis the temperature of the wall, Tis the temperature of the surface of the piece, and is

    Stefan-Boltzmans constant. The temperature of the oven wall is increased at a constant rate =1 K/s from its initial temperature Tini = 20C to its final temperature Tf = 470C which is held for

    thold= 1000 s before the temperature of the wall is reduced at the same constant rate back to itsinitial temperature. The pieces and the oven are initially in thermal equilibrium at Tt=0= Tini.

    a.) Is the lumped capacitance assumption appropriate for this problem?

    The inputs are entered in EES.

    "EXAMPLE 3.2-1(a): Oven Brazing (EES)"$UnitSystem SI MASS RAD PA K J$TABSTOPS 0.2 0.4 0.6 0.8 3.5 in

    "Inputs"

    V=10 [cm^3]*convert(cm^3,m^3) "volume"A_s=35 [cm^2]*convert(cm^2,m^2) "surface area"e=0.8 [-] "emissivity of surface"T_ini=converttemp(C,K,20 [C]) "initial temperature"T_f=converttemp(C,K,470 [C]) "final oven temperature"t_hold=1000 [s] "oven hold time"beta=1 [K/s] "oven ramp rate"c=500 [J/kg-K] "specific heat capacity"k=50 [W/m-K] "conductivity"rho=8700 [kg/m^3] "density"

    The lumped capacitance assumption ignores the internal resistance to conduction as being smallrelative to the resistance to heat transfer from the surface of the object. The radiation heat

    transfer coefficient, defined in Section 1.2.6, is:

    ( )( )2 2rad s w s wh T T T T = + +

    where Ts is the surface temperature of the object. The Biot number defined based on thisradiation heat transfer coefficient is:

  • 8/13/2019 EES Integration Example 3.2-1a

    2/10

    rad condh L

    Bik

    =

    where

    cond

    s

    VL

    A=

    The Biot number is largest (and therefore the lumped capacitance model is least justified) whenthe value of hradis largest which occurs if both Tsand Twachieve their maximum possible value(Tf).

    h_rad_max=sigma#*e*(T_f^2+T_f^2)*(T_f+T_f) "maximum radiation coefficient"L_cond=V/A_s "characteristic length for conduction"Bi=h_rad_max*L_cond/k "maximum Biot number"

    The Biot number is calculated to be 0.004 at this upper limit, which indicates that the lumpedcapacitance assumption is valid.

    b.) Calculate a lumped capacitance time constant that characterizes the brazing process.

    It is useful to calculate a time constant even when the problem is solved numerically. The valueof the time constant provides guidance relative to the time step that will be required and it alsoallows a sanity check on your results. The time constant, discussed in Section 3.1.4, is theproduct of the thermal capacitance of the object and the net resistance from the surface. Usingthe concept of the radiation coefficient allows the time constant to be written as:

    lumped

    rad s

    V ch A =

    The minimum value of the time-constant (again, corresponding to the object and the oven wallbeing at their maximum temperature) is computed in EES:

    tau=rho*c*V/(h_rad_max*A_s) "time constant"

    and found to be 167 s.

    c.) Develop a numerical solution based on Heuns method that predicts the temperature of the

    object for 3000 s after the oven is activated.

    A function T_wis defined which returns the wall temperature as a function of time; the functionis placed at the top of the EES file.

    "Oven temperature function"function T_w(time,T_ini,T_f,beta,t_hold)

    "INPUTS:

  • 8/13/2019 EES Integration Example 3.2-1a

    3/10

    time - time relative to initiation of process (s)T_ini - initial temperature (K)T_f - final temperature (K)beta - ramp rate (K/s)t_hold - hold time (s)

    OUTPUTST_w - wall temperature (K)"

    T_w=T_ini+beta*time "temperature of wall during ramp up period"t_ramp=(T_f-T_ini)/beta "duration of ramp period"if (time>t_ramp) then

    T_w=T_f "temperature of wall during hold period"endifif (time>(t_ramp+t_hold)) then

    T_w=T_f-beta*(time-t_ramp-t_hold) "temperature during ramp down period"endifif (time>(2*t_ramp+t_hold)) then

    T_w=T_ini "temperature after ramp down period"

    endifend

    Note the use of the if-then-endifstatements to activate different functions for the wall temperaturebased on the time of the simulation. The function T_wbe called from the Equation Window:

    T_w=T_w(time,T_i,T_f,beta,tau_hold)

    It is wise to check that the function is working correctly by setting up a parametric table thatincludes time and the wall temperature; the result is shown in Figure 1.

    0 500 1000 1500 2000 2500 3000200

    300

    400

    500

    600

    700

    800

    Time (s)

    Walltemperature(K)

    Figure 1: Oven wall temperature as a function of time.

    The simulation time and number of time steps are defined and used to compute the time and walltemperature at each time step:

    t_sim=3000 [s] "simulation time"M=101 [-] "number of time-steps"DELTAt=t_sim/(M-1) "time-step duration"duplicate j=1,M

    time[j]=(j-1)*t_sim/(M-1) "time"T_w[j]=T_w(time[j],T_ini,T_f,beta,t_hold) "wall temperature"

  • 8/13/2019 EES Integration Example 3.2-1a

    4/10

    end

    The governing equation is obtained from an energy balance on the piece:

    rad

    dUq

    dt=

    or

    ( )4 4s wdT

    A T T V cdt

    = (1)

    Rearranging Eq. (1) leads to the state equation that provides the time rate of change of thetemperature:

    ( )

    4 4

    s w

    A T TdTdt V c

    = (2)

    The temperature at the beginning of the first time step is the initial condition:

    1 iniT T=

    T[1]=T_ini "initial temperature"

    Heun's method consists of an initial, predictor step:

    1

    ,

    j j

    j j

    T T t t

    dTT T t

    dt+

    = =

    = + (3)

    Substituting the state equation, Eq. (2), into Eq. (3) leads to:

    ( )4 4,,

    j

    j j

    s w t t j

    T T t t

    A T TdT

    dt V c

    =

    = =

    =

    The corrector step is:

    1 1

    1, , 2j j j j

    j j

    T T t t T T t t

    dT dT t T T

    dt dt

    + +

    +

    = = = =

    = + +

    where

  • 8/13/2019 EES Integration Example 3.2-1a

    5/10

  • 8/13/2019 EES Integration Example 3.2-1a

    6/10

    EXAMPLE 3.2-1(b): Oven Brazing (MATLAB)

    Repeat EXAMPLE 3.2-1 using MATLAB rather than EES to do the calculations.

    a.) Develop a numerical solution that is based on Heuns method and implemented in MATLABthat predicts the temperature of the object for 3000 s after the oven is activated.

    The solution will be obtained in a function Oven_brazing that can be called from the commandspace. The function will accept the number of time steps (M) and the total simulation time (tsim)and return three arrays that are the values of time, and the wall and surface temperatures at eachtime step.

    function[time, T_w, T]=Oven_Brazing(M, t_sim)% EXAMPLE 3.2-1(b) Oven Brazing

    % INPUTS% M - number of time steps (-)% t_sim - duration of simulation (s)

    % OUTPUTS% time - array with the values of time for each time step (s)% T_w - array containing values of the wall temperature at each time (K)% T - array containing values of the surface temperature at each time (K)

    Next, the known information from the problem statement is entered into the function.

    %Known information

    V=10/100000; % volume (m^3)A_s=35/1000; % surface area (m^2)e=0.8; % emissivity of surface (-)T_ini=293.15; % initial temperature (K)T_f=743.15; % final oven temperature (K)t_hold=1000; % oven hold temperature (s)beta=1; % oven ramp rate (K/s)c=500; % specific heat capacity (J/kg-K)k=50; % conductivity (W/m-K)rho=8700; % density (kg/m^3)sigma=5.67e-8; % Stefan-Boltzmann constant (W/m^2-K^4)

    A function is needed to return the wall temperature as a function of time. The following code

    implements this function. Place this function at the bottom of the file, after an endstatement thatterminates the function Oven_Brazing.

    function[T_w]=T_wf(time, T_ini, T_f, beta, t_hold)% Oven temperature function% Inputs% time - current time value (s)% T_ini - initial value of the wall (K)% T_f - final value of the wall (K)

  • 8/13/2019 EES Integration Example 3.2-1a

    7/10

    % beta - rate of increase in temperature of the wall (K/s)% t_hold - time period in which the wall temperature is held constant (s)

    % Output% T_w - wall temperature at specfied time (K)

    T_w=T_ini+beta*time;t_ramp=(T_f-T_ini)/beta;if(time>t_ramp)

    T_w=T_f;endif(time>(t_ramp+t_hold))

    T_w=T_f-beta*(time-t_ramp-t_hold);endif(time>(2*t_ramp+t_hold))

    T_w=T_ini;end

    end

    Note the use of the if-endclauses to activate different functions for the wall temperature based onthe time of the simulation. The temperature of the wall at any time can be evaluated by a call tothe function T_w. The following lines fill the timeand T_wvectors with the values of time andthe wall temperature at each time step.

    DELTAt=t_sim/(M-1); % time step durationforj=1:M

    time(j)=(j-1)*t_sim/(M-1); % value of time for each stepT_w(j)=T_wf(time(j),T_ini,T_f,beta,t_hold); % value of the wall temperature at each step

    end

    The last task is to enter the equations that implement Heuns method for solving the differential

    equation. The governing equation is obtained from an energy balance on the piece:

    ( )4 4rad s wdT

    q A T T V cdt

    = =

    or

    ( )4 4s wA T TdTdt V c

    = (1)

    Heuns method consists of an initial, predictor step:

    1

    ,

    j j

    j j

    T T t t

    dTT T

    dt+

    = =

    = +

    where:

  • 8/13/2019 EES Integration Example 3.2-1a

    8/10

    ( )4 4,

    ,

    j

    j j

    s w t t j

    T T t t

    A T TdT

    dt V c

    =

    = =

    =

    The corrector step is:

    1 1

    1, , 2j j j j

    j j

    T T t t T T t t

    dT dT t T T

    dt dt

    + +

    +

    = = = =

    = + +

    where, from Eq. (1),

    ( )1

    *1 1

    4 4

    , 1

    ,

    j

    j j

    s w t t j

    T T t t

    A T TdT

    dt V c

    +

    + +

    = +

    = =

    =

    The following equations implement Heuns method in MATLAB:

    T(1)=T_ini;forj=1:(M-1)

    dTdt=e*A_s*sigma*(T_w(j)^4-T(j)^4)/(rho*V*c); %Temp deriv. at the start of the time stepT_hat=T(j)+dTdt*DELTAt; %Predictor stepdTdt_hat=e*A_s*sigma*(T_w(j+1)^4-T_hat^4)/(rho*V*c); %deriv. at end of time stepT(j+1)=T(j)+(dTdt+dTdt_hat)*DELTAt/2; %Corrector step"

    end

    The Oven_Brazingfunction is terminated with an endstatement and saved.

    end

    The function can now be called from the command window

    >> [time, T_w, T]=Oven_Brazing(101, 3000);

    The temperature of the wall and the piece is shown in Figure 1.

    0 500 1000 1500 2000 2500 3000200

    300

    400

    500

    600

    700

    800

    Time (s)

    Temperature(K)

    Heun's method

    ode45 solver

    oven wall temp.

    oven wall

    piece

    Figure 1: Temperature of the wall and work piece, predicted using Heun's method and the ode45

    solver, as a function of time

  • 8/13/2019 EES Integration Example 3.2-1a

    9/10

    b.) Develop a numerical solution using MATLABs ode45 function that predicts the temperatureof the object for 3000 s after the oven is activated.

    The ode solvers are designed to call a function the returns the derivative of dependent variablewith respect to the independent variable. In our case, the dependent variable is the temperature

    of the work piece and time is the independent variable. A function must be provided that returnsthe time derivative of the temperature at a specified time and temperature. The MATLABfunction dTdt_f accepts all of the input parameters that are needed to determine the derivative;

    according to Eq. (1), these includeAs, , , V,, and cas well as parameters needed determinethe wall temperature at any time. Place the function dTdt_fbelow the function T_wf. Note thatthe function dTdt_f calls the function T_wf in order to determine the wall temperature at aspecified time.

    function[dTdt]=dTdt_f(time,T,e,A_s,rho,V,c,T_f,T_ini,beta,t_hold)% dTdt is called by the ode45 solver to evaluate the derivative dTdt% INPUTS

    % time - time relative to start of process (s)% T - temperature of piece (K)% e - emissivity of piece (-)% A_s - surface area of piece (m^2)% rho - density (kg/m^3)% V - volume of piece (m^3)% c - specific heat capacity of piece (J/kg-K)% T_f - final oven temperature (K)% T_ini - initial oven temperature (K)% beta - oven ramp rate (K/s)% t_hold - oven hold time (s)

    % OUTPUTS% dTdt - rate of change of temperature of the piece (K/s)

    sigma=5.67e-8; % Stefan-Boltzmann constant (W/m^2-K^4)T_w=T_wf(time, T_ini, T_f, beta, t_hold); % wall temperaturedTdt=e*A_s*sigma*(T_w^4-T^4)/(rho*V*c); % energy balance

    end

    Now, all that is necessary is to comment out the code in the function Oven_brazing from part (a)and instead call the MATLAB ode45solver function to determine the temperatures as a functionof time.

    % T(1)=T_ini;% for j=1:(M-1)% dTdt=e*A_s*sigma*(T_w(j)^4-T(j)^4)/(rho*V*c);% T_hat=T(j)+dTdt*DELTAt;% dTdt_hat=e*A_s*sigma*(T_w(j+1)^4-T_hat^4)/(rho*V*c);% T(j+1)=T(j)+(dTdt+dTdt_hat)*DELTAt/2;% end

    %Solution determined by ode solver[time, T]=ode45(@(time,T) dTdt_f(time,T,e,A_s,rho,V,c,T_f,T_ini,beta,t_hold),time,T_ini);

  • 8/13/2019 EES Integration Example 3.2-1a

    10/10

    The time span for the integration is provided by supplying the time array to the ode45 function.As a result, MATLAB will evaluate the temperatures at the same times as were used with Heunsmethod. A plot of the ode solver results (identified with circles) is superimposed onto the resultsobtained using Heun's method in Figure 1.