Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cslotboom committed Feb 10, 2024
1 parent 212d63a commit 2f30c50
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 156 deletions.
155 changes: 0 additions & 155 deletions test/_test_postprocess.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/manual/Ex5.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

P = -2*kN
M = 5*kN*m
q = np.array([0.5*kN/m, kN/m])
q = np.array([0.2*kN/m, kN/m])

beam.addLinLoadVertical(0, 4.5, -q)
beam.addLinLoadVertical(0, 4.5, q)
Expand Down
69 changes: 69 additions & 0 deletions test/manual/_test_postprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
@author: Christian
Tests if teh post-processor functions are correctly returning values.
"""


import planesections as ps
import numpy as np
import textalloc as ta
import matplotlib.pyplot as plt


x1 = 0
x2 = 7
offset = x2*0.6

x = np.linspace(0, x2, 80)
fixed = np.array([1, 1, 0])
roller = np.array([0, 1, 0])

P = np.array([0., 1000.,0.])
q = np.array([0.,-1000.])

beam = ps.EulerBeam2D(x)
beam.setFixity(x1, fixed)
beam.addNode(x2/3, label = 'C')
beam.addNode(2*x2/3, label = 'D')
beam.setFixity(x2, fixed)
# beam.setFixity(x2/3, roller)
beam.addPointLoad(x2/2, [-1000.,-1000,0])


beam.addVerticalLoad(offset, -1000.)
# beam.addVerticalLoad(x2/2, -1000.)
beam.addVerticalLoad(x2 - offset,-1000.)
beam.addVerticalLoad(x2 - offset, -1000.)
beam.addDistLoad(0,x2,q)

analysis = ps.OpenSeesAnalyzer2D(beam)
analysis.runAnalysis()

ps.plotBeamDiagram(beam)


# =============================================================================
#
# =============================================================================


POIOptions = {'showLabels':True}
ps.plotInternalForce(beam,2,scale = 0.001, labelPOI=True, POIOptions = POIOptions, yunit='kNm')
ps.plotInternalForce(beam,0,scale = 0.001, labelPOI=True, POIOptions = POIOptions)

# # ps.plotMoment(beam,labelPOI=True, POIOptions = POIOptions)
ps.plotShear(beam,labelPOI=True, POIOptions = POIOptions)


# ps.plotDisp(beam,labelPOI=True)








81 changes: 81 additions & 0 deletions test/test_poi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
@author: Christian
Tests if teh post-processor functions are correctly returning values.
"""

import planesections as ps
import numpy as np

from planesections.postprocess.poi import findBeamForcePOI

x1 = 0
x2 = 7
offset = x2*0.6

x = np.linspace(0, x2, 80)
fixed = np.array([1, 1, 0])
roller = np.array([0, 1, 0])

P = np.array([0., 1000.,0.])
q = np.array([0.,-1000.])

beam = ps.EulerBeam2D(x)
beam.setFixity(x1, fixed)
beam.addNode(x2/3, label = 'C')
beam.addNode(2*x2/3, label = 'D')
beam.setFixity(x2, fixed)
beam.addPointLoad(x2/2, [-1000.,-1000,0])


beam.addVerticalLoad(offset, -1000.)
beam.addVerticalLoad(x2 - offset,-1000.)
beam.addVerticalLoad(x2 - offset, -1000.)
beam.addDistLoad(0,x2,q)

analysis = ps.OpenSeesAnalyzer2D(beam)
analysis.runAnalysis()

ps.plotBeamDiagram(beam)


# =============================================================================
#
# =============================================================================

def test_moment():
POIOptions = {'showLabels':True}
assert len(findBeamForcePOI(beam, 2, POIOptions)) == 3

def test_moment_labels():
POIOptions = {'showLabels':False}

assert len(findBeamForcePOI(beam, 2, POIOptions)) == 1

def test_shear():
POIOptions = {'showLabels':True}
assert len(findBeamForcePOI(beam, 1, POIOptions)) == 10

def test_shear_labels():
POIOptions = {'showLabels':False}
assert len(findBeamForcePOI(beam, 1, POIOptions)) == 8

def test_shear_dis():
POIOptions = {'showDiscontinutiy':False}
assert len(findBeamForcePOI(beam, 1, POIOptions)) == 4

if __name__ == "__main__":
test_moment()
test_moment_labels()

test_shear()
test_shear_labels()
test_shear_dis()






0 comments on commit 2f30c50

Please sign in to comment.