Complex results when using my annonymous function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey Guys,
I am using runge-kutta-method to integrate function 1, after that i integrate function 2. But I always get complex results for function 2 (except the first iteration). Can anybody tell my why it is how it is? All other variables make sense, so the error should be anywhere else.
Thank you!!
while betrag > tol
for i=1:integrationsende
T_H2O_vektor(i+1) = T_H2O_vektor(i)+h;
X_sat(i) = 0.622 * p_sat_Antoine(T_H2O_vektor(i))/(p - p_sat_Antoine(T_H2O_vektor(i)));
h_Luft_sat(i) = (cp_Luft + cp_Dampf * X_sat(i)) * (T_H2O_vektor(i))+X_sat(i)*h_verdampfung;
Massenstromverhaeltnis = M_H2O_ein/M_Luft*(1 - M_Luft/M_H2O_ein*(X_2 - X_vektor(i)));
%Funktion 1
f1 = @(T_H2O,h_Luft) cp_H2O * Massenstromverhaeltnis *(1+(X_sat(i)-X_vektor(i))*cp_H2O...
*T_H2O/(h_Luft_sat(i)- h_Luft +((0.865^(2/3)*(((0.622+X_sat(i))/...
(0.622+X_vektor(i))-1)/(log((0.622+X_sat(i))/(0.622 + ...
X_vektor(i))))))-1) *(h_Luft_sat(i)- h_Luft-(X_sat(i)-...
X_vektor(i))*(h_verdampfung +cp_Dampf*T_H2O)) - (X_sat(i) ...
- X_vektor(i))*cp_H2O*T_H2O));
l1 = f1((T_H2O_vektor(i) ),(h_Luft_vektor(i) ));
l2 = f1((T_H2O_vektor(i) + 0.5*h),(h_Luft_vektor(i) + 0.5*h*l1));
l3 = f1((T_H2O_vektor(i) + 0.5*h),(h_Luft_vektor(i) + 0.5*h*l2));
l4 = f1((T_H2O_vektor(i) + h),(h_Luft_vektor(i) + h*l3));
h_Luft_vektor(i+1) = h_Luft_vektor(i) + h/6*(l1+2*l2+2*l3+l4);
%Funktion 2
f2 = @(T_H2O,X) cp_H2O * Massenstromverhaeltnis * ((X_sat(i) - X)/(h_Luft_sat(i)...
- h_Luft_vektor(i) + ((0.865^(2/3)*(((0.622+X_sat(i))/(0.622+X)-1)/...
(log((0.622+X_sat(i))/(0.622+X)))))-1)*(h_Luft_sat(i) - ...
h_Luft_vektor(i) -(X_sat(i) - X)*(h_verdampfung + cp_Dampf*T_H2O))) ...
- (X_sat(i) - X)*cp_H2O * T_H2O);
k1 = f2((T_H2O_vektor(i) ),(X_vektor(i) ));
k2 = f2((T_H2O_vektor(i) + 0.5*h),(X_vektor(i) + 0.5*h*k1));
k3 = f2((T_H2O_vektor(i) + 0.5*h),(X_vektor(i) + 0.5*h*k2));
k4 = f2((T_H2O_vektor(i) + h),(X_vektor(i) + h*k3));
X_vektor(i+1) = X_vektor(i) + h/6*(k1+2*k2+2*k3+k4);
X_2R = X_vektor(i) + h/6*(k1+2*k2+2*k3+k4);
betrag = abs(X_2R - X_2);
end
1 Kommentar
Star Strider
am 27 Jan. 2020
Is the argument to the log function here:
log((0.622+X_sat(i))/(0.622+X))
ever negative?
That is the only part of ‘f2’ I can see that could produce a complex result.
Antworten (1)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!