% 
R = 3; 
U0 = 8;
Rt = 1.5*R;
n = 2.5;

A = [2/R -1/R 0 0 0 0 1;-1/R 3/(2*R)+1/Rt 0 0 1 0 0;...
	0 0 1/(2*R) 0 -1 0 -1;0 0 0 1 0 -n 0; ...
	0 0 0 0 n 0 1;0 -1 1 1 0 0 0;-1 0 1 0 0 1 0]
B = [U0/R;0;0;0;0;0;0]
fi = A\B

ut= fi(2)

%% Numerikus kiserletezes
Rtv = 0.1:0.001:20;
utv = zeros(size(Rtv));
ptv = zeros(size(Rtv));

for kiscica=1:length(Rtv)
	[ut, pt] = pentekfv( U0, R, Rtv(kiscica), n);
	ptv(kiscica) = pt;
	utv(kiscica) = ut;
end

figure; 
plot( Rtv, ptv, 'r-o', 'LineWidth',3);
xlabel('Rt', 'FontSize',12); 
ylabel('pt', 'FontSize',12);

%% 
pmax = max(ptv); 
idx = find(ptv==pmax);
Rmax = Rtv(idx);

%% Szakadasi feszultseg 

	A = [2/R -1/R 0 0 0 0 1;-1/R 3/(2*R) 0 0 1 0 0;...
	0 0 1/(2*R) 0 -1 0 -1;0 0 0 1 0 -n 0; ...
	0 0 0 0 n 0 1;0 -1 1 1 0 0 0;-1 0 1 0 0 1 0];
B = [U0/R;0;0;0;0;0;0];
fi = A\B;

UT= fi(2)
	
%% Rovidzarasi aram

	A = [2/R -1/R 0 0 0 0 1;0 1 0 0 0 0 0;...
	0 0 1/(2*R) 0 -1 0 -1;0 0 0 1 0 -n 0; ...
	0 0 0 0 n 0 1;0 -1 1 1 0 0 0;-1 0 1 0 0 1 0];
B = [U0/R;0;0;0;0;0;0];
x = A\B;

IRZ = x(5)-x(1)/R

RB = UT/(-IRZ)
