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

[WIP] Beam bending module. #11266

Closed
wants to merge 27 commits into
from

Conversation

Projects
None yet
3 participants
@sampadsaha5
Contributor

sampadsaha5 commented Jun 21, 2016

No description provided.

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jun 21, 2016

Contributor

Ping @moorepants @leosartaj. I have added the PointLoad and DistributedLoad classes.
There are some things needed to be discussed:

  • Whether these classes would be mutable?
  • If an object is called, then what would it return?
Contributor

sampadsaha5 commented Jun 21, 2016

Ping @moorepants @leosartaj. I have added the PointLoad and DistributedLoad classes.
There are some things needed to be discussed:

  • Whether these classes would be mutable?
  • If an object is called, then what would it return?
@nicoguaro

This comment has been minimized.

Show comment
Hide comment
@nicoguaro

nicoguaro Jun 26, 2016

Contributor

I am curious about this. Are there other changes planned for the mechanics module? I would like to have a continuum mechanics module. I did one in Maxima a while ago and I have been willing to rewrite it in SymPy.

Regarding beams, why not include a general solution like this?

Contributor

nicoguaro commented Jun 26, 2016

I am curious about this. Are there other changes planned for the mechanics module? I would like to have a continuum mechanics module. I did one in Maxima a while ago and I have been willing to rewrite it in SymPy.

Regarding beams, why not include a general solution like this?

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jun 27, 2016

Contributor

Thanks, @nicoguaro .
I am trying to solve the beam bending problems using singularity functions.
I will be using the concept, that you have posted, while implementing this module. Just the difference is, w(x), M(x) and q will be a singularity function.

Contributor

sampadsaha5 commented Jun 27, 2016

Thanks, @nicoguaro .
I am trying to solve the beam bending problems using singularity functions.
I will be using the concept, that you have posted, while implementing this module. Just the difference is, w(x), M(x) and q will be a singularity function.

@nicoguaro

This comment has been minimized.

Show comment
Hide comment
@nicoguaro

nicoguaro Jun 27, 2016

Contributor

@sampadsaha5, integral and diff should be able to handle Dirac deltas and Heaviside functions.

Contributor

nicoguaro commented Jun 27, 2016

@sampadsaha5, integral and diff should be able to handle Dirac deltas and Heaviside functions.

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jun 27, 2016

Contributor

Yes. I have implemented the integrations, Differentiation and all other mathematical operations that can be done using singularity functions in PR #11237 and #11178.

Contributor

sampadsaha5 commented Jun 27, 2016

Yes. I have implemented the integrations, Differentiation and all other mathematical operations that can be done using singularity functions in PR #11237 and #11178.

Show outdated Hide outdated sympy/physics/mechanics/beam.py
A SymPy expression representing the Beam's Young's Modulus.
It is a measure of the stiffness of the Beam material.
I : Sympifyable
A SymPy expression representing the Beam's Moment of Inertia.

This comment has been minimized.

@moorepants

moorepants Jul 3, 2016

Member

Second moment of area not "moment of inertia"

@moorepants

moorepants Jul 3, 2016

Member

Second moment of area not "moment of inertia"

This comment has been minimized.

@moorepants

moorepants Jul 3, 2016

Member

E and I should be words not single letters. Maybe: "length", "elastic_modulus", and "second_moment".

E: "Young's Modulus", "Modulus of Elasticity", or "Elastic Modulus". The later are preferred.

@moorepants

moorepants Jul 3, 2016

Member

E and I should be words not single letters. Maybe: "length", "elastic_modulus", and "second_moment".

E: "Young's Modulus", "Modulus of Elasticity", or "Elastic Modulus". The later are preferred.

Show outdated Hide outdated sympy/physics/mechanics/beam.py
"""
def __init__(self, length, E, I):

This comment has been minimized.

@moorepants

moorepants Jul 3, 2016

Member

You need to decided which things should be supplied in initialization and which shouldn't. For example, why should or shouldn't the boundary conditions and loads be supplied on initialization? Or should they by optional?

@moorepants

moorepants Jul 3, 2016

Member

You need to decided which things should be supplied in initialization and which shouldn't. For example, why should or shouldn't the boundary conditions and loads be supplied on initialization? Or should they by optional?

This comment has been minimized.

@sampadsaha5

sampadsaha5 Jul 4, 2016

Contributor

I think only "length", "elastic_modulus", and "second_moment" should be used to initialize the beam object. The others should be supplied later. This would make the API clean as well as more handy for beginners.

@sampadsaha5

sampadsaha5 Jul 4, 2016

Contributor

I think only "length", "elastic_modulus", and "second_moment" should be used to initialize the beam object. The others should be supplied later. This would make the API clean as well as more handy for beginners.

Show outdated Hide outdated sympy/physics/mechanics/beam.py
def I(self, e):
self._I = sympify(e)
def BoundaryConditions(self, **bcs):

This comment has been minimized.

@moorepants

moorepants Jul 3, 2016

Member

Method names should follow pep8: boundary_conditions.

@moorepants

moorepants Jul 3, 2016

Member

Method names should follow pep8: boundary_conditions.

@moorepants

This comment has been minimized.

Show comment
Hide comment
@moorepants

moorepants Jul 4, 2016

Member

@nicoguaro This work is the start of a continuum mechanics module. We are just working on 2D beam bending, focusing on singularity function solutions. I'll be using this in the mechanics class I teach at UC Davis.

Member

moorepants commented Jul 4, 2016

@nicoguaro This work is the start of a continuum mechanics module. We are just working on 2D beam bending, focusing on singularity function solutions. I'll be using this in the mechanics class I teach at UC Davis.

@nicoguaro

This comment has been minimized.

Show comment
Hide comment
@nicoguaro

nicoguaro Jul 5, 2016

Contributor

@moorepants, I would be interested in the continuum mechanics module. I could work on it. Do you think is viable right now?

Contributor

nicoguaro commented Jul 5, 2016

@moorepants, I would be interested in the continuum mechanics module. I could work on it. Do you think is viable right now?

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jul 5, 2016

Contributor

@moorepants Where should we keep this module?? In which directory?

Contributor

sampadsaha5 commented Jul 5, 2016

@moorepants Where should we keep this module?? In which directory?

@moorepants

This comment has been minimized.

Show comment
Hide comment
@moorepants

moorepants Jul 6, 2016

Member

For the location, I suggest either:

sympy.physics.continuum_mechanics

or

sympy.physics.solid_mechanics

or

we could create an new engineering package

sympy.engineering.solid_mechanics

or we could do

sympy.physics.mechanics.solid.beam

"mechanics" encompasses lots of stuff and we used the word for what is more explicitly "classical mechanics".

Member

moorepants commented Jul 6, 2016

For the location, I suggest either:

sympy.physics.continuum_mechanics

or

sympy.physics.solid_mechanics

or

we could create an new engineering package

sympy.engineering.solid_mechanics

or we could do

sympy.physics.mechanics.solid.beam

"mechanics" encompasses lots of stuff and we used the word for what is more explicitly "classical mechanics".

@moorepants

This comment has been minimized.

Show comment
Hide comment
@moorepants

moorepants Jul 6, 2016

Member

Is worth reading this to see all the language associated with "mechanics": https://en.wikipedia.org/wiki/Mechanics

Member

moorepants commented Jul 6, 2016

Is worth reading this to see all the language associated with "mechanics": https://en.wikipedia.org/wiki/Mechanics

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jul 6, 2016

Contributor

sympy.engineering.solid_mechanics or sympy.physics.continuum_mechanics
sounds nice to me...

Contributor

sampadsaha5 commented Jul 6, 2016

sympy.engineering.solid_mechanics or sympy.physics.continuum_mechanics
sounds nice to me...

@nicoguaro

This comment has been minimized.

Show comment
Hide comment
@nicoguaro

nicoguaro Jul 6, 2016

Contributor

I would vote for sympy.physics.continuum_mechanics.

Contributor

nicoguaro commented Jul 6, 2016

I would vote for sympy.physics.continuum_mechanics.

@sampadsaha5

This comment has been minimized.

Show comment
Hide comment
@sampadsaha5

sampadsaha5 Jul 6, 2016

Contributor

Thanks @nicoguaro. 😄

Contributor

sampadsaha5 commented Jul 6, 2016

Thanks @nicoguaro. 😄

@moorepants

This comment has been minimized.

Show comment
Hide comment
@moorepants

moorepants Jul 6, 2016

Member

@nicoguaro Do you want to use "continuum" because we should plan for fluid mechanics?

Member

moorepants commented Jul 6, 2016

@nicoguaro Do you want to use "continuum" because we should plan for fluid mechanics?

@nicoguaro

This comment has been minimized.

Show comment
Hide comment
@nicoguaro

nicoguaro Jul 6, 2016

Contributor

@moorepants, yes. And some definitions are general for both, fluids and solids, e.g, deformation gradient.

Contributor

nicoguaro commented Jul 6, 2016

@moorepants, yes. And some definitions are general for both, fluids and solids, e.g, deformation gradient.

class Beam(object):

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

no space here

@moorepants

moorepants Jul 13, 2016

Member

no space here

second_moment : Sympifyable
A SymPy expression representing the Beam's Second moment of area.
It is a geometrical property of an area which reflects how its
points are distributed with regard to an arbitrary axis.

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

This should be "with respect to its neutral axis".

@moorepants

moorepants Jul 13, 2016

Member

This should be "with respect to its neutral axis".

>>> bcs['moment']
[(0, 4), (4, 0)]
"""

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

