- if possible solve the equations symbolically/algreabrically, then simply insert the values into the solution.
- use a numeric optimization routine. In general this requires writing an objective function (containing your "equations") and providing that to the optimization routine. What routine to use depends on the nature of your problem: simple problems in one variable might be solved with FZERO, otherwise you might need to use FMINBND or similar.
Is there a way I could assign my variable to a bunch of equations with its value generated on its own ?
1 view (last 30 days)
Show older comments
Hi there everybody, Im currently doing on my coding right now and encountered on this problem. I would like my variable M2 to generate its own value in which the value satisfies to a bunch of equations that would lead the final equation DeltaP = Patm - P7 = 0. However i wasnt able to achieve such task and would like help on this matter.
R = 287;
T1 = 339;
kc = 1.4;
kc0 = 0.2;
kc1 = 2.498;
kc2 = 3.498;
ktp_volute = 0.9
r1 = 1;
rrms2 = 2;
SW = 0.95;
M1 = rand(1);
for i= 1:length(M1)
%% Ctheta Exit Volute
C1 = M1*(kc*R*T1)^0.5; %absolute velocity inlet
Ctheta_exitvolute = C1*SW*(r1 / rrms2 );
%% Ctheta Inlet Rotor
T02 = 339;
T2 = 332.193;
alpha2 = 70.423;
Rad = deg2rad(alpha2);
%M2 = (M1 * T1^0.5 * SW * r1/rrms2) / T2*0.5 * sin(Rad);
M2 = rand(1);
C2 = M2.*(kc*R*T2).^0.5; %absolute velocity inlet volute
Ctheta2_inletrotor = C2.*sin(Rad);
Delta_Ctheta = Ctheta_exitvolute - Ctheta2_inletrotor;
iter = 0;
maxIter = 0;
%% Delta_Ctheta
while Delta_Ctheta < 0 && iter > maxIter
iter = iter + 1;
Ctheta_exitvolute = C1*SW*(r1 / rrms2 );
Ctheta2_inletrotor = C2.*sin(Rad);
Delta_Ctheta = Ctheta_exitvolute - Ctheta2_inletrotor;
end
if iter == maxIter
warning('Max Iterations reached')
end
end
M6 = rand (1);
M7 = rand(1);
Ktp1 = 1.6775e-12 ;
M2_rel = 0.288;
P01 = 124638.717;
P2 = P01./(((1 + kc0 * M2.^2).^kc2).*(1+ktp_volute)-ktp_volute)
P02_rel = P2.*(1 + kc0 * M2_rel.^2).^kc2;
W2 = 79.468;
W6 = 61.967;
Kpass6 = 0.1;
Kinc1 = 0.522;
Kpass2 = 0.060;
U2 = 207.88944;
U6 = 136.4506;
W6_ideal = sqrt(((W6.^2).* (1+Kpass6)) + ((Kpass2 + Kinc1).* (W2.^2)));
T02_rel = T2.*(1 + kc0 * M2_rel.^2);
T06_rel = T02_rel - kc0./(kc*R) * (U2.^2 - U6.^2);
P06_idrel = P02_rel.* (T06_rel/T02_rel).^kc2;
Wcr2 = sqrt((2 * kc * R * T02_rel)./(kc+1))
Wcr6 = Wcr2.* sqrt(T06_rel/T02_rel)
P6 = (1 - ((W6_ideal./Wcr6).^2).* ((kc-1)./(kc+1))).^(1/kc2).* P06_idrel;
P06 = P6.*((1 + kc0 * M6.^2).^kc2);
for i = 1:length(M7);
P7 = P06 / (((1 + kc0 * M7^2)^kc2) * (1 + Ktp1) - Ktp1)
Patm = 101325;
DeltaP = Patm - P7;
while DeltaP < 0 && iter > maxIter
iter = iter + 1;
P7 = P06 / (((1 + kc0 * M7^2)^kc2) * (1 + Ktp1) - Ktp1);
Delta_P = Patm - P7;
end
if iter == maxIter
warning('Max Iterations reached')
end
end
3 Comments
Torsten
on 10 Apr 2022
I already solved this problem in an earlier post:
Was something unclear about the solution ?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!