Inverse Problem, I have unknowns to solve it
64 ビュー (過去 30 日間)
古いコメントを表示
I can make as many as equation I want with changing Kf, which it will give me A, B, C, D, F equal to the length of Kf, menas you can make it overdetermind
I want to find the values of A1,A2,A3,A4,A5, L and N
clc;
clear;
close all;
K1 = 60;
K2 = 40;
U1 = 30;
U2 = 20;
pt1 = 0;
pt2 = 0.4;
Kf = linspace(1, 3, 3);
Kf1 = 0;
Xl1 = 0.5;
Xl2 = 1-Xl1;
Uf1 = 0;
Uf2 = 0;
phi = Xl1 * pt1 + Xl2 * pt2;
[~,Kub_frame_1,~,Uub_frame_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf1,Uf1);
[~,Kub_frame_2,~,Uub_frame_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf1,Uf1);
Y1_Frame = Kub_frame_1 - (2*Uub_frame_1)/3;
Y2_Frame = Kub_frame_2 - (2*Uub_frame_2)/3;
[Cij_A_Frame] = Backus_average([Xl1,Xl2],[Uub_frame_1,Kub_frame_2],[Y1_Frame,Y2_Frame]);
Sij_A_Frame = inv(Cij_A_Frame);
Sig_D = zeros(6, 6, numel(Kf));
for i = 1:numel(Kf)
Kf2 = Kf(i);
[~,Kub_ud_1,~,Uub_ud_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf2,Uf2);
[~,Kub_ud_2,~,Uub_ud_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf2,Uf2);
Y1_Sat = Kub_ud_1 - (2*Uub_ud_1)/3;
Y2_Sat = Kub_ud_2 - (2*Uub_ud_2)/3;
[Cij_A_Ud] = Backus_average([Xl1,Xl2],[Uub_ud_1,Uub_ud_2],[Y1_Sat,Y2_Sat]);
Sij_star = inv(Cij_A_Ud);
Sig_D(:,:,i) = Sij_A_Frame - Sij_star;
end
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
kappa_f = 1./Kf;
kappa_a = trace(Sij_A_Frame);
%FinD A1,A2,A3,A4,A5, L and N
A = A1/((kappa_f - L) * phi + (kappa_a - N));
B = A2/((kappa_f - L) * phi + (kappa_a - N));
C = A3/((kappa_f - L) * phi + (kappa_a - N));
D = A4/((kappa_f - L) * phi + (kappa_a - N));
F = A5/((kappa_f - L) * phi + (kappa_a - N));
function [Klb,Kub,Ulb,Uub]=Hashin_Shtrikhman_full(K,U,Vfr,P,Kf,Uf)
Umin=min(U);
Umax=max(U);
Kmin=min(K);
Kmax=max(K);
if P==0
Klb = 1./((1-P).*sum(Vfr./K));
elseif P>0
Klb = 1./((P./Kf)+((1-P).* sum (Vfr./K)));
end
Kub = ((P * (1./(Kf+((4/3)*Umax))) + (1-P) * sum(Vfr./(K+((4/3).*Umax))))^(-1)) - (4/3)*Umax;
Zmax =(Umax/6)*((9*Kmax+8*Umax)/(Kmax+2*Umax));
if P ==0
Zmin =(Umin/6)*((9*Kmin+8*Umin)/(Kmin+2*Umin));
elseif P>0
Zmin =(Uf/6)*((9*Kf+8*Uf)/(Kf+2*Uf));
end
Uub = (( (P/Zmax) + (1-P) * sum (Vfr./(U+Zmax)))^(-1))-Zmax;
Ulb = (( (P/Zmin) + (1-P) * sum (Vfr./(U+Zmin)))^(-1))-Zmin;
end
function [c]=Backus_average(VF,G,Y)
x = sum(VF.*G.*(Y+G)./(Y+2*G));
y = sum(VF.*G.*Y./(Y+2*G));
z = sum(VF.*Y./(Y+2*G));
u = sum(VF./(Y+2*G));
v = sum(VF./G);
w = sum(VF.*G);
A = 4*x + z*z/u;
B = 2*y + z*z/u;
E = 1/u;
F = z/u;
D = 1/v;
M = w;
c = zeros(6,6);
c(1,1) = A;
c(1,2) = B;
c(1,3) = F;
c(2,1) = B;
c(2,2) = A;
c(2,3) = F;
c(3,1) = F;
c(3,2) = F;
c(3,3) = E;
c(4,4) = D;
c(5,5) = D;
c(6,6) = M;
end
0 件のコメント
採用された回答
Torsten
約3時間 前
編集済み: Torsten
約3時間 前
L and N cannot be estimated separately.
As long as phi is a single scalar value , L*phi + N must be treated as only one parameter that replaces L*phi + N. Otherwise, you do overfitting.
I didn't do that in the code below, but it should be easy for you to modify it accordingly.
clc;
clear;
close all;
K1 = 60;
K2 = 40;
U1 = 30;
U2 = 20;
pt1 = 0;
pt2 = 0.4;
Kf = linspace(1, 3, 3);
Kf1 = 0;
Xl1 = 0.5;
Xl2 = 1-Xl1;
Uf1 = 0;
Uf2 = 0;
phi = Xl1 * pt1 + Xl2 * pt2;
[~,Kub_frame_1,~,Uub_frame_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf1,Uf1);
[~,Kub_frame_2,~,Uub_frame_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf1,Uf1);
Y1_Frame = Kub_frame_1 - (2*Uub_frame_1)/3;
Y2_Frame = Kub_frame_2 - (2*Uub_frame_2)/3;
[Cij_A_Frame] = Backus_average([Xl1,Xl2],[Uub_frame_1,Kub_frame_2],[Y1_Frame,Y2_Frame]);
Sij_A_Frame = inv(Cij_A_Frame);
Sig_D = zeros(6, 6, numel(Kf));
for i = 1:numel(Kf)
Kf2 = Kf(i);
[~,Kub_ud_1,~,Uub_ud_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf2,Uf2);
[~,Kub_ud_2,~,Uub_ud_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf2,Uf2);
Y1_Sat = Kub_ud_1 - (2*Uub_ud_1)/3;
Y2_Sat = Kub_ud_2 - (2*Uub_ud_2)/3;
[Cij_A_Ud] = Backus_average([Xl1,Xl2],[Uub_ud_1,Uub_ud_2],[Y1_Sat,Y2_Sat]);
Sij_star = inv(Cij_A_Ud);
Sig_D(:,:,i) = Sij_A_Frame - Sij_star;
end
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
kappa_f = 1./Kf;
kappa_a = trace(Sij_A_Frame);
x = [A,B,C,D,F];
y = @(A1,A2,A3,A4,A5,L,N)[A1./((kappa_f - L) * phi + (kappa_a - N)),...
A2./((kappa_f - L) * phi + (kappa_a - N)),...
A3./((kappa_f - L) * phi + (kappa_a - N)),...
A4./((kappa_f - L) * phi + (kappa_a - N)),...
A5./((kappa_f - L) * phi + (kappa_a - N))];
fy = @(p)y(p(1),p(2),p(3),p(4),p(5),p(6),p(7));
F = @(p) fy(p) - x;
sol = lsqnonlin(F,[7 6 5 4 3 2 1])
%FinD A1,A2,A3,A4,A5, L and N
%A = A1/((kappa_f - L) * phi + (kappa_a - N));
%B = A2/((kappa_f - L) * phi + (kappa_a - N));
%C = A3/((kappa_f - L) * phi + (kappa_a - N));
%D = A4/((kappa_f - L) * phi + (kappa_a - N));
%F = A5/((kappa_f - L) * phi + (kappa_a - N));
function [Klb,Kub,Ulb,Uub]=Hashin_Shtrikhman_full(K,U,Vfr,P,Kf,Uf)
Umin=min(U);
Umax=max(U);
Kmin=min(K);
Kmax=max(K);
if P==0
Klb = 1./((1-P).*sum(Vfr./K));
elseif P>0
Klb = 1./((P./Kf)+((1-P).* sum (Vfr./K)));
end
Kub = ((P * (1./(Kf+((4/3)*Umax))) + (1-P) * sum(Vfr./(K+((4/3).*Umax))))^(-1)) - (4/3)*Umax;
Zmax =(Umax/6)*((9*Kmax+8*Umax)/(Kmax+2*Umax));
if P ==0
Zmin =(Umin/6)*((9*Kmin+8*Umin)/(Kmin+2*Umin));
elseif P>0
Zmin =(Uf/6)*((9*Kf+8*Uf)/(Kf+2*Uf));
end
Uub = (( (P/Zmax) + (1-P) * sum (Vfr./(U+Zmax)))^(-1))-Zmax;
Ulb = (( (P/Zmin) + (1-P) * sum (Vfr./(U+Zmin)))^(-1))-Zmin;
end
function [c]=Backus_average(VF,G,Y)
x = sum(VF.*G.*(Y+G)./(Y+2*G));
y = sum(VF.*G.*Y./(Y+2*G));
z = sum(VF.*Y./(Y+2*G));
u = sum(VF./(Y+2*G));
v = sum(VF./G);
w = sum(VF.*G);
A = 4*x + z*z/u;
B = 2*y + z*z/u;
E = 1/u;
F = z/u;
D = 1/v;
M = w;
c = zeros(6,6);
c(1,1) = A;
c(1,2) = B;
c(1,3) = F;
c(2,1) = B;
c(2,2) = A;
c(2,3) = F;
c(3,1) = F;
c(3,2) = F;
c(3,3) = E;
c(4,4) = D;
c(5,5) = D;
c(6,6) = M;
end
4 件のコメント
Torsten
約3時間 前
編集済み: Torsten
約3時間 前
Every combination of L and N that makes LN = L*phi + N solves the fitting task. You must consider L*phi + N as one constant as long as phi is a constant that is equally valid for A, B, C, D and F.
"lsqnonlin" is especially suited for least-squares problems - that's why I chose it. If you want to set constraints on the parameters, you will have to use "fmincon" instead.
その他の回答 (2 件)
Walter Roberson
約19時間 前
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
each of those is a row vector with the same number of elements as Kf has
%FinD A1,A2,A3,A4,A5, L and N
A = A1/((kappa_f - L) * phi + (kappa_a - N));
B = A2/((kappa_f - L) * phi + (kappa_a - N));
C = A3/((kappa_f - L) * phi + (kappa_a - N));
D = A4/((kappa_f - L) * phi + (kappa_a - N));
F = A5/((kappa_f - L) * phi + (kappa_a - N));
In each case, A, B, C, D, F are known, but A1, A2, A3, A4, A5, L and N are unknown. These should instead be equations expressing that the left hand side is equal to the right hand side.
Notice though that the right hand sides all involve division by the same factor. So if you were to do something like
TEMP = ((kappa_f - L) * phi + (kappa_a - N));
then you would have
A == A1/TEMP
B == A2/TEMP
C == A3/TEMP
D == A4/TEMP
F == A5/TEMP
At this point we need to pause and ask whether the / operator is really the one intended, or if instead the ./ operator is intended, which in turn revolves around the expected size of TEMP and the expected size of A1 and so on.
We see that TEMP is constructed in part from kappa_f and kappa_f is constructed from 1./Kf and Kf is a row vector -- so kappa_f is a row vector and so TEMP must be a row vector. The A B etc. are all row vectors, so we have row_vector == UNKNOWN / row_vector . Experimentally, scalar / row_vector fails, and row_vector / row_vector yields a scalar rather than a row vector, so we deduce that the stated / operations must have been intended to be ./ operations. Unfortunately, we still cannot deduce whether the operation is row_vector == scalar ./ row_vector or if it is row_vector == row_vector ./ row_vector. However, if we rearrange to row_vector .* TEMP where TEMP is a row vector, then we can see that the result must be a row vector. This leads to
A1 = A .* TEMP;
A2 = B .* TEMP;
A3 = C .* TEMP;
A4 = D .* TEMP;
A5 = F .* TEMP;
Now we have a problem: TEMP is defined in terms of the underfined variables L and N, There are 5(*3) equations in 5(*3) unknowns excluding L and N... so there just are not equations to be able to deduce L or N. There is also not enough information to be able to deduce the expected size of L and N.
So... the system is not solvable.
7 件のコメント
Walter Roberson
約1時間 前
Sig_D_P = S_A / ((kappa_f - L) * phi + (kappa_a - N));
S_A is 6 x 6
kappa_f is 1 x 3.
L is unknown size.
phi is scalar.
kappa_a is scalar.
N is unknown size.
In order for kappa_f - L to be valid, L must be scalar, or L must be 1 x 3, or L must be something by 1 or something by 3. The results of the subtraction would be 1 x 3, 1 x 3, or something by 3, or something by 3
With phi being a scalar, * phi gives the same size as the left of the * operator, so (kappa_f - L) * phi must be 1 x 3, 1 x 3, or something x 3, or something by 3
With kappa_a being a scalar, and N being an unknown size, the result of the subtraction is always valid. So (kappa_a - N) is possibly scalar, but could just as easily be 17 x 49 x 14 as far as operand consistency is concerned.
For (kappa_f - L) * phi to be consistent with (kappa_a - N), then the (kappa_a - N) part could be scalar, or could be 1 x 3, or something by 1, or something by 3, with N being scalar, or 1 x 3, or something by 1 or something by 3 respectively.
The overall expression ((kappa_f - L) * phi + (kappa_a - N)) must work out to 1 x 3 or something by 3.
There is no circumstances under which the / operator can be used between a 6 x 6 and a 1 x 3 or something by 3.
There is no circumstances under which the ./ operator can be used between a 6 x 6 and a 1 x 3 or something by 3.
Therefore S_A / ((kappa_f - L) * phi + (kappa_a - N)) and S_A ./ ((kappa_f - L) * phi + (kappa_a - N)) are both impossible operations.
Torsten
約15時間 前
編集済み: Torsten
約15時間 前
Maybe you want to give weights to the fitting of the A(i),B(i),C(i),D(i) and F(i) according to the number of times they appear in the matrix Sig_D(:,:,i). But in principle, I arrive at the same code as before.
Or do you want to use a specific matrix norm to compare the numel(Kf) data matrices Sig_D(:,:,i) with the simulated matrices Sig_D_P(:,:,i) ?
K1 = 60;
K2 = 40;
U1 = 30;
U2 = 20;
pt1 = 0;
pt2 = 0.4;
Kf = linspace(1, 7, 7);
Kf1 = 0;
Xl1 = 0.5;
Xl2 = 1-Xl1;
Uf1 = 0;
Uf2 = 0;
phi = Xl1 * pt1 + Xl2 * pt2;
[~,Kub_frame_1,~,Uub_frame_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf1,Uf1);
[~,Kub_frame_2,~,Uub_frame_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf1,Uf1);
Y1_Frame = Kub_frame_1 - (2*Uub_frame_1)/3;
Y2_Frame = Kub_frame_2 - (2*Uub_frame_2)/3;
[Cij_A_Frame] = Backus_average([Xl1,Xl2],[Uub_frame_1,Kub_frame_2],[Y1_Frame,Y2_Frame]);
Sij_A_Frame = inv(Cij_A_Frame);
Sig_D = zeros(6, 6, numel(Kf));
for i = 1:numel(Kf)
Kf2 = Kf(i);
[~,Kub_ud_1,~,Uub_ud_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf2,Uf2);
[~,Kub_ud_2,~,Uub_ud_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf2,Uf2);
Y1_Sat = Kub_ud_1 - (2*Uub_ud_1)/3;
Y2_Sat = Kub_ud_2 - (2*Uub_ud_2)/3;
[Cij_A_Ud] = Backus_average([Xl1,Xl2],[Uub_ud_1,Uub_ud_2],[Y1_Sat,Y2_Sat]);
Sij_star = inv(Cij_A_Ud);
Sig_D(:,:,i) = Sij_A_Frame - Sij_star;
end
% solve this function for unknowns A, B, F, C, D, N, L
%Sig_D_P = Sig_D;
%Sig_D_P = sovle_this(kappa_f,kappa_a,phi,A,B,F,C,D,N,L);
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,2,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(4,4,:)).';
F = squeeze(Sig_D(3,1,:)).';
kappa_f = 1./Kf;
kappa_a = trace(Sij_A_Frame);
ydata = [A,B,C,D,F];
ysim = @(A1,B1,C1,D1,F1,LN) [A1./(kappa_f * phi + kappa_a - LN),...
B1./(kappa_f * phi + kappa_a - LN),...
C1./(kappa_f * phi + kappa_a - LN),...
D1./(kappa_f * phi + kappa_a - LN),...
F1./(kappa_f * phi + kappa_a - LN)];
ysim = @(p)ysim(p(1),p(2),p(3),p(4),p(5),p(6));
F = @(p) ysim(p) - ydata;
sol = lsqnonlin(F,[2 3 4 5 6 7])
function Sig_D_P = sovle_this(kappa_f,kappa_a,phi,A,B,F,C,D,N,L)
S_A = zeros(6,6);
S_A(1,1) = A;
S_A(2,2) = A;
S_A(1,2) = B;
S_A(2,1) = B;
S_A(1,3) = F;
S_A(2,3) = F;
S_A(3,1) = F;
S_A(3,2) = F;
S_A(3,3) = C;
S_A(4,4) = D;
S_A(5,5) = D;
S_A(6,6) = (1/2) * (A-B);
Sig_D_P = S_A / ((kappa_f - L) * phi + (kappa_a - N));
end
function [Klb,Kub,Ulb,Uub]=Hashin_Shtrikhman_full(K,U,Vfr,P,Kf,Uf)
Umin=min(U);
Umax=max(U);
Kmin=min(K);
Kmax=max(K);
if P==0
Klb = 1./((1-P).*sum(Vfr./K));
elseif P>0
Klb = 1./((P./Kf)+((1-P).* sum (Vfr./K)));
end
Kub = ((P * (1./(Kf+((4/3)*Umax))) + (1-P) * sum(Vfr./(K+((4/3).*Umax))))^(-1)) - (4/3)*Umax;
Zmax =(Umax/6)*((9*Kmax+8*Umax)/(Kmax+2*Umax));
if P ==0
Zmin =(Umin/6)*((9*Kmin+8*Umin)/(Kmin+2*Umin));
elseif P>0
Zmin =(Uf/6)*((9*Kf+8*Uf)/(Kf+2*Uf));
end
Uub = (( (P/Zmax) + (1-P) * sum (Vfr./(U+Zmax)))^(-1))-Zmax;
Ulb = (( (P/Zmin) + (1-P) * sum (Vfr./(U+Zmin)))^(-1))-Zmin;
end
function [c]=Backus_average(VF,G,Y)
x = sum(VF.*G.*(Y+G)./(Y+2*G));
y = sum(VF.*G.*Y./(Y+2*G));
z = sum(VF.*Y./(Y+2*G));
u = sum(VF./(Y+2*G));
v = sum(VF./G);
w = sum(VF.*G);
A = 4*x + z*z/u;
B = 2*y + z*z/u;
E = 1/u;
F = z/u;
D = 1/v;
M = w;
c = zeros(6,6);
c(1,1) = A;
c(1,2) = B;
c(1,3) = F;
c(2,1) = B;
c(2,2) = A;
c(2,3) = F;
c(3,1) = F;
c(3,2) = F;
c(3,3) = E;
c(4,4) = D;
c(5,5) = D;
c(6,6) = M;
end
参考
カテゴリ
Help Center および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!