You are on page 1of 7

%PartC.

m
%Ella Maule
%11/11/2016
%PartC.m Allows the user to manually optimise horizontal forces on pylons
%by changing pylon position and sag. It allows the user to calcaulte,
%maximum tensions, resultant forces on pylons and cable lengths for any
%number of pylons at any position on a terrain with as many gradient
%changes as required. The model can be tested at any temperature t in teh
%range -10degC to 30degC. (reasonable range for the Scottish Highlands)

% Variable Dictionary
% C Matrix of values for each cable curve
% c_mass Mass per unit length of cable (kg/m)
% Cp Matrix of top of pylons (cable-pylon nodes)
% g Acceleration due to gravity (m/(s^2))
% H Horizontal forces for each span (N)
% He Estimate for span horizontal force (taking sag at
% centre of span and using trigonometry) (N)
%i,k,m,n Loop run definitions
% L Matrix of cable lengths (m)
% p Number of pylons required for model (input)
% pylon_coords Cell of pylon coordinate matrices (m)
% qc Weight per unit length (N/m)
% r Cell of ground range coordinates for each gradient (m)
% R Matrix of resultant forces on each pylon (N)
% S Matrix of sags for each span (m)
% T Tensions at each node per span
% (node A Tensio , node B Tension) (N)
% v Number of terrain coordinates (input)
% X Span x values to caluculate curve coordinates (m)
% X_all Matrix of span x coordinates for all curves (m)
% Xa x-coordinate of left hand pylon (cloeset to origin) (m)
% Xb x-coordinate of right hand pylon (m)
% Xd1 x-coordinate of sag point (where dy/dx=0) (m)
% Xe Estimate of xd as midpoint of span (for use in He) (m)
% xg x-coordinates of ground terrain (m)
% xp x-coordinates of pylon (bottom) position
% (x distace from origin) (m)
% xynodes all possible pylon-cable nodes (m)
% Ya y-coordinate of left hand pylon (cloeset to origin) (m)
% Yb y-coordinate of right hand pylon (m)
% Yd y-coordinate of sag point (where dy/dx=0) (m)
% yg Matrix of y-coordinates of the ground (m)
% yn y-coordinates of pylon-cable nodes (m)
% ys BS for miniumum height above ground of cable (m)
% Yt y-coordinates of ground terrain (m)
% t Temperature (-5degC 30degC) to ckeck model
% C_mass_t Mass per unit length at temperature t (kg/m)
% qc_t Weight per unit length at temperature t (N/m)
% L_t_true The true length of the cable at temperature t (m)
% He_t Matrix of estimates for span horizontal force for
% range of sag point y coordinates (taking sag at
% centre of span and using trigonometry)to give an
% appropriate start vale for fzero solver at
% temperature t(N)
% H_t Matrix of horizontal force in each cable for
% range of sag point y coordinates at temperature t (N)
% Xd_t Matric of X coordinate of lowest point of sag for
% range of sag point y coordinates at temperature t (N)
%L_t Matrix of length for length of cable for
% range of sag point y coordinates at temperature t (N)
%Yd_t Matrix of possible sag point y coordinates at
% temperature t (N)
% f,m,n.w Loop run definitions
% Idx Matrix of index numbers for correct loop cyle for each
% span at temperature t
% poss Matrix of lengths for range of Yd
% true True length of cable at temperature t
% He_t_true Matrix of estimates for span horizontal force for
% closest y coordinates (taking sag at
% centre of span and using trigonometry)to give an
% appropriate start vale for fzero solver at
% temperature t(N)
% H_t_true Matrix of horizontal force in each cable for
% closest sag point y coordinates at temperature t (N)
% Xd_t_ true Matric of X coordinate of lowest point of sag for
% closest sag point y coordinates at temperature t (N)
% T_t Max tension in each cable at temperate t
% 'Tension at node A, Tension at node B' (N)
% C_t Sag curves at temperature t
% R_t Matrix of resultant horizontal force on each pylon
% at temperature t (N)

% Sources
% [1] http://www.maths.lth.se/na/courses/Documents/papini.pdf
% - eqn 2.14 (pg 10)
% - eqns 2.17 and 2.18 (pg11)
% [2] http://www.spenergynetworks.co.uk/userfiles/file/ohl-03-099_issue1_forinternet.pdf
% - coefficient of linear expansion (pg 89) = 0.000023 (/degC)
% - mass per unit length (pg89) = 0.6812
%%
clear all
clc
%% User to define scale of model (number of terrain gradient changes and
% number of pylons)
disp('the slope between terrain coordinates is assumed straight')
v=input('number of terrain coordinates desired:');
p=input('number of pylons required:');
Xt=zeros(v,1); % pre-assigns matrix dimensions to speed up processing
Yt=zeros(v,1); % pre-assigns matrix dimensions to speed up processing

%% User to input x and y coordinates of each terraine point.


% eg for student number (*4): 0 4 60 16 150 8 270 12 330 20 420 20 540 32
disp('Enter the coordinates for each terrain node in order. First being closest to
origin')
for n=1:v % loop creates matrix of terrain points
disp('terrain coordinate point:')
disp(n)
Xt(n,1)=input('Enter x coordinate of terrain point to (0.1m):');
Yt(n,1)=input('Enter y coordinate of terrain point to (0.1m):');
end

xg=0:0.1:Xt(v,1); % assigns number of x-coordinates for the ground


yg=zeros(size(xg)); % pre-assigns matrix dimensions to speed up processing

%% Creates cell of ground range definitions


r=cell(1,6);
for i=1:(v-1)
r{i} = xg>=Xt(i,1) & xg< Xt(i+1,1);
for i=v-1
r{i} = xg>=Xt(i,1) & xg<= Xt(i+1,1);
end
end

%% Calculates y coordinate of ground at each x coordinate


%using (y-y1)=m(x-x1) rearraged
for i=1:(v-1)
yg(r{i})=(((Yt(i+1,1)-Yt(i,1))./(Xt(i+1,1)-Xt(i,1))).*(xg(r{i})-Xt(i,1)))+Yt(i,1);
end

%% creates matrix of all possible cable-pylon nodes


yn=yg+10; % pylons are 10m tall therefore node is 10m above ground
ys=yg+5.2; % BS for miniumum height above ground of cable
xynodes=[xg' , yn']; % creates matrix of possible coordinates of nodes
%% User to input x coordinate of pylon foundation
xp=zeros(p,1); % pre-assigns matrix dimensions to speed up processing
for k=1:p % loop creates matrix of pylon x values
%pylon1=('x-coordinate of pylon 1 (to 0.1m):');
disp('for pylon:')
disp(k)
xp(k,:)=input('x-coordinate of pylon (to 0.1m):');
end

%% Coordinates of defined pylon


Cp=zeros(p,2); % pre-assigns matrix dimensions to speed up processing
pylon_coords=cell(1,p); % pre-assigns cell dimensions to speed up processing
for k = 1:p % loop creates matrix of pylon- cable node coordinates
Cp(k,:)=xynodes(find(xynodes(:,1)==xp(k,1)),:); %find function finds corresponding
xynode coordinates to user input
pylon_coords{k}=[Cp(k,1) Cp(k,2); Cp(k,1) Cp(k,2)-10];
end

%% Plots a graph of the ground and the pylons, allows user to check inputs are correct
hold on
for k=1:p
plot(pylon_coords{1,k}(:,1),pylon_coords{1,k}(:,2), 'blue'); axis([-10 (Xt(v,1)+50) 0
45]);
end
plot ( xg,yg,'green'); xlabel('Horizontal distance from origin (m)');...
ylabel('Vertical distnace from origin (m)'); title('Terrain And Pylon Position Of
Model');
hold off

%%
% %f1 and f2 are eqn. 2.14 from [1] rearranged %f3=f1-f2
%f1=Xd1=Xa+((H./qc).*(acosh(((qc.*(Ya-Yd))./H)+1))); % acosh function is added
% because inversing a hyperbolic cos function loses any information about
% the sign (+/-) of the value
%f2=Xd2=Xb-((H./qc).*(acosh(((qc.*(Yb-Yd))./H)+1)));
%f3= Xb-Xa+((H./qc).*(acosh(((qc.*(Ya-Yd))./H)+1)-acosh(((qc.*(Yb-Yd))./H)+1)));
%% Constants and matrix size assignment
c_mass=0.6812; %Industry Standard gives this value at 20 degreeesC [2]
g=9.81;
qc=3*c_mass*g; %3 phase tranmission in delta formation
H=zeros(i:1); % pre-assigns matrix dimensions to speed up processing
He=zeros(i:1);
Xd1=zeros(i:1);
S=zeros(i:1);
L=zeros(i:1);
T=zeros(i:2);
C=zeros(i,100);
X_all=zeros(n,100);
R=zeros(p,1);

%% User to input sag values


disp('Sag is defined as the x-distance below the left(A) pylon')
disp('Sag values entered below are for Design Standard at 20 degC')
for i=1:(v-1) % for loop creates matrix of sag values
disp('for sag')
disp(i)
S(i,:)=input('Enter sag:');
end

%% Solves f3 using the function fzero


for m=1:i
Xa=Cp(m,1); Ya=Cp(m,2); %coordinates for pylones A and B and sag point D
Xb=Cp(m+1,1); Yb=Cp(m+1,2);
Yd=Ya-S(m,:);
Xe=(((Xb-Xa)./2)+Xa); % estimate for sag x-coordinate
%% Initial Estimate for H to start iteration
%Estimate for span horizontal force (taking sag at centre of span and
%using trigonometry)to give an
%appropriate start value for fzero solver for all pylon positions, sags
%and terrains.%Ensures only correct value of H( not alternate due to the cyclic
%nature of trig functions) is found.
He(m,:)=(3.*qc.*(sqrt((Xe-Xa).^2+(Yd-Ya).^2)+sqrt((Xe-Xb).^2+(Yd-
Yb).^2)).*cos(atan(abs((Yb-Yd)./(Xb-Xe)))))./...
(sin(atan(abs((Yb-Yd)./(Xb-Xe)))+(cos(atan(abs((Yb-Yd)./(Xb-Xe))).*abs(((Ya-
Yd)./(Xe-Xa)))))));
%% calculating the horizontal tension in span
H(m,:)=fzero(@(H) ((Xa+((H./qc).*(acosh(((qc.*(Ya-Yd))./H)+1))))-(Xb-
((H./qc).*(acosh(((qc.*(Yb-Yd))./H)+1))))), He(m,:)); %%[1]%%
%% calculating the x-coordinate of the sag point
Xd1(m,:)=Xa+((H(m,:)./qc).*(acosh(((qc.*(Ya-Yd))./H(m,:))+1))); %%[1]%%
%% total cable tension %maximum tension occurs at the cable-pylon nodes
T(m,1)=H(m,:)+(qc.*(Ya-Yd)); %%[1]%%
T(m,2)=H(m,:)+(qc.*(Yb-Yd)); %%[1]%%
%% Cable Lengths (L)
L(m,:)=(H(m,:)./qc).*(sinh((qc./H(m,:)).*(Xb-Xd1(m,:)))-sinh((qc./H(m,:)).*(Xa-
Xd1(m,:)))); %%[1]%%
%% equation for curve
X=linspace(Xa, Xb,100);
C(m,:)=((H(m,:)./qc).*(cosh((qc./H(m,:)).*(X-Xd1(m,:)))))-(H(m,:)./qc)+Yd; %%[1]%%
end

%% Creates matrix of x coordinates of each span


for n=1:i
X_all(n,:)=linspace(Cp(n,1),Cp(n+1,1),100);
end

%% Plot graph of ground, all pylons, and all cables


hold on
for k=1:p %plots all pylons
plot(pylon_coords{1,k}(:,1),pylon_coords{1,k}(:,2), 'blue'); axis([-10 (Xt(v,1)+50) 0
45]);
end
for n=1:i %plots all curves
plot(X_all(n,:), C(n,:));
end
xlabel('Horizontal distance from origin (m)');...
ylabel('Vertical distnace from origin (m)'); title('Terrain, Pylon Position and Cable
Curves Of Model At Design Temperature Of 20dgC');
plot( xg,yg,'green', xg, ys, 'k --'); %plots the ground and safety height
hold off

%% Resolves forces on each pylon


% +ve - resultant in +ve x direction
% -ve - resultant in the -ve x direction
for n=2:i
R(n,:)= H(n,1)-H(n-1);
end
R(1,:)=H(1,1)-0;
R(p,:)=0-H(i,1);

%% Displays all variables solved.


disp('resultant force on each pylon (N)')
disp(R)
disp('Positive Values - Resultant force in positive x direction (right)')
disp('Negative Values - Resultant force in the negative x-direction (left)')
disp('Maximum cable tensions (at cable-pylon node) (N)')
disp('Tension at node A, Tension at node B')
disp(T)
disp('Do these tensions exceed maximum conductor tension before failure?')
disp('Cable Length (m)')
disp(L)
%% User to check cable position, horizontl force and max cable tension at
%temperatures within range -5 degC to 30 degC.
t=input('Enter value of temperature (-10 degC to 30 degC)');

C_mass_t=((c_mass)./(1+(0.000023.*(t-20))));% Redefine value for mass per unit length


taking into account expansion
qc_t=3.*g.*C_mass_t;
L_t_true=L*(1+(0.000023.*(t-20))); %redefine length of cable at new temperature.
H_t=zeros(i,200); % pre-assigns matrix dimensions to speed up processing
Xd_t=zeros(i,200);
L_t=zeros(i,200);
Yd_t=zeros(i,200);
He_t=zeros(i,200);
%% Nested loops create matrix of cable lengths at a range of possible y-coordinates
%of the new sag point (taking into account temperature change)
for w=1:i % for each cable span
Xa=Cp(w,1); Ya=Cp(w,2);
Xb=Cp(w+1,1); Yb=Cp(w+1,2);
Yd=Ya-S(w,:);
Yd_t(w,:)=linspace(Yd-0.5,Yd+0.5,200); % range of sags either side of design sag
Xe=(((Xb-Xa)./2)+Xa);
for f=1:200 % for each possible y position of sag
%% Initial Estimate for H for each possible Yd@t to start iteration
%Estimate for span horizontal force (taking sag at centre of span and
%using trigonometry)to give an
%appropriate start value for fzero solver for all pylon positions, sags
%and terrains.%Ensures only correct value of H( not alternate due to the cyclic
%nature of trig functions) is found.
He_t(w,f)=(3.*qc_t.*(sqrt((Xe-Xa).^2+(Yd_t(w,f)-Ya).^2)+sqrt((Xe-
Xb).^2+(Yd_t(w,f)-Yb).^2)).*cos(atan(abs((Yb-Yd_t(w,f))./(Xb-Xe)))))./...
(sin(atan(abs((Yb-Yd_t(w,f))./(Xb-Xe)))+(cos(atan(abs((Yb-Yd_t(w,f))./(Xb-
Xe))).*abs(((Ya-Yd_t(w,f))./(Xe-Xa)))))));
%% calculating the horizontal tension in span for each possible Yd @ new
tempeature
H_t(w,f)=fzero(@(H_t) ((Xa+((H_t./qc_t).*(acosh(((qc_t.*(Ya-
Yd_t(w,f)))./H_t)+1))))-(Xb-((H_t./qc_t).*...
(acosh(((qc_t.*(Yb-Yd_t(w,f)))./H_t)+1))))), He_t(w,f),
optimset('Display','off')); %%[1]%%rearranged

%% calculating the x-coordinate of the sag point for all possible Yd @ new
tempeature
Xd_t(w,f)=Xa+((H_t(w,f)./qc_t).*(acosh(((qc_t.*(Ya-
Yd_t(w,f)))./H_t(w,f))+1))); %%[1]%%rearranged

%% Cable Lengths for all possible Yd @ new tempeature


L_t(w,f)=(H_t(w,f)./qc_t).*(sinh((qc_t./H_t(w,f)).*(Xb-Xd_t(w,f)))-
sinh((qc_t./H_t(w,f)).*(Xa-Xd_t(w,f)))); %%[1]%%

end
end
%% Finding the matrix index number for the closest possible length (at all Yd@t)
%closest to the true length @ new tempeature.
Idx=zeros(i,1);
for m=1:i
poss=L_t(m,:);
true=L_t_true(m,:);
tmp=abs(poss-true);
[~, idx] =min(tmp);
Idx(m,:)=idx;
end
%% Solves f3 using the function fzero for the closest y coordinate of sag point @ new
temperature
He_t_true=zeros(i,1); % pre-assigns matrix dimensions to speed up processing
H_t_true=zeros(i,1);
Xd_t_true=zeros(i,1);
T_t=zeros(i,2);
C_t=zeros(i,100);
R_t=zeros(p,1);
for m=1:i
Xa=Cp(m,1); Ya=Cp(m,2); %% coordinates for pylones A and B and sag point D
Xb=Cp(m+1,1); Yb=Cp(m+1,2);
Yd_t_true=Yd_t(m,Idx(m,:));
Xe=(((Xb-Xa)./2)+Xa);
He_t_true=He_t(m,Idx(m,:));
%% calculating the horizontal tension in span
H_t_true(m,:)=fzero(@(H_t_true) ((Xa+((H_t_true./qc_t).*(acosh(((qc_t.*(Ya-
Yd_t_true))./H_t_true)+1))))-(Xb-((H_t_true./qc_t).*...
(acosh(((qc_t.*(Yb-Yd_t_true))./H_t_true)+1))))), He_t_true); %%[1]%%rearranged
%% calculating the x-coordinate of the sag point
Xd_t_true(m,:)=Xa+((H_t_true(m,:)./qc_t).*(acosh(((qc_t.*(Ya-
Yd_t_true))./H_t_true(m,:))+1))); %%[1]%%
%% total cable tension %maximum tension occurs at the cable-pylon nodes
T_t(m,1)=H_t_true(m,:)+(qc_t.*(Ya-Yd_t_true)); %%[1]%%
T_t(m,2)=H_t_true(m,:)+(qc_t.*(Yb-Yd_t_true)); %%[1]%%
%% equation for curve
X=linspace(Xa, Xb,100);
C_t(m,:)=((H_t_true(m,:)./qc_t).*(cosh((qc_t./H_t_true(m,:)).*(X-Xd_t_true(m,:)))))-
(H_t_true(m,:)./qc_t)+Yd_t_true; %%[1]%%

end

%% Plot graph of ground, all pylons, and all cables


hold on
for k=1:p %plots all pylons
plot(pylon_coords{1,k}(:,1),pylon_coords{1,k}(:,2), 'blue'); axis([-10 (Xt(v,1)+50) 0
45]);
end
for n=1:i %plots all curves
plot(X_all(n,:), C_t(n,:));
end
xlabel('Horizontal distance from origin (m)');...
ylabel('Vertical distnace from origin (m)'); title('Terrain, Pylon Position and Cable
Curves Of Model At Temperature t');
plot( xg,yg,'green', xg, ys, 'k --'); %plots the ground and safety height
hold off

%% Resolves forces on each pylon at new temperature t


% +ve - resultant in +ve x direction
% -ve - resultant in the -ve x direction

for n=2:i
R_t(n,:)= H_t_true(n,1)-H_t_true(n-1);
end
R_t(1,:)=H_t_true(1,1)-0;
R_t(p,:)=0-H_t_true(i,1);

%% Displays all variables solved.


disp('resultant force on each pylon at new temperature (N)')
disp(R_t)
disp('Positive Values - Resultant force in positive x direction (right)')
disp('Negative Values - Resultant force in the negative x-direction (left)')
disp('Maximum cable tensions (at cable-pylon node) at new temperature (N)')
disp('Tension at node A, Tension at node B')
disp(T_t)
disp('Do these tensions exceed maximum conductor tension before failure?')
disp('Cable Length at new temperature (m)')
disp(L_t_true)

You might also like