ccaprani / pycba

Python Continuous Beam Analysis
https://ccaprani.github.io/pycba/
Apache License 2.0
64 stars 29 forks source link

End Moment Fix: conditional heaviside function for LoadML #16

Closed robbievanleeuwen closed 2 years ago

robbievanleeuwen commented 2 years ago

This solution passes all tests in the repo, but not sure if it breaks anything else?

Reference tests:

  1. Mid-span moment (identical results):
import pycba as cba

L = [10]
EI = [30 * 600e7 * 1e-6]
R = [-1, 0, -1, 0]
LM = [[1, 4, 10, 5, 0]]

beam_analysis = cba.BeamAnalysis(L, EI, R, LM)
beam_analysis.analyze()
beam_analysis.plot_results()

main branch: test1_main

_end_momentfix branch: test1_fix

  1. End-span moments (PR fixes step at ends):
import pycba as cba

L = [10]
EI = [30 * 600e7 * 1e-6]
R = [-1, 0, -1, 0]
LM_1 = [[1, 4, 10, 0, 0]]
LM_2 = [[1, 4, 10, 10, 0]]

beam_analysis = cba.BeamAnalysis(L, EI, R, LM_1)
beam_analysis.analyze()
beam_analysis.plot_results()

beam_analysis = cba.BeamAnalysis(L, EI, R, LM_2)
beam_analysis.analyze()
beam_analysis.plot_results()

main branch: test2a_main test2b_main

_end_momentfix branch: test2a_fix test2b_fix

  1. Prestressed concrete example:
import pycba as cba
import numpy as np

L = [32]
EI = [32.8 * 49.9e9 * 1e-6]
R = [-1, 0, -1, 0]

LM = np.array([
    [1, 4, 34695095.91380897, 0.0, 0],
    [1, 4, -34695095.91380897, 32000.0, 0],
    [1, 4, 34695095.91380897, 0.0, 0],
    [1, 4, -34695095.91380897, 32000.0, 0],
    [1, 4, 34695095.91380897, 0.0, 0],
    [1, 4, -34695095.91380897, 32000.0, 0],
    [1, 4, 42820095.91380897, 0.0, 0],
    [1, 4, -42820095.91380897, 32000.0, 0],
    [1, 4, 42820095.91380897, 0.0, 0],
    [1, 4, -42820095.91380897, 32000.0, 0],
    [1, 4, 42820095.91380897, 0.0, 0],
    [1, 4, -42820095.91380897, 32000.0, 0],
    [1, 4, 42820095.91380897, 0.0, 0],
    [1, 4, -42820095.91380897, 32000.0, 0],
    [1, 4, 42820095.91380897, 0.0, 0],
    [1, 4, -42820095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0],
    [1, 4, 50945095.91380897, 0.0, 0],
    [1, 4, -50945095.91380897, 32000.0, 0]
])

LM[:,2] *= 1e-6
LM[:,3] *= 1e-3
LM = LM.tolist()
LM.append([1, 1, 7.695090745199957, 0, 0])

beam_analysis = cba.BeamAnalysis(L, EI, R, LM)
beam_analysis.analyze()
beam_analysis.plot_results()

main branch: test3_main

_end_momentfix branch: test3_fix

ccaprani commented 2 years ago

Thank you so much @robbievanleeuwen ! That's a lovely fix. We might need to extend it to use np.isclose for comparison of floats but looks fine now. Thanks!