Pascal Language
hi there
I'm sorry if I'm posting this on the wrong place.
I'm here to ask for your help
I have to do a program that can do the calculation of the deflection caused by one or more loads on a beam (like on the image).
have it working for 1 load but I want it to calculate for more.
need to use Arrays but can't get it to work properly :S
can you guys that a look at the code and try to tell what I'm supose to do?
that's what I need to do:
1) Read data from the beam: K, B, E, MI (positive values);
Calculate alfa, beta and lambda;
Read as: L (L> 2.5*lambda)
2) Read data load: P and (a is a positive value);
3) Read number of equidistant sections: NSEQ
4) For each section (0 to NSEQ) calculate:
4.1) Distance x to the origin O;
4.2) Arrow F for the distance x ;
5) For each section (0 to NSEQ) write on the screen:
5.1) Distance x to the origin O;
5.2) Arrow F for the distance x ;
and also have calculate when the deflection is zero,
ask if the user wants to save or not the results in a file,
make a graph..
where:
P - Value of Load
L - Length of Beam
a - distance between source and point of application of load
x - section corresponding to the point of application of load
b - beam width
K - Soil Module
E - modulus
MI - Moment of inertia of section
NSEQ - Number of Sections Equidistant
NCP - Number of point charges
hi there
I'm sorry if I'm posting this on the wrong place.
I'm here to ask for your help
I have to do a program that can do the calculation of the deflection caused by one or more loads on a beam (like on the image).
have it working for 1 load but I want it to calculate for more.
need to use Arrays but can't get it to work properly :S
can you guys that a look at the code and try to tell what I'm supose to do?
Code:
program calculo_flexa;
uses crt;
Const MaxSec=1000;
MaxNcp=500;
Type Tab1=Array[0..MaxSec] of Real;
Tab2=array[1..MaxNCP]of real;
VAR K,E,MI,b,L,alfa,beta,lambda:real;
P:real;
a,fx,x:real;
SomaFx:real;
i,NSEQ,NCP:integer;
Sair:Char;
{================================ Erro ====================================}
Procedure Erro(Mensagem:String);
Begin
TextColor(LightRed);
gotoxy(06,13);Writeln('Valor Incorrecto: ' + Mensagem);
TextColor(White)
End;
{========================== Nome Instituição ================================}
PROCEDURE ISEL(Cor:Integer);
Begin
textcolor(lightgreen);
Gotoxy(54,03); Write(' ..... ..... ..... . ');
Gotoxy(54,04); Write(' . . . . ');
Gotoxy(54,05); Write(' . ..... ... . ');
Gotoxy(54,06); Write(' . . . . ');
Gotoxy(54,07); Write(' ..... ..... ..... .....');
Gotoxy(54,09); Write('Instituto ');
Gotoxy(54,11); Write(' Superior ');
Gotoxy(54,13); Write(' Engenharia ');
Gotoxy(54,15); Write(' Lisboa');
End;
{================== Bloquer o Programa em Caso de Erro na Password ===========}
Procedure Bloquear;
Var x:Integer;
Begin
X:=1;
While X=1 DO Begin
Gotoxy(Random(77),Random(32));
TextColor(random(40));
Write('error')
End;
End;
{================= Registar a Tecla escolhida e Escrever um "*" =============}
Procedure Tecla(VAR C:Char);
Begin
TextColor(Black);
C:=Readkey;
C:=UpCase(C);
TextColor(Yellow); Write('*')
End;
{================== Validar Password maximo 3 tentativas =====================}
Procedure Password;
Var Chave,Pass:String[4];
C1,C2,C3,C4,C5:Char;
Conta:Integer;
Begin
Chave:='LC11N';
Conta:=1;
TextBackground(Black);
Repeat
TextColor(lightred);
Gotoxy(10,10); Write(' ':40);
Gotoxy(10,10); Write('Tentativa -',Conta,'- Password ---> ');
Tecla(C1);
Tecla(C2);
Tecla(C3);
Tecla(C4);
Tecla(C5);
Pass:=C1+C2+C3+C4+C5;
Conta:=Conta+1
Until (Chave=Pass) or (Conta=4);
IF Chave<>Pass Then Bloquear
End;
{========== Escrever os caracteres escolhidos na posicao selecionada =========}
Procedure Tracos(Col,Lin,Simbolo:Integer);
Begin
Gotoxy(Col,Lin); Write(Char(Simbolo))
End;
{====== Desenhar a Moldura do Trabalho...Designacao, autores, data, ISEL,..===}
Procedure Moldura(Cor:Integer);
Var i:Integer;
Begin
ISEL(LightGreen);
TextColor(lightblue);
For i:=1 TO 78 DO Tracos(i+1,01,205);
For i:=1 TO 78 DO Tracos(i+1,16,205);
For i:=1 TO 78 DO Tracos(i+1,25,205);
For i:=1 TO 24 DO Tracos(01,i+1,186);
For i:=1 TO 24 DO Tracos(50,i+1,186);
For i:=1 TO 24 DO Tracos(80,i+1,186);
TextColor(lightblue);
Tracos(01,01,201);
Tracos(01,25,200);
Tracos(80,01,187);
Tracos(80,25,188);
Tracos(50,01,203);
Tracos(50,25,202);
Tracos(01,16,204);
Tracos(80,16,185);
Tracos(50,16,206);
Gotoxy(07,05); TextColor(lightred);Write('- - - - - - - - - - - - - - - - - - - - ');
Gotoxy(07,06); TextColor(lightred); Write('| | ');
Gotoxy(07,07); TextColor(lightred);Write('- - - - - - - - - - - - - - - - - - - - ');
Gotoxy(08,06);TextColor(yellow);Write('*Viga sobre apoio elastico continuo*');
end;
{======================== Pedir os Dados da Viga ===========================}
procedure intdados_viga(var L,b,K,E,MI:real; var alfa,beta,Lambda:real);
begin
Clrscr;
textcolor(white);
repeat
Gotoxy(06,03);Write('Largura da Viga (b) ? ');
Readln(b);
IF b<=0 THEN Erro ('Atencao: b > 0')
Until b>0;
Repeat
Gotoxy(06,04);Write('Modulo do Solo (K) ? ');
Readln(K);
IF K<=0 THEN Erro ('Atencao: K > 0')
Until K>0;
Repeat
Gotoxy(06,05);Write('Modulo de Elasticidade (E) ? ');
Readln(E);
IF E<=0 THEN Erro ('Atencao: E > 0')
Until E>0;
Repeat
Gotoxy(06,06);Write('Momento de Inercia (MI) ? ');
Readln(MI);
IF MI<=0 THEN Erro ('Atencao: MI > 0')
Until MI>0;
Beta:=K*B;
Alfa:=exp((1/4)*ln(Beta/(4*E*MI)));
Lambda:=2*Pi/Alfa;
Repeat
Gotoxy(06,02);Write('Comprimento da Viga (L) ? ');
Readln(L);
IF (L<=2.5*Lambda) THEN Erro ('Atencao: Comprimento Insuficiente')
Until L>2.5*Lambda;
end;
{======================= Pedir os Dados da Carga ===========================}
procedure intdados_carga ( var P,a:real ; var NSEQ:integer);
Var Texto_MaxSec:String;
i:integer;
begin
Clrscr;
textcolor(white);
Str(MaxSec,Texto_MaxSec);
Gotoxy(06,02);Write('Indique o numero de Cargas Pontuais? ');
Readln(NCP);
for i:=1 to NCP do Begin
Repeat
Gotoxy(06,03);DelLine;
Gotoxy(06,03);Write('Indique o valor da Carga ',i:2,'? ');
Readln(p);
IF P=0 THEN Erro ('Atencao: Carga <> 0')
Until P<>0;
end;
for i:=1 to NCP do Begin
Repeat
Gotoxy(06,04);DelLine;
Gotoxy(06,04);Write('Distancia da origem á Carga',i:2,' ? ');
Readln(a);
IF a<0 THEN Erro ('Atencao: Distancia >= 0')
Until a>=0;
end;
Gotoxy(06,05);Write('Numero de Seccoes Equidistantes (NSEQ) ? ');
Repeat
Readln(NSEQ);
IF (NSEQ<=0) or (NSEQ>MaxSec)
THEN Erro('Atencao: NSEQ > 0 e NSEQ<=' + Texto_MaxSec);
Until (NSEQ>0) and (NSEQ<=MaxSec)
end;
{========================= calculo da flecha =================================}
Procedure calc_flecha(NSEQ:Integer;L,P,a,x,Beta,Alfa:Real);
Var Q,B1,B2,dx,Fx:Real;
i:Integer;
Begin
Q:=(P*Alfa)/(2*Beta);
B1:=Alfa*(a-x);
B2:=Alfa*(x-a);
dx:=L/(NSEQ);
For i:=0 to NSEQ do begin
If(x>=0) and (x<=a) then
Fx:=Q*exp(-B1)*(sin(Alfa*(a-x))+cos(Alfa*(a-x)));
If(x>a) and (x<=L) then
Fx:=Q*exp(-B2)*(sin(Alfa*(x-a))+cos(Alfa*(x-a)));
x:=i*dx;
end;
End;
{============================ Autores do programa=============================}
PROCEDURE Autores;
Begin
TextColor(yellow);
Gotoxy(06,18); Write('Carlos Luis Pedroso Filipe - 37738 ');
Gotoxy(06,20); Write('Henrique Manuel Narciso Esgueira - 37740 ');
Gotoxy(06,22); Write('Tiago Filipe Camilo Alves - 37751');
Gotoxy(06,24); Write('Data: / / ');
End;
{=============== Perguntar se quer abandonar programa ========================}
Procedure SairPrograma(VAR Sair:Char);
Begin
Clrscr;
Repeat
Gotoxy(08,22);
Write('Pretende Abandonar o Programa (S/N) ? ');
Sair:=Readkey;
Sair:=UpCase(Sair);
Until sair IN ['S','N']
End;
{=======================-_-= -*Bloco Principal*- =-_-=======================}
begin
Moldura(Lightblue);
{ password;}
Autores;
Writeln;
TextColor(lightred);
Gotoxy(55,21); write(' Prima qualquer tecla');
Gotoxy(55,22); Write('para continuar programa');
Readln();
Repeat
Clrscr;
intdados_viga(L,b,K,MI,E,alfa,beta,lambda);
intdados_carga(P,a,NSEQ);
calc_flecha(NSEQ,L,P,a,x,Beta,Alfa);
SairPrograma(sair)
Until Sair='S'
end.
that's what I need to do:
1) Read data from the beam: K, B, E, MI (positive values);
Calculate alfa, beta and lambda;
Read as: L (L> 2.5*lambda)
2) Read data load: P and (a is a positive value);
3) Read number of equidistant sections: NSEQ
4) For each section (0 to NSEQ) calculate:
4.1) Distance x to the origin O;
4.2) Arrow F for the distance x ;
5) For each section (0 to NSEQ) write on the screen:
5.1) Distance x to the origin O;
5.2) Arrow F for the distance x ;
and also have calculate when the deflection is zero,
ask if the user wants to save or not the results in a file,
make a graph..
where:
P - Value of Load
L - Length of Beam
a - distance between source and point of application of load
x - section corresponding to the point of application of load
b - beam width
K - Soil Module
E - modulus
MI - Moment of inertia of section
NSEQ - Number of Sections Equidistant
NCP - Number of point charges
Attachments
Last edited: