Monday, September 26, 2011

CONTINUOUS BEAM ANALYSIS - QBASIC / FREEBASIC - STRUCTURAL ANALYSIS / CIVIL ENGINEERING REM SHEAR AND MOMENT ENVELOPES FOR A CONTINUOUS BEAM
REM ************************************************
DIM VS(10, 11), VE(10, 11), MS(10, 21), MN(10, 21), MP(10, 21)
DIM CantileverLeft(20),CantileverRight(20),MM(20),SM(20),K2(20)
DIM DVar(20),E(20),FLeft(20),FRight(20),WD(20,20),FVar(20),R(200)
DIM ML(200),MR(200)
REM *************************************** Input of data
PRINT "ENTER TITLE"
INPUT T\$
REM *************************** Partial factors of safety
INPUT GK
PRINT "ENTER PARTIAL FACTOR OF SAFETY FOR IMPOSED LOAD,QK"
INPUT QK
REM *********************************** Beam information
PRINT "ENTER NO. OF SPANS"
INPUT NumberOfSpan
FOR I = 1 TO NumberOfSpan
PRINT "SPAN NO"; I
PRINT "ENTER SPAN LENGTH-metres"
INPUT Length(I)
PRINT "ENTER '2ND MOMENT OF AREA OF SPAN'S SECTION,IZ-mm^4"
INPUT MomentArea(I)
NEXT I
FOR I = 1 TO NumberOfSpan
PRINT "SPAN NO."; I
PRINT "ENTER NO. OF LOADS ON SPAN"; I
IF NumberOfLoads(I) = 0 THEN 390
FOR J = 1 TO NumberOfLoads(I)
PRINT "SPAN NO. "; I; "LOAD NO. "; J
PRINT "ENTER LOAD START DISTANCE,A-metres "
NEXT J
390 NEXT I
REM ***************** Cantilevers characteristic moments
PRINT "ENTER CANTILEVER CHARACTERISTIC DEAD MOMENT AT L.H.S.-kN.m"
INPUT CantileverLeft(1)
PRINT "ENTER CANTILEVER CHARACTERISTIC IMPOSED MOMENT AT L.H.S.-kN.m"
INPUT CantileverLeft(2)
PRINT "ENTER CANTILEVER CHARACTERISTIC DEAD MOMENT AT R.H.S.-kN.m"
INPUT CantileverRight(1)
PRINT "ENTER CANTILEVER CHARACTERISTIC IMPOSED MOMENT AT R.H.S.-kN.m"
INPUT CantileverRight(2)
REM ***************************** Initialising variables
CL = 0: CR = 0
FOR I = 1 TO NumberOfSpan
MM(I) = 0: SM(I) = 0
FOR K = 1 TO 21
VE(I, (K + 1) / 2) = 0: MN(I, K) = 10 ^ 10: MP(I, K) = -(10 ^ 10)
NEXT K
NEXT I
REM ************************************* Beam stiffness
FOR I = 1 TO NumberOfSpan
K2(I) = MomentArea(I) / Length(I)
NEXT I
GOSUB 4000: REM ******* Subroutine for slope deflection equations -- L.H.S
REM No. of load patterns = NP
NP = NumberOfSpan + 1
IF CantileverLeft(1) + CantileverLeft(2) > 0 THEN NP = NP + 1
IF CantileverRight(1) + CantileverRight(2) > 0 THEN NP = NP + 1
REM ********************* Analysis for each load pattern
LP = 0
680 LP = LP + 1
GOSUB 9000: REM ***Subroutine to calculate design loads
GOSUB 5000: REM ****** Subroutine for fixed end moments
GOSUB 6000: REM ******* Subroutine for slope deflection equations - R.H.S.
GOSUB 7000: REM Subroutine for sol'n of eq'ons and c'tion of end moments
GOSUB 8000: REM Subroutine for span shear and moments
GOSUB 10000: REM Subroutine to sort for shear and moment envelopes
IF LP < NP THEN 680 REM *** Sort for maximum sagging moment and its position FOR I = 1 TO NumberOfSpan FOR K = 1 TO 21 IF MP(I, K) > MM(I) THEN MM(I) = MP(I, K): SM(I) = Length(I) * (K - 1) / 20
NEXT K
NEXT I
REM *********************** Printout of data and results
OPEN "BEAMOUT.TXT" FOR OUTPUT AS #1
PRINT #1, "TITLE "
PRINT #1, "PARTIAL FACTORS OF SAFETY"
PRINT #1, "FACTOR OF SAFETY FOR IMPOSED LOAD="; QK
PRINT #1,
PRINT #1, : PRINT #1, "STRUCTURE INFORMATION"
PRINT #1, "---------------------"
PRINT #1, "NO. OF SPANS "; NumberOfSpan
PRINT #1,
PRINT #1, " SPAN SPAN 2ND MOMENT"
PRINT #1, " NO. LENGTH(m) OF AREA(mm^4)"
FOR I = 1 TO NumberOfSpan
PRINT #1, USING " ## ####.## ####.##"; I; Length(I); MomentArea(I)
NEXT I
REM
PRINT #1, "-------------------"
PRINT #1, " NO. WEIGHT(kN) DISTANCE(m) DISTANCE(m) OR IMPOSED"
FOR I = 1 TO NumberOfSpan
IF NumberOfLoads(I) = 0 THEN 1080
FOR J = 1 TO NumberOfLoads(I)
NEXT J
1080 NEXT I
REM
PRINT #1, "CANTILEVER CHARACTERISTIC DEAD MOMENT AT L.H.S.="; CantileverLeft(1); "kN.m"
PRINT #1, "CANTILEVER CHARACTERISTIC IMPOSED MOMENT AT L.H.S.="; CantileverLeft(2); "kN.m"
PRINT #1, "CANTILEVER CHARACTERISTIC DEAD MOMENT AT R.H.S.="; CantileverRight(1); "kN.m"
PRINT #1, "CANTILEVER CHARACTERISTIC IMPOSED MOMENT AT R.H.S.="; CantileverRight(2); "kN.m"
REM ******************************* Printout of results
PRINT "PRINT RESULT IN BEAMOUT.TXT FILE"
PRINT #1, : PRINT #1, : PRINT #1, "SHEAR AND MOMENT ENVELOPES"
PRINT #1, "__________________________"
PRINT #1, "SHEARS,kN AND MOMENTS,kN.m AT 10TH INTERVALS ALONG SPANS"
FOR I = 1 TO NumberOfSpan
PRINT #1, : PRINT #1, "SPAN NO."; I
PRINT #1, "SECTION SHEAR HOGGING SAGGING"
PRINT #1, " NO. MOMENT MOMENT"
FOR K = 1 TO 21 STEP 2
PRINT #1, USING " ## ####.## ####.## ####.##"; (K + 1) / 2; VE(I, (K + 1) / 2); MN(I, K); MP(I, K)
REM
NEXT K
PRINT #1, "MAXIMUM SPAN MOMENT = "; INT(MM(I) * 100) / 100; "kN.m"
PRINT #1, "AT A DISTANCE = "; INT(SM(I) * 100) / 100; "metres"
NEXT I
CLOSE #1
END
REM ***************************************************
4000 REM Subroutine for slope deflection equations - L.H.S.
DVar(1) = 4 * K2(1): E(1) = 2 * K2(1)
FOR I = 2 TO NumberOfSpan
DVar(I) = 4 * (K2(I - 1) + K2(I))
E(I) = 2 * K2(I)
NEXT I
DVar(NumberOfSpan + 1) = 4 * K2(NumberOfSpan)
E(NumberOfSpan + 1) = 0
RETURN
REM ***************************************************
5000 REM ********* Subroutine to calculate fixed end moments
FOR I = 1 TO NumberOfSpan
FLeft(I) = 0: FRight(I) = 0
IF NumberOfLoads(I) = 0 THEN 5120
FOR J = 1 TO NumberOfLoads(I)
W = WD(I, J): A = LoadStart(I, J): C = LoadCover(I, J): L = Length(I)
S = A + C / 2: T = L - S
FL = W * (S * T ^ 2 + (S - 2 * T) * C ^ 2 / 12) / L ^ 2
FR = W * (T * S ^ 2 + (T - 2 * S) * C ^ 2 / 12) / L ^ 2
FLeft(I) = FLeft(I) + FL
FRight(I) = FRight(I) + FR
NEXT J
5120 NEXT I
RETURN
REM ***************************************************
6000 REM Subroutine for slope deflection equations - R.H.S.
FVar(1) = -(FLeft(1)) + CL
FOR I = 2 TO NumberOfSpan
FVar(I) = FRight(I - 1) - FLeft(I)
NEXT I
FVar(NumberOfSpan + 1) = FRight(NumberOfSpan) - CR
RETURN
REM ***************************************************
7000 REM *** Subroutine for equation solution and end moment calculation
D = DVar(1): F = FVar(1)
FOR I = 2 TO NumberOfSpan + 1
F = FVar(I) - E(I - 1) * F / D
D = DVar(I) - E(I - 1) ^ 2 / D
NEXT I
R(NumberOfSpan + 1) = F / D
R(NumberOfSpan) = (FVar(NumberOfSpan + 1) - DVar(NumberOfSpan + 1) * R(NumberOfSpan + 1)) / E(NumberOfSpan)
FOR I = NumberOfSpan TO 2 STEP -1
R(I - 1) = (FVar(I) - DVar(I) * R(I) - E(I) * R(I + 1)) / E(I - 1)
NEXT I
REM End moments
FOR I = 1 TO NumberOfSpan
ML(I) = (4 * R(I) + 2 * R(I + 1)) * K2(I) + FLeft(I)
MR(I) = (2 * R(I) + 4 * R(I + 1)) * K2(I) - FRight(I)
NEXT I
RETURN
REM ***************************************************
8000 REM *** Subroutine to calculate span shears and moments
FOR I = 1 TO NumberOfSpan
REM ***** Calculation of span shears and moments due to end moments
RL = (ML(I) + MR(I)) / Length(I)
FOR K = 1 TO 11: VS(I, K) = RL: NEXT K
FOR K = 1 TO 21: MS(I, K) = -ML(I) + RL * Length(I) * (K - 1) / 20: NEXT K
FOR J = 1 TO NumberOfLoads(I)
IF NumberOfLoads(I) = 0 THEN 8300
W = WD(I, J): A = LoadStart(I, J): C = LoadCover(I, J): L = Length(I)
S = L - A - C / 2
RL = W * S / L: RR = W - RL
REM ********************* Span shears at 10th intervals
FOR K = 1 TO 11
Z = (K - 1) * L / 10
IF Z <= A THEN VK = RL: GOTO 8180 IF Z > A + C THEN VK = -RR: GOTO 8180
Z1 = Z - A
VK = RL - W * Z1 / C
8180 VS(I, K) = VS(I, K) + VK
NEXT K
REM ******************** Span moments at 20th intervals
FOR K = 1 TO 21
Z = (K - 1) * L / 20
IF Z <= A THEN MK = RL * Z: GOTO 8270 IF Z >= A + C THEN MK = RR * (L - Z): GOTO 8270
Z1 = Z - A: WZ = W * Z1 / C
MK = RL * Z - WZ * Z1 / 2
8270 MS(I, K) = MS(I, K) + MK
NEXT K
NEXT J
8300 NEXT I
RETURN
REM ***************************************************
9000 REM ************** Subroutine to calculate design loads
FOR I = 1 TO NumberOfSpan
IF NumberOfLoads(I) = 0 THEN 9290
REM **************************** Partial safety factors
GG = 1: QG = 0
IF LP = 1 THEN 9090
IF LP = 2 THEN 9120
IF LP > 2 AND LP < NumberOfSpan + 2 THEN 9150
IF LP > NumberOfSpan + 1 THEN 9190
9090 REM ******* Odd numbered spans, maximum sagging moments
IF I / 2 > INT(I / 2) THEN 9230
GOTO 9240
9120 REM ****** Even numbered spans, maximum sagging moments
IF I / 2 = INT(I / 2) THEN 9230
GOTO 9240
9150 REM *************************** Maximum support moments
IF I = LP - 2 THEN 9230
IF I = LP - 1 THEN 9230
GOTO 9240
9190 REM **** Maximum shear at end supports with cantilevers
IF LP = NumberOfSpan + 2 AND I = 1 THEN 9230
IF LP = NumberOfSpan + 3 AND I = NumberOfSpan THEN 9230
GOTO 9240
9230 GG = GK: QG = QK
FOR J = 1 TO NumberOfLoads(I)
NEXT J
9290 NEXT I
REM ************************* Cantilever design moments
IF CantileverLeft(1) + CantileverLeft(2) = 0 THEN 9370
GG = 1: QG = 0
REM *********************************** Left cantilever
IF LP = 2 THEN GG = GK: QG = QK
IF LP = NumberOfSpan + 2 THEN GG = GK: QG = QK
CL = CantileverLeft(1) * GG + CantileverLeft(2) * QG
9370 REM ********************************** Right cantilever
IF CantileverRight(1) + CantileverRight(2) = 0 THEN 9440
GG = 1: QG = 0
IF LP = 1 AND NumberOfSpan / 2 = INT(NumberOfSpan / 2) THEN GG = GK: QG = QK
IF LP = 2 AND NumberOfSpan / 2 > INT(NumberOfSpan / 2) THEN GG = GK: QG = QK
IF LP = NumberOfSpan + 3 THEN GG = GK: QG = QK
CR = CantileverRight(1) * GG + CantileverRight(2) * QG
9440 RETURN
REM ***************************************************
10000 REM *** Subroutine to sort for shear force and bending moment envelopes
REM *********************************** Shear envelope
FOR I = 1 TO NumberOfSpan
FOR K = 1 TO 11
IF ABS(VE(I, K)) < ABS(VS(I, K)) THEN VE(I, K) = VS(I, K)
NEXT K
NEXT I
REM ************************** Bending moment envelope
FOR I = 1 TO NumberOfSpan
FOR K = 1 TO 21
REM ********************************* Hogging envelope
IF MN(I, K) > MS(I, K) THEN MN(I, K) = MS(I, K)
IF MN(I, K) > 0 THEN MN(I, K) = 0
REM ********************************* Sagging envelope
IF MP(I, K) < MS(I, K) THEN MP(I, K) = MS(I, K)
IF MP(I, K) < 0 THEN MP(I, K) = 0
NEXT K
NEXT I
RETURN
REM **************************************************