This docstring doesn't yet explain what [(0, 4), (4, 0)] is. This is a list of two tuples and the numbers must represent something. What do they represent?

@moorepants

moorepants Jul 13, 2016

Member

This docstring doesn't yet explain what [(0, 4), (4, 0)] is. This is a list of two tuples and the numbers must represent something. What do they represent?

self._boundary_conditions['slope'].append(s_bcs)
for d_bcs in bcs['deflection']:
self._boundary_conditions['deflection'].append(d_bcs)
return self._boundary_conditions

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

What if they supply an incorrent keyword? Mispelling or something not relevant? You should provide an error if this happens.

@moorepants

moorepants Jul 13, 2016

Member

What if they supply an incorrent keyword? Mispelling or something not relevant? You should provide an error if this happens.

def second_moment(self, i):
self._second_moment = sympify(i)
def apply_boundary_conditions(self, **bcs):

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Since there are only three kwargs it would be better if this was:

def apply_boundary_conditions(self, slope=None, deflection=None, moment=None)

This also begs the question why this is needed. If you use collections.defaultdict for list the user could simply do something like:

beam.boundary_conditions['moment'].append((3, 5))

@moorepants

moorepants Jul 13, 2016

Member

Since there are only three kwargs it would be better if this was:

def apply_boundary_conditions(self, slope=None, deflection=None, moment=None)

This also begs the question why this is needed. If you use collections.defaultdict for list the user could simply do something like:

beam.boundary_conditions['moment'].append((3, 5))

self._boundary_conditions['moment'].append(bcs)
return self._boundary_conditions['moment']
def apply_slope_boundary_conditions(self, *s_bcs):

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

I think this should be:

apply_slope_boundary_conditions(self, location, value)

and apply only one at a time.

@moorepants

moorepants Jul 13, 2016

Member

I think this should be:

apply_slope_boundary_conditions(self, location, value)

and apply only one at a time.

@@ -0,0 +1,343 @@
"""
This module can be used to solve beam bending problems in mechanics.

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

"solve beam..." > "solve 2D beam bending problems with singularity functions"

@moorepants

moorepants Jul 13, 2016

Member

"solve beam..." > "solve 2D beam bending problems with singularity functions"

Examples
========
"""

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Needs code.

@moorepants

moorepants Jul 13, 2016

Member

Needs code.

self._boundary_conditions['deflection'].append(bcs)
return self._boundary_conditions['deflection']
def boundary_conditions(self):

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

@property?

@moorepants

moorepants Jul 13, 2016

Member

@property?

class PointLoad(object):
"""A Point Load.

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

A load (force or moment) applied at a point.

@moorepants

moorepants Jul 13, 2016

Member

A load (force or moment) applied at a point.

Examples
========
>>> from sympy.physics.continuum_mechanics.beam import PointLoad
>>> from sympy.physics.mechanics import Point

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

I don't think this should be tied to Point in mechanics. I don't think it should be tied to a Point object at all. We also have a geometry module with 2d points which would be more appropriate. But I don't see why this overhead is needed at all

@moorepants

moorepants Jul 13, 2016

Member

I don't think this should be tied to Point in mechanics. I don't think it should be tied to a Point object at all. We also have a geometry module with 2d points which would be more appropriate. But I don't see why this overhead is needed at all

========
>>> from sympy.physics.continuum_mechanics.beam import PointLoad
>>> from sympy.physics.mechanics import Point
>>> p = Point('4')

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

This isn't even how Point works!

@moorepants

moorepants Jul 13, 2016

Member

This isn't even how Point works!

A Moment can be defined just by passing moment=True as an argument.
>>> PointLoad(location = p, value = -4, moment=True)

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Do you think this API is better than:

MomentPointLoad()

and

ForcePointLoad()

Or PointForce() PointMoment()

@moorepants

moorepants Jul 13, 2016

Member

Do you think this API is better than:

MomentPointLoad()

and

ForcePointLoad()

Or PointForce() PointMoment()

order : Sympifyable
The order of the applied load.
value : Sympifyable
A SymPy expression representing the value of the applied load.

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

I'd order them as: value, start, order

@moorepants

moorepants Jul 13, 2016

Member

I'd order them as: value, start, order

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

I'd order them as: value, start, order.

@moorepants

moorepants Jul 13, 2016

Member

I'd order them as: value, start, order.

>>> from sympy import Symbol
>>> a = Point('4')
>>> b = 2
>>> DistributedLoad(start = a, order = b, value = 2)

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Are you going to support start and end with this where it creates two distributed loads, one that makes a composite of two?

@moorepants

moorepants Jul 13, 2016

Member

Are you going to support start and end with this where it creates two distributed loads, one that makes a composite of two?

b = Beam(1, E, I)
assert b._length == 1
assert b._elastic_modulus == E
assert b._second_moment == I

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

These should be b.length == 1 not the underscore version.

@moorepants

moorepants Jul 13, 2016

Member

These should be b.length == 1 not the underscore version.

Load_3 = DistributedLoad(start = 3, order = 2, value = -2)
p = b.apply(Load_1, Load_2, Load_3)
q = -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 3, 2)
assert p == q

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Why does apply return anything? And if it returns something, why does it return a singularity function?

@moorepants

moorepants Jul 13, 2016

Member

Why does apply return anything? And if it returns something, why does it return a singularity function?

Load_2 = PointLoad(location = P1, value = 5, moment=True)
assert Load_2.location == P1
assert Load_2.value == 5
assert Load_2.moment is True

This comment has been minimized.

@moorepants

moorepants Jul 13, 2016

Member

Is there any reason for these loads to be mutable? Seems like it is just a container for some attributes. Maybe a collections.namedtuple is a better choice than a class. If these loads don't do anything else, then there is no need to use a class.

@moorepants

moorepants Jul 13, 2016

Member

Is there any reason for these loads to be mutable? Seems like it is just a container for some attributes. Maybe a collections.namedtuple is a better choice than a class. If these loads don't do anything else, then there is no need to use a class.

@moorepants

This comment has been minimized.

Show comment
Hide comment
@moorepants

moorepants Jul 13, 2016

Member

Please close this PR (either fix issues first or move comments to #11374). I don't think there needs to be two PRs for this.

Member

moorepants commented Jul 13, 2016

Please close this PR (either fix issues first or move comments to #11374). I don't think there needs to be two PRs for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment