Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PedroBern opened this issue May 3, 2020 · 0 comments · Fixed by #11
Closed

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

PedroBern opened this issue May 3, 2020 · 0 comments · Fixed by #11

Comments

@PedroBern
Copy link
Contributor

PedroBern commented May 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant