-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreport.py
114 lines (108 loc) · 5.95 KB
/
report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def solve_sfd(input_values):
print('SHEAR FORCE DIAGRAM\n')
print('To draw a Shear Force Diagram, first solve the shear reactions at supports. Then from the left end of the beam, consider the sum of shear force acting upto that point. Plot the shear force corresponding to its position along the beam. Continue by taking small intervals along the beam till you reach the right end.\n')
position = float(input_values.get('span'))/2
print('For example, let us find Shear Force at '+str(position)+'\n')
sfd = ''
sfd_value = 0
ploads = input_values.get('point_loads')
udls = input_values.get('UDLs')
supports = input_values.get('supports')
for pload in ploads:
if(float(pload[1])<=position):
sfd+=str(pload[0])+' + '
sfd_value += float(pload[0])
for udl in udls:
if (float(udl[1])<=position and min(position,float(udl[2]))<=position):
sfd += str(udl[0])+'*'+'('+str(min(position,float(udl[2])))+'-'+str(udl[1])+')'+' + '
sfd_value += float(udl[0])*(min(position,float(udl[2]))-float(udl[1]))
for support in supports:
if((support[0] in ('pin', 'roller')) and float(support[2])<=position):
sfd += str(-support[1])+' + '
sfd_value -= support[1]
if(sfd==''):
sfd = str(0)+' + '
print('Shear Force = '+sfd[:-3])
print('Shear Force = '+str(sfd_value)+'\n')
def solve_bmd(input_values):
print('BENDING MOMENT DIAGRAM\n')
print('To draw a Bending Moment Diagram, first solve the moment reactions at supports. Then from the left end of the beam, consider few points at some interval till you reach the right end of the beam. Sum up the bending moments from the point to the right end of the beam. Plot the Bending Moment to its corresponding position on the beam till you reach the right end.\n')
position = float(input_values.get('span'))/2
print('For example, let us find Bending Moment at '+str(position)+'\n')
bmd=''
bmd_value=0
ploads = input_values.get('point_loads')
udls = input_values.get('UDLs')
supports = input_values.get('supports')
for pload in ploads:
if (float(pload[1])>=position):
bmd += str(pload[0])+'*'+'('+str(pload[1])+'-'+str(position)+')'+' + '
bmd_value += float(pload[0])*(float(pload[1])-position)
for udl in udls:
if (max(position,float(udl[1]))>=position and float(udl[2])>=position):
pass
bmd += str(udl[0])+'*'+'('+str(udl[2])+'-'+str(max(position, float(udl[1])))+')'+'*'+'('+'('+str(udl[2])+'+'+str(max(position, float(udl[1])))+')/2'+'-'+str(position)+')'+' + '
bmd_value += float(udl[0])*(float(udl[2])-max(position, float(udl[1])))*((float(udl[2])+max(position, float(udl[1])))/2 -position)
for support in supports:
if(support[0]=='fixed' and support[2]>=position):
bmd += str(support[1])+' + '
bmd_value += support[1]
if((support[0] in ('pin', 'roller')) and float(support[2])>=position):
bmd += str(support[1])+'*'+'('+str(support[2])+'-'+str(position)+')'+' + '
bmd_value = float(support[1])*(float(support[2])-position) - bmd_value
if(bmd==''):
bmd= str(0)+' + '
print('Bending Moment = '+bmd[:-3])
print('Bending Moment = '+str(bmd_value)+'\n')
def solve_reactions(input_values):
print('SOLVING SUPPORT REACTIONS\n')
reactions = input_values.get('supports')
if(len(reactions)==1):
ploads = input_values.get('point_loads')
udls = input_values.get('UDLs')
line1 = ''
value1= 0
line2 = ''
value2= 0
for pload in ploads:
line1+= str(pload[0])+'*'+'('+str(pload[1])+'-'+str(reactions[0][2])+')'+' + '
value1+= float(pload[0])*(float(pload[1])-float(reactions[0][2]))
line2+= str(pload[0])
value2+= float(pload[0])
for udl in udls:
line1+=str(udl[0])+'*'+'('+str(udl[2])+'-'+str(udl[1])+')'+'*'+'('+'('+str(udl[1])+'+'+str(udl[2])+')/2'+'-'+str(reactions[0][2])+')'+' + '
value1+=float(udl[0])*(float(udl[2])-float(udl[1]))*((float(udl[1])+float(udl[2]))/2-float(reactions[0][2]))
line2+=str(udl[0])+'*'+'('+str(udl[2])+'-'+str(udl[1])+')'+' + '
value2+= float(udl[0]*(udl[2]-udl[1]))
if(line1 == ''):
line1 = str(0)+' + '
if(line2 == ''):
line2= str(0)+ ' + '
print('M1 = '+str(line1[:-3]))
print('M1= '+str(value1)+' -> Equation1\n')
print('R1 = '+str(line2[:3]))
print('R1 = '+str(value2)+' -> Equation2\n')
elif(len(reactions)==2):
ploads = input_values.get('point_loads')
udls = input_values.get('UDLs')
line1 = ''
line2 = ''
value1 = 0
value2 = 0
for pload in ploads:
line1+=str(pload[0]) + ' + '
value1+=float(pload[0])
line2+= str(pload[0])+'*'+'('+str(pload[1])+'-'+str(reactions[0][2])+')'+' + '
value2+= float(pload[0])*(float(pload[1])-float(reactions[0][2]))
for udl in udls:
line1+=str(udl[0])+'*'+'('+str(udl[2])+'-'+str(udl[1])+')'+' + '
value1+=float(udl[0])*(float(udl[2])-float(udl[1]))
line2+=str(udl[0])+'*'+'('+str(udl[2])+'-'+str(udl[1])+')'+'*'+'('+'('+str(udl[1])+'+'+str(udl[2])+')/2'+'-'+str(reactions[0][2])+')'+' + '
value2+=float(udl[0])*(float(udl[2])-float(udl[1]))*((float(udl[1])+float(udl[2]))/2-float(reactions[0][2]))
print('R1 + R2 = '+line1[:-3])
print('R1 + R2 = '+str(value1)+' -> Equation1\n')
print('R2'+'*'+'('+str(reactions[1][2])+'-'+str(reactions[0][2])+')'+' = '+line2[:-3]+' -> Equation2')
print('R2'+' = '+str(float(value2)/(float(reactions[1][2])-float(reactions[0][2])))+' -> From Equation2\n')
print('Using Equation1')
print('R1'+' = '+str(value1)+'-'+'R2')
print('Therefore, '+'R1'+' = '+str(value1-(float(value2)/(float(reactions[1][2])-float(reactions[0][2]))))+'\n')