Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
935 B
1
Indexable
Never
clc;clear;
% Define parameters
rho = 2700; % kg/m^3
Cp = 903; % J/(kg*K)
t = 0.01; % m
L = 1; % m
e = 0.7;
sigma = 5.67e-8; % W/(m^2*K^4)
T_inf = 298; % K
T_surroundings = 298; % K
h = 25; % W/(m^2*K)
q_flux = 10; % W/m^2
dt = 0.1; % s, time step

% Compute mass and area
A = L * L;
m = rho * A * t;

% Initial condition
T = T_inf; % Start at ambient temperature

% Time and energy variables
time = 0;
energy_in = 0;
energy_out = 0;

% Time loop
while T < 3*T_inf
    q_in = q_flux * A * dt;
    energy_in = energy_in + q_in;

    q_out = h*A*(T - T_inf) * dt + e*sigma*A*(T^4 - T_surroundings^4) * dt;
    energy_out = energy_out + q_out;

    dT = (q_in - q_out) / (m * Cp);
    T = T + dT;
    time = time + dt;
end

disp(['Time to reach three times the initial temperature: ', num2str(time), ' seconds'])
disp(['Total energy input: ', num2str(energy_in), ' Joules'])
disp(['Total energy output: ', num2str(energy_out), ' Joules'])