How to solve a five equations systems to get the five unknown

35 visualizzazioni (ultimi 30 giorni)
Romain
Romain il 5 Dic 2024 alle 13:00
Modificato: Torsten il 5 Dic 2024 alle 16:06
I have my code that i wrote to solve a system of 5 equations in which there is five unknown. I'm trying to get an expression for five of those variables. The functions in the equation are quite complex and i don't think its doable by hand. However when i try to run my code the output is not what i expect to get
Here is my code :
clc; clear all; close all;
syms alpha_inf phi sigma lambda V;
syms T_1_exp T_2_exp T_3_exp T_4_exp T_5_exp;
syms theta_1 theta_2 theta_3 theta_4 theta_5;
syms E_0(theta);
syms coeff_transmission(theta);
syms gamma;
omega = 2*pi*1e5;
syms l;
c_0 = 340;
syms nu;
rho_0 = 1.2;
P_r = 0.07;
delta = sqrt(nu/(omega*rho_0));
A = alpha_inf*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))) ;
B_1 = alpha_inf*((gamma - 1)/(3*lambda*P_r) +4*(gamma - 1)/(3*sigma^2*sqrt(P_r)) + 3/sigma) ;
B_2 = 4*alpha_inf^2*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))) ;
C_1 = alpha_inf*((15/(4*V))*((gamma-1)/(27*P_r) +1) + (6*(gamma-1)/(3*sigma*lambda))*(1/(3*P_r) + 1/sqrt(P_r)));
C_2 = alpha_inf^2*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r)))*((gamma - 1)/(3*lambda*P_r) ...
+4*(gamma - 1)/(3*sigma^2*sqrt(P_r)) + 3/sigma);
C_3 = alpha_inf^3*((1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))))^3;
C_4 = C_2;
E_0(theta) = phi*sqrt(alpha_inf - sin(theta)^2)/(cos(theta)*alpha_inf);
coeff_transmission(theta) = abs(4*E_0(theta)/(1 + E_0(theta))^2)*exp(-(omega*l/(2*c_0))*sqrt(2)*delta*(A/sqrt(alpha_inf - sin(theta)^2)) ...
- nu*l/(2*c_0*rho_0)*(B_1/sqrt(alpha_inf - sin(theta)^2) ...
- B_2/(8*sqrt(alpha_inf - sin(theta)^2)^3)) ...
- (omega*l*sqrt(2)/(2*c_0))*delta^3*(C_1/(2*sqrt(alpha_inf - sin(theta)^2)) ...
- C_2/(12*sqrt(alpha_inf - sin(theta)^2)^3) ...
+ C_3/(4*sqrt(alpha_inf - sin(theta)^2)^5) ...
- C_4/(24*sqrt(alpha_inf - sin(theta)^2)^5)));
eqns = [T_1_exp == coeff_transmission(theta_1), T_2_exp == coeff_transmission(theta_2), T_3_exp == coeff_transmission(theta_3), T_4_exp == coeff_transmission(theta_4), T_5_exp == coeff_transmission(theta_5)];
assume(alpha_inf>0 & phi>=0 & phi<=1 )
s = solve(eqns, [alpha_inf, phi, lambda, sigma, V],'IgnoreAnalyticConstraints', true, 'ReturnConditions',true);
disp(s)
And here is the output :
alpha_inf: z3
phi: z4
lambda: z5
sigma: z6
V: z7
parameters: [z3 z4 z5 z6 z7]
conditions: T_1_exp - (4*exp(- (l*nu*((z3*(3/z6 + (100*(gamma - 1))/(21*z5) + (10*7^(1/2)*…
Does anyone know why it doesn't give me an expression for my unknown and if it is even possible to do
  3 Commenti
Romain
Romain il 5 Dic 2024 alle 13:26
Well basically i have an equation for a coefficient T which depends on theta the angle of incidence of a wave on a porous material. So in order to find my parameters i just vary the angle to get get different values of T which i can evaluate experimentally on a graph which here are the T_1_exp. My goal is to be able to evaluate alpah phi lambda sigma and V independently with this equation
Star Strider
Star Strider il 5 Dic 2024 alle 13:38
syms alpha_inf phi sigma lambda V;
syms T_1_exp T_2_exp T_3_exp T_4_exp T_5_exp;
syms theta_1 theta_2 theta_3 theta_4 theta_5;
syms E_0(theta);
syms coeff_transmission(theta);
syms gamma;
omega = 2*pi*1e5;
syms l;
c_0 = 340;
syms nu;
rho_0 = 1.2;
P_r = 0.07;
delta = sqrt(nu/(omega*rho_0));
A = alpha_inf*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))) ;
B_1 = alpha_inf*((gamma - 1)/(3*lambda*P_r) +4*(gamma - 1)/(3*sigma^2*sqrt(P_r)) + 3/sigma) ;
B_2 = 4*alpha_inf^2*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))) ;
C_1 = alpha_inf*((15/(4*V))*((gamma-1)/(27*P_r) +1) + (6*(gamma-1)/(3*sigma*lambda))*(1/(3*P_r) + 1/sqrt(P_r)));
C_2 = alpha_inf^2*(1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r)))*((gamma - 1)/(3*lambda*P_r) ...
+4*(gamma - 1)/(3*sigma^2*sqrt(P_r)) + 3/sigma);
C_3 = alpha_inf^3*((1/lambda)*(1 + (gamma - 1)/(3*sqrt(P_r))))^3;
C_4 = C_2;
E_0(theta) = phi*sqrt(alpha_inf - sin(theta)^2)/(cos(theta)*alpha_inf);
coeff_transmission(theta) = abs(4*E_0(theta)/(1 + E_0(theta))^2)*exp(-(omega*l/(2*c_0))*sqrt(2)*delta*(A/sqrt(alpha_inf - sin(theta)^2)) ...
- nu*l/(2*c_0*rho_0)*(B_1/sqrt(alpha_inf - sin(theta)^2) ...
- B_2/(8*sqrt(alpha_inf - sin(theta)^2)^3)) ...
- (omega*l*sqrt(2)/(2*c_0))*delta^3*(C_1/(2*sqrt(alpha_inf - sin(theta)^2)) ...
- C_2/(12*sqrt(alpha_inf - sin(theta)^2)^3) ...
+ C_3/(4*sqrt(alpha_inf - sin(theta)^2)^5) ...
- C_4/(24*sqrt(alpha_inf - sin(theta)^2)^5)));
eqns = [T_1_exp == coeff_transmission(theta_1), T_2_exp == coeff_transmission(theta_2), T_3_exp == coeff_transmission(theta_3), T_4_exp == coeff_transmission(theta_4), T_5_exp == coeff_transmission(theta_5)];
assume(alpha_inf>0 & phi>=0 & phi<=1 )
s = solve(eqns, [alpha_inf, phi, lambda, sigma, V],'IgnoreAnalyticConstraints', true, 'ReturnConditions',true);
% disp(s)
disp("Conditions: ")
Conditions:
pretty(vpa(simplify(s.conditions, 500), 5))
z3 cos(theta_2) + z4 sqrt(#16) ~= 0.0 and z3 cos(theta_3) + z4 sqrt(#17) ~= 0.0 and z3 cos(theta_4) + z4 sqrt(#18) ~= 0.0 and z3 cos(theta_5) + z4 sqrt(#19) ~= 0.0 2 and z3 (sin(0.5 theta_1) 2.0 - 1.0) ~= z4 sqrt(#15) and not 0.31831 theta_1 - 0.5 in integer and not 0.31831 theta_2 - 0.5 in integer and not 0.31831 theta_3 - 0.5 in integer and not 0.31831 theta_4 - 0.5 in integer and not 0.31831 theta_5 - 0.5 in integer and 0.0 < z3 2 / / z3 #13 #7 \ / #1 #6 #3 #4 \ #5 \ and z4 in [0.0, 1.0] and sqrt(|sin(theta_1) - 1.0 z3|) exp| - l nu | --------- - -- | 0.0012255 - l #2 | --------- + ---------- - -- - --------- | 1306.7 - ------------ | | \ sqrt(#15) #8 / | sqrt(#15) 3 5/2 #8 5/2 | z5 sqrt(#15) | \ \ z5 #15 z5 #15 / / | z4 sqrt(#15) | 2 2 / / z3 #13 #7 \ |z4| 4.0 == T_1_exp | --------------- + 1.0 | |cos(theta_1)| |z3| and sqrt(|sin(theta_2) - 1.0 z3|) exp| - l nu | --------- - -- | | z3 cos(theta_1) | | \ sqrt(#16) #9 / \ / #1 #6 #3 #4 \ #5 \ 0.0012255 - l #2 | --------- + ---------- - -- - --------- | 1306.7 - ------------ | |z4| 4.0 | sqrt(#16) 3 5/2 #9 5/2 | z5 sqrt(#16) | \ z5 #16 z5 #16 / / | z4 sqrt(#16) | 2 2 / / z3 #13 #7 \ == T_2_exp | --------------- + 1.0 | |cos(theta_2)| |z3| and sqrt(|sin(theta_3) - 1.0 z3|) exp| - l nu | --------- - --- | | z3 cos(theta_2) | | \ sqrt(#17) #10 / \ / #1 #6 #3 #4 \ #5 \ 0.0012255 - l #2 | --------- + ---------- - --- - --------- | 1306.7 - ------------ | |z4| 4.0 | sqrt(#17) 3 5/2 #10 5/2 | z5 sqrt(#17) | \ z5 #17 z5 #17 / / | z4 sqrt(#17) | 2 2 / / z3 #13 #7 \ == T_3_exp | --------------- + 1.0 | |cos(theta_3)| |z3| and sqrt(|sin(theta_4) - 1.0 z3|) exp| - l nu | --------- - --- | | z3 cos(theta_3) | | \ sqrt(#18) #11 / \ / #1 #6 #3 #4 \ #5 \ 0.0012255 - l #2 | --------- + ---------- - --- - --------- | 1306.7 - ------------ | |z4| 4.0 | sqrt(#18) 3 5/2 #11 5/2 | z5 sqrt(#18) | \ z5 #18 z5 #18 / / | z4 sqrt(#18) | 2 2 / / z3 #13 #7 \ == T_4_exp | --------------- + 1.0 | |cos(theta_4)| |z3| and sqrt(|sin(theta_5) - 1.0 z3|) exp| - l nu | --------- - --- | | z3 cos(theta_4) | | \ sqrt(#19) #12 / \ / #1 #6 #3 #4 \ #5 \ | z4 sqrt(#19) | 2 0.0012255 - l #2 | --------- + ---------- - --- - --------- | 1306.7 - ------------ | |z4| 4.0 == T_5_exp | --------------- + 1.0 | |cos(theta_5)| |z3| | sqrt(#19) 3 5/2 #12 5/2 | z5 sqrt(#19) | | z3 cos(theta_5) | \ z5 #19 z5 #19 / / where / (0.5291 gamma + 0.4709) 3.75 (6.0 gamma - 6.0) 2.8472 \ #1 == z3 | ---------------------------- + ------------------------ | 0.5 \ z7 z5 z6 / 3/2 #2 == (1.3263e-6 nu) 2 #3 == z3 #14 #13 0.083333 2 #4 == z3 #14 #13 0.041667 #5 == l z3 sqrt(1.3263e-6 nu) #14 1306.7 3 3 #6 == z3 #14 0.25 2 #7 == z3 #14 0.5 3/2 #8 == z5 #15 3/2 #9 == z5 #16 3/2 #10 == z5 #17 3/2 #11 == z5 #18 3/2 #12 == z5 #19 4.7619 (gamma - 1.0) 3.0 (4.0 gamma - 4.0) 1.2599 #13 == -------------------- + --- + ------------------------ z5 z6 2 z6 #14 == 1.2599 gamma - 0.25988 2 #15 == z3 - 1.0 sin(theta_1) 2 #16 == z3 - 1.0 sin(theta_2) 2 #17 == z3 - 1.0 sin(theta_3) 2 #18 == z3 - 1.0 sin(theta_4) 2 #19 == z3 - 1.0 sin(theta_5)
.

Accedi per commentare.

Risposte (1)

Torsten
Torsten il 5 Dic 2024 alle 16:05
Modificato: Torsten il 5 Dic 2024 alle 16:06
Directly use the five experimental values (T_exp,theta) as numerical data and "lsqcurvefit" or "fmincon" to solve for the five unknowns.
But note that the measurement data must be very precise to get physically senseful values for the unknown parameters alpha_inf, phi, lambda, sigma, V. It would be better if you had more than five measurements.

Community Treasure Hunt

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

Start Hunting!

Translated by