This is the same frame as used in the main code file.
In [1]:
import nbformat
In [2]:
from __future__ import division, print_function
from IPython import display
import salib.nbloader # so that we can directly import other notebooks
In [3]:
import Frame2D_v03 as f2d
In [4]:
frame = f2d.Frame2D()
frame.read_data('frame-6')
frame.doall()
In [5]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import display
def vm(self,loads,mefs=None):
"""Return shear and moment 'diagrams'. Return (xv,v,xm,m) -
xv and xm are positions along span, and v and m are shears and
moments at those points. Use normal sign convention (not beam sign
convention) - on left FBD, moments +ive CCW, shear +ive upwards.
"""
def _getx(self,loads,attr):
degree = 0
pts = [0.,self.L]
for load in loads:
pt1,pt2,d = getattr(load,attr)
for p in pt1,pt2:
if p is not None:
pts.append(p)
if d > degree:
degree = d
ptsv = np.array(pts)
if degree > 1:
ptsv = np.concatenate((ptsv,np.linspace(0,self.L)))
ptsv.sort()
return np.unique(ptsv)
if mefs is None:
mefs = self.mefs
##print(mefs)
xv = _getx(self,loads,'vpts')
xm = _getx(self,loads,'mpts')
v = xv * 0. - mefs[1,0]
m = xm * mefs[1,0] - mefs[2,0]
for load in loads:
v += load.shear(xv)
m += load.moment(xm)
return xv,v,xm,m
In [6]:
memb = 'BC'
m = frame.members[memb]
l = frame.membloads[memb]
xv,v,xm,m = vm(m,l)
In [7]:
display(xv,-v*1e-3)
In [8]:
plt.grid(True)
plt.plot(xv,-v*1e-3)
Out[8]:
In [9]:
plt.subplot(2,1,1)
plt.title('Member {}'.format(memb))
plt.grid(True)
plt.fill_between(x=xv,y1=-v*1e-3,color='lightgray',edgecolor='black')
plt.ylabel('Shear')
plt.subplot(2,1,2)
plt.grid(True)
plt.fill_between(xm,m*1e-6,color='lightblue',edgecolor='black')
plt.ylabel('Moment')
None
In [ ]: