积分计算

时间:2012-11-24 21:36:33

标签: matlab integral

我想执行以下操作:

enter image description here

,其中

enter image description here

后一个图中显示的参数可以如下获得:

%% Inizialization
time = 614.4; % Analysis Time
Uhub = 11;
HubHt = 90;
alpha = 0.14;
TI = 'A'; % Turbulent Intensity (A,B,C as in the IEC or Specific value)
N1 = 4096;
N2 = 32;
N3 = 32;

N = N1*N2*N3; % Total Number of Point
t = 0:(time/(N1-1)):time; % Sampled Time Vector

L1 = Uhub*time; % Box length along X
L2 = 150; % Box length along Y
L3 = 220; % Box length along Z

dx = L1/N1; % Grid Resolution along X-axis
dy = L2/N2; % Grid Resolution along Y-axis
dz = L3/N3; % Grid Resolution along Z-axis

V = L1*L2*L3; % Analysis Box Volume

gamma = 3.9; % Turbulent Eddies Distorsion Factor
c = 1.476;
b = 5.6;

if HubHt < 60
    lambda1 = 0.7*HubHt;
else
    lambda1 = 42;
end
L = 0.8*lambda1;

if isequal(TI,'A')
    Iref = 0.16;
    sigma1 = Iref*(0.75*Uhub + b);
elseif isequal(TI,'B')
    Iref = 0.14;
    sigma1 = Iref*(0.75*Uhub + b);
elseif isequal(TI,'C')
    Iref = 0.12;
    sigma1 = Iref*(0.75*Uhub + b);
else
    sigma1 = str2num(TI)*Uhub/100;
end

sigma_iso = 0.55*sigma1;
sigma2 = 0.7*sigma1;
sigma3 = 0.5*sigma1;


%% Wave number vectors
ik1 = cat(2,(-N1/2:-1/2),(1/2:N1/2));
ik2 = -N2/2:N2/2-1;
ik3 = -N3/2:N3/2-1;

[x y z] = ndgrid(ik1,ik2,ik3);

k1 = reshape((2*pi*L/L1)*x,N1*N2*N3,1);
k2 = reshape((2*pi*L/L2)*y,N1*N2*N3,1);
k3 = reshape((2*pi*L/L3)*z,N1*N2*N3,1);

k = sqrt(k1.^2 + k2.^2 + k3.^2);

%% Calculation of beta by means of the Energy Spectrum Integration
E = @(k) (1.453*k.^4)./((1 + k.^2).^(17/6));

%//Independent integration on segments 
Local_int = arrayfun(@(i)quad(E,i-1,i), 2:(N1*N2*N3));      
%//integral additivity + cumulative removal of queues
E_int = 1.5 - [0 fliplr(cumsum(fliplr(Local_int)))]; %//To remove queues

E_int = reshape(E_int,N,1);
S = k.*sqrt(E_int);
beta = (c*gamma)./S;

%% Help Parameters
k30 = k3 + beta.*k1;

k0 = sqrt(k1.^2 + k2.^2 + k30.^2);

C1 = (beta.*k1.^2.*(k1.^2 + k2.^2 - k3.*k30))./(k.^2.*(k1.^2 + k2.^2));
C2 = (k2.*k0.^2./((k1.^2 + k2.^2).^(3/2))).*atan2((beta.*k1.*sqrt(k1.^2 + k2.^2)),(k0.^2 - k30.*k1.*beta));

xhsi1 = C1 - (k2./k1).*C2;
xhsi2 = (k2./k1).*C1 + C2;

E_k0 = (1.453*k0.^4)./((1 + k0.^2).^(17/6));

例如,输入

phi_33 = @(k2,k3) (E_k0./(4*pi.*k.^4)).*((k1.^2 + k2.^2));

F_33 = arrayfun(@(i) dblquad(phi_33,k3(i),k3(i+1),k2(i),k2(i+1)), 1:((N1*N2*N3)-1));

Matlab检索以下错误信息:

Error using  + 
Matrix dimensions must agree.

Error in @(k2,k3)(E_k0./(4*pi.*k.^4)).*((k1.^2+k2.^2))

您是否知道如何克服这个问题?

我真的很期待收到你的来信。

祝你好运, FPE

2 个答案:

答案 0 :(得分:1)

错误很容易解释:

首先定义E_k0,然后尝试拨打Ek0

phi_11 = @(k1,k2,k3) (E_k0./4*pi.*kabs.^4).*(k0abs.^2 - k1.^2 - 2*k1.*k03.*xhsi1 + (k1.^2 +  k2.^2).*xhsi1.^2);

答案 1 :(得分:0)

我这样解决了:

  1. 为每个PHI元素编写一个函数,例如(对于PHI11)

    功能phi_11 = phi_11_new(k1,k2,k3,beta,i) k = sqrt(k1(i)。^ 2 + k2。^ 2 + k3。^ 2); k30 = k3 + beta(i)。* k1(i); k0 = sqrt(k1(i)。^ 2 + k2。^ 2 + k30。^ 2); E_k0 = 1.453。* k0。^ 4 ./((1 + k0。^ 2)。^(17/6)); C1 =(β(i)。 k1(i)。^ 2)。(k1(i)。^ 2 + k2。^ 2 - k3。 k30)./(k。 ^ 2. (k1(i)。^ 2 + k2。^ 2)); C2 = k2。* k0。^ 2 ./((k1(i)。^ 2 + k2。^ 2)。^(3/2))。* atan2((beta(i)。* k1(i)。 * sqrt(k1(i)。^ 2 + k2。^ 2)),(k0。^ 2 - k30。* k1(i)。* beta(i))); xhsi1 = C1 - k2./k1(i).*C2; xhsi1_q = xhsi1。^ 2; phi_11 = E_k0./(4.*pi.k0.^4).(k0.^2 - k1(i)。^ 2 - 2. * k1(i)。* k30。* xhsi1 +(k1(i)。^ 2 + k2。^ 2)。* xhsi1_q); 端

  2. 我在主代码中回忆起这个函数如下

    对于l = 1:numel(k1) phi11 = @(k2,k3)phi_11(k1,k2,k3,l) F11(l)=积分2(phi,-1000,1000,-1000,1000); 端

  3. 它似乎有效。