Git Product home page Git Product logo

alfredocarella / simplebendingpractice Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 12.0 8.96 MB

BeamBending: a teaching aid for 1-D shear-force and bending-moment diagrams

Home Page: https://alfredocarella.github.io/simplebendingpractice

License: Creative Commons Attribution 4.0 International

Python 33.19% Jupyter Notebook 58.63% TeX 8.18%
statics mechanics python3 stresses bending-moment-diagrams shear-force

simplebendingpractice's People

Contributors

alfredocarella avatar louisgag avatar nicoguaro avatar pedrobern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

simplebendingpractice's Issues

My Overall Comments

@alfredocarella

  • I think this software is neat and I could picture it being used by future students and teachers. I appreciate the Welcome to BeamBending (https://alfredocarella.github.io/simplebendingpractice/index.html), and found it very helpful in reviewing BeamBending as 'an instructor'.

  • You refer to an applet for more info to your audience for a system in equilibrium (https://www.edumedia-sciences.com/en/media/80-action-reaction-principle), but this page requires a subscription - is there any other open source page you can use?

  • Can you provide some of the comments from the students from Autumn 2018 in the 'Recent Uses' section of the paper?

  • Again, add more references including similar statics or engineering software.

ModuleNotFoundError: No module named 'beambending'

pip list
beambending 1.1.1

import os
from beambending import Beam, DistributedLoadV, PointLoadH, PointLoadV, x

I am using pyscripter version 4.3.4.0 x 64
ModuleNotFoundError: No module named 'beambending'

*** Remote Interpreter Reinitialized ***
Traceback (most recent call last):
File "H:\n.py", line 2, in
from beambending import Beam, DistributedLoadV, PointLoadH, PointLoadV, x
ModuleNotFoundError: No module named 'beambending'

Please Help me

PointTorque does not exist

Hi Alfredo,
First of all, I would like to thank you for such an amazing package. Now, I was using your library but the PointTorque cannot be loaded due to this class does not exist, either in the beam class or calling directly.

I do not know what can be happening.
Sincerely,

Nikolay Prieto

Can't run example with Beam equal or greater than 10m

Hi, thanks for this awesome package!

If I run the example code with Beam length equal or greater than 10:

import os
from beambending import Beam, DistributedLoadV, PointLoadH, PointLoadV, x

def example_1():
    """Run example 1"""
    
    # <<< ONLY CHANGE >>>
    beam = Beam(10)  # Initialize a Beam object of length 9 m
    # <<< ONLY CHANGE >>>
    
    beam.pinned_support = 2    # x-coordinate of the pinned support
    beam.rolling_support = 7  # x-coordinate of the rolling support
    beam.add_loads((
                    PointLoadH(10, 3),  # 10 kN pointing right, at x=3 m
                    PointLoadV(-20, 3),  # 20 kN downwards, at x=3 m
                    DistributedLoadV(-10, (3, 9)),  # 10 kN/m, downwards, for 3 m <= x <= 9 m
                    DistributedLoadV(-20 + x**2, (0, 2)),  # variable load, for 0 <= x <= 2 m
                ))
    fig = beam.plot()

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)


if __name__ == '__main__':  # call function when run as script
    example_1()

I get the following error:

Traceback (most recent call last):
  File "/Users/pedrober/.local/share/virtualenvs/pontes/lib/python3.7/site-packages/numpy/core/function_base.py", line 117, in linspace
    num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "diagrams.py", line 28, in <module>
    example_1()
  File "diagrams.py", line 18, in example_1
    fig = beam.plot()
  File "/Users/pedrober/.local/share/virtualenvs/pontes/lib/python3.7/site-packages/beambending/beam.py", line 229, in plot
    self.plot_beam_diagram(ax1)
  File "/Users/pedrober/.local/share/virtualenvs/pontes/lib/python3.7/site-packages/beambending/beam.py", line 252, in plot_beam_diagram
    self._plot_analytical(ax, sum(self._distributed_forces_y), **plot01_params)
  File "/Users/pedrober/.local/share/virtualenvs/pontes/lib/python3.7/site-packages/beambending/beam.py", line 307, in _plot_analytical
    x_vec = np.linspace(self._x0, self._x1, min(int((self.length) * 1000 + 1), 1e4))
  File "<__array_function__ internals>", line 6, in linspace
  File "/Users/pedrober/.local/share/virtualenvs/pontes/lib/python3.7/site-packages/numpy/core/function_base.py", line 121, in linspace
    .format(type(num)))
TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.

If I try to plot each figure instead of plotting all together, I get the same error.

Version badge points to a dead-end

The badge points to the following link:

 https://github.com/alfredocarella/simplebendingpractice/blob/master/None

Maybe the author is waiting after the JOSE Review to create a release. In that case, this Issue would be closed accordingly.

Tests not passing

After running

pytest docstring-modules

The following message is returned.

============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/nguarinz/workspace/simplebendingpractice, inifile: setup.cfg
plugins: cov-2.7.1
collected 18 items

beambending/beam.py .....                                                [ 27%]
examples/example_1.py F                                                  [ 33%]
examples/example_normal0.py .                                            [ 38%]
examples/example_normal1.py .                                            [ 44%]
examples/example_shear0.py .                                             [ 50%]
examples/example_shear1.py F                                             [ 55%]
test/test_beam.py .....FFF                                               [100%]

=================================== FAILURES ===================================
__________________________________ example_1 ___________________________________

    def example_1():
        """Run example 1"""
        beam = Beam(9)  # Initialize a Beam object of length 9m
        beam.pinned_support = 2    # x-coordinate of the pinned support
        beam.rolling_support = 7  # x-coordinate of the rolling support
        beam.add_loads((
                        PointLoadH(10, 3),  # 10kN pointing right, at x=3m
                        PointLoadV(-20, 3),  # 20kN downwards, at x=3m
                        DistributedLoadV(-10, (3, 9)),  # 10 kN/m, downwards, for 3m <= x <= 9m
                        DistributedLoadV(-20 + x**2, (0, 2)),  # variable load, for 0m <= x <= 2m
                    ))
>       fig = beam.plot()

examples/example_1.py:19: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
beambending/beam.py:224: in plot
    self.plot_shear_force(ax3)
beambending/beam.py:264: in plot_shear_force
    self._plot_analytical(ax, -1* sum(self._shear_forces), **plot03_params)
beambending/beam.py:297: in _plot_analytical
    y_vec = lambdify(x, sym_func, "numpy")(x_vec)
<lambdifygenerated-3>:2: in _lambdifygenerated
    return (-select([less(x, 0),True], [0,(1/3)*amin((2,x))**3 - 20*amin((2,x))], default=numpy.nan) - select([less(x, 0),True], [0,10*amin((3,x)) - 10*amin((9,x))], default=numpy.nan) - select([less(x, 2),True], [0,73.0666666666666], default=numpy.nan) - select([less(x, 3),True], [0,-20], default=numpy.nan) - select([less(x, 7),True], [0,44.2666666666667], default=numpy.nan))
<__array_function__ internals>:6: in amin
    ???
../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2746: in amin
    keepdims=keepdims, initial=initial, where=where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = (2, array([0.000e+00, 1.000e-03, 2.000e-03, ..., 8.998e+00, 8.999e+00,
       9.000e+00]))
ufunc = <ufunc 'minimum'>, method = 'min', axis = None, dtype = None, out = None
kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
passkwargs = {}

    def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
        passkwargs = {k: v for k, v in kwargs.items()
                      if v is not np._NoValue}
    
        if type(obj) is not mu.ndarray:
            try:
                reduction = getattr(obj, method)
            except AttributeError:
                pass
            else:
                # This branch is needed for reductions like any which don't
                # support a dtype.
                if dtype is not None:
                    return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                else:
                    return reduction(axis=axis, out=out, **passkwargs)
    
>       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:90: ValueError
________________________________ example_shear1 ________________________________

    def example_shear1():
        """Generate shear force introductory problem schematic"""
        my_beam = Beam(6)
        my_beam.rolling_support = 0  # x-coordinate of the rolling support
        my_beam.pinned_support = 3    # x-coordinate of the pinned support
        my_beam.add_loads([PointLoadV(10, 6)])  # 10kN pointing upwards, at x=6m
        fig = plt.figure()
        my_beam.plot_shear_force(fig.add_subplot(2, 1, 1))
>       my_beam.plot_bending_moment(fig.add_subplot(2, 1, 2))

examples/example_shear1.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
beambending/beam.py:275: in plot_bending_moment
    self._plot_analytical(ax, -1* sum(self._bending_moments), **plot04_params)
beambending/beam.py:297: in _plot_analytical
    y_vec = lambdify(x, sym_func, "numpy")(x_vec)
<lambdifygenerated-8>:2: in _lambdifygenerated
    return (-select([less(x, 0),True], [0,10.0*x], default=numpy.nan) - select([less(x, 0),True], [0,-20.0*x + 20.0*amin((3,x))], default=numpy.nan) - select([less(x, 0),True], [0,10*x - 10*amin((6,x))], default=numpy.nan))
<__array_function__ internals>:6: in amin
    ???
../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2746: in amin
    keepdims=keepdims, initial=initial, where=where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = (3, array([0.000e+00, 1.000e-03, 2.000e-03, ..., 5.998e+00, 5.999e+00,
       6.000e+00]))
ufunc = <ufunc 'minimum'>, method = 'min', axis = None, dtype = None, out = None
kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
passkwargs = {}

    def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
        passkwargs = {k: v for k, v in kwargs.items()
                      if v is not np._NoValue}
    
        if type(obj) is not mu.ndarray:
            try:
                reduction = getattr(obj, method)
            except AttributeError:
                pass
            else:
                # This branch is needed for reductions like any which don't
                # support a dtype.
                if dtype is not None:
                    return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                else:
                    return reduction(axis=axis, out=out, **passkwargs)
    
>       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:90: ValueError
_____________________ test_beam_normal_forces_are_correct ______________________

    def test_beam_normal_forces_are_correct():
        with defined_canonical_beam() as (the_beam, x, x_vec):
>           normal_force_sample = lambdify(x, sum(the_beam._normal_forces), "numpy")(x_vec)

test/test_beam.py:86: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<lambdifygenerated-10>:2: in _lambdifygenerated
    return (-select([less(x, 0),True], [0,2*amin((7,x)) - 2*amin((9,x))], default=numpy.nan) - select([less(x, 2),True], [0,-11.0], default=numpy.nan) - select([less(x, 5),True], [0,15], default=numpy.nan))
<__array_function__ internals>:6: in amin
    ???
../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2746: in amin
    keepdims=keepdims, initial=initial, where=where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = (7, array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. , 5.5, 6. ,
       6.5, 7. , 7.5, 8. , 8.5, 9. ]))
ufunc = <ufunc 'minimum'>, method = 'min', axis = None, dtype = None, out = None
kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
passkwargs = {}

    def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
        passkwargs = {k: v for k, v in kwargs.items()
                      if v is not np._NoValue}
    
        if type(obj) is not mu.ndarray:
            try:
                reduction = getattr(obj, method)
            except AttributeError:
                pass
            else:
                # This branch is needed for reductions like any which don't
                # support a dtype.
                if dtype is not None:
                    return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                else:
                    return reduction(axis=axis, out=out, **passkwargs)
    
>       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:90: ValueError
______________________ test_beam_shear_forces_are_correct ______________________

    def test_beam_shear_forces_are_correct():
        with defined_canonical_beam() as (the_beam, x, x_vec):
>           shear_force_sample = lambdify(x, sum(the_beam._shear_forces), "numpy")(x_vec)

test/test_beam.py:93: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<lambdifygenerated-11>:2: in _lambdifygenerated
    return (select([less(x, 0),True], [0,10*amin((3,x)) - 10*amin((9,x))], default=numpy.nan) + select([less(x, 0),True], [0,-20*amin((2,x))], default=numpy.nan) + select([less(x, 2),True], [0,76.0], default=numpy.nan) + select([less(x, 3),True], [0,-20], default=numpy.nan) + select([less(x, 7),True], [0,44.0], default=numpy.nan))
<__array_function__ internals>:6: in amin
    ???
