Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

Programming in Civil engineering

Puntuación
-
Vendido
-
Páginas
16
Subido en
20-07-2025
Escrito en
2024/2025

By reading and practice these documents you will get very interested information

Institución
Grado

Vista previa del contenido

In [1]: import numpy as np
import matplotlib.pyplot as plt

print("Simply Supported Beam")
print("\nType 1 for point load, Type 2 for UDL")
Type = int(input("Load case = "))

L = float(input("\nLength of beam in meter = "))

if Type == 1:
P = float(input("\nLoad applied in kN = "))
a = float(input("Location of Load from left end of the beam in meter = "))
c = L - a

R1 = P * (L - a) / L
R2 = P * a / L
else:
W = float(input("\nUniformly distributed load in kN/m = "))
b = float(input("Length of UDL in meter = "))
cg = float(input("C.G of UDL from left end of the beam in meter = "))
a = cg - b / 2
c = L - a - b

R1 = W * b * (b + 2 * c) / (2 * L)
R2 = W * b * (b + 2 * a) / (2 * L)

# Discretization
n = 1000
delta_x = L / n
x = np.linspace(0, L, n + 1)

V = np.zeros_like(x)
M = np.zeros_like(x)

# Calculation
if Type == 1:
for i in range(n + 1):
if x[i] < a:
V[i] = R1
M[i] = R1 * x[i]
else:
V[i] = R1 - P
M[i] = R1 * x[i] - P * (x[i] - a)
x1 = a
Mmax = P * a * (L - a) / L
else:
for i in range(n + 1):
if x[i] < a:
V[i] = R1
M[i] = R1 * x[i]
elif a <= x[i] < a + b:
V[i] = R1 - W * (x[i] - a)
M[i] = R1 * x[i] - W * ((x[i] - a) ** 2) / 2
else:
V[i] = -R2
M[i] = R2 * (L - x[i])
x1 = a + b * (b + 2 * c) / (2 * L)
Mmax = W * b * (b + 2 * c) * (4 * a * L + 2 * b * c + b ** 2) / (8 * L ** 2)

,# Results
print(f"\nLeft support Reaction = {R1:.2f} kN")
print(f"Right support Reaction = {R2:.2f} kN")
print(f"Maximum bending moment = {Mmax:.2f} kNm")

# Plotting
plt.figure(figsize=(10, 8))

# SFD
plt.subplot(2, 1, 1)
plt.plot(x, V, 'r', linewidth=1.5)
plt.axhline(0, color='k')
plt.axvline(0, color='r', linewidth=1.5)
plt.axvline(L, color='r', linewidth=1.5)
plt.title('Shear Force Diagram', fontsize=16)
plt.text(a / 2, V[0], f'{V[0]:.2f}', ha='center', fontweight='bold', fontsize=12)
plt.text(L - c / 2, V[-1], f'{V[-1]:.2f}', ha='center', fontweight='bold', fontsize=12
plt.grid(True)

# BMD
plt.subplot(2, 1, 2)
plt.plot(x, M, 'r', linewidth=1.5)
plt.axhline(0, color='k')
plt.axvline(x1, linestyle='--', color='b')
plt.title('Bending Moment Diagram', fontsize=16)
plt.text(x1 + 1 / L, Mmax / 2, f'{round(Mmax, 2):.2f}', ha='center', fontweight='bold'
plt.text(x1, 0, f'{round(x1, 2)} m', ha='center', fontweight='bold', fontsize=12)
plt.grid(True)

plt.tight_layout()
plt.show()

Simply Supported Beam

Type 1 for point load, Type 2 for UDL
Load case = 2

Length of beam in meter = 10

Uniformly distributed load in kN/m = 3
Length of UDL in meter = 10
C.G of UDL from left end of the beam in meter = 5

Left support Reaction = 15.00 kN
Right support Reaction = 15.00 kN
Maximum bending moment = 37.50 kNm

, In [2]: import numpy as np
import matplotlib.pyplot as plt

def get_input():
print("Simply Supported Beam Analysis\n")
load_type = int(input("Enter 1 for Point Load or 2 for UDL: "))
length = float(input("Enter beam length (m): "))

if load_type == 1:
P = float(input("Enter Point Load (kN): "))
a = float(input("Enter location of load from left support (m): "))
return load_type, length, {'P': P, 'a': a}

else:
W = float(input("Enter Uniformly Distributed Load (kN/m): "))
b = float(input("Enter length of UDL (m): "))
cg = float(input("Enter C.G. of UDL from left support (m): "))
return load_type, length, {'W': W, 'b': b, 'cg': cg}

def calculate_reactions(load_type, L, data):
if load_type == 1:
a = data['a']
c = L - a
P = data['P']
R1 = P * (L - a) / L
R2 = P * a / L
return R1, R2, a, c
else:

Escuela, estudio y materia

Grado

Información del documento

Subido en
20 de julio de 2025
Número de páginas
16
Escrito en
2024/2025
Tipo
NOTAS DE LECTURA
Profesor(es)
Sir ali
Contiene
Todas las clases

Temas

$8.49
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
adilrazaq14

Conoce al vendedor

Seller avatar
adilrazaq14 Punjab college
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
2 año
Número de seguidores
0
Documentos
10
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes