Comments (8)
There used to be an infinitesimal
assumption that symbols could use. Use of a specific symbol seems fragile. What about using an expression eps = 1/Dummy('OO', infinite=True)
? Used with L=var('L', positive=True)
gives SingularityFunction(L - eps, L/2, 1)->L/2-1/OO
For clean-up, replace with oo
and you should have what you want.
from sympy.
Can the epsilon symbol be used to track this symbolically?
from sympy.
@moorepants, It is possible to use the epsilon symbol here. This will result in answers that still contain singularity functions. Example 1 with the use of epsilon will look like:
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import Symbol
L = Symbol('L', positive='true')
eps = Symbol('eps', positive='true')
F = Symbol('F')
E = Symbol('E')
I = Symbol('I')
b = Beam(L, E, I)
r0 = b.apply_support(0, type="pin")
rL, mL = b.apply_support(L, type="fixed")
b.apply_load(F, L/2, -1)
b.apply_rotation_hinge(L-eps)
b.solve_for_reaction_loads(r0, rL, mL)
b.reaction_loads
{R_0: -F*SingularityFunction(L - eps, L/2, 1)/SingularityFunction(L - eps, 0, 1),
R_L: -F + F*SingularityFunction(L - eps, L/2, 1)/SingularityFunction(L - eps, 0, 1),
M_L: -F*L/2 + F*L*SingularityFunction(L - eps, L/2, 1)/SingularityFunction(L - eps, 0, 1)}
Simplifying this with the knowledge that eps is very close to 0 gives:
{R_0: -F/2, R_L: -F/2, M_L: 0}
This is correct. The problem is that sympy does not know that eps is very close to zero and is only there to show which item should be evaluated first. That is why it can't solve the SingularityFunction(L - eps, L/2, 1) to L/2.
This problem can be solved by hand for these type of equations, but for larger equations this will become a lot of work.
from sympy.
@smichr Thanks for thinking with me. This is something I would not have come up with. The strange thing is that the solution changes when doing this.
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import Symbol, Dummy, var
L = var('L', positive=True)
eps = 1/Dummy('OO', infinite=True)
F = Symbol('F')
E = Symbol('E')
I = Symbol('I')
b = Beam(L, E, I)
r0 = b.apply_support(0, type="pin")
rL, mL = b.apply_support(L, type="fixed")
b.apply_load(F, L/2, -1)
b.apply_rotation_hinge(L-eps)
b.solve_for_reaction_loads(r0, rL, mL)
b.reaction_loads
Outputs: {R_0: -F, R_L: 0, M_L: F*L/2}
It should not be possible to get a bending moment in the fixed support as there is a hinge right before it. I am not sure why this still happens.
from sympy.
A way that does work:
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import Symbol, Dummy, var
L = var('L', positive=True)
eps = Dummy('eps', positive=True)
F = Symbol('F')
E = Symbol('E')
I = Symbol('I')
b = Beam(L, E, I)
r0 = b.apply_support(0, type="pin")
rL, mL = b.apply_support(L, type="fixed")
b.apply_load(F, L/2, -1)
b.apply_rotation_hinge(L - eps)
b.solve_for_reaction_loads(r0, rL, mL)
b.subbed_reaction_loads = {reaction: eq.subs(eps, 0) for reaction, eq in b.reaction_loads.items()}
b.subbed_reaction_loads
Ouputs: {R_0: -F/2, R_L: -F/2, M_L: 0}
This does not seem like the most robust way to do this, but does give the correct answer for this example.
from sympy.
Another strange thing. If you try the same code for example 2, the correct output depends on if you use b.apply_load(M, L/2+eps, -2)
or b.apply_rotation_hinge(L/2-eps)
.
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import Symbol, Dummy, var
L = var('L', positive=True)
eps = Dummy('eps', positive=True)
M = Symbol('M')
E = Symbol('E')
I = Symbol('I')
b = Beam(L, E, I)
r0 = b.apply_support(0, type="pin")
rL, mL = b.apply_support(L, type="fixed")
b.apply_load(M, L/2+eps, -2)
b.apply_rotation_hinge(L/2)
b.solve_for_reaction_loads(r0, rL, mL)
b.reaction_loads
Outputs: {R_0: 0, R_L: 0, M_L: 0}
While
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import Symbol, Dummy, var
L = var('L', positive=True)
eps = Dummy('eps', positive=True)
M = Symbol('M')
E = Symbol('E')
I = Symbol('I')
b = Beam(L, E, I)
r0 = b.apply_support(0, type="pin")
rL, mL = b.apply_support(L, type="fixed")
b.apply_load(M, L/2, -2)
b.apply_rotation_hinge(L/2-eps)
b.solve_for_reaction_loads(r0, rL, mL)
b.reaction_loads
Outputs: {R_0: 0, R_L: 0, M_L: -M}
, which is correct.
from sympy.
Rethinking about OO: if it is only infinite, then the sign is unknown so x+1/OO
might be greater, equal or less than x. If you make it positive, there is no guarantee about ordering, e.g. x+eps
might be bigger than y
. But maybe (in this case) that is not a concern?
from sympy.
If you need a number that is guaranteed less than 1 you could use 1/Dummy(prime=True)
.
from sympy.
Related Issues (20)
- sympy.Float and sympy.Integer compare equal but have different hashes HOT 1
- Duffing Spring Simulation HOT 5
- Formal Power Series with even or odd terms shouldn't return Piecewise formula for coefficients HOT 3
- The `join` method is unable to create beams with discontinuous values of elastic modulus.
- `lambdify()` and `lambdastr()` can't unpack `sympy.Matrix` typed parameter symbols properly
- RecursionError in sympy.solvers.inequalities.reduce_inequalities with custom function HOT 1
- The `point_cflexure` method doesn't return points when a region of the bending moment line is 0.
- variable of differentiation returns True from `has_free` HOT 4
- parse_mathematica cannot handle greek letters HOT 1
- FiniteField.__call__ returns different types depending on whether flint is installed or not HOT 6
- Incorrect partial fraction expansion with floats HOT 3
- Sphinx build failing regularly HOT 1
- calling `latex` on `Array` with less rows than columns, and at least 10 columns, emit bad latex
- Does solve(...) respects symbol(..., real=True) assumption?
- Sympy results are int, not Integer HOT 1
- Regression: lambdify of Derivative instance now throws PrintMethodNotImplementedError HOT 24
- sp.solve: expected an integer, got rational HOT 2
- Cannot determine truth value of Relational HOT 1
- plot error after a "clean" simpify check up HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sympy.