../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2746: in amin
    keepdims=keepdims, initial=initial, where=where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = (3, array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. , 5.5, 6. ,
       6.5, 7. , 7.5, 8. , 8.5, 9. ]))
ufunc = <ufunc 'minimum'>, method = 'min', axis = None, dtype = None, out = None
kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
passkwargs = {}

    def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
        passkwargs = {k: v for k, v in kwargs.items()
                      if v is not np._NoValue}
    
        if type(obj) is not mu.ndarray:
            try:
                reduction = getattr(obj, method)
            except AttributeError:
                pass
            else:
                # This branch is needed for reductions like any which don't
                # support a dtype.
                if dtype is not None:
                    return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                else:
                    return reduction(axis=axis, out=out, **passkwargs)
    
>       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:90: ValueError
____________________ test_beam_bending_moments_are_correct _____________________

    def test_beam_bending_moments_are_correct():
        with defined_canonical_beam() as (the_beam, x, x_vec):
>           bending_moment_sample = lambdify(x, sum(the_beam._bending_moments), "numpy")(x_vec)

test/test_beam.py:100: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<lambdifygenerated-12>:2: in _lambdifygenerated
    return (select([less(x, 0),True], [0,-20*x + 20*amin((3,x))], default=numpy.nan) + select([less(x, 0),True], [0,44.0*x - 44.0*amin((7,x))], default=numpy.nan) + select([less(x, 0),True], [0,76.0*x - 76.0*amin((2,x))], default=numpy.nan) + select([less(x, 0),True], [0,-40*x - 10*amin((2,x))**2 + 40*amin((2,x))], default=numpy.nan) + select([less(x, 0),True], [0,-60*x + 5*amin((3,x))**2 - 30*amin((3,x)) - 5*amin((9,x))**2 + 90*amin((9,x))], default=numpy.nan))
<__array_function__ internals>:6: in amin
    ???
../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2746: in amin
    keepdims=keepdims, initial=initial, where=where)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = (3, array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. , 5.5, 6. ,
       6.5, 7. , 7.5, 8. , 8.5, 9. ]))
ufunc = <ufunc 'minimum'>, method = 'min', axis = None, dtype = None, out = None
kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
passkwargs = {}

    def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
        passkwargs = {k: v for k, v in kwargs.items()
                      if v is not np._NoValue}
    
        if type(obj) is not mu.ndarray:
            try:
                reduction = getattr(obj, method)
            except AttributeError:
                pass
            else:
                # This branch is needed for reductions like any which don't
                # support a dtype.
                if dtype is not None:
                    return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                else:
                    return reduction(axis=axis, out=out, **passkwargs)
    
>       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../../.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:90: ValueError
===================== 5 failed, 13 passed in 26.34 seconds =====================

syntax error in fig = beam.plot()

Hi there, I have been trying to use this package and everything seems to work fine until I get to the fig = beam.plot() part, I always get a syntax error there.
This is my code, I have also tried having "pip install --user beambending" and "python3 -m pip install --user beambending" at the top but that just gives me another error.
Do you know what the problem might be?

from beambending import beam

print('Specify the values of the variables')
#lengdirnar (Lengths)
l1 = int(input('L1: '))
l2 = int(input('L2: '))
a = int(input('a: '))
#samfellt álag (Distributed load, vertical)
q = int(input('q: '))
#stakur kraftur (Point load, vertical)
p = int(input('P: '))
#þversniðsstærðirnar (Cross section measurements)
b = int(input('b: '))
h = int(input('h: '))

beam = beam(l1+l2)
beam.pinned_support = l1
beam.rolling_support = (l1+l2)
beam.add_loads((
PointLoadV(P, a),
DistributedLoadV(q, (0, (l1+l2))
))

fig = beam.plot()

Teaching Environment for Educators using Python (Beginners)

@alfredocarella Using the BeamBending software using the launch binder in Git works well. I was wondering if you are able to create a "python tutorial steps" to complement the python coding environment for teachers and educators to use and carry out in their classes. I noticed installing the packages and using python to run the beambending software wasn't so clear compared to running it online in the launch binder. Many teachers might not have python expertise (including terminal executions), so including a detailed install instruction and example in the repository would be a great addition.

@moorepants thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.