%globales Koordinatensystem X Y Z und Umrechnung aus dem polaren KS
R=275;                                  %Radius Düsenanordnung
ci=0.075;
d0=10.4;
rd=d0/2;                                %Düsenradius
theta1=0;                               %Düsenposition (Winkel) im polaren KS auf R
theta2=theta1+2*pi/8;
theta3=theta2+2*pi/8;
theta4=theta3+2*pi/8;
theta5=theta4+2*pi/8;
theta6=theta5+2*pi/8;
theta7=theta6+2*pi/8;
theta8=theta7+2*pi/8;
n1=7;                                   %Anzahl Elementardüsen der Sekundärgasdüsen
A0=pi*d0^2/4;                           %Austrittsfläche
dE=(d0^2/n1)^0.5;                       %Elementardüsendurchmesser
re=dE/2;                                %Elementardüsenradius
RE=dE/2*(pi)^0.5                        %Radius für Elementardüsenmittelpunkte
delta1=0;                               %Elementardüsenposition (Winkel) im polaren KS auf RE
delta2=delta1+2*pi/6;
delta3=delta2+2*pi/6;
delta4=delta3+2*pi/6;
delta5=delta4+2*pi/6;
delta6=delta5+2*pi/6;
n2=10;                                  %Anzahl der Elementardüsen des Luftringspaltes
di=200;                                 %Innendurchmesser
da=416;                                 %Außendurchmesser
ri=di/2;                                    
ra=da/2;
nmin=5/(1-di/da)                        %Minimalanzahl Elementardüsen
nmax=10/(1-di/da)                       %Maximalanzahl Elementardüsen
dm=((da^2+di^2)/2)^0.5;                 %Durchmesser zur Flächenmitte
Rm=dm/2;
dRe=(1/n2*(da^2-di^2)/da^2)^0.5*da;     %Durchmesser Elementardüsen im Ringspalt
rRe=dRe/2;
deltaR1=0;                              %Elementardüsenposition (Winkel) im polaren KS auf Rm
deltaR2=deltaR1+2*pi/n2;
deltaR3=deltaR2+2*pi/n2;
deltaR4=deltaR3+2*pi/n2;
deltaR5=deltaR4+2*pi/n2;
deltaR6=deltaR5+2*pi/n2;
deltaR7=deltaR6+2*pi/n2;
deltaR8=deltaR7+2*pi/n2;
deltaR9=deltaR8+2*pi/n2;
deltaR10=deltaR9+2*pi/n2;

phi=1:.01:360;                          %Winkel zur Visualisierung der Austrittsgeometrie
phi=phi./180.*pi;                       %deg-->rad
z=0;                                    %Abstand zur Austrittsebene
%---------------------------------------
%Sekundärgasdüsen positionieren
%---------------------------------------
[X,Y]=pol2cart(phi,R);
[x1,y1]=pol2cart(theta1,R);
% [x11 y11]=pol2cart(phi,rd);
% X1=x11+x1;
% Y1=y11+y1;

[x2,y2]=pol2cart(theta2,R);
% [x22 y22]=pol2cart(phi,rd);
% X2=x22+x2;
% Y2=y22+y2;

[x3,y3]=pol2cart(theta3,R);
% [x33 y33]=pol2cart(phi,rd);
% X3=x33+x3;
% Y3=y33+y3;

[x4,y4]=pol2cart(theta4,R);
% [x44 y44]=pol2cart(phi,rd);
% X4=x44+x4;
% Y4=y44+y4;

[x5,y5]=pol2cart(theta5,R);
% [x55 y55]=pol2cart(phi,rd);
% X5=x55+x5;
% Y5=y55+y5;

[x6,y6]=pol2cart(theta6,R);
% [x66 y66]=pol2cart(phi,rd);
% X6=x66+x6;
% Y6=y66+y6;

[x7,y7]=pol2cart(theta7,R);
% [x77 y77]=pol2cart(phi,rd);
% X7=x77+x7;
% Y7=y77+y7;

[x8,y8]=pol2cart(theta8,R);
% [x88 y88]=pol2cart(phi,rd);
% X8=x88+x8;
% Y8=y88+y8;
%---------------------------------------
%Elementardüsen in Sekundärgasdüsen positionieren
%---------------------------------------
%Düse 1
[xe0 ye0]=pol2cart(phi,re);
X10e=x1;
Y10e=y1;

[xe11 ye11]=pol2cart(delta1,RE);
X11e=xe11+x1;
Y11e=ye11+y1;

[xe21 ye21]=pol2cart(delta2,RE);
X12e=xe21+x1;
Y12e=ye21+y1;

[xe31 ye31]=pol2cart(delta3,RE);
X13e=xe31+x1;
Y13e=ye31+y1;

[xe41 ye41]=pol2cart(delta4,RE);
X14e=xe41+x1;
Y14e=ye41+y1;

[xe51 ye51]=pol2cart(delta5,RE);
X15e=xe51+x1;
Y15e=ye51+y1;

[xe61 ye61]=pol2cart(delta6,RE);
X16e=xe61+x1;
Y16e=ye61+y1;
%Düse 2
[xe0 ye0]=pol2cart(phi,re);
X20e=x2;
Y20e=y2;

[xe11 ye11]=pol2cart(delta1,RE);
X21e=xe11+x2;
Y21e=ye11+y2;

[xe21 ye21]=pol2cart(delta2,RE);
X22e=xe21+x2;
Y22e=ye21+y2;

[xe31 ye31]=pol2cart(delta3,RE);
X23e=xe31+x2;
Y23e=ye31+y2;

[xe41 ye41]=pol2cart(delta4,RE);
X24e=xe41+x2;
Y24e=ye41+y2;

[xe51 ye51]=pol2cart(delta5,RE);
X25e=xe51+x2;
Y25e=ye51+y2;

[xe61 ye61]=pol2cart(delta6,RE);
X26e=xe61+x2;
Y26e=ye61+y2;
%Düse 3
[xe0 ye0]=pol2cart(phi,re);
X30e=x3;
Y30e=y3;

[xe11 ye11]=pol2cart(delta1,RE);
X31e=xe11+x3;
Y31e=ye11+y3;

[xe21 ye21]=pol2cart(delta2,RE);
X32e=xe21+x3;
Y32e=ye21+y3;

[xe31 ye31]=pol2cart(delta3,RE);
X33e=xe31+x3;
Y33e=ye31+y3;

[xe41 ye41]=pol2cart(delta4,RE);
X34e=xe41+x3;
Y34e=ye41+y3;

[xe51 ye51]=pol2cart(delta5,RE);
X35e=xe51+x3;
Y35e=ye51+y3;

[xe61 ye61]=pol2cart(delta6,RE);
X36e=xe61+x3;
Y36e=ye61+y3;
%Düse 4
[xe0 ye0]=pol2cart(phi,re);
X40e=x4;
Y40e=y4;

[xe11 ye11]=pol2cart(delta1,RE);
X41e=xe11+x4;
Y41e=ye11+y4;

[xe21 ye21]=pol2cart(delta2,RE);
X42e=xe21+x4;
Y42e=ye21+y4;

[xe31 ye31]=pol2cart(delta3,RE);
X43e=xe31+x4;
Y43e=ye31+y4;

[xe41 ye41]=pol2cart(delta4,RE);
X44e=xe41+x4;
Y44e=ye41+y4;

[xe51 ye51]=pol2cart(delta5,RE);
X45e=xe51+x4;
Y45e=ye51+y4;

[xe61 ye61]=pol2cart(delta6,RE);
X46e=xe61+x4;
Y46e=ye61+y4;
%Düse 5
[xe0 ye0]=pol2cart(phi,re);
X50e=x5;
Y50e=y5;

[xe11 ye11]=pol2cart(delta1,RE);
X51e=xe11+x5;
Y51e=ye11+y5;

[xe21 ye21]=pol2cart(delta2,RE);
X52e=xe21+x5;
Y52e=ye21+y5;

[xe31 ye31]=pol2cart(delta3,RE);
X53e=xe31+x5;
Y53e=ye31+y5;

[xe41 ye41]=pol2cart(delta4,RE);
X54e=xe41+x5;
Y54e=ye41+y5;

[xe51 ye51]=pol2cart(delta5,RE);
X55e=xe51+x5;
Y55e=ye51+y5;

[xe61 ye61]=pol2cart(delta6,RE);
X56e=xe61+x5;
Y56e=ye61+y5;
%Düse 6
[xe0 ye0]=pol2cart(phi,re);
X60e=x6;
Y60e=y6;

[xe11 ye11]=pol2cart(delta1,RE);
X61e=xe11+x6;
Y61e=ye11+y6;

[xe21 ye21]=pol2cart(delta2,RE);
X62e=xe21+x6;
Y62e=ye21+y6;

[xe31 ye31]=pol2cart(delta3,RE);
X63e=xe31+x6;
Y63e=ye31+y6;

[xe41 ye41]=pol2cart(delta4,RE);
X64e=xe41+x6;
Y64e=ye41+y6;

[xe51 ye51]=pol2cart(delta5,RE);
X65e=xe51+x6;
Y65e=ye51+y6;

[xe61 ye61]=pol2cart(delta6,RE);
X66e=xe61+x6;
Y66e=ye61+y6;
%Düse 7
[xe0 ye0]=pol2cart(phi,re);
X70e=x7;
Y70e=y7;

[xe11 ye11]=pol2cart(delta1,RE);
X71e=xe11+x7;
Y71e=ye11+y7;

[xe21 ye21]=pol2cart(delta2,RE);
X72e=xe21+x7;
Y72e=ye21+y7;

[xe31 ye31]=pol2cart(delta3,RE);
X73e=xe31+x7;
Y73e=ye31+y7;

[xe41 ye41]=pol2cart(delta4,RE);
X74e=xe41+x7;
Y74e=ye41+y7;

[xe51 ye51]=pol2cart(delta5,RE);
X75e=xe51+x7;
Y75e=ye51+y7;

[xe61 ye61]=pol2cart(delta6,RE);
X76e=xe61+x7;
Y76e=ye61+y7;
%Düse 8
[xe0 ye0]=pol2cart(phi,re);
X80e=x8;
Y80e=y8;

[xe11 ye11]=pol2cart(delta1,RE);
X81e=xe11+x8;
Y81e=ye11+y8;

[xe21 ye21]=pol2cart(delta2,RE);
X82e=xe21+x8;
Y82e=ye21+y8;

[xe31 ye31]=pol2cart(delta3,RE);
X83e=xe31+x8;
Y83e=ye31+y8;

[xe41 ye41]=pol2cart(delta4,RE);
X84e=xe41+x8;
Y84e=ye41+y8;

[xe51 ye51]=pol2cart(delta5,RE);
X85e=xe51+x8;
Y85e=ye51+y8;

[xe61 ye61]=pol2cart(delta6,RE);
X86e=xe61+x8;
Y86e=ye61+y8;

%---------------------------------------
%Luftringspalt
%---------------------------------------
[XRa YRa]=pol2cart(phi,ra);
[XRi YRi]=pol2cart(phi,ri);

[XR1 YR1]=pol2cart(deltaR1,Rm);

[XR2 YR2]=pol2cart(deltaR2,Rm);

[XR3 YR3]=pol2cart(deltaR3,Rm);

[XR4 YR4]=pol2cart(deltaR4,Rm);

[XR5 YR5]=pol2cart(deltaR5,Rm);

[XR6 YR6]=pol2cart(deltaR6,Rm);

[XR7 YR7]=pol2cart(deltaR7,Rm);

[XR8 YR8]=pol2cart(deltaR8,Rm);

[XR9 YR9]=pol2cart(deltaR9,Rm);

[XR10 YR10]=pol2cart(deltaR10,Rm);

%---------------------------------------
%Stromdichteverteilung
%---------------------------------------
x1=X;
y1=Y;
Z=300;
zk=0;
M=[X10e Y10e;X11e Y11e;X12e Y12e;X13e Y13e;X14e Y14e;X15e Y15e;X16e Y16e];
xk=M(:,1);
yk=M(:,2);
SDV=sum(1/(4+ci^2*((Z-zk)/d0)^2)*exp(-(1/ci^2*((Y-yk)^2+(X-xk)^2)/(Z-zk)^2)))
%---------------------------------------
%Plotten
%---------------------------------------
hold on
%Geometrie
plot(X,Y)
plot(XRa,YRa)
plot(XRi,YRi)
%Nullpunkt
scatter3(0,0,0,'r','filled')
%Mittelpunkte Elementardüsen, Gasdüsen
scatter3(X10e,Y10e,z,'r','filled')
scatter3(X11e,Y11e,z,'r','filled')
scatter3(X12e,Y12e,z,'r','filled')
scatter3(X13e,Y13e,z,'r','filled')
scatter3(X14e,Y14e,z,'r','filled')
scatter3(X15e,Y15e,z,'r','filled')
scatter3(X16e,Y16e,z,'r','filled')
scatter3(X20e,Y20e,z,'r','filled')
scatter3(X21e,Y21e,z,'r','filled')
scatter3(X22e,Y22e,z,'r','filled')
scatter3(X23e,Y23e,z,'r','filled')
scatter3(X24e,Y24e,z,'r','filled')
scatter3(X25e,Y25e,z,'r','filled')
scatter3(X26e,Y26e,z,'r','filled')
scatter3(X30e,Y30e,z,'r','filled')
scatter3(X31e,Y31e,z,'r','filled')
scatter3(X32e,Y32e,z,'r','filled')
scatter3(X33e,Y33e,z,'r','filled')
scatter3(X34e,Y34e,z,'r','filled')
scatter3(X35e,Y35e,z,'r','filled')
scatter3(X36e,Y36e,z,'r','filled')
scatter3(X40e,Y40e,z,'r','filled')
scatter3(X41e,Y41e,z,'r','filled')
scatter3(X42e,Y42e,z,'r','filled')
scatter3(X43e,Y43e,z,'r','filled')
scatter3(X44e,Y44e,z,'r','filled')
scatter3(X45e,Y45e,z,'r','filled')
scatter3(X46e,Y46e,z,'r','filled')
scatter3(X50e,Y50e,z,'r','filled')
scatter3(X51e,Y51e,z,'r','filled')
scatter3(X52e,Y52e,z,'r','filled')
scatter3(X53e,Y53e,z,'r','filled')
scatter3(X54e,Y54e,z,'r','filled')
scatter3(X55e,Y55e,z,'r','filled')
scatter3(X56e,Y56e,z,'r','filled')
scatter3(X60e,Y60e,z,'r','filled')
scatter3(X61e,Y61e,z,'r','filled')
scatter3(X62e,Y62e,z,'r','filled')
scatter3(X63e,Y63e,z,'r','filled')
scatter3(X64e,Y64e,z,'r','filled')
scatter3(X65e,Y65e,z,'r','filled')
scatter3(X66e,Y66e,z,'r','filled')
scatter3(X70e,Y70e,z,'r','filled')
scatter3(X71e,Y71e,z,'r','filled')
scatter3(X72e,Y72e,z,'r','filled')
scatter3(X73e,Y73e,z,'r','filled')
scatter3(X74e,Y74e,z,'r','filled')
scatter3(X75e,Y75e,z,'r','filled')
scatter3(X76e,Y76e,z,'r','filled')
scatter3(X80e,Y80e,z,'r','filled')
scatter3(X81e,Y81e,z,'r','filled')
scatter3(X82e,Y82e,z,'r','filled')
scatter3(X83e,Y83e,z,'r','filled')
scatter3(X84e,Y84e,z,'r','filled')
scatter3(X85e,Y85e,z,'r','filled')
scatter3(X86e,Y86e,z,'r','filled')
%Mittelpunkte Elementardüsen, Luftringspalt
scatter3(XR1,YR1,z,'r','filled')
scatter3(XR2,YR2,z,'r','filled')
scatter3(XR3,YR3,z,'r','filled')
scatter3(XR4,YR4,z,'r','filled')
scatter3(XR5,YR5,z,'r','filled')
scatter3(XR6,YR6,z,'r','filled')
scatter3(XR7,YR7,z,'r','filled')
scatter3(XR8,YR8,z,'r','filled')
scatter3(XR9,YR9,z,'r','filled')
scatter3(XR10,YR10,z,'r','filled')

grid on
hold off