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

[GSoC] physics/continuum_mechanics: solve Method along with documentation and tests added for the Truss class #23755

Merged
merged 4 commits into from
Aug 2, 2022

Conversation

AdvaitPote
Copy link
Member

References to other Issues or PRs

Brief description of what is fixed or changed

After the implementation of the truss class with the initialising methods like add_node and add_method along with many others, the main solving method responsible for solving a given Truss added. After calling the solve method for a given truss, the reaction_loads and internal_forces are updated with the calculated values.

Other comments

Release Notes

  • physics.continuum_mechanics
    • Added the solve method for solving a given truss for its reaction loads and internal forces.

@sympy-bot
Copy link

sympy-bot commented Jul 10, 2022

Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • physics.continuum_mechanics
    • Added the solve method for solving a given truss for its reaction loads and internal forces. (#23755 by @AdvaitPote)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed
After the implementation of the `truss` class with the initialising methods like `add_node` and `add_method` along with many others, the main solving method responsible for solving a given Truss added. After calling the `solve` method for a given truss, the `reaction_loads` and `internal_forces` are updated with the calculated values. 

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* physics.continuum_mechanics
  * Added the `solve` method for solving a given `truss` for its reaction loads and internal forces. 
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@github-actions
Copy link

github-actions bot commented Jul 10, 2022

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@AdvaitPote
Copy link
Member Author

@Psycho-Pirate

equations. However, the truss needs to be stable as well and may be unstable if 2n > r + m.
The number of variables is simply the sum of the number of reaction forces and member
forces.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention what signs the compressive and tensile forces are using.

@Psycho-Pirate
Copy link
Member

Psycho-Pirate commented Jul 21, 2022

I tried solving the following problem
image

Here is the code:

from sympy.physics.continuum_mechanics.truss import Truss
import math
t = Truss()

>>> t.add_node("A", -4, 0)
>>> t.add_node("B", 0, 0)
>>> t.add_node("C", 4, 0)
>>> t.add_node("D", 8, 0)
>>> t.add_node("E", 6, 2/math.sqrt(3))
>>> t.add_node("F", 2, 2*math.sqrt(3))
>>> t.add_node("G", -2, 2/math.sqrt(3))

>>> t.add_member("AB","A","B")
>>> t.add_member("BC","B","C")
>>> t.add_member("CD","C","D")
>>> t.add_member("AG","A","G")
>>> t.add_member("GB","G","B")
>>> t.add_member("GF","G","F")
>>> t.add_member("BF","B","F")
>>> t.add_member("FC","F","C")
>>> t.add_member("CE","C","E")
>>> t.add_member("FE","F","E")
>>> t.add_member("DE","D","E")

>>> t.apply_support("A","pinned")
>>> t.apply_support("D","roller")
>>> t.apply_load("G", 3, 90)
>>> t.apply_load("E", 3, 90)
>>> t.apply_load("F", 2, 90)
>>> t.solve()
>>> t.reaction_loads
{'R_A_x': 3.98027755288532e-16, 'R_A_y': -4.00000000000000, 'R_D_y': -4.00000000000000}

It solves the internal forces correctly but for reaction forces, R_A_x should equal to zero.

@AdvaitPote
Copy link
Member Author

@Psycho-Pirate I have made the required changes. For the second issue, there wasn't any major flaw with how equations were solved but just that when dealing with floats, it just returned a term tending to an infinitesimal term. To get around this, I just found out the minimum load applied and then iterated through the forces_matrix and if there happened to be a force which is smaller than min_load by a certain degree, 1E-10 in this case, then that force would just be reduced to zero.

@AdvaitPote
Copy link
Member Author

@Psycho-Pirate

@Psycho-Pirate
Copy link
Member

Looks good to me! Merging!

@Psycho-Pirate Psycho-Pirate merged commit 82f264c into sympy:master Aug 2, 2022
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 this pull request may close these issues.

3 participants