Skip to content

Commit

Permalink
🎨 Format Python code with psf/black (#52)
Browse files Browse the repository at this point in the history
Co-authored-by: ccaprani <[email protected]>
  • Loading branch information
github-actions[bot] and ccaprani authored Oct 5, 2023
1 parent 911a12b commit b83af47
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/pycba/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def plot(self, each=False, **kwargs):
raise ValueError("No results to display")

L = self.x[-1]

fig, axs = plt.subplots(2, 1, sharex=True, **kwargs)

ax = axs[0]
Expand All @@ -389,7 +389,7 @@ def plot(self, each=False, **kwargs):
ax.grid()
ax.set_ylabel("Shear Force (kN)")
ax.set_xlabel("Distance along beam (m)")

if each:
for res in self.vResults:
axs[0].plot(self.x, res.results.M, "r", lw=0.5)
Expand Down
45 changes: 25 additions & 20 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,36 +227,41 @@ def test_moment_load():
d = beam_analysis.beam_results.D[[0, 2]]
assert d == pytest.approx([0.0, 0.0])


def test_envelopes():
L = [6,4,6]
L = [6, 4, 6]
EI = 30 * 10e9 * 1e-6
R = [-1,0,-1,0,-1,0,-1,0]
R = [-1, 0, -1, 0, -1, 0, -1, 0]
beam_analysis = cba.BeamAnalysis(L, EI, R)

LMg = [[1,1,25,0,0],
[2,1,25,0,0],
[3,1,25,0,0]]

LMg = [[1, 1, 25, 0, 0], [2, 1, 25, 0, 0], [3, 1, 25, 0, 0]]
γg_max = 1.4
γg_min = 1.0
LMq = [[1,1,10,0,0],
[2,1,10,0,0],
[3,1,10,0,0]]
LMq = [[1, 1, 10, 0, 0], [2, 1, 10, 0, 0], [3, 1, 10, 0, 0]]
γq_max = 1.6
γq_min = 0

lp = cba.LoadPattern(beam_analysis)
lp.set_dead_loads(LMg,γg_max,γg_min)
lp.set_live_loads(LMq,γq_max,γq_min)
lp.set_dead_loads(LMg, γg_max, γg_min)
lp.set_live_loads(LMq, γq_max, γq_min)
env = lp.analyze()

m_locs = np.array([3, 6, 8, 10, 13])
idx = [(np.abs(env.x - x)).argmin() for x in m_locs]
assert np.allclose(env.Mmax[idx],np.array([163.79, 0, 11.75, 0, 163.79]),atol=1e-2)
assert np.allclose(env.Mmin[idx],np.array([0, -163.38, -81.42, -163.38, 0]),atol=1e-2)

assert np.allclose(
env.Mmax[idx], np.array([163.79, 0, 11.75, 0, 163.79]), atol=1e-2
)
assert np.allclose(
env.Mmin[idx], np.array([0, -163.38, -81.42, -163.38, 0]), atol=1e-2
)

n = beam_analysis.beam_results.npts
nspans = beam_analysis.beam.no_spans
Vmax = np.array([np.max(env.Vmax[i*(n+3):(i+1)*(n+3)]) for i in range(nspans)])
assert np.allclose(Vmax,np.array([131.1, 123.94, 180.23]),atol=1e-2)
Vmin = np.array([np.min(env.Vmin[i*(n+3):(i+1)*(n+3)]) for i in range(nspans)])
assert np.allclose(Vmin,np.array([-180.23, -123.94, -131.10]),atol=1e-2)
Vmax = np.array(
[np.max(env.Vmax[i * (n + 3) : (i + 1) * (n + 3)]) for i in range(nspans)]
)
assert np.allclose(Vmax, np.array([131.1, 123.94, 180.23]), atol=1e-2)
Vmin = np.array(
[np.min(env.Vmin[i * (n + 3) : (i + 1) * (n + 3)]) for i in range(nspans)]
)
assert np.allclose(Vmin, np.array([-180.23, -123.94, -131.10]), atol=1e-2)

0 comments on commit b83af47

Please sign in to comment.