The code does not converge

1 Ansicht (letzte 30 Tage)
David Ricardo Macedo Ramos De Afonso Matias
Bearbeitet: Torsten am 16 Feb. 2024
%% Input data
MM = 23.546; % molar mass, g/mol
gamma = 1.2775;
T0t = 600 + 273.15; % inlet total temperature, kelvin
m_flow = 0.65; % mass flow, kg/s
betaTS = 2.5; % total to static expansion ratio available
P4 = 1*101325; % outlet pressure, Pa
P0t = betaTS*P4;
R = 8.314/(MM*10^-3); % specifc gas constant
Cp = R/(gamma - 1); % specific heat at constant pressure, J/kg*K
viscosity = 1.8e-5; % viscosity of the fluid assumed equal to the one of air
%% Starting design point
% Balje Chart
etaTT = 0.9; % total to total efficiency
omega_s = 0.5; % specific speed
D_s = 4; % specific diameter
% Chen-Baines (for eta_TT = 0.9)
flow_coeff = 0.215; % flow coefficient
work_coeff = 0.94; % work coefficient
%% Optimal work computation
T2t = T0t;
L_is = Cp*T0t*(1-betaTS^((1-gamma)/gamma)); % isentropic work, J/kg
P3t_is = P4; % isentropic total pressure at rotor outlet, Pa
T3t_is = T2t - L_is/Cp; % isentropic total temperature at rotor outlet, kelvin
rho3t_is = P3t_is/(R*T3t_is); % isentropic total density at rotor outlet, kg/
err_rho3 = 1;
rho3 = rho3t_is;
while abs(err_rho3) > 1e-6
Q_out = m_flow/rho3; % volumetric flow rate at rotor outlet
omega = ((omega_s*L_is^0.75)/Q_out^0.5)*60/(2*pi); % rotor rotational speed, rpm
D2 = (D_s*Q_out^0.5)/L_is^0.25; % rotor inlet diameter
U2 = omega*(2*pi/60)*D2/2; % rotor inlet peripheral speed
V3_tangential = 0; % rotor outlet tangential absolute velocity
L_eul = etaTT*L_is; % Euler work isentropic
V2_tangential = L_eul/U2;
V3_axial = flow_coeff*U2;
% Rotor outlet design
R3_hub = 0.09; % DESIGN CHOICE (hub radius, m)
equation = @(rho) rho*V3_axial*pi*((R3_hub^2+(2*(m_flow/(rho*pi*omega*(2*pi/60)))^2)^(1/3))-R3_hub^2)-m_flow;
rho3_new = fsolve(equation, rho3);
err_rho3 = rho3_new - rho3;
rho3 = rho3 + 0.1 *(rho3_new - rho3);
end
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance. No solution found. fsolve stopped because the problem appears regular as measured by the gradient, but the vector of function values is not near zero as measured by the value of the function tolerance.
  3 Kommentare
Les Beckham
Les Beckham am 16 Feb. 2024
Bearbeitet: Les Beckham am 16 Feb. 2024
The code you posted doesn't run at all (see error message below) so it will be difficult for anyone to help you figure out why it isn't converging. Please provide all data necessary to allow it to run. Also, please format the code as code (select all of the code and click the left hand button in the CODE section of the toolstrip).
%% Input data
MM = 23.546; % molar mass, g/mol
gamma = 1.2775;
T0t = 600 + 273.15; % inlet total temperature, kelvin
m_flow = 0.65; % mass flow, kg/s
betaTS = 2.5; % total to static expansion ratio available
P4 = 1*101325; % outlet pressure, Pa
P0t = betaTS*P4;
R = 8.314/(MM*10^-3); % specifc gas constant
Cp = R/(gamma - 1); % specific heat at constant pressure, J/kg*K
viscosity = 1.8e-5; % viscosity of the fluid assumed equal to the one of air
%% Starting design point
% Balje Chart
etaTT = 0.9; % total to total efficiency
omega_s = 0.5; % specific speed
D_s = 4; % specific diameter
% Chen-Baines (for eta_TT = 0.9)
flow_coeff = 0.215; % flow coefficient
work_coeff = 0.94; % work coefficient
%% Optimal work computation
T2t = T0t;
L_is = Cp*T0t*(1-betaTS^((1-gamma)/gamma)); % isentropic work, J/kg
P3t_is = P4; % isentropic total pressure at rotor outlet, Pa
T3t_is = T2t - L_is/Cp; % isentropic total temperature at rotor outlet, kelvin
rho3t_is = P3t_is/(R*T3t_is); % isentropic total density at rotor outlet, kg/
err_rho3 = 1;
rho3 = rho3t_is;
while abs(err_rho3) > 1e-5
Q_out = m_flow/rho3; % volumetric flow rate at rotor outlet
omega = ((omega_s*head_is^0.75)/Q_out^0.5)*60/(2*pi); % rotor rotational speed, rpm
D2 = (D_s*Q_out^0.5)/head_is^0.25; % rotor inlet diameter
U2 = omega*(2*pi/60)*D2/2; % rotor inlet peripheral speed
V3_tangential = 0; % rotor outlet tangential absolute velocity
L_eul = etaTT*L_is; % Euler work isentropic
V2_tangential = L_eul/U2;
V3_axial = flow_coeff*U2;
% Rotor outlet design
R3_hub = 0.09; % DESIGN CHOICE (hub radius, m)
equation = @(rho) rho*V3_axial*pi*((R3_hub^2+(2*(m_flow/(rho*pi*omega*(2*pi/60)))^2)^(1/3))-R3_hub^2)-m_flow;
rho3_new = fsolve(equation, rho3);
err_rho3 = rho3_new - rho3;
rho3 = rho3 + 0.1 * (rho3_new - rho3);
end
Unrecognized function or variable 'head_is'.
David Ricardo Macedo Ramos De Afonso Matias
I'm sorry about that, the code should run now.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Torsten
Torsten am 16 Feb. 2024
Bearbeitet: Torsten am 16 Feb. 2024
I seems your function does not vary much with rho. The evaluation cannot find a value for rho for which the function has a zero.
rho=0.01:0.1:200;
res = arrayfun(@(i)fun(rho(i)),1:numel(rho));
plot(rho,res)
function res = fun(rho3)
%% Input data
MM = 23.546; % molar mass, g/mol
gamma = 1.2775;
T0t = 600 + 273.15; % inlet total temperature, kelvin
m_flow = 0.65; % mass flow, kg/s
betaTS = 2.5; % total to static expansion ratio available
P4 = 1*101325; % outlet pressure, Pa
P0t = betaTS*P4;
R = 8.314/(MM*10^-3); % specifc gas constant
Cp = R/(gamma - 1); % specific heat at constant pressure, J/kg*K
viscosity = 1.8e-5; % viscosity of the fluid assumed equal to the one of air
%% Starting design point
% Balje Chart
etaTT = 0.9; % total to total efficiency
omega_s = 0.5; % specific speed
D_s = 4; % specific diameter
% Chen-Baines (for eta_TT = 0.9)
flow_coeff = 0.215; % flow coefficient
work_coeff = 0.94; % work coefficient
%% Optimal work computation
T2t = T0t;
L_is = Cp*T0t*(1-betaTS^((1-gamma)/gamma)); % isentropic work, J/kg
P3t_is = P4; % isentropic total pressure at rotor outlet, Pa
T3t_is = T2t - L_is/Cp; % isentropic total temperature at rotor outlet, kelvin
Q_out = m_flow/rho3; % volumetric flow rate at rotor outlet
omega = ((omega_s*L_is^0.75)/Q_out^0.5)*60/(2*pi); % rotor rotational speed, rpm
D2 = (D_s*Q_out^0.5)/L_is^0.25; % rotor inlet diameter
U2 = omega*(2*pi/60)*D2/2; % rotor inlet peripheral speed
V3_tangential = 0; % rotor outlet tangential absolute velocity
L_eul = etaTT*L_is; % Euler work isentropic
V2_tangential = L_eul/U2;
V3_axial = flow_coeff*U2;
% Rotor outlet design
R3_hub = 0.09; % DESIGN CHOICE (hub radius, m)
res=rho3*V3_axial*pi*((R3_hub^2+(2*(m_flow/(rho3*pi*omega*(2*pi/60)))^2)^(1/3))-R3_hub^2)-m_flow;
end

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by